private void HandleChangedAgents() { while (addRemoveQueue.Count > 0) { Pair <IFOWAgent, bool> pair = addRemoveQueue.Dequeue(); IFOWAgent agent = pair.left; if (pair.right) { Point2D current = data.ClampToPoint(agent.PosX, agent.PosZ); agentViews.Add(agent, new AgentInfo(current)); } else { AgentInfo info = agentViews.ContainsKey(agent) ? agentViews[agent] : null; if (info != null) { updater.SetRemovedAgentColors(info); } agentViews.Remove(agent); } updateNeeded = true; } }
private IEnumerator UpdateRoutine() { YieldInstruction wait = new WaitForEndOfFrame(); while (true) { if (!isActive || !cachedSettingUseFOW) { yield return(wait); continue; } if (!fogColor.Equals(lastColor)) { lastColor = fogColor; decal.Material.SetColor("_Color", fogColor); yield return(UpdateAgentViews(wait)); } else if (filterMode != lastFilter) { lastFilter = filterMode; secondBlurRender.filterMode = filterMode; } foreach (KeyValuePair <IFOWAgent, AgentInfo> pair in agentViews) { IFOWAgent agent = pair.Key; AgentInfo info = pair.Value; float x = agent.PosX; float z = agent.PosZ; Point2D point = data.ClampToPoint(x, z); bool valid = !data.ValidPoint(point) ? data.FindValidPoint(x, z, out point) : true; if (!point.Equals(info.lastPoint) && valid) { info.lastPoint = point; updateNeeded = true; } } HandleChangedAgents(); if (updateNeeded) { yield return(UpdateAgentViews(wait)); } yield return(wait); } }
public static float GetCamoValue(IFOWAgent agent) { return(GetCamoValue(agent.PosX, agent.PosZ)); }
public static bool CanSee(IFOWAgent looker, IFOWAgent target) { return(CanSee(looker.PosX, looker.PosZ, target.PosX, target.PosZ, looker.VisionRange)); }
public static void NotifyAgentVisionChange(IFOWAgent agent) { // Sub-optimal solution for now // instance.updateNeeded = true; }
public static void UnRegisterAgent(IFOWAgent agent) { instance.addRemoveQueue.Enqueue(new Pair <IFOWAgent, bool>(agent, false)); }