Turn interaction related attempt events into structs (#29168)

* Turn InteractionAttemptEvent into a struct event

* readonly

* GettingInteractedWithAttemptEvent

* ConsciousAttemptEvent
This commit is contained in:
Leon Friedrich
2024-06-19 02:30:41 +12:00
committed by GitHub
parent db30b5e040
commit ee2c115e5b
13 changed files with 80 additions and 37 deletions

View File

@@ -6,6 +6,7 @@ using Content.Shared.Movement.Events;
namespace Content.Shared.Interaction;
// TODO deduplicate with AdminFrozenComponent
/// <summary>
/// Handles <see cref="BlockMovementComponent"/>, which prevents various
/// kinds of movement and interactions when attached to an entity.
@@ -16,7 +17,7 @@ public partial class SharedInteractionSystem
{
SubscribeLocalEvent<BlockMovementComponent, UpdateCanMoveEvent>(OnMoveAttempt);
SubscribeLocalEvent<BlockMovementComponent, UseAttemptEvent>(CancelEvent);
SubscribeLocalEvent<BlockMovementComponent, InteractionAttemptEvent>(CancelEvent);
SubscribeLocalEvent<BlockMovementComponent, InteractionAttemptEvent>(CancelInteractEvent);
SubscribeLocalEvent<BlockMovementComponent, DropAttemptEvent>(CancelEvent);
SubscribeLocalEvent<BlockMovementComponent, PickupAttemptEvent>(CancelEvent);
SubscribeLocalEvent<BlockMovementComponent, ChangeDirectionAttemptEvent>(CancelEvent);
@@ -25,6 +26,11 @@ public partial class SharedInteractionSystem
SubscribeLocalEvent<BlockMovementComponent, ComponentShutdown>(OnBlockingShutdown);
}
private void CancelInteractEvent(Entity<BlockMovementComponent> ent, ref InteractionAttemptEvent args)
{
args.Cancelled = true;
}
private void OnMoveAttempt(EntityUid uid, BlockMovementComponent component, UpdateCanMoveEvent args)
{
if (component.LifeStage > ComponentLifeStage.Running)