List<AgentCutaway> IAgentFunctions.agentsInRange(ref AgentEnv client) { //Returns list of Agents Cutaways of observable agents Coordinates obs = client.getCoord(); List<AgentCutaway> rez = new List<AgentCutaway>(); foreach (AgentEnv ag in agentListm) { if (ag.getTypeName() == AgentType.Finder && client.getTypeName() == AgentType.Finder && canCommunicate(client, ag)) { rez.Add(ag.getCutaway()); } else if ((ag.getCoord() - obs).norm() < client.getViewRadius() && canSee(obs, ag.getCoord()) && ag.getID() != client.getID()) { rez.Add(ag.getCutaway()); } } return rez; }
bool canTouch1(Coordinates point, ref AgentEnv client) { //Checks if one agent is in proper distance to pick up another agent Coordinates pos = client.getCoord(); return (isPathLegal(pos, point) && ((pos - point).norm() < touchDist)); }
List<Wall> IAgentFunctions.wallsAround(ref AgentEnv agent) { // Returns List of observable walls return wallList.wallsAroundPoint(agent.getCoord(), agent.getViewRadius()); }
private bool canCommunicate(AgentEnv sender, AgentEnv reciever) { //Checks if sender can send messages to reciever return (sender.getCoord() - reciever.getCoord()).norm() < sender.getCommRadius(); }
bool IAgentFunctions.askStep(Coordinates direction, float speedPercent, ref AgentEnv client) { //Try to make step in specific direction. The length = max(speedPercent,1) * maxSpeed Coordinates pos = client.getCoord(), des; float perc = Math.Min(Math.Max(0.0f, speedPercent), 1.0f); des = pos + (direction.normalize()) * (perc * client.getSpeed()); if (isPathLegal(pos, des)) { client.setCoord(des); return true; } else { return false; } }