public void UpdateAgentParameters(int idx, CrowdAgentParams param) { if (idx < 0 || idx > _maxAgents) { return; } _agents[idx].Param = param; }
public int AddAgent(float[] pos, CrowdAgentParams param) { int idx = -1; for (int i = 0; i < _maxAgents; i++) { if (!_agents[i].Active) { idx = i; break; } } if (idx == -1) { return(-1); } CrowdAgent ag = _agents[idx]; float[] nearest = new float[3]; long refId = 0; _navQuery.FindNearestPoly(pos, _ext, _filter, ref refId, ref nearest); ag.Corridor.Reset(refId, nearest); ag.Boundary.Reset(); UpdateAgentParameters(idx, param); ag.TopologyOptTime = 0; ag.TargetReplanTime = 0; ag.NNeis = 0; Helper.VSet(ref ag.dvel, 0, 0, 0); Helper.VSet(ref ag.nvel, 0, 0, 0); Helper.VSet(ref ag.vel, 0, 0, 0); Helper.VCopy(ref ag.npos, nearest); ag.DesiredSpeed = 0; if (refId > 0) { ag.State = CrowdAgentState.Walking; } else { ag.State = CrowdAgentState.Invalid; } ag.TargetState = MoveRequestState.TargetNone; ag.Active = true; return(idx); }