SharedPointingSystem.cs 913 B

123456789101112131415161718192021222324252627282930313233343536
  1. using Robust.Shared.Serialization;
  2. using System.Numerics;
  3. namespace Content.Shared.Pointing;
  4. public abstract class SharedPointingSystem : EntitySystem
  5. {
  6. protected readonly TimeSpan PointDuration = TimeSpan.FromSeconds(4);
  7. protected readonly float PointKeyTimeMove = 0.1f;
  8. protected readonly float PointKeyTimeHover = 0.5f;
  9. [Serializable, NetSerializable]
  10. public sealed class SharedPointingArrowComponentState : ComponentState
  11. {
  12. public Vector2 StartPosition { get; init; }
  13. public TimeSpan EndTime { get; init; }
  14. }
  15. public bool CanPoint(EntityUid uid)
  16. {
  17. var ev = new PointAttemptEvent(uid);
  18. RaiseLocalEvent(uid, ev, true);
  19. return !ev.Cancelled;
  20. }
  21. }
  22. public sealed class PointAttemptEvent : CancellableEntityEventArgs
  23. {
  24. public PointAttemptEvent(EntityUid uid)
  25. {
  26. Uid = uid;
  27. }
  28. public EntityUid Uid { get; }
  29. }