Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
 public static float GetCamoValue(IFOWAgent agent)
 {
     return(GetCamoValue(agent.PosX, agent.PosZ));
 }
Esempio n. 4
0
 public static bool CanSee(IFOWAgent looker, IFOWAgent target)
 {
     return(CanSee(looker.PosX, looker.PosZ, target.PosX, target.PosZ, looker.VisionRange));
 }
Esempio n. 5
0
 public static void NotifyAgentVisionChange(IFOWAgent agent)
 {
     // Sub-optimal solution for now //
     instance.updateNeeded = true;
 }
Esempio n. 6
0
 public static void UnRegisterAgent(IFOWAgent agent)
 {
     instance.addRemoveQueue.Enqueue(new Pair <IFOWAgent, bool>(agent, false));
 }