private bool ContainsPathCostIgnoreRepeater(IntVec3 c) { List <Thing> list = this.map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { if (PathGrid.IsPathCostIgnoreRepeater(list[i].def)) { return(true); } } return(false); }
public static void ThingPathCostsIgnoreRepeaters() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("===============PATH COST IGNORE REPEATERS=============="); foreach (ThingDef current in DefDatabase <ThingDef> .AllDefs) { if (PathGrid.IsPathCostIgnoreRepeater(current) && current.passability != Traversability.Impassable) { stringBuilder.AppendLine(current.defName + " " + current.pathCost); } } stringBuilder.AppendLine("===============NON-PATH COST IGNORE REPEATERS that are buildings with >0 pathCost =============="); foreach (ThingDef current2 in DefDatabase <ThingDef> .AllDefs) { if (!PathGrid.IsPathCostIgnoreRepeater(current2) && current2.passability != Traversability.Impassable && current2.category == ThingCategory.Building && current2.pathCost > 0) { stringBuilder.AppendLine(current2.defName + " " + current2.pathCost); } } Log.Message(stringBuilder.ToString(), false); }
public int CalculatedCostAt(IntVec3 c, bool perceivedStatic, IntVec3 prevCell) { bool flag = false; TerrainDef terrainDef = this.map.terrainGrid.TerrainAt(c); if (terrainDef == null || terrainDef.passability == Traversability.Impassable) { return(10000); } int num = terrainDef.pathCost; List <Thing> list = this.map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing.def.passability == Traversability.Impassable) { return(10000); } if (!PathGrid.IsPathCostIgnoreRepeater(thing.def) || !prevCell.IsValid || !this.ContainsPathCostIgnoreRepeater(prevCell)) { int pathCost = thing.def.pathCost; if (pathCost > num) { num = pathCost; } } if (thing is Building_Door && prevCell.IsValid) { Building edifice = prevCell.GetEdifice(this.map); if (edifice != null && edifice is Building_Door) { flag = true; } } } int num2 = SnowUtility.MovementTicksAddOn(this.map.snowGrid.GetCategory(c)); if (num2 > num) { num = num2; } if (flag) { num += 45; } if (perceivedStatic) { for (int j = 0; j < 9; j++) { IntVec3 b = GenAdj.AdjacentCellsAndInside[j]; IntVec3 c2 = c + b; if (c2.InBounds(this.map)) { Fire fire = null; list = this.map.thingGrid.ThingsListAtFast(c2); for (int k = 0; k < list.Count; k++) { fire = (list[k] as Fire); if (fire != null) { break; } } if (fire != null && fire.parent == null) { if (b.x == 0 && b.z == 0) { num += 1000; } else { num += 150; } } } } } return(num); }
public int CalculatedCostAt(IntVec3 c, bool perceivedStatic, IntVec3 prevCell) { int num = 0; TerrainDef terrainDef = this.map.terrainGrid.TerrainAt(c); num = ((terrainDef != null && terrainDef.passability != Traversability.Impassable) ? (num + terrainDef.pathCost) : 10000); int num2 = SnowUtility.MovementTicksAddOn(this.map.snowGrid.GetCategory(c)); num += num2; List <Thing> list = this.map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing.def.passability == Traversability.Impassable) { return(10000); } if (!PathGrid.IsPathCostIgnoreRepeater(thing.def) || !prevCell.IsValid || !this.ContainsPathCostIgnoreRepeater(prevCell)) { num += thing.def.pathCost; } if (prevCell.IsValid && thing is Building_Door) { Building edifice = prevCell.GetEdifice(this.map); if (edifice != null && edifice is Building_Door) { num += 45; } } } if (perceivedStatic) { for (int j = 0; j < 9; j++) { IntVec3 b = GenAdj.AdjacentCellsAndInside[j]; IntVec3 c2 = c + b; if (c2.InBounds(this.map)) { Fire fire = null; list = this.map.thingGrid.ThingsListAtFast(c2); int num3 = 0; while (num3 < list.Count) { fire = (list[num3] as Fire); if (fire == null) { num3++; continue; } break; } if (fire != null && fire.parent == null) { num = ((b.x != 0 || b.z != 0) ? (num + 150) : (num + 1000)); } } } } return(num); }