public SimAgent AddAgent(SimAgentType agentType, SimPoint position, SimUnit owner, SimResourceBinCollection resources, string searchTarget) { SimAgent agent = new SimAgent(); agent.Init(agentType, nextAgentId++, position, owner, resources, searchTarget); agents.Add(agent); boxListener.OnAgentAdded(agent); return(agent); }
public void Init(SimAgentType agentType, int id, SimPoint position, SimUnit owner, SimResourceBinCollection resources, string searchTarget) { this.agentType = agentType; this.id = id; this.owner = owner; this.searchTarget = searchTarget; this.resources.AddResources(resources); this.worldPosition = position.worldPosition; this.lastPoint = position; }
private void ParseAgent() { string line = GetNextLine(); string[] lineSplit = SplitLine(line); if (lineSplit.Length == 1) { ThrowInvalidLine("ParseAgent()"); } SimAgentType agentType = new SimAgentType(); agentType.id = lineSplit[1]; int splitOffset = 2; while (splitOffset < lineSplit.Length) { switch (lineSplit[splitOffset++]) { case "color": agentType.color = ParseUint(lineSplit[splitOffset++]); break; case "speed": agentType.speed = ParseFloat(lineSplit[splitOffset++]); break; default: ThrowInvalidLine("ParseAgent()"); break; } } definition.agentTypes.Add(agentType.id, agentType); }