Beispiel #1
0
        public void OnDisable()
        {
            Pathfinding.RVO.Simulator sim         = AStarPathfindingUtils.GetSimulator();
            RVOContourObstacle        cutObstacle = GetRVOContourObstacle();

            if (cutObstacle)
            {
                cutObstacle.RemoveDynamicObstacles(sim);
            }

            if (_wasActive)
            {
                if (cutObstacle)
                {
                    cutObstacle.SetObstaclesActive(sim, false);
                }

                if (null != TileHandlerHelper.instance)
                {
                    TileHandlerHelper.instance.OnNavMeshCutDisabled(lastBounds);
                }
            }
            _UpdateIsRequired = false;
            EventManager.instance.RemoveListener <PopulateZonesPlayingEvent>(OnPopulateZones);
            EventManager.instance.RemoveListener <LevelStartEvent>(OnLevelStart);
        }
Beispiel #2
0
        public void NotifyUpdated()
        {
#if BNICKSON_UPDATED
            Pathfinding.RVO.Simulator sim         = AStarPathfindingUtils.GetSimulator();
            RVOContourObstacle        cutObstacle = GetRVOContourObstacle();
            if (cutObstacle)
            {
                cutObstacle.SetObstaclesActive(sim, isActive);
                if (HasMoved())
                {
                    cutObstacle.Move(sim);
                }
                else if (_UpdateIsRequired && isActive)
                {
                    cutObstacle.CreateDynamicEdgesIfNoStaticEdgesExist(sim);
                }
            }

            _wasActive        = isActive;
            _UpdateIsRequired = false;
#endif
            wasEnabled = enabled;

            if (wasEnabled)
            {
                lastPosition = tr.position;
                lastBounds   = GetBounds();

                if (useRotation)
                {
                    lastRotation = tr.rotation;
                }
            }
        }
Beispiel #3
0
        public RVOContourObstacle GetRVOContourObstacle()
        {
            RVOContourObstacle cutObstacle = gameObject.GetComponent <RVOContourObstacle>();

            if (!cutObstacle)
            {
                cutObstacle = gameObject.AddComponent <RVOContourObstacle>();
            }
            return(cutObstacle);
        }
Beispiel #4
0
        public void OnPopulateZones(PopulateZonesPlayingEvent evt)
        {
            if (isActive != _wasActive)             // if our active state has changed, it means we are awaiting for the fact this has hapenned to be picked up in the TileHandlerHelper Update
            {
                lastPosition = tr.position;         // set this here so TileHandlerHelper picks up the activity change, and not the movement, so NotifyUpdated() will not flag
                // this cuts obstacles as dynamic
            }
            RVOContourObstacle cutObstacle = GetRVOContourObstacle();

            cutObstacle.OnLatePostScan(AStarPathfindingUtils.GetSimulator());
        }
Beispiel #5
0
        // make sure everything is correct on level start
        public void OnLevelStart(LevelStartEvent e)
        {
            RVOContourObstacle cutObstacle = GetRVOContourObstacle();

            cutObstacle.SetObstaclesActive(AStarPathfindingUtils.GetSimulator(), isActive);
        }