acdream/src/AcDream.App/Physics/RemoteMovementObservationTracker.cs

27 lines
871 B
C#

using System.Numerics;
namespace AcDream.App.Physics;
/// <summary>
/// Session-scoped observation timestamps used to infer when a remote
/// locomotion cycle has stopped. Canonical live identity remains in
/// <c>LiveEntityRuntime</c>; this owner contains only derived observer state.
/// </summary>
internal sealed class RemoteMovementObservationTracker
{
private readonly Dictionary<uint, (Vector3 Pos, DateTime Time)> _lastMove = new();
internal (Vector3 Pos, DateTime Time) this[uint serverGuid]
{
set => _lastMove[serverGuid] = value;
}
internal bool TryGetValue(
uint serverGuid,
out (Vector3 Pos, DateTime Time) observation) =>
_lastMove.TryGetValue(serverGuid, out observation);
internal bool Remove(uint serverGuid) => _lastMove.Remove(serverGuid);
internal void Clear() => _lastMove.Clear();
}