public virtual float GetUsageScoreForAgent(AgentValuePair <float> agentPair) { float num1 = agentPair.Value; float num2 = (double)num1 < 0.0 ? float.MinValue : -num1; if (agentPair.Agent == this.FavoredUser) { num2 *= 0.5f; } return(num2); }
internal void TickAgent(Agent agent) { if (!agent.IsDetachedFromFormation) { float time = MBCommon.TimeType.Mission.GetTime(); bool flag = (double)time - (double)agent.LastDetachmentTickAgentTime > 1.5; foreach (IDetachment detachment in agent.Formation.Detachments) { if ((double)detachment.GetDetachmentWeight(agent.Formation.Team.Side) > -3.40282346638529E+38) { DetachmentData detachmentData = this.data[detachment]; AgentValuePair <float[]> agentValuePair = (AgentValuePair <float[]>)null; for (int index = 0; index < detachmentData.agentScores.Count; ++index) { if (detachmentData.agentScores[index].Agent == agent) { agentValuePair = detachmentData.agentScores[index]; break; } } if (agentValuePair == null) { if (detachmentData.agentScores.Count == 0) { detachmentData.firstTime = time; } float[] templateCostsOfAgent = detachment.GetTemplateCostsOfAgent(agent, (float[])null); detachmentData.agentScores.Add(new AgentValuePair <float[]>(agent, templateCostsOfAgent)); agent.LastDetachmentTickAgentTime = time; } else if (flag) { agentValuePair.Value = detachment.GetTemplateCostsOfAgent(agent, agentValuePair.Value); agent.LastDetachmentTickAgentTime = time; } } else { this.data[detachment].firstTime = time; } } } else { if (agent.Detachment == null || agent.Detachment.IsAgentEligible(agent)) { return; } agent.Detachment.RemoveAgent(agent); agent.Formation?.AttachUnit(agent); } }