Move reticle targeting into daemon operations
This commit is contained in:
parent
1f47ea387b
commit
712c34bf52
7 changed files with 168 additions and 9 deletions
|
|
@ -2057,12 +2057,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
Input.Player.TargetReticle.performed += context =>
|
||||
{
|
||||
if (!CurrentEntity.VisibleEnemies.Any()) return;
|
||||
var underReticle = CurrentEntity.VisibleEnemies.Where(x => x != CurrentEntity)
|
||||
.MaxBy(x => CultMath.math.dot(
|
||||
CultMath.math.normalize(x.CultPosition - CurrentEntity.CultPosition),
|
||||
CurrentEntity.CultLookDirection));
|
||||
RequestTargetSelection(CurrentEntity.Target.Value == underReticle ? null : underReticle);
|
||||
RequestTargetReticle();
|
||||
};
|
||||
|
||||
Input.Player.TargetNearest.performed += context =>
|
||||
|
|
@ -3744,6 +3739,11 @@ public class ActionGameManager : MonoBehaviour
|
|||
TryRequestDaemonTargetCycle(AetheriaRuntimeDaemonCommandKinds.TargetPrevious);
|
||||
}
|
||||
|
||||
private void RequestTargetReticle()
|
||||
{
|
||||
TryRequestDaemonTargetReticle(_viewDirection);
|
||||
}
|
||||
|
||||
private bool TryRequestDaemonTargetSelection(Entity target)
|
||||
{
|
||||
var observer = ResolveDaemonObserver();
|
||||
|
|
@ -3776,6 +3776,26 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private bool TryRequestDaemonTargetReticle(Vector3 lookDirection)
|
||||
{
|
||||
var observer = ResolveDaemonObserver();
|
||||
if (observer == null || !observer.HasAuthoritativeState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
observer.Operations.TargetReticle(lookDirection.x, lookDirection.y, lookDirection.z);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to send Aetheria daemon reticle target operation; operation not submitted: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryRequestDaemonTargetCycle(AetheriaRuntimeDaemonCommandKinds command)
|
||||
{
|
||||
var observer = ResolveDaemonObserver();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ public sealed class AetheriaDaemonOperations
|
|||
return Send((client, observed) => client.TargetPrevious(observed));
|
||||
}
|
||||
|
||||
public AetheriaRuntimeDaemonCommandEnvelope TargetReticle(double directionX, double directionY, double directionZ)
|
||||
{
|
||||
return Send((client, observed) => client.TargetReticle(observed, directionX, directionY, directionZ));
|
||||
}
|
||||
|
||||
public AetheriaRuntimeDaemonCommandEnvelope SetMoveVector(
|
||||
double directionX,
|
||||
double directionY,
|
||||
|
|
|
|||
|
|
@ -1144,6 +1144,63 @@ public class DaemonRuntimeDocumentTests
|
|||
Assert.AreEqual(2, zone.Entities[0].TargetEntityIndex);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DaemonOperationsTargetsReticleFromAuthoritativeContacts()
|
||||
{
|
||||
var run = RunWithTwoEntities();
|
||||
var zone = run.Zones[0];
|
||||
zone.Entities[0].PositionX = 0;
|
||||
zone.Entities[0].PositionY = 0;
|
||||
zone.Entities[0].PositionZ = 0;
|
||||
zone.Entities[1].PositionX = 0;
|
||||
zone.Entities[1].PositionY = 0;
|
||||
zone.Entities[1].PositionZ = 5;
|
||||
zone.Entities = zone.Entities
|
||||
.Concat(new[]
|
||||
{
|
||||
new AetheriaRuntimeEntitySnapshotCommit
|
||||
{
|
||||
EntityIndex = 2,
|
||||
Name = "Off Reticle",
|
||||
PositionX = 5,
|
||||
PositionY = 0,
|
||||
PositionZ = 0
|
||||
}
|
||||
})
|
||||
.ToArray();
|
||||
zone.Entities[0].Contacts = new[]
|
||||
{
|
||||
new AetheriaRuntimeEntityContactCommit
|
||||
{
|
||||
TargetEntityIndex = 1,
|
||||
Visible = true,
|
||||
Hostile = true
|
||||
},
|
||||
new AetheriaRuntimeEntityContactCommit
|
||||
{
|
||||
TargetEntityIndex = 2,
|
||||
Visible = true,
|
||||
Hostile = true
|
||||
}
|
||||
};
|
||||
|
||||
var command = AetheriaRuntimeDaemonCommandDocument.Create(
|
||||
AetheriaRuntimeDaemonCommandKinds.TargetReticle,
|
||||
"codex",
|
||||
"session-reticle",
|
||||
18,
|
||||
"zone.0.entity.0");
|
||||
command.PositionZ = 1;
|
||||
|
||||
var targetResult = AetheriaRuntimeDaemonOperations.Execute(run, new[] { command });
|
||||
Assert.AreEqual(1, targetResult.AppliedCommandIds.Count);
|
||||
Assert.AreEqual(1, zone.Entities[0].TargetEntityIndex);
|
||||
|
||||
var toggleResult = AetheriaRuntimeDaemonOperations.Execute(run, new[] { command });
|
||||
Assert.AreEqual(1, toggleResult.AppliedCommandIds.Count);
|
||||
Assert.AreEqual(-1, zone.Entities[0].TargetEntityIndex);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DaemonOperationsMutatesHotEntityControlsInDaemonState()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue