public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { MonumentMarker monumentMarker = thing as MonumentMarker; if (monumentMarker != null) { CellRect rect = monumentMarker.sketch.OccupiedRect.MovedBy(loc); Blueprint_Install thingToIgnore2 = monumentMarker.FindMyBlueprint(rect, map); foreach (SketchEntity entity in monumentMarker.sketch.Entities) { CellRect cellRect = entity.OccupiedRect.MovedBy(loc); if (!cellRect.InBounds(map)) { return(false); } if (cellRect.InNoBuildEdgeArea(map)) { return("TooCloseToMapEdge".Translate()); } foreach (IntVec3 item in cellRect) { if (!entity.CanBuildOnTerrain(item, map)) { TerrainDef terrain = item.GetTerrain(map); return("CannotPlaceMonumentOnTerrain".Translate(terrain.LabelCap)); } } } tmpMonumentThings.Clear(); foreach (SketchBuildable buildable in monumentMarker.sketch.Buildables) { Thing spawnedBlueprintOrFrame = buildable.GetSpawnedBlueprintOrFrame(loc + buildable.pos, map); SketchThing sketchThing; if (spawnedBlueprintOrFrame != null) { tmpMonumentThings.Add(spawnedBlueprintOrFrame); } else if ((sketchThing = buildable as SketchThing) != null) { Thing sameSpawned = sketchThing.GetSameSpawned(loc + sketchThing.pos, map); if (sameSpawned != null) { tmpMonumentThings.Add(sameSpawned); } } } foreach (SketchEntity entity2 in monumentMarker.sketch.Entities) { if (entity2.IsSameSpawnedOrBlueprintOrFrame(loc + entity2.pos, map)) { continue; } foreach (IntVec3 item2 in entity2.OccupiedRect.MovedBy(loc)) { if (item2.InBounds(map)) { Building firstBuilding = item2.GetFirstBuilding(map); if (firstBuilding != null && !tmpMonumentThings.Contains(firstBuilding)) { tmpMonumentThings.Clear(); return("CannotPlaceMonumentOver".Translate(firstBuilding.LabelCap)); } } } SketchBuildable sketchBuildable; if ((sketchBuildable = entity2 as SketchBuildable) != null) { Thing thing2 = sketchBuildable.FirstPermanentBlockerAt(loc + entity2.pos, map); if (thing2 != null && !tmpMonumentThings.Contains(thing2)) { tmpMonumentThings.Clear(); return("CannotPlaceMonumentOver".Translate(thing2.LabelCap)); } } } foreach (SketchEntity entity3 in monumentMarker.sketch.Entities) { Building firstAdjacentBuilding = MonumentMarkerUtility.GetFirstAdjacentBuilding(entity3, loc, tmpMonumentThings, map); if (firstAdjacentBuilding != null) { return("MonumentAdjacentToBuilding".Translate(firstAdjacentBuilding.LabelCap)); } if (entity3.IsSpawningBlockedPermanently(loc + entity3.pos, map, thingToIgnore2)) { tmpMonumentThings.Clear(); return("MonumentBlockedPermanently".Translate()); } } tmpMonumentThings.Clear(); } return(true); }
public void DrawGhost_NewTmp(IntVec3 at, bool placingMode, Rot4 rotation) { CellRect rect = sketch.OccupiedRect.MovedBy(at); Blueprint_Install thingToIgnore = FindMyBlueprint(rect, Find.CurrentMap); sketch.Rotate(rotation); Func <SketchEntity, IntVec3, List <Thing>, Map, bool> validator = null; if (placingMode) { validator = (SketchEntity entity, IntVec3 offset, List <Thing> things, Map map) => MonumentMarkerUtility.GetFirstAdjacentBuilding(entity, offset, things, map) == null; } sketch.DrawGhost_NewTmp(at, Sketch.SpawnPosType.Unchanged, placingMode, thingToIgnore, validator); }