ReplaySpectatorSystem.Blockers.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Content.Shared.Hands;
  2. using Content.Shared.Interaction.Events;
  3. using Content.Shared.Inventory.Events;
  4. using Content.Shared.Item;
  5. using Content.Shared.Movement.Events;
  6. using Content.Shared.Movement.Pulling.Events;
  7. using Content.Shared.Throwing;
  8. namespace Content.Client.Replay.Spectator;
  9. public sealed partial class ReplaySpectatorSystem
  10. {
  11. private void InitializeBlockers()
  12. {
  13. // Block most interactions to avoid mispredicts
  14. // This **shouldn't** be required, but just in case.
  15. SubscribeLocalEvent<ReplaySpectatorComponent, UseAttemptEvent>(OnAttempt);
  16. SubscribeLocalEvent<ReplaySpectatorComponent, PickupAttemptEvent>(OnAttempt);
  17. SubscribeLocalEvent<ReplaySpectatorComponent, ThrowAttemptEvent>(OnAttempt);
  18. SubscribeLocalEvent<ReplaySpectatorComponent, InteractionAttemptEvent>(OnInteractAttempt);
  19. SubscribeLocalEvent<ReplaySpectatorComponent, AttackAttemptEvent>(OnAttempt);
  20. SubscribeLocalEvent<ReplaySpectatorComponent, DropAttemptEvent>(OnAttempt);
  21. SubscribeLocalEvent<ReplaySpectatorComponent, IsEquippingAttemptEvent>(OnAttempt);
  22. SubscribeLocalEvent<ReplaySpectatorComponent, IsUnequippingAttemptEvent>(OnAttempt);
  23. SubscribeLocalEvent<ReplaySpectatorComponent, UpdateCanMoveEvent>(OnUpdateCanMove);
  24. SubscribeLocalEvent<ReplaySpectatorComponent, ChangeDirectionAttemptEvent>(OnUpdateCanMove);
  25. SubscribeLocalEvent<ReplaySpectatorComponent, PullAttemptEvent>(OnPullAttempt);
  26. }
  27. private void OnInteractAttempt(Entity<ReplaySpectatorComponent> ent, ref InteractionAttemptEvent args)
  28. {
  29. args.Cancelled = true;
  30. }
  31. private void OnAttempt(EntityUid uid, ReplaySpectatorComponent component, CancellableEntityEventArgs args)
  32. {
  33. args.Cancel();
  34. }
  35. private void OnUpdateCanMove(EntityUid uid, ReplaySpectatorComponent component, CancellableEntityEventArgs args)
  36. {
  37. args.Cancel();
  38. }
  39. private void OnPullAttempt(EntityUid uid, ReplaySpectatorComponent component, PullAttemptEvent args)
  40. {
  41. args.Cancelled = true;
  42. }
  43. }