상속: UnityEngine.MonoBehaviour
예제 #1
0
        public override void OnLatePostScan()
        {
            if (!Application.isPlaying)
            {
                return;
            }

            RemoveObstacles();

            NavGraph[] graphs = AstarPath.active.graphs;

            RVOSimulator rvosim = FindObjectOfType(typeof(RVOSimulator)) as RVOSimulator;

            if (rvosim == null)
            {
                throw new System.NullReferenceException("No RVOSimulator could be found in the scene. Please add one to any GameObject");
            }

            Pathfinding.RVO.Simulator sim = rvosim.GetSimulator();

            for (int i = 0; i < graphs.Length; i++)
            {
                AddGraphObstacles(sim, graphs[i]);
            }

            sim.UpdateObstacles();
        }
예제 #2
0
		public override void OnLatePostScan()
		{
			if (!Application.isPlaying)
			{
				return;
			}
			this.RemoveObstacles();
			NavGraph[] graphs = AstarPath.active.graphs;
			RVOSimulator rvosimulator = UnityEngine.Object.FindObjectOfType<RVOSimulator>();
			if (rvosimulator == null)
			{
				throw new NullReferenceException("No RVOSimulator could be found in the scene. Please add one to any GameObject");
			}
			Simulator simulator = rvosimulator.GetSimulator();
			for (int i = 0; i < graphs.Length; i++)
			{
				RecastGraph recastGraph = graphs[i] as RecastGraph;
				if (recastGraph != null)
				{
					foreach (RecastGraph.NavmeshTile ng in recastGraph.GetTiles())
					{
						this.AddGraphObstacles(simulator, ng);
					}
				}
				else
				{
					INavmesh navmesh = graphs[i] as INavmesh;
					if (navmesh != null)
					{
						this.AddGraphObstacles(simulator, navmesh);
					}
				}
			}
			simulator.UpdateObstacles();
		}
예제 #3
0
 void OnDestroy()
 {
     active = null;
     if (simulator != null)
     {
         simulator.OnDestroy();
     }
 }
예제 #4
0
 // Token: 0x0600290C RID: 10508 RVA: 0x001BF147 File Offset: 0x001BD347
 private void OnDestroy()
 {
     RVOSimulator.active = null;
     if (this.simulator != null)
     {
         this.simulator.OnDestroy();
     }
 }
예제 #5
0
 private void OnDestroy()
 {
     this.simulator.OnDestroy();
     if (RVOSimulator.Instance == this)
     {
         RVOSimulator.Instance = null;
     }
 }
예제 #6
0
 void OnDestroy()
 {
     active = null;
     if (simulatorBurst != null)
     {
         simulatorBurst.OnDestroy();
     }
 }
예제 #7
0
        protected void FindSimulator()
        {
            RVOSimulator rvosimulator = UnityEngine.Object.FindObjectOfType(typeof(RVOSimulator)) as RVOSimulator;

            if (rvosimulator == null)
            {
                throw new InvalidOperationException("No RVOSimulator could be found in the scene. Please add one to any GameObject");
            }
            this.sim = rvosimulator.GetSimulator();
        }
예제 #8
0
        /** Finds a simulator in the scene.
         *
         * Saves found simulator in #sim.
         *
         * \throws System.InvalidOperationException When no RVOSimulator could be found.
         */
        protected void FindSimulator()
        {
            RVOSimulator rvosim = FindObjectOfType(typeof(RVOSimulator)) as RVOSimulator;

            if (rvosim == null)
            {
                throw new System.InvalidOperationException("No RVOSimulator could be found in the scene. Please add one to any GameObject");
            }

            sim = rvosim.GetSimulator();
        }
예제 #9
0
 public static RVOSimulator GetInstance()
 {
     if (RVOSimulator.Instance == null)
     {
         RVOSimulator rVOSimulator = UnityEngine.Object.FindObjectOfType <RVOSimulator>();
         if (rVOSimulator != null)
         {
             rVOSimulator.Awake();
         }
     }
     return(RVOSimulator.Instance);
 }
예제 #10
0
 protected override void Awake()
 {
     base.Awake();
     // We need to set active during Awake as well to ensure it is set when graphs are being scanned.
     // That is important if the RVONavmesh component is being used.
     active = this;
     if (simulator == null && Application.isPlaying)
     {
         int threadCount = AstarPath.CalculateThreadCount(workerThreads);
         simulator = new Pathfinding.RVO.Simulator(threadCount, doubleBuffering, movementPlane);
     }
 }
