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

@@ -31,7 +31,7 @@ public partial class MobStateSystem
SubscribeLocalEvent<MobStateComponent, ChangeDirectionAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, UseAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, AttackAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, ConsciousAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, ConsciousAttemptEvent>(CheckConcious);
SubscribeLocalEvent<MobStateComponent, ThrowAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, SpeakAttemptEvent>(OnSpeakAttempt);
SubscribeLocalEvent<MobStateComponent, IsEquippingAttemptEvent>(OnEquipAttempt);
@@ -48,6 +48,17 @@ public partial class MobStateSystem
SubscribeLocalEvent<MobStateComponent, AttemptPacifiedAttackEvent>(OnAttemptPacifiedAttack);
}
private void CheckConcious(Entity<MobStateComponent> ent, ref ConsciousAttemptEvent args)
{
switch (ent.Comp.CurrentState)
{
case MobState.Dead:
case MobState.Critical:
args.Cancelled = true;
break;
}
}
private void OnStateExitSubscribers(EntityUid target, MobStateComponent component, MobState state)
{
switch (state)