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 (FunkyGame.Navigation.CheckPointAgainstBlockedDirection(point))
                {
                    return(false);
                }
            }

            //Create Vector3
            Vector3 pointVectorReturn = (Vector3)point;
            Vector3 pointVector       = pointVectorReturn;
            Vector3 botcurpos         = FunkyGame.Hero.Position;

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

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

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

            if (!Navigation.CheckVectorFlags(botcurpos, pointVector, flags))
            {
                return(false);
            }

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