diff --git a/Content.Client/CombatMode/CombatModeSystem.cs b/Content.Client/CombatMode/CombatModeSystem.cs index 2c938b1b93..85a33b4cfe 100644 --- a/Content.Client/CombatMode/CombatModeSystem.cs +++ b/Content.Client/CombatMode/CombatModeSystem.cs @@ -1,5 +1,4 @@ using Content.Client.Hands.Systems; -using Content.Client.NPC.HTN; using Content.Shared.CCVar; using Content.Shared.CombatMode; using Robust.Client.Graphics; @@ -59,11 +58,6 @@ public sealed class CombatModeSystem : SharedCombatModeSystem UpdateHud(entity); } - protected override bool IsNpc(EntityUid uid) - { - return HasComp(uid); - } - private void UpdateHud(EntityUid entity) { if (entity != _playerManager.LocalEntity || !Timing.IsFirstTimePredicted) diff --git a/Content.Client/NPC/Systems/NPCSystem.cs b/Content.Client/NPC/Systems/NPCSystem.cs new file mode 100644 index 0000000000..b20756aea5 --- /dev/null +++ b/Content.Client/NPC/Systems/NPCSystem.cs @@ -0,0 +1,12 @@ +using Content.Client.NPC.HTN; +using Content.Shared.NPC.Systems; + +namespace Content.Client.NPC.Systems; + +public sealed class NPCSystem : SharedNPCSystem +{ + public override bool IsNpc(EntityUid uid) + { + return HasComp(uid); + } +} diff --git a/Content.Server/CombatMode/CombatModeSystem.cs b/Content.Server/CombatMode/CombatModeSystem.cs index e04463c534..af36bb5947 100644 --- a/Content.Server/CombatMode/CombatModeSystem.cs +++ b/Content.Server/CombatMode/CombatModeSystem.cs @@ -1,12 +1,5 @@ -using Content.Server.NPC.HTN; using Content.Shared.CombatMode; namespace Content.Server.CombatMode; -public sealed class CombatModeSystem : SharedCombatModeSystem -{ - protected override bool IsNpc(EntityUid uid) - { - return HasComp(uid); - } -} +public sealed class CombatModeSystem : SharedCombatModeSystem; diff --git a/Content.Server/NPC/Systems/NPCSystem.cs b/Content.Server/NPC/Systems/NPCSystem.cs index 7aea766930..5788d20ad8 100644 --- a/Content.Server/NPC/Systems/NPCSystem.cs +++ b/Content.Server/NPC/Systems/NPCSystem.cs @@ -18,7 +18,7 @@ namespace Content.Server.NPC.Systems /// /// Handles NPCs running every tick. /// - public sealed partial class NPCSystem : EntitySystem + public sealed partial class NPCSystem : SharedNPCSystem { private static readonly Gauge ActiveGauge = Metrics.CreateGauge( "npc_active_count", @@ -78,6 +78,11 @@ namespace Content.Server.NPC.Systems SleepNPC(uid, component); } + public override bool IsNpc(EntityUid uid) + { + return HasComp(uid); + } + /// /// Is the NPC awake and updating? /// diff --git a/Content.Shared/CombatMode/SharedCombatModeSystem.cs b/Content.Shared/CombatMode/SharedCombatModeSystem.cs index af7bb9fefe..9063d0a6b8 100644 --- a/Content.Shared/CombatMode/SharedCombatModeSystem.cs +++ b/Content.Shared/CombatMode/SharedCombatModeSystem.cs @@ -2,8 +2,8 @@ using Content.Shared.Actions; using Content.Shared.Mind; using Content.Shared.MouseRotator; using Content.Shared.Movement.Components; +using Content.Shared.NPC.Systems; using Content.Shared.Popups; -using Robust.Shared.Network; using Robust.Shared.Timing; namespace Content.Shared.CombatMode; @@ -14,6 +14,7 @@ public abstract class SharedCombatModeSystem : EntitySystem [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedMindSystem _mind = default!; + [Dependency] private readonly SharedNPCSystem _npc = default!; public override void Initialize() { @@ -77,7 +78,7 @@ public abstract class SharedCombatModeSystem : EntitySystem _actionsSystem.SetToggled(component.CombatToggleActionEntity, component.IsInCombatMode); // Change mouse rotator comps if flag is set - if (!component.ToggleMouseRotator || IsNpc(entity) && !_mind.TryGetMind(entity, out _, out _)) + if (!component.ToggleMouseRotator || _npc.IsNpc(entity) && !_mind.TryGetMind(entity, out _, out _)) return; SetMouseRotatorComponents(entity, value); @@ -96,9 +97,6 @@ public abstract class SharedCombatModeSystem : EntitySystem RemComp(uid); } } - - // todo: When we stop making fucking garbage abstract shared components, remove this shit too. - protected abstract bool IsNpc(EntityUid uid); } public sealed partial class ToggleCombatActionEvent : InstantActionEvent diff --git a/Content.Shared/NPC/Systems/SharedNPCSystem.cs b/Content.Shared/NPC/Systems/SharedNPCSystem.cs index 247ab478a1..178856c904 100644 --- a/Content.Shared/NPC/Systems/SharedNPCSystem.cs +++ b/Content.Shared/NPC/Systems/SharedNPCSystem.cs @@ -2,4 +2,10 @@ namespace Content.Shared.NPC.Systems; public abstract partial class SharedNPCSystem : EntitySystem { + /// + /// Returns whether the given entity is an NPC. + /// + /// Entity UID to check. + /// true if the entity is an NPC, otherwise false. + public abstract bool IsNpc(EntityUid uid); }