예제 #11
0
        // Token: 0x0600079A RID: 1946 RVA: 0x00049C98 File Offset: 0x00048098
        public void Awake()
        {
            this.tr = base.transform;
            RVOSimulator rvosimulator = UnityEngine.Object.FindObjectOfType(typeof(RVOSimulator)) as RVOSimulator;

            if (rvosimulator == null)
            {
                Debug.LogError("No RVOSimulator component found in the scene. Please add one.");
                return;
            }
            this.simulator = rvosimulator.GetSimulator();
        }
예제 #12
0
        public void Awake()
        {
            tr = transform;

            RVOSimulator sim = FindObjectOfType(typeof(RVOSimulator)) as RVOSimulator;

            if (sim == null)
            {
                Debug.LogError("No RVOSimulator component found in the scene. Please add one.");
                return;
            }
            simulator = sim.GetSimulator();
        }
예제 #13
0
 public void Awake()
 {
     this.tr = base.transform;
     RVOController.cachedSimulator = (RVOController.cachedSimulator ?? (UnityEngine.Object.FindObjectOfType(typeof(RVOSimulator)) as RVOSimulator));
     if (RVOController.cachedSimulator == null)
     {
         Debug.LogError("No RVOSimulator component found in the scene. Please add one.");
     }
     else
     {
         this.simulator = RVOController.cachedSimulator.GetSimulator();
     }
 }
예제 #14
0
        public void Awake()
        {
            tr = transform;

            // Find the RVOSimulator in this scene
            cachedSimulator = cachedSimulator ?? FindObjectOfType(typeof(RVOSimulator)) as RVOSimulator;
            if (cachedSimulator == null)
            {
                Debug.LogError("No RVOSimulator component found in the scene. Please add one.");
            }
            else
            {
                simulator = cachedSimulator.GetSimulator();
            }
        }
        public void EnsureActorAndSimulator()
        {
            if (!this.actor)
            {
                this.actor = ActorHelper.GetActorRoot(base.gameObject);
            }
            if (this.simulator == null)
            {
                RVOSimulator instance = RVOSimulator.GetInstance();
                if (instance == null)
                {
                    return;
                }
                this.simulator = instance.GetSimulator();
            }
            if (this.simulator == null)
            {
                return;
            }
            VInt3 vInt;

            if (this.actor)
            {
                vInt = this.actor.handle.location;
            }
            else
            {
                vInt = (VInt3)base.transform.position;
            }
            if (this.rvoAgent != null)
            {
                if (!this.simulator.GetAgents().Contains(this.rvoAgent))
                {
                    this.simulator.AddAgent(this.rvoAgent);
                }
            }
            else
            {
                this.rvoAgent = this.simulator.AddAgent(vInt);
            }
            if (this.rvoAgent != null)
            {
                this.rvoAgent.owner = base.gameObject;
            }
            this.UpdateAgentProperties();
            this.rvoAgent.Teleport(vInt);
            this.adjustedY = this.rvoAgent.Position.y;
        }
예제 #16
0
 public void Awake()
 {
     this.tr = base.transform;
     if (cachedSimulator == null)
     {
         cachedSimulator = UnityEngine.Object.FindObjectOfType <RVOSimulator>();
     }
     if (cachedSimulator == null)
     {
         Debug.LogError("No RVOSimulator component found in the scene. Please add one.");
     }
     else
     {
         this.simulator = cachedSimulator.GetSimulator();
     }
 }
예제 #17
0
        public override void OnLatePostScan()
        {
            if (!Application.isPlaying)
            {
                return;
            }

            Profiler.BeginSample("Update RVO Obstacles From Graphs");
            RemoveObstacles();
            NavGraph[]   graphs = AstarPath.active.graphs;
            RVOSimulator rvosim = RVOSimulator.active;

            if (rvosim == null)
            {
                throw new System.NullReferenceException("No RVOSimulator could be found in the scene. Please add one to any GameObject");
            }

            // Remember which simulator these obstacles were added to
            lastSim = rvosim.GetSimulator();

            for (int i = 0; i < graphs.Length; i++)
            {
                RecastGraph recast  = graphs[i] as RecastGraph;
                INavmesh    navmesh = graphs[i] as INavmesh;
                GridGraph   grid    = graphs[i] as GridGraph;
                if (recast != null)
                {
                    foreach (var tile in recast.GetTiles())
                    {
                        AddGraphObstacles(lastSim, tile);
                    }
                }
                else if (navmesh != null)
                {
                    AddGraphObstacles(lastSim, navmesh);
                }
                else if (grid != null)
                {
                    AddGraphObstacles(lastSim, grid);
                }
            }
            Profiler.EndSample();
        }
