private void RecycleNpcInfo(NpcInfo npcInfo) { if (null != npcInfo) { int id = npcInfo.GetId(); if (id >= c_StartId && id < c_StartId + c_MaxIdNum) { m_UnusedIds.Push(id); } if (m_UnusedNpcs.Count < m_NpcPoolSize) { npcInfo.Reset(); m_UnusedNpcs.Enqueue(npcInfo); } } }
private NpcInfo NewNpcInfo(int id) { NpcInfo npc = null; if (m_UnusedNpcs.Count > 0) { npc = m_UnusedNpcs.Dequeue(); npc.Reset(); npc.InitId(id); } else { npc = new NpcInfo(id); } return(npc); }