public static SettlerInventory GetSettlerInventory(NPCBase npc) { SettlerInventory inv = null; if (npc.CustomData == null) { npc.CustomData = new JSONNode(); } try { if (!npc.CustomData.TryGetAs(GameLoader.SETTLER_INV, out inv) || inv == null) { inv = new SettlerInventory(npc); npc.CustomData.SetAs(GameLoader.SETTLER_INV, inv); } } catch (Exception ex) { PandaLogger.LogError(ex); } if (inv == null) { inv = new SettlerInventory(npc); } return(inv); }
public static SettlerInventory GetSettlerInventory(NPC.NPCBase npc) { var tempVals = npc.GetTempValues(true); if (!tempVals.TryGet(GameLoader.SETTLER_INV, out SettlerInventory inv)) { inv = new SettlerInventory(npc.ID); tempVals.Set(GameLoader.SETTLER_INV, inv); } return(inv); }