Beispiel #1
0
        public GPQuadrant(GridPoint[] points, Vector3 GPCenteringVector, GridPoint endpoint)
        {
            this.ContainedPoints.AddRange(points);
            this.StartPoint  = GPCenteringVector;
            this.CornerPoint = endpoint.Clone();


            if (points.Length > 0)
            {
                this.AverageAreaVectorZ = this.ContainedPoints.Sum(gp => gp.Z) / this.ContainedPoints.Count;
                this.AreaIsFlat         = (this.AverageAreaVectorZ == this.ContainedPoints.First().Z);
            }
        }
Beispiel #2
0
        private bool CheckPoint(GridPoint point, Vector3 LoSCheckV3, PointCheckingFlags flags)
        {
            //Check blacklisted points and ignored
            if (point.Ignored)
            {
                return(false);
            }

            //Check if this point is in a blocked direction
            if (flags.HasFlag(PointCheckingFlags.BlockedDirection))
            {
                if (Bot.NavigationCache.CheckPointAgainstBlockedDirection(point))
                {
                    return(false);
                }
            }

            //Create Vector3
            Vector3 pointVectorReturn = (Vector3)point;
            Vector3 pointVector       = pointVectorReturn;
            Vector3 botcurpos         = Bot.Character.Data.Position;

            //2D Obstacle Navigation Check
            bool ZCheck = false;

            if (this.AreaIsFlat)
            {
                if (flags.HasFlag(PointCheckingFlags.ObstacleOverlap))
                {
                    if (ObjectCache.Obstacles.Values.OfType <CacheServerObject>().Any(obj => ObstacleType.Navigation.HasFlag(obj.Obstacletype.Value) && obj.PointInside(point)))
                    {
                        return(false);
                    }
                }

                if (flags.HasFlag(PointCheckingFlags.ObstacleIntersection))
                {
                    if (ObjectCache.Obstacles.Values.OfType <CacheServerObject>().Any(obj => ObstacleType.Navigation.HasFlag(obj.Obstacletype.Value) && obj.TestIntersection(botcurpos, point)))
                    {
                        return(false);
                    }
                }

                ZCheck = true;
            }



            //Check if we already within this "point".
            if (botcurpos.Distance2D(pointVector) < 2.5f)
            {
                return(false);
            }

            //3D Obstacle Navigation Check
            if (!ZCheck)
            {
                //Because Z Variance we need to check if we can raycast walk to the location.
                if (!Navigation.CanRayCast(botcurpos, pointVector))
                {
                    return(false);
                }
                if (!Navigation.MGP.CanStandAt(pointVector))
                {
                    return(false);
                }

                if (flags.HasFlag(PointCheckingFlags.ObstacleOverlap))
                {
                    if (ObjectCache.Obstacles.Values.OfType <CacheServerObject>().Any(obj => ObstacleType.Navigation.HasFlag(obj.Obstacletype.Value) && obj.PointInside(pointVector)))
                    {
                        return(false);
                    }
                }
                if (flags.HasFlag(PointCheckingFlags.ObstacleIntersection))
                {
                    if (ObjectCache.Obstacles.Values.OfType <CacheServerObject>().Any(obj => ObstacleType.Navigation.HasFlag(obj.Obstacletype.Value) && obj.TestIntersection(botcurpos, pointVector)))
                    {
                        return(false);
                    }
                }
            }


            //Avoidance Check (Any Avoidance)
            if (flags.HasFlag(PointCheckingFlags.AvoidanceOverlap))
            {
                if (ObjectCache.Obstacles.IsPositionWithinAvoidanceArea(pointVector))
                {
                    return(false);
                }
            }


            //Kiting Check
            if (flags.HasFlag(PointCheckingFlags.MonsterOverlap))
            {
                if (ObjectCache.Objects.OfType <CacheUnit>().Any(m => m.ShouldFlee && m.IsPositionWithinRange(pointVector, Bot.Settings.Fleeing.FleeMaxMonsterDistance)))
                {
                    return(false);
                }
            }


            //Avoidance Intersection Check
            if (flags.HasFlag(PointCheckingFlags.AvoidanceIntersection))
            {
                //if (ObjectCache.Obstacles.TestVectorAgainstAvoidanceZones(botcurpos, pointVector)) return false;
            }

            if (flags.HasFlag(PointCheckingFlags.Raycast))
            {
                if (!Navigation.CanRayCast(botcurpos, pointVector))
                {
                    return(false);
                }
            }
            if (flags.HasFlag(PointCheckingFlags.RaycastWalkable))
            {
                if (!Navigation.CanRayCast(botcurpos, pointVector, NavCellFlags.AllowWalk))
                {
                    return(false);
                }
            }
            if (flags.HasFlag(PointCheckingFlags.RaycastNavProvider))
            {
                if (!Navigation.CanRayCast(botcurpos, pointVector, UseSearchGridProvider: true))
                {
                    return(false);
                }
            }

            LastSafespotFound      = pointVectorReturn;
            LastSafeGridPointFound = point.Clone();
            return(true);
        }