diff --git a/Content.Server/NPC/Components/NPCComponent.cs b/Content.Server/NPC/Components/NPCComponent.cs
index 88ec70e0e3..b1d5bfcf5f 100644
--- a/Content.Server/NPC/Components/NPCComponent.cs
+++ b/Content.Server/NPC/Components/NPCComponent.cs
@@ -1,13 +1,12 @@
using Content.Shared.NPC;
-namespace Content.Server.NPC.Components
+namespace Content.Server.NPC.Components;
+
+public abstract partial class NPCComponent : SharedNPCComponent
{
- public abstract partial class NPCComponent : SharedNPCComponent
- {
- ///
- /// Contains all of the world data for a particular NPC in terms of how it sees the world.
- ///
- [DataField("blackboard", customTypeSerializer: typeof(NPCBlackboardSerializer))]
- public NPCBlackboard Blackboard = new();
- }
+ ///
+ /// Contains all of the world data for a particular NPC in terms of how it sees the world.
+ ///
+ [DataField("blackboard", customTypeSerializer: typeof(NPCBlackboardSerializer))]
+ public NPCBlackboard Blackboard = new();
}
diff --git a/Content.Server/NPC/HTN/HTNComponent.cs b/Content.Server/NPC/HTN/HTNComponent.cs
index 7fe6bd7d98..f482e0808c 100644
--- a/Content.Server/NPC/HTN/HTNComponent.cs
+++ b/Content.Server/NPC/HTN/HTNComponent.cs
@@ -3,7 +3,7 @@ using Content.Server.NPC.Components;
namespace Content.Server.NPC.HTN;
-[RegisterComponent, ComponentReference(typeof(NPCComponent))]
+[RegisterComponent]
public sealed partial class HTNComponent : NPCComponent
{
///
diff --git a/Content.Server/NPC/HTN/HTNSystem.cs b/Content.Server/NPC/HTN/HTNSystem.cs
index 6a85fe050c..b557ff3d4d 100644
--- a/Content.Server/NPC/HTN/HTNSystem.cs
+++ b/Content.Server/NPC/HTN/HTNSystem.cs
@@ -8,8 +8,10 @@ using Content.Server.NPC.Components;
using Content.Server.NPC.HTN.PrimitiveTasks;
using Content.Server.NPC.Systems;
using Content.Shared.Administration;
+using Content.Shared.Mobs;
using Content.Shared.NPC;
using JetBrains.Annotations;
+using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
@@ -32,6 +34,10 @@ public sealed class HTNSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
+ SubscribeLocalEvent(_npc.OnMobStateChange);
+ SubscribeLocalEvent(_npc.OnNPCMapInit);
+ SubscribeLocalEvent(_npc.OnPlayerNPCAttach);
+ SubscribeLocalEvent(_npc.OnPlayerNPCDetach);
SubscribeLocalEvent(OnHTNShutdown);
SubscribeNetworkEvent(OnHTNMessage);
@@ -132,6 +138,7 @@ public sealed class HTNSystem : EntitySystem
private void OnHTNShutdown(EntityUid uid, HTNComponent component, ComponentShutdown args)
{
+ _npc.OnNPCShutdown(uid, component, args);
component.PlanningToken?.Cancel();
component.PlanningJob = null;
}
diff --git a/Content.Server/NPC/Systems/NPCSystem.cs b/Content.Server/NPC/Systems/NPCSystem.cs
index 1a2d3fcab3..82607cbab1 100644
--- a/Content.Server/NPC/Systems/NPCSystem.cs
+++ b/Content.Server/NPC/Systems/NPCSystem.cs
@@ -12,7 +12,6 @@ namespace Content.Server.NPC.Systems
///
/// Handles NPCs running every tick.
///
- [UsedImplicitly]
public sealed partial class NPCSystem : EntitySystem
{
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
@@ -33,21 +32,16 @@ namespace Content.Server.NPC.Systems
{
base.Initialize();
- SubscribeLocalEvent(OnMobStateChange);
- SubscribeLocalEvent(OnNPCMapInit);
- SubscribeLocalEvent(OnNPCShutdown);
- SubscribeLocalEvent(OnPlayerNPCAttach);
- SubscribeLocalEvent(OnPlayerNPCDetach);
_configurationManager.OnValueChanged(CCVars.NPCEnabled, SetEnabled, true);
_configurationManager.OnValueChanged(CCVars.NPCMaxUpdates, SetMaxUpdates, true);
}
- private void OnPlayerNPCAttach(EntityUid uid, NPCComponent component, PlayerAttachedEvent args)
+ public void OnPlayerNPCAttach(EntityUid uid, NPCComponent component, PlayerAttachedEvent args)
{
SleepNPC(uid, component);
}
- private void OnPlayerNPCDetach(EntityUid uid, NPCComponent component, PlayerDetachedEvent args)
+ public void OnPlayerNPCDetach(EntityUid uid, NPCComponent component, PlayerDetachedEvent args)
{
if (_mobState.IsIncapacitated(uid) || TerminatingOrDeleted(uid))
return;
@@ -65,13 +59,13 @@ namespace Content.Server.NPC.Systems
_configurationManager.UnsubValueChanged(CCVars.NPCMaxUpdates, SetMaxUpdates);
}
- private void OnNPCMapInit(EntityUid uid, NPCComponent component, MapInitEvent args)
+ public void OnNPCMapInit(EntityUid uid, NPCComponent component, MapInitEvent args)
{
component.Blackboard.SetValue(NPCBlackboard.Owner, uid);
WakeNPC(uid, component);
}
- private void OnNPCShutdown(EntityUid uid, NPCComponent component, ComponentShutdown args)
+ public void OnNPCShutdown(EntityUid uid, NPCComponent component, ComponentShutdown args)
{
SleepNPC(uid, component);
}
@@ -134,7 +128,7 @@ namespace Content.Server.NPC.Systems
_htn.UpdateNPC(ref _count, _maxUpdates, frameTime);
}
- private void OnMobStateChange(EntityUid uid, NPCComponent component, MobStateChangedEvent args)
+ public void OnMobStateChange(EntityUid uid, NPCComponent component, MobStateChangedEvent args)
{
if (HasComp(uid))
return;