private static void DestroyAgentBuffer(DeactivationData data)
        {
            RTSAgent agent = data.Agent;

            if (agent.IsActive == false)
            {
                return;
            }
            bool immediate = data.Immediate;

            agent.Deactivate(immediate);
            ChangeController(agent, null);

            //Pool if the agent is registered
            ushort agentCodeID;

            if (agent.TypeIndex != UNREGISTERED_TYPE_INDEX)
            {
                // if (CodeIndexMap.TryGetValue(agent.MyAgentCode, out agentCodeID))
                // {
                agentCodeID = GameResourceManager.GetAgentCodeIndex(agent.MyAgentCode);
                if (agentCodeID.IsNotNull())
                {
                    TypeAgentsActive[agentCodeID][agent.TypeIndex] = false;
                }
            }
        }
        private static void DestroyAgentBuffer(DeactivationData data)
        {
            LSAgent agent = data.Agent;

            if (agent.IsActive == false)
            {
                return;
            }
            bool immediate = data.Immediate;

            agent.Deactivate(immediate);

            ushort agentCodeID = AgentController.GetAgentCodeIndex(agent.MyAgentCode);

            TypeAgentsActive [agentCodeID] [agent.TypeIndex] = false;

            ChangeController(agent, null);
        }