Resolve UI targets from daemon snapshots
This commit is contained in:
parent
e0063a622e
commit
d7a9fe9ef0
3 changed files with 114 additions and 12 deletions
|
|
@ -1842,6 +1842,8 @@ static void RequireDaemonRenderQueryAuthority(string root)
|
|||
"public static bool TryQueryEntityContact(",
|
||||
"public static AetheriaRuntimeDaemonEntityContact[] QueryEntityContacts(",
|
||||
"public static int QueryEntityContacts(",
|
||||
"AetheriaRuntimeDaemonEntityTarget",
|
||||
"public static bool TryQueryEntityTarget(",
|
||||
"AetheriaRuntimeDaemonWormholeExit",
|
||||
"public static AetheriaRuntimeDaemonWormholeExit[] QueryWormholeExits(",
|
||||
"public static int QueryWormholeExits(",
|
||||
|
|
@ -7718,9 +7720,11 @@ static void RequireMainMenuContinueRunState(string root)
|
|||
"resourceScanner.RestoreRuntimeState(",
|
||||
"AetheriaRuntimeDaemonRenderQueries.TryQueryEntityContact(",
|
||||
"AetheriaRuntimeDaemonRenderQueries.QueryEntityContacts(",
|
||||
"AetheriaRuntimeDaemonRenderQueries.TryQueryEntityTarget(",
|
||||
"GetObservedTarget(CurrentEntity)",
|
||||
"ReconcileVisibleTargetIndicators();",
|
||||
"GetObservedInfoGathered(CurrentEntity, target)",
|
||||
"IsObservedHostileContact(CurrentEntity, CurrentEntity.Target.Value)",
|
||||
"IsObservedHostileContact(CurrentEntity, observedTarget)",
|
||||
"_observedEntityFacadesByRecordKey",
|
||||
"entity.RestoreStatGrids(entitySnapshot.StatGrids)",
|
||||
"RestoreThermalExposure((float)entitySnapshot.Heatstroke, (float)entitySnapshot.Hypothermia)",
|
||||
|
|
@ -7758,7 +7762,11 @@ static void RequireMainMenuContinueRunState(string root)
|
|||
"CurrentEntity.VisibleFriendlies.ObserveAdd()",
|
||||
"CurrentEntity.VisibleFriendlies.ObserveRemove()",
|
||||
"foreach (var hostile in CurrentEntity.VisibleEnemies)",
|
||||
"foreach (var friendly in CurrentEntity.VisibleFriendlies)"
|
||||
"foreach (var friendly in CurrentEntity.VisibleFriendlies)",
|
||||
"UpdateTargetPanel(CurrentEntity.Target.Value)",
|
||||
"var target = CurrentEntity.Target.Value;",
|
||||
"TargetIndicator.Target = CurrentEntity.Target.Value.Position",
|
||||
"indicator.Target = CurrentEntity.Target.Value.Position"
|
||||
};
|
||||
|
||||
var forbiddenGameplayHits = forbiddenGameplaySymbols
|
||||
|
|
|
|||
|
|
@ -2158,7 +2158,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
EnablePlayerInput();
|
||||
UpdatePlayerPanel();
|
||||
UpdateTargetPanel(CurrentEntity.Target.Value);
|
||||
UpdateTargetPanel(GetObservedTarget(CurrentEntity));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2173,7 +2173,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
EnablePlayerInput();
|
||||
UpdatePlayerPanel();
|
||||
UpdateTargetPanel(CurrentEntity.Target.Value);
|
||||
UpdateTargetPanel(GetObservedTarget(CurrentEntity));
|
||||
GameplayUI.gameObject.SetActive(true);
|
||||
}
|
||||
return;
|
||||
|
|
@ -3155,6 +3155,31 @@ public class ActionGameManager : MonoBehaviour
|
|||
out contact);
|
||||
}
|
||||
|
||||
private bool TryQueryDaemonEntityTarget(
|
||||
Entity observer,
|
||||
out AetheriaRuntimeDaemonEntityTarget target)
|
||||
{
|
||||
target = default;
|
||||
if (observer == null)
|
||||
return false;
|
||||
|
||||
return AetheriaRuntimeDaemonRenderQueries.TryQueryEntityTarget(
|
||||
FindCurrentDaemonZoneSnapshot(),
|
||||
observer.DaemonEntityIndex,
|
||||
out target);
|
||||
}
|
||||
|
||||
private Entity GetObservedTarget(Entity observer)
|
||||
{
|
||||
if (TryQueryDaemonEntityTarget(observer, out var target) &&
|
||||
TryGetObservedEntityFacade(target.TargetEntityIndex, out var targetEntity))
|
||||
{
|
||||
return targetEntity;
|
||||
}
|
||||
|
||||
return observer?.Target.Value;
|
||||
}
|
||||
|
||||
private float GetObservedInfoGathered(Entity observer, Entity target)
|
||||
{
|
||||
if (TryQueryDaemonEntityContact(observer, target, out var contact))
|
||||
|
|
@ -3477,10 +3502,11 @@ public class ActionGameManager : MonoBehaviour
|
|||
// ItemManager.Time = _time;
|
||||
if(CurrentEntity !=null && CurrentEntity.Parent==null)
|
||||
{
|
||||
var observedTarget = GetObservedTarget(CurrentEntity);
|
||||
ReconcileVisibleTargetIndicators();
|
||||
foreach (var indicator in _visibleHostileIndicators)
|
||||
{
|
||||
indicator.Value.gameObject.SetActive(indicator.Key!=CurrentEntity.Target.Value);
|
||||
indicator.Value.gameObject.SetActive(indicator.Key != observedTarget);
|
||||
indicator.Value.Place.Target = indicator.Key.Position;
|
||||
if (!indicator.Key.Active)
|
||||
indicator.Value.Fill.enabled = false;
|
||||
|
|
@ -3496,7 +3522,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
foreach (var indicator in _visibleFriendlyIndicators)
|
||||
{
|
||||
indicator.Value.gameObject.SetActive(indicator.Key!=CurrentEntity.Target.Value);
|
||||
indicator.Value.gameObject.SetActive(indicator.Key != observedTarget);
|
||||
indicator.Value.Place.Target = indicator.Key.Position;
|
||||
if (!indicator.Key.Active)
|
||||
indicator.Value.Fill.enabled = false;
|
||||
|
|
@ -3526,7 +3552,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
TryRequestDaemonMoveVector(movement);
|
||||
}
|
||||
|
||||
var target = CurrentEntity.Target.Value;
|
||||
var target = observedTarget;
|
||||
if (target != null)
|
||||
{
|
||||
var threshold = Settings.GameplaySettings.TargetDetectionInfoThreshold;
|
||||
|
|
@ -4084,9 +4110,10 @@ public class ActionGameManager : MonoBehaviour
|
|||
if (!ZoneRenderer.TryGetEntityInstance(CurrentEntity, out var entityInstance))
|
||||
return;
|
||||
|
||||
var observedTarget = GetObservedTarget(CurrentEntity);
|
||||
ViewDot.Target = entityInstance.LookAtPoint.position;
|
||||
if (CurrentEntity.Target.Value != null)
|
||||
TargetIndicator.Target = CurrentEntity.Target.Value.Position;
|
||||
if (observedTarget != null)
|
||||
TargetIndicator.Target = observedTarget.Position;
|
||||
var distance = CultMath.math.length(AetheriaMath.ToCult((float3)ViewDot.Target) - CurrentEntity.CultPosition);
|
||||
foreach (var (_, barrels, crosshair) in _articulationGroups)
|
||||
{
|
||||
|
|
@ -4100,12 +4127,12 @@ public class ActionGameManager : MonoBehaviour
|
|||
foreach (var (targetLock, indicator, spin) in _lockingIndicators)
|
||||
{
|
||||
var showLockingIndicator = targetLock.Lock > .01f &&
|
||||
CurrentEntity.Target.Value != null &&
|
||||
IsObservedHostileContact(CurrentEntity, CurrentEntity.Target.Value);
|
||||
observedTarget != null &&
|
||||
IsObservedHostileContact(CurrentEntity, observedTarget);
|
||||
indicator.gameObject.SetActive(showLockingIndicator);
|
||||
if(showLockingIndicator)
|
||||
{
|
||||
indicator.Target = CurrentEntity.Target.Value.Position;
|
||||
indicator.Target = observedTarget.Position;
|
||||
indicator.NoiseAmplitude = Settings.GameplaySettings.LockIndicatorNoiseAmplitude * (1 - targetLock.Lock);
|
||||
indicator.NoiseFrequency = Settings.GameplaySettings.LockIndicatorFrequency.Evaluate(targetLock.Lock);
|
||||
spin.Speed = Settings.GameplaySettings.LockSpinSpeed.Evaluate(targetLock.Lock);
|
||||
|
|
|
|||
|
|
@ -226,6 +226,35 @@ namespace GameCult.Aetheria.State.Verse
|
|||
public bool Visible { get; }
|
||||
}
|
||||
|
||||
public readonly struct AetheriaRuntimeDaemonEntityTarget
|
||||
{
|
||||
public AetheriaRuntimeDaemonEntityTarget(
|
||||
int observerEntityIndex,
|
||||
int targetEntityIndex,
|
||||
double targetPositionX,
|
||||
double targetPositionZ,
|
||||
double deltaX,
|
||||
double deltaZ,
|
||||
double distance)
|
||||
{
|
||||
ObserverEntityIndex = observerEntityIndex;
|
||||
TargetEntityIndex = targetEntityIndex;
|
||||
TargetPositionX = targetPositionX;
|
||||
TargetPositionZ = targetPositionZ;
|
||||
DeltaX = deltaX;
|
||||
DeltaZ = deltaZ;
|
||||
Distance = Math.Max(0, distance);
|
||||
}
|
||||
|
||||
public int ObserverEntityIndex { get; }
|
||||
public int TargetEntityIndex { get; }
|
||||
public double TargetPositionX { get; }
|
||||
public double TargetPositionZ { get; }
|
||||
public double DeltaX { get; }
|
||||
public double DeltaZ { get; }
|
||||
public double Distance { get; }
|
||||
}
|
||||
|
||||
public readonly struct AetheriaRuntimeDaemonWormholeExit
|
||||
{
|
||||
public AetheriaRuntimeDaemonWormholeExit(
|
||||
|
|
@ -631,6 +660,27 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return contacts.Count;
|
||||
}
|
||||
|
||||
public static bool TryQueryEntityTarget(
|
||||
AetheriaRuntimeZoneSnapshotCommit? zone,
|
||||
int observerEntityIndex,
|
||||
out AetheriaRuntimeDaemonEntityTarget entityTarget)
|
||||
{
|
||||
entityTarget = default;
|
||||
if (zone == null || observerEntityIndex < 0)
|
||||
return false;
|
||||
|
||||
var entities = BuildEntityMap(zone);
|
||||
if (!entities.TryGetValue(observerEntityIndex, out var observer) ||
|
||||
observer.TargetEntityIndex < 0 ||
|
||||
!entities.TryGetValue(observer.TargetEntityIndex, out var target))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
entityTarget = BuildEntityTarget(observer, target);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeDaemonWormholeExit[] QueryWormholeExits(
|
||||
AetheriaRuntimeRunCheckpointCommit? run,
|
||||
AetheriaRuntimeZoneSnapshotCommit? zone,
|
||||
|
|
@ -819,6 +869,23 @@ namespace GameCult.Aetheria.State.Verse
|
|||
contact.Visible);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeDaemonEntityTarget BuildEntityTarget(
|
||||
AetheriaRuntimeEntitySnapshotCommit observer,
|
||||
AetheriaRuntimeEntitySnapshotCommit target)
|
||||
{
|
||||
var deltaX = target.PositionX - observer.PositionX;
|
||||
var deltaZ = target.PositionZ - observer.PositionZ;
|
||||
var distance = Math.Sqrt(deltaX * deltaX + deltaZ * deltaZ);
|
||||
return new AetheriaRuntimeDaemonEntityTarget(
|
||||
observer.EntityIndex,
|
||||
target.EntityIndex,
|
||||
target.PositionX,
|
||||
target.PositionZ,
|
||||
deltaX,
|
||||
deltaZ,
|
||||
distance);
|
||||
}
|
||||
|
||||
private static Dictionary<int, AetheriaRuntimeZoneSnapshotCommit> BuildZoneMap(AetheriaRuntimeRunCheckpointCommit run)
|
||||
{
|
||||
var zones = new Dictionary<int, AetheriaRuntimeZoneSnapshotCommit>();
|
||||
|
|
|
|||
Loading…
Reference in a new issue