]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix post-mapinit NPC exception (#40244)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Tue, 7 Oct 2025 14:03:45 +0000 (03:03 +1300)
committerGitHub <noreply@github.com>
Tue, 7 Oct 2025 14:03:45 +0000 (14:03 +0000)
Ensure `NPCBlackboard.Owner` is set during startup

Content.Server/NPC/Components/NPCComponent.cs
Content.Server/NPC/HTN/HTNComponent.cs
Content.Server/NPC/HTN/HTNSystem.cs
Content.Server/NPC/Systems/NPCSystem.cs

index b1d5bfcf5f20e41f5878f2504585de51f6fc1d7b..3b396f034e3233f3c14ec77bf0b1a6a4702ca877 100644 (file)
@@ -9,4 +9,5 @@ public abstract partial class NPCComponent : SharedNPCComponent
     /// </summary>
     [DataField("blackboard", customTypeSerializer: typeof(NPCBlackboardSerializer))]
     public NPCBlackboard Blackboard = new();
+    // TODO FULL GAME SAVE Serialize this
 }
index 43b8a70785a12c6fe346f93348f29f79394775a1..d9b392ab146a16faf0d00976b8157f776b2a0f7d 100644 (file)
@@ -24,6 +24,7 @@ public sealed partial class HTNComponent : NPCComponent
     /// </summary>
     [ViewVariables]
     public HTNPlan? Plan;
+    // TODO FULL GAME SAVE serialize this?
 
     /// <summary>
     /// How long to wait after having planned to try planning again.
index 4d9e321dd91f0421a8488a2a9ac25102aea2f512..7bfe432998653c5be941ca6be1a39b526e7cc942 100644 (file)
@@ -33,6 +33,7 @@ public sealed class HTNSystem : EntitySystem
         base.Initialize();
         SubscribeLocalEvent<HTNComponent, MobStateChangedEvent>(_npc.OnMobStateChange);
         SubscribeLocalEvent<HTNComponent, MapInitEvent>(_npc.OnNPCMapInit);
+        SubscribeLocalEvent<HTNComponent, ComponentStartup>(_npc.OnNPCStartup);
         SubscribeLocalEvent<HTNComponent, PlayerAttachedEvent>(_npc.OnPlayerNPCAttach);
         SubscribeLocalEvent<HTNComponent, PlayerDetachedEvent>(_npc.OnPlayerNPCDetach);
         SubscribeLocalEvent<HTNComponent, ComponentShutdown>(OnHTNShutdown);
index 27b2a1691d62b682550b1796659a150fe9468b99..7aea766930b524688cd5812abb54c68d1e1604bf 100644 (file)
@@ -63,9 +63,13 @@ namespace Content.Server.NPC.Systems
             WakeNPC(uid, component);
         }
 
-        public void OnNPCMapInit(EntityUid uid, HTNComponent component, MapInitEvent args)
+        public void OnNPCStartup(EntityUid uid, HTNComponent component, ComponentStartup args)
         {
             component.Blackboard.SetValue(NPCBlackboard.Owner, uid);
+        }
+
+        public void OnNPCMapInit(EntityUid uid, HTNComponent component, MapInitEvent args)
+        {
             WakeNPC(uid, component);
         }