/// <summary> /// Called pretty fast, it's just like Update() /// </summary> public void Micro() { //difficulty == 0 means the AI is disabled if (ai.DifficultyLvl > 0) { foreach (BaseAgent agent in agents) { agent.PreUpdate(); } for (int i = 0; i < squads.Count; i++) { // Update squad squads[i].Update(); if (squads[i].Units.Count > 0) { float bVal = float.MinValue; BaseAgent bAgent = agents[0]; int val; foreach (BaseAgent a in agents) { val = a.getConfidence(squads[i]); if (AIController.AI_DEBUG_ENABLED) { ai.aiDebug.setAgentConfidence(a.agentName, val); } if (val > bVal) { bVal = val; bAgent = a; } } squads[i].UserData = bAgent; if (AIController.AI_DEBUG_ENABLED) { ai.aiDebug.setControllingAgent(bAgent.agentName, bVal); } bAgent.controlUnits(squads[i]); foreach (BaseAgent agent in agents) { agent.PostSquad(); } } } foreach (BaseAgent agent in agents) { agent.PostUpdate(); } } }