Esempio n. 1
0
        private void iterateGPRectsSafeSpot(Vector3 CurrentPosition, out Vector3 safespot, Vector3 LOS, PointCheckingFlags Flags)
        {
            //blacklisted a point?.. we advance to next index!
            if (BlacklistedPoint)
            {
                lastGPRectIndexUsed++;
                BlacklistedPoint = false;
            }

            GPRectangle PositionRect = GetGPRectContainingPoint(CurrentPosition);

            if (PositionRect != null)
            {
                PositionRect.UpdateObjectCount();
            }

            GPQuadrant PositionQuadrant = PositionRect.GetQuadrantContainingPoint(CurrentPosition);
            double     CompareWeight    = PositionQuadrant != null ? PositionQuadrant.ThisWeight : PositionRect != null ? PositionRect.Weight : 0;

            safespot = Vector3.Zero;
            for (int i = lastGPRectIndexUsed; i < gridpointrectangles_.Count - 1; i++)
            {
                GPRectangle item = gridpointrectangles_[i];

                item.UpdateObjectCount(AllGPRectsFailed);

                if (item.TryFindSafeSpot(CurrentPosition, out safespot, LOS, Flags, BlacklistedGridpoints, AllGPRectsFailed, CompareWeight))
                {
                    lastUsedGPRect = gridpointrectangles_[i];
                    return;
                }
            }
            lastGPRectIndexUsed = 0;
        }
Esempio n. 2
0
        private void UpdateQuadrants()
        {
            QuadrantLocation[] sectors_    = Quadrant.Keys.ToArray();
            string             debugstring = "";

            foreach (var item in sectors_)
            {
                GridPoint   cornerPoint;
                GridPoint[] sectorpoints = this.QuadrantPoints(item, out cornerPoint);
                if (sectorpoints == null || cornerPoint == null)
                {
                    this.Quadrant[item] = null;
                    continue;
                }
                //Logger.DBLog.InfoFormat("Sectorpoints Count {0}", sectorpoints.Length);
                Quadrant[item] = new GPQuadrant(sectorpoints, CreationVector, cornerPoint);

                //item = new Sector(Points.SectorPoints(item.SectorCode, true));
                debugstring += "SectorID: " + item.ToString() + " " + Quadrant[item].ContainedPoints.Count + ",";
            }

            //if (Bot.SettingsFunky.Debug.FunkyLogFlags.HasFlag(LogLevel.Movement))
            //	 Logger.DBLog.DebugFormat(debugstring);
        }
Esempio n. 3
0
        private void UpdateQuadrants()
        {
            QuadrantLocation[] sectors_ = Quadrant.Keys.ToArray();
            string debugstring = "";

            foreach (var item in sectors_)
            {
                GridPoint cornerPoint;
                GridPoint[] sectorpoints = this.QuadrantPoints(item, out cornerPoint);
                if (sectorpoints == null || cornerPoint == null)
                {
                    this.Quadrant[item] = null;
                    continue;
                }
                //Logger.DBLog.InfoFormat("Sectorpoints Count {0}", sectorpoints.Length);
                Quadrant[item] = new GPQuadrant(sectorpoints, CreationVector, cornerPoint);

                //item = new Sector(Points.SectorPoints(item.SectorCode, true));
                debugstring += "SectorID: " + item.ToString() + " " + Quadrant[item].ContainedPoints.Count + ",";
            }

            //if (Bot.SettingsFunky.Debug.FunkyLogFlags.HasFlag(LogLevel.Movement))
            //	 Logger.DBLog.DebugFormat(debugstring);
        }
Esempio n. 4
0
        public bool TryFindSafeSpot(Vector3 CurrentPosition, out Vector3 safespot, Vector3 los, PointCheckingFlags Flags, List<GridPoint> BlacklistedPoints, bool expandOnFailure = false, double CurrentWeight = 0)
        {
            lastUsedQuadrant = null;
            safespot = Vector3.Zero;

            //Do not continue search if all sectors failed recently.
            if (AllQuadrantsFailed) return false;

            bool CheckingWeight = (CurrentWeight > 0);

            foreach (var item in Quadrant.Values)
            {
                if (item == null) continue;

                if (CheckingWeight && item.ThisWeight > CurrentWeight)
                    continue;

                if (item.FindSafeSpot(CurrentPosition, out safespot, los, Flags, BlacklistedPoints))
                {
                    lastUsedQuadrant = item;
                    return true;
                }
            }

            AllQuadrantsFailed = true;

            if (expandOnFailure && CanExpandFurther)
            {
                //Logger.DBLog.InfoFormat("Expanding GPC due to failure to find a location!");
                this.FullyExpand();
                this.UpdateQuadrants();
                this.UpdateObjectCount();
            }
            return false;
        }