fix(swap): give our NPC the prefab's id again (Rust 11/25) #34

Merged
whitlocktech merged 1 commits from fix/swap-prefab-id into main 2026-11-30 23:16:53 -06:00
Showing only changes of commit f21a468863 - Show all commits

View File

@@ -1123,6 +1123,10 @@ namespace Oxide.Plugins
RunicNpcBrain brain = go.AddComponent<RunicNpcBrain>(); RunicNpcBrain brain = go.AddComponent<RunicNpcBrain>();
CopyFields(_npcFields, stock, npc); CopyFields(_npcFields, stock, npc);
CopyFields(_brainFields, stockBrain, brain); CopyFields(_brainFields, stockBrain, brain);
// prefabID is a property now (Rust 11/25): Unity's deserialisation fills its encrypted
// value from serializedPrefabID, and an AddComponent never deserialises, so copying the
// field list leaves ours without the prefab's id (#32).
npc.prefabID = stock.prefabID;
UnityEngine.Object.DestroyImmediate(stock, true); UnityEngine.Object.DestroyImmediate(stock, true);
UnityEngine.Object.DestroyImmediate(stockBrain, true); UnityEngine.Object.DestroyImmediate(stockBrain, true);