예제 #18
0
        public override void OnLatePostScan()
        {
            if (!Application.isPlaying)
            {
                return;
            }

            RemoveObstacles();

            NavGraph[] graphs = AstarPath.active.graphs;

            RVOSimulator rvosim = FindObjectOfType <RVOSimulator>();

            if (rvosim == null)
            {
                throw new System.NullReferenceException("No RVOSimulator could be found in the scene. Please add one to any GameObject");
            }

            Pathfinding.RVO.Simulator sim = rvosim.GetSimulator();

            for (int i = 0; i < graphs.Length; i++)
            {
                var recast = graphs[i] as RecastGraph;
                if (recast != null)
                {
                    foreach (var tile in recast.GetTiles())
                    {
                        AddGraphObstacles(sim, tile);
                    }
                }
                else
                {
                    var navmesh = graphs[i] as INavmesh;
                    if (navmesh != null)
                    {
                        AddGraphObstacles(sim, navmesh);
                    }
                }
            }

            sim.UpdateObstacles();
        }
예제 #19
0
 private void Awake()
 {
     if (RVOSimulator.Instance == null)
     {
         RVOSimulator.Instance = this;
     }
     else if (RVOSimulator.Instance != this)
     {
         RVOSimulator.Instance.enabled = false;
         RVOSimulator.Instance         = this;
     }
     if (this.desiredSimulationFPS < 1)
     {
         this.desiredSimulationFPS = 1;
     }
     if (this.simulator == null)
     {
         int workers = AstarPath.CalculateThreadCount(this.workerThreads);
         this.simulator = new Simulator(workers, this.doubleBuffering);
         this.simulator.Interpolation = this.interpolation;
     }
 }
예제 #20
0
        public override void OnLatePostScan()
        {
            if (!Application.isPlaying)
            {
                return;
            }
            this.RemoveObstacles();
            NavGraph[]   graphs       = AstarPath.active.graphs;
            RVOSimulator rVOSimulator = UnityEngine.Object.FindObjectOfType(typeof(RVOSimulator)) as RVOSimulator;

            if (rVOSimulator == null)
            {
                throw new NullReferenceException("No RVOSimulator could be found in the scene. Please add one to any GameObject");
            }
            Simulator simulator = rVOSimulator.GetSimulator();

            for (int i = 0; i < graphs.Length; i++)
            {
                this.AddGraphObstacles(simulator, graphs[i]);
            }
            simulator.UpdateObstacles();
        }
예제 #21
0
        public override void OnLatePostScan()
        {
            if (!Application.isPlaying)
            {
                return;
            }
            this.RemoveObstacles();
            NavGraph[]   graphs = AstarPath.active.graphs;
            RVOSimulator active = RVOSimulator.active;

            if (active == null)
            {
                throw new NullReferenceException("No RVOSimulator could be found in the scene. Please add one to any GameObject");
            }
            this.lastSim = active.GetSimulator();
            for (int i = 0; i < graphs.Length; i++)
            {
                RecastGraph recastGraph = graphs[i] as RecastGraph;
                INavmesh    navmesh     = graphs[i] as INavmesh;
                GridGraph   gridGraph   = graphs[i] as GridGraph;
                if (recastGraph != null)
                {
                    foreach (NavmeshTile ng in recastGraph.GetTiles())
                    {
                        this.AddGraphObstacles(this.lastSim, ng);
                    }
                }
                else if (navmesh != null)
                {
                    this.AddGraphObstacles(this.lastSim, navmesh);
                }
                else if (gridGraph != null)
                {
                    this.AddGraphObstacles(this.lastSim, gridGraph);
                }
            }
        }
예제 #22
0
		public void Awake () {
			tr = transform;

			// Find the RVOSimulator in this scene
			cachedSimulator = cachedSimulator ?? FindObjectOfType(typeof(RVOSimulator)) as RVOSimulator;
			if (cachedSimulator == null) {
				Debug.LogError("No RVOSimulator component found in the scene. Please add one.");
			} else {
				simulator = cachedSimulator.GetSimulator();
			}
		}
예제 #23
0
 void OnEnable()
 {
     active = this;
 }
예제 #24
0
 // Token: 0x06002909 RID: 10505 RVA: 0x001BF0A7 File Offset: 0x001BD2A7
 private void OnEnable()
 {
     RVOSimulator.active = this;
 }