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); }
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; }