private static IEnumerable <IntVec3> GetAdjacentCardinalCellsForBestStandCell(IntVec3 x, float radius, Pawn pawn) { if ((float)(x - pawn.Position).LengthManhattan <= radius) { for (int i = 0; i < 4; i++) { IntVec3 c = x + GenAdj.CardinalDirections[i]; if (c.InBounds(pawn.Map) && c.Walkable(pawn.Map)) { Building_Door door = c.GetEdifice(pawn.Map) as Building_Door; if (door == null || door.CanPhysicallyPass(pawn)) { yield return(c); } } } } }
public static bool ConnectedToRoofHolder(IntVec3 c, Map map, bool assumeRoofAtRoot) { bool connected = false; map.floodFiller.FloodFill(c, (IntVec3 x) => (x.Roofed(map) || (x == c && assumeRoofAtRoot)) && !connected, delegate(IntVec3 x) { for (int i = 0; i < 5; i++) { IntVec3 c2 = x + GenAdj.CardinalDirectionsAndInside[i]; if (c2.InBounds(map)) { Building edifice = c2.GetEdifice(map); if (edifice != null && edifice.def.holdsRoof) { connected = true; break; } } } }, 2147483647, false, null); return(connected); }
public static bool WithinRangeOfRoofHolder(IntVec3 c, Map map, bool assumeNonNoRoofCellsAreRoofed = false) { bool connected = false; map.floodFiller.FloodFill(c, (IntVec3 x) => (x.Roofed(map) || x == c || (assumeNonNoRoofCellsAreRoofed && !map.areaManager.NoRoof[x])) && x.InHorDistOf(c, 6.9f), delegate(IntVec3 x) { for (int i = 0; i < 5; i++) { IntVec3 c2 = x + GenAdj.CardinalDirectionsAndInside[i]; if (c2.InBounds(map) && c2.InHorDistOf(c, 6.9f)) { Building edifice = c2.GetEdifice(map); if (edifice != null && edifice.def.holdsRoof) { connected = true; return(true); } } } return(false); }, int.MaxValue, false, null); return(connected); }
public static bool ConnectsToRoofHolder(IntVec3 c, Map map, HashSet <IntVec3> visitedCells) { bool connected = false; map.floodFiller.FloodFill(c, (IntVec3 x) => x.Roofed(map) && !connected, delegate(IntVec3 x) { if (visitedCells.Contains(x)) { connected = true; } else { visitedCells.Add(x); int num = 0; while (true) { if (num < 5) { IntVec3 c2 = x + GenAdj.CardinalDirectionsAndInside[num]; if (c2.InBounds(map)) { Building edifice = c2.GetEdifice(map); if (edifice != null && edifice.def.holdsRoof) { break; } } num++; continue; } return; } connected = true; } }, 2147483647, false, null); return(connected); }
private bool HideRainPrimary(IntVec3 c) { if (base.Map.fogGrid.IsFogged(c)) { return(false); } if (c.Roofed(base.Map)) { Building edifice = c.GetEdifice(base.Map); if (edifice == null) { return(true); } if (edifice.def.Fillage != FillCategory.Full) { return(true); } if (edifice.def.size.x > 1 || edifice.def.size.z > 1) { return(true); } } return(false); }
public static void DrawInteractionCell(ThingDef tDef, IntVec3 center, Rot4 placingRot) { if (!tDef.hasInteractionCell) { return; } IntVec3 c = ThingUtility.InteractionCellWhenAt(tDef, center, placingRot, Find.CurrentMap); Vector3 vector = c.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays); if (c.InBounds(Find.CurrentMap)) { Building edifice = c.GetEdifice(Find.CurrentMap); if (edifice != null && edifice.def.building != null && edifice.def.building.isSittable) { return; } } if (tDef.interactionCellGraphic == null && tDef.interactionCellIcon != null) { ThingDef thingDef = tDef.interactionCellIcon; if (thingDef.blueprintDef != null) { thingDef = thingDef.blueprintDef; } tDef.interactionCellGraphic = thingDef.graphic.GetColoredVersion(ShaderTypeDefOf.EdgeDetect.Shader, InteractionCellIntensity, Color.white); } if (tDef.interactionCellGraphic != null) { Rot4 rot = tDef.interactionCellIconReverse ? placingRot.Opposite : placingRot; tDef.interactionCellGraphic.DrawFromDef(vector, rot, tDef.interactionCellIcon); } else { Graphics.DrawMesh(MeshPool.plane10, vector, Quaternion.identity, InteractionCellMaterial, 0); } }
public static bool Filled(this IntVec3 c, Map map) { Building edifice = c.GetEdifice(map); return(edifice != null && edifice.def.Fillage == FillCategory.Full); }
public static bool CanBeSeenOverFast(this IntVec3 c, Map map) { Building edifice = c.GetEdifice(map); return(edifice == null || edifice.CanBeSeenOver()); }
public virtual IEnumerable <IntVec3> ExplosionCellsToHit(IntVec3 center, Map map, float radius) { openCells.Clear(); adjWallCells.Clear(); int num = GenRadial.NumCellsInRadius(radius); for (int i = 0; i < num; i++) { IntVec3 intVec = center + GenRadial.RadialPattern[i]; if (intVec.InBounds(map) && GenSight.LineOfSight(center, intVec, map, skipFirstCell: true)) { openCells.Add(intVec); } } for (int j = 0; j < openCells.Count; j++) { IntVec3 intVec2 = openCells[j]; if (intVec2.Walkable(map)) { for (int k = 0; k < 4; k++) { IntVec3 intVec3 = intVec2 + GenAdj.CardinalDirections[k]; if (intVec3.InHorDistOf(center, radius) && intVec3.InBounds(map) && !intVec3.Standable(map) && intVec3.GetEdifice(map) != null && !openCells.Contains(intVec3) && adjWallCells.Contains(intVec3)) { adjWallCells.Add(intVec3); } } } } return(openCells.Concat(adjWallCells)); }
public override void Regenerate() { ClearSubMeshes(MeshParts.All); TerrainGrid terrainGrid = base.Map.terrainGrid; CellRect cellRect = section.CellRect; TerrainDef[] array = new TerrainDef[8]; HashSet <TerrainDef> hashSet = new HashSet <TerrainDef>(); bool[] array2 = new bool[8]; foreach (IntVec3 item in cellRect) { hashSet.Clear(); TerrainDef terrainDef = terrainGrid.TerrainAt(item); LayerSubMesh subMesh = GetSubMesh(GetMaterialFor(terrainDef)); if (subMesh != null && AllowRenderingFor(terrainDef)) { int count = subMesh.verts.Count; subMesh.verts.Add(new Vector3(item.x, 0f, item.z)); subMesh.verts.Add(new Vector3(item.x, 0f, item.z + 1)); subMesh.verts.Add(new Vector3(item.x + 1, 0f, item.z + 1)); subMesh.verts.Add(new Vector3(item.x + 1, 0f, item.z)); subMesh.colors.Add(ColorWhite); subMesh.colors.Add(ColorWhite); subMesh.colors.Add(ColorWhite); subMesh.colors.Add(ColorWhite); subMesh.tris.Add(count); subMesh.tris.Add(count + 1); subMesh.tris.Add(count + 2); subMesh.tris.Add(count); subMesh.tris.Add(count + 2); subMesh.tris.Add(count + 3); } for (int i = 0; i < 8; i++) { IntVec3 c = item + GenAdj.AdjacentCellsAroundBottom[i]; if (!c.InBounds(base.Map)) { array[i] = terrainDef; continue; } TerrainDef terrainDef2 = terrainGrid.TerrainAt(c); Thing edifice = c.GetEdifice(base.Map); if (edifice != null && edifice.def.coversFloor) { terrainDef2 = TerrainDefOf.Underwall; } array[i] = terrainDef2; if (terrainDef2 != terrainDef && terrainDef2.edgeType != 0 && terrainDef2.renderPrecedence >= terrainDef.renderPrecedence && !hashSet.Contains(terrainDef2)) { hashSet.Add(terrainDef2); } } foreach (TerrainDef item2 in hashSet) { LayerSubMesh subMesh2 = GetSubMesh(GetMaterialFor(item2)); if (subMesh2 == null || !AllowRenderingFor(item2)) { continue; } int count = subMesh2.verts.Count; subMesh2.verts.Add(new Vector3((float)item.x + 0.5f, 0f, item.z)); subMesh2.verts.Add(new Vector3(item.x, 0f, item.z)); subMesh2.verts.Add(new Vector3(item.x, 0f, (float)item.z + 0.5f)); subMesh2.verts.Add(new Vector3(item.x, 0f, item.z + 1)); subMesh2.verts.Add(new Vector3((float)item.x + 0.5f, 0f, item.z + 1)); subMesh2.verts.Add(new Vector3(item.x + 1, 0f, item.z + 1)); subMesh2.verts.Add(new Vector3(item.x + 1, 0f, (float)item.z + 0.5f)); subMesh2.verts.Add(new Vector3(item.x + 1, 0f, item.z)); subMesh2.verts.Add(new Vector3((float)item.x + 0.5f, 0f, (float)item.z + 0.5f)); for (int j = 0; j < 8; j++) { array2[j] = false; } for (int k = 0; k < 8; k++) { if (k % 2 == 0) { if (array[k] == item2) { array2[(k - 1 + 8) % 8] = true; array2[k] = true; array2[(k + 1) % 8] = true; } } else if (array[k] == item2) { array2[k] = true; } } for (int l = 0; l < 8; l++) { if (array2[l]) { subMesh2.colors.Add(ColorWhite); } else { subMesh2.colors.Add(ColorClear); } } subMesh2.colors.Add(ColorClear); for (int m = 0; m < 8; m++) { subMesh2.tris.Add(count + m); subMesh2.tris.Add(count + (m + 1) % 8); subMesh2.tris.Add(count + 8); } } } FinalizeMesh(MeshParts.All); }