public static bool CanPlaceBlueprintOver(BuildableDef newDef, ThingDef oldDef) { if (oldDef.EverHaulable) { return(true); } TerrainDef terrainDef = newDef as TerrainDef; if (terrainDef != null) { if (oldDef.IsBlueprint || oldDef.IsFrame) { if (!terrainDef.affordances.Contains(oldDef.entityDefToBuild.terrainAffordanceNeeded)) { return(false); } } else if (oldDef.category == ThingCategory.Building && !terrainDef.affordances.Contains(oldDef.terrainAffordanceNeeded)) { return(false); } } ThingDef thingDef = newDef as ThingDef; BuildableDef buildableDef = GenConstruct.BuiltDefOf(oldDef); ThingDef thingDef2 = buildableDef as ThingDef; if (oldDef == ThingDefOf.SteamGeyser && !newDef.ForceAllowPlaceOver(oldDef)) { return(false); } if (oldDef.category == ThingCategory.Plant && oldDef.passability == Traversability.Impassable && thingDef != null && thingDef.category == ThingCategory.Building && !thingDef.building.canPlaceOverImpassablePlant) { return(false); } if (oldDef.category == ThingCategory.Building || oldDef.IsBlueprint || oldDef.IsFrame) { if (thingDef != null) { if (!thingDef.IsEdifice()) { return((oldDef.building == null || oldDef.building.canBuildNonEdificesUnder) && (!thingDef.EverTransmitsPower || !oldDef.EverTransmitsPower)); } if (thingDef.IsEdifice() && oldDef != null && oldDef.category == ThingCategory.Building && !oldDef.IsEdifice()) { return(thingDef.building == null || thingDef.building.canBuildNonEdificesUnder); } if (thingDef2 != null && (thingDef2 == ThingDefOf.Wall || thingDef2.IsSmoothed) && thingDef.building != null && thingDef.building.canPlaceOverWall) { return(true); } if (newDef != ThingDefOf.PowerConduit && buildableDef == ThingDefOf.PowerConduit) { return(true); } } return((newDef is TerrainDef && buildableDef is ThingDef && ((ThingDef)buildableDef).CoexistsWithFloors) || (buildableDef is TerrainDef && !(newDef is TerrainDef))); } return(true); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null) { for (int i = 0; i < 4; i++) { IntVec3 c = loc + GenAdj.CardinalDirections[i]; if (c.InBounds(map)) { List <Thing> thingList = c.GetThingList(map); for (int j = 0; j < thingList.Count; j++) { Thing thing = thingList[j]; ThingDef thingDef = GenConstruct.BuiltDefOf(thing.def) as ThingDef; if (thingDef != null && thingDef.building != null && thingDef.building.wantsHopperAdjacent) { return(true); } } } } return("MustPlaceNextToHopperAccepter".Translate()); }