private void RecreatePaths() { ReleasePaths(); WorldPathFinder worldPathFinder = Find.WorldPathFinder; for (int i = 1; i < waypoints.Count; i++) { paths.Add(worldPathFinder.FindPath(waypoints[i - 1].Tile, waypoints[i].Tile, null)); } cachedTicksToWaypoint.Clear(); int num = 0; int caravanTicksPerMove = CaravanTicksPerMove; for (int j = 0; j < waypoints.Count; j++) { if (j == 0) { cachedTicksToWaypoint.Add(0); } else { num += CaravanArrivalTimeEstimator.EstimatedTicksToArrive(waypoints[j - 1].Tile, waypoints[j].Tile, paths[j - 1], 0f, caravanTicksPerMove, GenTicks.TicksAbs + num); cachedTicksToWaypoint.Add(num); } } }
public void ConstructComponents() { worldObjects = new WorldObjectsHolder(); factionManager = new FactionManager(); worldPawns = new WorldPawns(); gameConditionManager = new GameConditionManager(this); storyState = new StoryState(this); renderer = new WorldRenderer(); UI = new WorldInterface(); debugDrawer = new WorldDebugDrawer(); dynamicDrawManager = new WorldDynamicDrawManager(); pathFinder = new WorldPathFinder(); pathPool = new WorldPathPool(); reachability = new WorldReachability(); floodFiller = new WorldFloodFiller(); ticksAbsCache = new ConfiguredTicksAbsAtGameStartCache(); components.Clear(); FillComponents(); }
public void ConstructComponents() { this.worldObjects = new WorldObjectsHolder(); this.factionManager = new FactionManager(); this.uniqueIDsManager = new UniqueIDsManager(); this.worldPawns = new WorldPawns(); this.settings = new WorldSettings(); this.gameConditionManager = new GameConditionManager(null); this.storyState = new StoryState(this); this.renderer = new WorldRenderer(); this.UI = new WorldInterface(); this.debugDrawer = new WorldDebugDrawer(); this.dynamicDrawManager = new WorldDynamicDrawManager(); this.pathFinder = new WorldPathFinder(); this.pathPool = new WorldPathPool(); this.reachability = new WorldReachability(); this.floodFiller = new WorldFloodFiller(); this.ticksAbsCache = new ConfiguredTicksAbsAtGameStartCache(); this.components.Clear(); this.FillComponents(); }
private List <Link> GenerateProspectiveLinks(List <int> indexToTile) { Dictionary <int, int> tileToIndexLookup = new Dictionary <int, int>(); for (int i = 0; i < indexToTile.Count; i++) { tileToIndexLookup[indexToTile[i]] = i; } List <Link> linkProspective = new List <Link>(); List <int> list = new List <int>(); int srcIndex; for (srcIndex = 0; srcIndex < indexToTile.Count; srcIndex++) { int srcTile = indexToTile[srcIndex]; list.Clear(); list.Add(srcTile); int found = 0; Find.WorldPathFinder.FloodPathsWithCost(list, (int src, int dst) => WorldPathFinder.StandardPathCost(src, dst, null), null, delegate(int tile, float distance) { if (tile != srcTile && tileToIndexLookup.ContainsKey(tile)) { found++; linkProspective.Add(new Link { distance = distance, indexA = srcIndex, indexB = tileToIndexLookup[tile] }); } return(found >= 8); }); } linkProspective.Sort((Link lhs, Link rhs) => lhs.distance.CompareTo(rhs.distance)); return(linkProspective); }