public static void RefreshConfig(this RoomNpcComponent self, params long[] idList) { ConfigComponent configComponent = Game.Scene.GetComponent <ConfigComponent>(); for (int i = 0; i < idList?.Length; i++) { long id = idList[i]; if (!configComponent.AllConfig.TryGetValue(typeof(NPCConfig), out ACategory configCategory)) { Log.Error("ConfigComponent not found key: NPCConfig"); continue; } var newConfig = configCategory.TryGet(id) as NPCConfig; if (newConfig == null) { Log.Error($"NPCConfig is null, id:{id}"); continue; } if (self._npcDicts.TryGetValue(id, out var npc)) { npc.RefreshConfig(newConfig); } else { self.CreateNPC(newConfig); } } }
private static void UpdateNPC(this RoomNpcComponent self) { for (int i = 0; i < self._npcs.Count; i++) { self._npcs[i].Update(); } }
private static void StartNPC(this RoomNpcComponent self) { for (int i = 0; i < self._npcs.Count; i++) { self._npcs[i].Start(); } }
public static void EventHandler_2(this RoomNpcComponent self, object a, object b) { long maxId = Math.Max((long)a, (long)b); long minId = Math.Min((long)a, (long)b); List <long> ids = new List <long>(); for (long i = minId; i <= maxId; i++) { ids.Add(i); } self.RefreshConfig(ids.ToArray()); }
public static void EventHandler_1(this RoomNpcComponent self, object a) { self.RefreshConfig((long)a); }