From 7beb363285346e9a5a95464fa93e8850fb8ed86d Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Thu, 21 Oct 2021 13:03:14 +1100 Subject: [PATCH] Deprecate a bunch of IActionBlocker (#4852) * Deprecate IActionBlocker ChangeDirectionAttempt * Woops * Throw and interact * Deperacte speech * ActionBlocker in fucking shambles * CanEmote go byebye * CanAttack is GONE * IActionBlocker finally ded * DRY --- Content.Client/Cuffs/CuffableSystem.cs | 9 ++ Content.Server/Cuffs/CuffableSystem.cs | 2 +- .../Components/EntityStorageComponent.cs | 2 +- .../ActionBlocker/ActionBlockerSystem.cs | 90 ------------------- .../ActionBlocker/IActionBlocker.cs | 43 --------- .../Climbing/SharedClimbingComponent.cs | 2 +- .../Components/SharedCuffableComponent.cs | 15 +--- Content.Shared/Cuffs/SharedCuffableSystem.cs | 56 ++++++++++++ .../EffectBlocker/IEffectBlocker.cs | 2 +- Content.Shared/Ghost/SharedGhostComponent.cs | 12 +-- Content.Shared/Ghost/SharedGhostSystem.cs | 49 ++++++++++ .../MobState/Components/MobStateComponent.cs | 53 +---------- .../MobState/EntitySystems/MobStateSystem.cs | 70 ++++++++++++++- Content.Shared/MobState/State/BaseMobState.cs | 50 ----------- Content.Shared/MobState/State/IMobState.cs | 2 +- .../MobState/State/SharedCriticalMobState.cs | 51 ----------- .../MobState/State/SharedDeadMobState.cs | 60 ------------- .../MobState/State/SharedNormalMobState.cs | 50 ----------- .../Speech/SharedSpeechComponent.cs | 5 +- Content.Shared/Speech/SpeechSystem.cs | 10 +-- 20 files changed, 196 insertions(+), 437 deletions(-) create mode 100644 Content.Client/Cuffs/CuffableSystem.cs delete mode 100644 Content.Shared/ActionBlocker/IActionBlocker.cs diff --git a/Content.Client/Cuffs/CuffableSystem.cs b/Content.Client/Cuffs/CuffableSystem.cs new file mode 100644 index 0000000000..a2fa91c1e8 --- /dev/null +++ b/Content.Client/Cuffs/CuffableSystem.cs @@ -0,0 +1,9 @@ +using Content.Shared.Cuffs; + +namespace Content.Client.Cuffs +{ + public sealed class CuffableSystem : SharedCuffableSystem + { + + } +} diff --git a/Content.Server/Cuffs/CuffableSystem.cs b/Content.Server/Cuffs/CuffableSystem.cs index a031212903..159373d6a3 100644 --- a/Content.Server/Cuffs/CuffableSystem.cs +++ b/Content.Server/Cuffs/CuffableSystem.cs @@ -15,7 +15,7 @@ using Robust.Shared.Player; namespace Content.Server.Cuffs { [UsedImplicitly] - internal sealed class CuffableSystem : SharedCuffableSystem + public sealed class CuffableSystem : SharedCuffableSystem { [Dependency] private readonly SharedPopupSystem _popupSystem = default!; [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; diff --git a/Content.Server/Storage/Components/EntityStorageComponent.cs b/Content.Server/Storage/Components/EntityStorageComponent.cs index 04f9478a3d..d53be8d360 100644 --- a/Content.Server/Storage/Components/EntityStorageComponent.cs +++ b/Content.Server/Storage/Components/EntityStorageComponent.cs @@ -36,7 +36,7 @@ namespace Content.Server.Storage.Components [RegisterComponent] [ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IStorageComponent))] - public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing, IDestroyAct, IActionBlocker, IExAct + public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing, IDestroyAct, IExAct { public override string Name => "EntityStorage"; diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index 60e034abe6..186d96f17f 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -42,15 +42,6 @@ namespace Content.Shared.ActionBlocker RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in ev.Entity.GetAllComponents()) - { - if (!blocker.CanInteract()) - { - ev.Cancel(); - break; - } - } - return !ev.Cancelled; } @@ -65,15 +56,6 @@ namespace Content.Shared.ActionBlocker RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in ev.Entity.GetAllComponents()) - { - if (!blocker.CanUse()) - { - ev.Cancel(); - break; - } - } - return !ev.Cancelled; } @@ -88,15 +70,6 @@ namespace Content.Shared.ActionBlocker RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in ev.Entity.GetAllComponents()) - { - if (!blocker.CanThrow()) - { - ev.Cancel(); - break; - } - } - return !ev.Cancelled; } @@ -111,15 +84,6 @@ namespace Content.Shared.ActionBlocker RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in ev.Entity.GetAllComponents()) - { - if (!blocker.CanSpeak()) - { - ev.Cancel(); - break; - } - } - return !ev.Cancelled; } @@ -134,15 +98,6 @@ namespace Content.Shared.ActionBlocker RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in ev.Entity.GetAllComponents()) - { - if (!blocker.CanDrop()) - { - ev.Cancel(); - break; - } - } - return !ev.Cancelled; } @@ -157,15 +112,6 @@ namespace Content.Shared.ActionBlocker RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in ev.Entity.GetAllComponents()) - { - if (!blocker.CanPickup()) - { - ev.Cancel(); - break; - } - } - return !ev.Cancelled; } @@ -180,15 +126,6 @@ namespace Content.Shared.ActionBlocker RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in ev.Entity.GetAllComponents()) - { - if (!blocker.CanEmote()) - { - ev.Cancel(); - break; - } - } - return !ev.Cancelled; } @@ -203,15 +140,6 @@ namespace Content.Shared.ActionBlocker RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in ev.Entity.GetAllComponents()) - { - if (!blocker.CanAttack()) - { - ev.Cancel(); - break; - } - } - return !ev.Cancelled; } @@ -226,15 +154,6 @@ namespace Content.Shared.ActionBlocker RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in ev.Entity.GetAllComponents()) - { - if (!blocker.CanEquip()) - { - ev.Cancel(); - break; - } - } - return !ev.Cancelled; } @@ -249,15 +168,6 @@ namespace Content.Shared.ActionBlocker RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in ev.Entity.GetAllComponents()) - { - if (!blocker.CanUnequip()) - { - ev.Cancel(); - break; - } - } - return !ev.Cancelled; } diff --git a/Content.Shared/ActionBlocker/IActionBlocker.cs b/Content.Shared/ActionBlocker/IActionBlocker.cs deleted file mode 100644 index f92829159b..0000000000 --- a/Content.Shared/ActionBlocker/IActionBlocker.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using Content.Shared.EffectBlocker; - -namespace Content.Shared.ActionBlocker -{ - /// - /// This interface gives components the ability to block certain actions from - /// being done by the owning entity. For effects see - /// - [Obsolete("Use events instead")] - public interface IActionBlocker - { - [Obsolete("Use InteractAttemptEvent instead")] - bool CanInteract() => true; - - [Obsolete("Use UseAttemptEvent instead")] - bool CanUse() => true; - - [Obsolete("Use ThrowAttemptEvent instead")] - bool CanThrow() => true; - - [Obsolete("Use SpeakAttemptEvent instead")] - bool CanSpeak() => true; - - [Obsolete("Use DropAttemptEvent instead")] - bool CanDrop() => true; - - [Obsolete("Use PickupAttemptEvent instead")] - bool CanPickup() => true; - - [Obsolete("Use EmoteAttemptEvent instead")] - bool CanEmote() => true; - - [Obsolete("Use AttackAttemptEvent instead")] - bool CanAttack() => true; - - [Obsolete("Use EquipAttemptEvent instead")] - bool CanEquip() => true; - - [Obsolete("Use UnequipAttemptEvent instead")] - bool CanUnequip() => true; - } -} diff --git a/Content.Shared/Climbing/SharedClimbingComponent.cs b/Content.Shared/Climbing/SharedClimbingComponent.cs index b139b0e3f1..b799fd7e7c 100644 --- a/Content.Shared/Climbing/SharedClimbingComponent.cs +++ b/Content.Shared/Climbing/SharedClimbingComponent.cs @@ -10,7 +10,7 @@ using Robust.Shared.ViewVariables; namespace Content.Shared.Climbing { [NetworkedComponent()] - public abstract class SharedClimbingComponent : Component, IActionBlocker + public abstract class SharedClimbingComponent : Component { public sealed override string Name => "Climbing"; diff --git a/Content.Shared/Cuffs/Components/SharedCuffableComponent.cs b/Content.Shared/Cuffs/Components/SharedCuffableComponent.cs index 72c61a6cb3..8ffe4d7b8e 100644 --- a/Content.Shared/Cuffs/Components/SharedCuffableComponent.cs +++ b/Content.Shared/Cuffs/Components/SharedCuffableComponent.cs @@ -1,6 +1,4 @@ using System; -using Content.Shared.ActionBlocker; -using Content.Shared.Pulling.Components; using Robust.Shared.GameObjects; using Robust.Shared.GameStates; using Robust.Shared.Maths; @@ -10,24 +8,13 @@ using Robust.Shared.ViewVariables; namespace Content.Shared.Cuffs.Components { [NetworkedComponent()] - public class SharedCuffableComponent : Component, IActionBlocker + public class SharedCuffableComponent : Component { public override string Name => "Cuffable"; [ViewVariables] public bool CanStillInteract { get; set; } = true; - #region ActionBlockers - - bool IActionBlocker.CanInteract() => CanStillInteract; - bool IActionBlocker.CanUse() => CanStillInteract; - bool IActionBlocker.CanPickup() => CanStillInteract; - bool IActionBlocker.CanDrop() => CanStillInteract; - bool IActionBlocker.CanAttack() => CanStillInteract; - bool IActionBlocker.CanEquip() => CanStillInteract; - bool IActionBlocker.CanUnequip() => CanStillInteract; - #endregion - [Serializable, NetSerializable] protected sealed class CuffableComponentState : ComponentState { diff --git a/Content.Shared/Cuffs/SharedCuffableSystem.cs b/Content.Shared/Cuffs/SharedCuffableSystem.cs index 473925515e..92d1ee0a72 100644 --- a/Content.Shared/Cuffs/SharedCuffableSystem.cs +++ b/Content.Shared/Cuffs/SharedCuffableSystem.cs @@ -1,4 +1,8 @@ using Content.Shared.Cuffs.Components; +using Content.Shared.DragDrop; +using Content.Shared.Interaction.Events; +using Content.Shared.Inventory.Events; +using Content.Shared.Item; using Content.Shared.Movement; using Content.Shared.Pulling.Components; using Robust.Shared.GameObjects; @@ -12,6 +16,13 @@ namespace Content.Shared.Cuffs base.Initialize(); SubscribeLocalEvent(HandleStopPull); SubscribeLocalEvent(HandleMoveAttempt); + SubscribeLocalEvent(OnUseAttempt); + SubscribeLocalEvent(OnInteractAttempt); + SubscribeLocalEvent(OnEquipAttempt); + SubscribeLocalEvent(OnUnequipAttempt); + SubscribeLocalEvent(OnAttackAttempt); + SubscribeLocalEvent(OnDropAttempt); + SubscribeLocalEvent(OnPickupAttempt); } private void HandleMoveAttempt(EntityUid uid, SharedCuffableComponent component, MovementAttemptEvent args) @@ -31,5 +42,50 @@ namespace Content.Shared.Cuffs args.Cancel(); } } + + #region ActionBlocker + + private void CheckAct(EntityUid uid, SharedCuffableComponent component, CancellableEntityEventArgs args) + { + if (!component.CanStillInteract) + args.Cancel(); + } + + private void OnUseAttempt(EntityUid uid, SharedCuffableComponent component, UseAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnInteractAttempt(EntityUid uid, SharedCuffableComponent component, InteractionAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnEquipAttempt(EntityUid uid, SharedCuffableComponent component, EquipAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnUnequipAttempt(EntityUid uid, SharedCuffableComponent component, UnequipAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnAttackAttempt(EntityUid uid, SharedCuffableComponent component, AttackAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnDropAttempt(EntityUid uid, SharedCuffableComponent component, DropAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnPickupAttempt(EntityUid uid, SharedCuffableComponent component, PickupAttemptEvent args) + { + CheckAct(uid, component, args); + } + + #endregion } } diff --git a/Content.Shared/EffectBlocker/IEffectBlocker.cs b/Content.Shared/EffectBlocker/IEffectBlocker.cs index c8c3d05d2e..6f1ce4b541 100644 --- a/Content.Shared/EffectBlocker/IEffectBlocker.cs +++ b/Content.Shared/EffectBlocker/IEffectBlocker.cs @@ -4,7 +4,7 @@ namespace Content.Shared.EffectBlocker { /// /// This interface gives components the ability to block certain effects - /// from affecting the owning entity. For actions see + /// from affecting the owning entity. /// public interface IEffectBlocker { diff --git a/Content.Shared/Ghost/SharedGhostComponent.cs b/Content.Shared/Ghost/SharedGhostComponent.cs index f5545d137b..70169c1ee1 100644 --- a/Content.Shared/Ghost/SharedGhostComponent.cs +++ b/Content.Shared/Ghost/SharedGhostComponent.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using Content.Shared.ActionBlocker; using Robust.Shared.GameObjects; using Robust.Shared.GameStates; using Robust.Shared.Players; @@ -11,7 +9,7 @@ using Robust.Shared.ViewVariables; namespace Content.Shared.Ghost { [NetworkedComponent()] - public class SharedGhostComponent : Component, IActionBlocker + public class SharedGhostComponent : Component { public override string Name => "Ghost"; @@ -66,14 +64,6 @@ namespace Content.Shared.Ghost CanReturnToBody = state.CanReturnToBody; CanGhostInteract = state.CanGhostInteract; } - - public bool CanInteract() => CanGhostInteract; - public bool CanUse() => CanGhostInteract; - public bool CanThrow() => CanGhostInteract; - public bool CanDrop() => CanGhostInteract; - public bool CanPickup() => CanGhostInteract; - public bool CanEmote() => false; - public bool CanAttack() => CanGhostInteract; } [Serializable, NetSerializable] diff --git a/Content.Shared/Ghost/SharedGhostSystem.cs b/Content.Shared/Ghost/SharedGhostSystem.cs index a7e5d23fa1..fadf894e0d 100644 --- a/Content.Shared/Ghost/SharedGhostSystem.cs +++ b/Content.Shared/Ghost/SharedGhostSystem.cs @@ -1,5 +1,9 @@ using System; using System.Collections.Generic; +using Content.Shared.DragDrop; +using Content.Shared.Emoting; +using Content.Shared.Interaction.Events; +using Content.Shared.Item; using Robust.Shared.GameObjects; using Robust.Shared.Serialization; @@ -7,6 +11,51 @@ namespace Content.Shared.Ghost { public abstract class SharedGhostSystem : EntitySystem { + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnUseAttempt); + SubscribeLocalEvent(OnInteractAttempt); + SubscribeLocalEvent(OnEmoteAttempt); + SubscribeLocalEvent(OnAttackAttempt); + SubscribeLocalEvent(OnDropAttempt); + SubscribeLocalEvent(OnPickupAttempt); + } + + private void OnUseAttempt(EntityUid uid, SharedGhostComponent component, UseAttemptEvent args) + { + if (!component.CanGhostInteract) + args.Cancel(); + } + + private void OnInteractAttempt(EntityUid uid, SharedGhostComponent component, InteractionAttemptEvent args) + { + if (!component.CanGhostInteract) + args.Cancel(); + } + + private void OnEmoteAttempt(EntityUid uid, SharedGhostComponent component, EmoteAttemptEvent args) + { + args.Cancel(); + } + + private void OnAttackAttempt(EntityUid uid, SharedGhostComponent component, AttackAttemptEvent args) + { + args.Cancel(); + } + + private void OnDropAttempt(EntityUid uid, SharedGhostComponent component, DropAttemptEvent args) + { + if (!component.CanGhostInteract) + args.Cancel(); + } + + private void OnPickupAttempt(EntityUid uid, SharedGhostComponent component, PickupAttemptEvent args) + { + if (!component.CanGhostInteract) + args.Cancel(); + } + public void SetCanReturnToBody(SharedGhostComponent component, bool canReturn) { if (component.CanReturnToBody == canReturn) diff --git a/Content.Shared/MobState/Components/MobStateComponent.cs b/Content.Shared/MobState/Components/MobStateComponent.cs index 1c6a531453..2a5cf2509b 100644 --- a/Content.Shared/MobState/Components/MobStateComponent.cs +++ b/Content.Shared/MobState/Components/MobStateComponent.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; -using Content.Shared.ActionBlocker; using Content.Shared.Alert; using Content.Shared.Damage; using Content.Shared.MobState.State; @@ -24,7 +23,7 @@ namespace Content.Shared.MobState.Components [RegisterComponent] [ComponentReference(typeof(IMobStateComponent))] [NetworkedComponent()] - public class MobStateComponent : Component, IMobStateComponent, IActionBlocker + public class MobStateComponent : Component, IMobStateComponent { public override string Name => "MobState"; @@ -318,56 +317,6 @@ namespace Content.Shared.MobState.Components Dirty(); } - - bool IActionBlocker.CanInteract() - { - return CurrentState?.CanInteract() ?? true; - } - - bool IActionBlocker.CanUse() - { - return CurrentState?.CanUse() ?? true; - } - - bool IActionBlocker.CanThrow() - { - return CurrentState?.CanThrow() ?? true; - } - - bool IActionBlocker.CanSpeak() - { - return CurrentState?.CanSpeak() ?? true; - } - - bool IActionBlocker.CanDrop() - { - return CurrentState?.CanDrop() ?? true; - } - - bool IActionBlocker.CanPickup() - { - return CurrentState?.CanPickup() ?? true; - } - - bool IActionBlocker.CanEmote() - { - return CurrentState?.CanEmote() ?? true; - } - - bool IActionBlocker.CanAttack() - { - return CurrentState?.CanAttack() ?? true; - } - - bool IActionBlocker.CanEquip() - { - return CurrentState?.CanEquip() ?? true; - } - - bool IActionBlocker.CanUnequip() - { - return CurrentState?.CanUnequip() ?? true; - } } [Serializable, NetSerializable] diff --git a/Content.Shared/MobState/EntitySystems/MobStateSystem.cs b/Content.Shared/MobState/EntitySystems/MobStateSystem.cs index 5f05420d11..033bc3bb45 100644 --- a/Content.Shared/MobState/EntitySystems/MobStateSystem.cs +++ b/Content.Shared/MobState/EntitySystems/MobStateSystem.cs @@ -1,10 +1,15 @@ using Content.Shared.Damage; +using Content.Shared.DragDrop; using Content.Shared.Interaction.Events; +using Content.Shared.Inventory.Events; +using Content.Shared.Item; using Content.Shared.MobState.Components; using Content.Shared.MobState.State; using Content.Shared.Movement; using Content.Shared.Pulling.Events; +using Content.Shared.Speech; using Content.Shared.Standing; +using Content.Shared.Throwing; using Robust.Shared.GameObjects; namespace Content.Shared.MobState.EntitySystems @@ -16,6 +21,15 @@ namespace Content.Shared.MobState.EntitySystems base.Initialize(); SubscribeLocalEvent(OnChangeDirectionAttempt); + SubscribeLocalEvent(OnUseAttempt); + SubscribeLocalEvent(OnInteractAttempt); + SubscribeLocalEvent(OnThrowAttempt); + SubscribeLocalEvent(OnSpeakAttempt); + SubscribeLocalEvent(OnEquipAttempt); + SubscribeLocalEvent(OnUnequipAttempt); + SubscribeLocalEvent(OnAttackAttempt); + SubscribeLocalEvent(OnDropAttempt); + SubscribeLocalEvent(OnPickupAttempt); SubscribeLocalEvent(OnStartPullAttempt); SubscribeLocalEvent(UpdateState); SubscribeLocalEvent(OnMoveAttempt); @@ -23,7 +37,9 @@ namespace Content.Shared.MobState.EntitySystems // Note that there's no check for Down attempts because if a mob's in crit or dead, they can be downed... } - private void OnChangeDirectionAttempt(EntityUid uid, MobStateComponent component, ChangeDirectionAttemptEvent args) + #region ActionBlocker + + private void CheckAct(EntityUid uid, MobStateComponent component, CancellableEntityEventArgs args) { switch (component.CurrentState) { @@ -34,6 +50,58 @@ namespace Content.Shared.MobState.EntitySystems } } + private void OnChangeDirectionAttempt(EntityUid uid, MobStateComponent component, ChangeDirectionAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnUseAttempt(EntityUid uid, MobStateComponent component, UseAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnInteractAttempt(EntityUid uid, MobStateComponent component, InteractionAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnThrowAttempt(EntityUid uid, MobStateComponent component, ThrowAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnSpeakAttempt(EntityUid uid, MobStateComponent component, SpeakAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnEquipAttempt(EntityUid uid, MobStateComponent component, EquipAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnUnequipAttempt(EntityUid uid, MobStateComponent component, UnequipAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnAttackAttempt(EntityUid uid, MobStateComponent component, AttackAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnDropAttempt(EntityUid uid, MobStateComponent component, DropAttemptEvent args) + { + CheckAct(uid, component, args); + } + + private void OnPickupAttempt(EntityUid uid, MobStateComponent component, PickupAttemptEvent args) + { + CheckAct(uid, component, args); + } + + #endregion + private void OnStartPullAttempt(EntityUid uid, MobStateComponent component, StartPullAttemptEvent args) { if(component.IsIncapacitated()) diff --git a/Content.Shared/MobState/State/BaseMobState.cs b/Content.Shared/MobState/State/BaseMobState.cs index bb8dec110f..7c45cea2cf 100644 --- a/Content.Shared/MobState/State/BaseMobState.cs +++ b/Content.Shared/MobState/State/BaseMobState.cs @@ -33,55 +33,5 @@ namespace Content.Shared.MobState.State public virtual void ExitState(IEntity entity) { } public virtual void UpdateState(IEntity entity, int threshold) { } - - public virtual bool CanInteract() - { - return true; - } - - public virtual bool CanUse() - { - return true; - } - - public virtual bool CanThrow() - { - return true; - } - - public virtual bool CanSpeak() - { - return true; - } - - public virtual bool CanDrop() - { - return true; - } - - public virtual bool CanPickup() - { - return true; - } - - public virtual bool CanEmote() - { - return true; - } - - public virtual bool CanAttack() - { - return true; - } - - public virtual bool CanEquip() - { - return true; - } - - public virtual bool CanUnequip() - { - return true; - } } } diff --git a/Content.Shared/MobState/State/IMobState.cs b/Content.Shared/MobState/State/IMobState.cs index 9f79a3806c..706baca857 100644 --- a/Content.Shared/MobState/State/IMobState.cs +++ b/Content.Shared/MobState/State/IMobState.cs @@ -8,7 +8,7 @@ namespace Content.Shared.MobState.State /// (i.e. Normal, Critical, Dead) and what effects to apply upon entering or /// exiting the state. /// - public interface IMobState : IActionBlocker + public interface IMobState { bool IsAlive(); diff --git a/Content.Shared/MobState/State/SharedCriticalMobState.cs b/Content.Shared/MobState/State/SharedCriticalMobState.cs index 470eba0b61..8eddf4fc5a 100644 --- a/Content.Shared/MobState/State/SharedCriticalMobState.cs +++ b/Content.Shared/MobState/State/SharedCriticalMobState.cs @@ -1,5 +1,4 @@ using Content.Shared.Alert; -using Content.Shared.Hands; using Content.Shared.Standing; using Robust.Shared.GameObjects; @@ -35,55 +34,5 @@ namespace Content.Shared.MobState.State EntitySystem.Get().Stand(entity.Uid); } - - public override bool CanInteract() - { - return false; - } - - public override bool CanUse() - { - return false; - } - - public override bool CanThrow() - { - return false; - } - - public override bool CanSpeak() - { - return false; - } - - public override bool CanDrop() - { - return false; - } - - public override bool CanPickup() - { - return false; - } - - public override bool CanEmote() - { - return false; - } - - public override bool CanAttack() - { - return false; - } - - public override bool CanEquip() - { - return false; - } - - public override bool CanUnequip() - { - return false; - } } } diff --git a/Content.Shared/MobState/State/SharedDeadMobState.cs b/Content.Shared/MobState/State/SharedDeadMobState.cs index 25b5c5ec2f..75de9026ac 100644 --- a/Content.Shared/MobState/State/SharedDeadMobState.cs +++ b/Content.Shared/MobState/State/SharedDeadMobState.cs @@ -43,65 +43,5 @@ namespace Content.Shared.MobState.State physics.CanCollide = true; } } - - public override bool CanInteract() - { - return false; - } - - public override bool CanUse() - { - return false; - } - - public override bool CanThrow() - { - return false; - } - - public override bool CanSpeak() - { - return false; - } - - public override bool CanDrop() - { - return false; - } - - public override bool CanPickup() - { - return false; - } - - public override bool CanEmote() - { - return false; - } - - public override bool CanAttack() - { - return false; - } - - public override bool CanEquip() - { - return false; - } - - public override bool CanUnequip() - { - return false; - } - - public bool CanShiver() - { - return false; - } - - public bool CanSweat() - { - return false; - } } } diff --git a/Content.Shared/MobState/State/SharedNormalMobState.cs b/Content.Shared/MobState/State/SharedNormalMobState.cs index 943797f976..681e70e89a 100644 --- a/Content.Shared/MobState/State/SharedNormalMobState.cs +++ b/Content.Shared/MobState/State/SharedNormalMobState.cs @@ -21,55 +21,5 @@ namespace Content.Shared.MobState.State appearance.SetData(DamageStateVisuals.State, DamageState.Alive); } } - - public override bool CanInteract() - { - return true; - } - - public override bool CanUse() - { - return true; - } - - public override bool CanThrow() - { - return true; - } - - public override bool CanSpeak() - { - return true; - } - - public override bool CanDrop() - { - return true; - } - - public override bool CanPickup() - { - return true; - } - - public override bool CanEmote() - { - return true; - } - - public override bool CanAttack() - { - return true; - } - - public override bool CanEquip() - { - return true; - } - - public override bool CanUnequip() - { - return true; - } } } diff --git a/Content.Shared/Speech/SharedSpeechComponent.cs b/Content.Shared/Speech/SharedSpeechComponent.cs index fdc736447d..8f3145d29a 100644 --- a/Content.Shared/Speech/SharedSpeechComponent.cs +++ b/Content.Shared/Speech/SharedSpeechComponent.cs @@ -1,4 +1,3 @@ -using Content.Shared.ActionBlocker; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; @@ -8,7 +7,7 @@ namespace Content.Shared.Speech /// Component required for entities to be able to speak. /// [RegisterComponent] - public class SharedSpeechComponent : Component, IActionBlocker + public class SharedSpeechComponent : Component { public override string Name => "Speech"; @@ -25,7 +24,5 @@ namespace Content.Shared.Speech Dirty(); } } - - bool IActionBlocker.CanSpeak() => Enabled; } } diff --git a/Content.Shared/Speech/SpeechSystem.cs b/Content.Shared/Speech/SpeechSystem.cs index 3f0b1b32f5..e7bb379d59 100644 --- a/Content.Shared/Speech/SpeechSystem.cs +++ b/Content.Shared/Speech/SpeechSystem.cs @@ -8,15 +8,13 @@ namespace Content.Shared.Speech { base.Initialize(); - SubscribeLocalEvent(OnSpeakAttempt); + SubscribeLocalEvent(OnSpeakAttempt); } - private void OnSpeakAttempt(SpeakAttemptEvent ev) + private void OnSpeakAttempt(EntityUid uid, SharedSpeechComponent component, SpeakAttemptEvent args) { - if (!ev.Entity.HasComponent()) - { - ev.Cancel(); - } + if (!component.Enabled) + args.Cancel(); } } }