//////////////// private static void AddAll(NPC npc) { foreach (var kv in AltNPCInfo.NpcInfoTypes) { AltNPCInfo.Add(npc, kv.Key, kv.Value); } }
public static void RegisterInfoType(Mod mod, AltNPCInfo info) { string modname = TmlHelpers.GetModUniqueName(mod); //AltNPCInfo.NpcInfoModMappedTypes[modname] = info.GetType(); Type t = info.GetType(); AltNPCInfo.NpcInfoTypes[modname] = t; }
//////////////// internal static void UpdateAll() { if (AltNPCInfo.NpcInfoTypes.Count == 0) { return; } var map = AltNPCInfo.NpcInfos; for (int who = 0; who < Main.npc.Length; who++) { NPC npc = Main.npc[who]; bool is_empty = map[who].Count == 0; if (npc == null || !npc.active || npc.type == 0) { if (!is_empty) { AltNPCInfo.Clear(who); } continue; } if (!is_empty) { foreach (AltNPCInfo info in map[who].Values) { if (info.NpcType != npc.type) { is_empty = true; break; } } if (is_empty) { AltNPCInfo.Clear(who); } } if (is_empty) { AltNPCInfo.AddAll(npc); } // Run updates foreach (AltNPCInfo info in map[who].Values) { info.Update(); } } }
//////////////// static AltNPCInfo() { AltNPCInfo.DataInitialize(); }