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 static bool TryFindSpawnCell(Thing parent, ThingDef thingToSpawn, int spawnCount, out IntVec3 result) { foreach (IntVec3 intVec in GenAdj.CellsAdjacent8Way(parent).InRandomOrder(null)) { if (intVec.Walkable(parent.Map)) { Building edifice = intVec.GetEdifice(parent.Map); if (edifice == null || !thingToSpawn.IsEdifice()) { Building_Door building_Door = edifice as Building_Door; if ((building_Door == null || building_Door.FreePassage) && (parent.def.passability == Traversability.Impassable || GenSight.LineOfSight(parent.Position, intVec, parent.Map, false, null, 0, 0))) { bool flag = false; List <Thing> thingList = intVec.GetThingList(parent.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category == ThingCategory.Item && (thing.def != thingToSpawn || thing.stackCount > thingToSpawn.stackLimit - spawnCount)) { flag = true; break; } } if (!flag) { result = intVec; return(true); } } } } } result = IntVec3.Invalid; return(false); }
//A17 public static bool BlocksFramePlacement(Blueprint blue, Thing t) { if (t.def.category == ThingCategory.Plant) { return(t.def.plant.harvestWork > 200f); } if (blue.def.entityDefToBuild is TerrainDef || blue.def.entityDefToBuild.passability == Traversability.Standable) { return(false); } if (t.def == ThingDefOf.SteamGeyser && blue.def.entityDefToBuild.ForceAllowPlaceOver(t.def)) { return(false); } ThingDef thingDef = blue.def.entityDefToBuild as ThingDef; if (thingDef != null) { if (thingDef.EverTransmitsPower && t.def == ThingDefOf.PowerConduit && thingDef != ThingDefOf.PowerConduit) { return(false); } //if (t.def == ThingDefOf.Wall && thingDef.building != null && thingDef.building.canPlaceOverWall) if (walls.Contains(t.def.defName) && thingDef.building != null && thingDef.building.canPlaceOverWall) { return(false); } } return((t.def.IsEdifice() && thingDef.IsEdifice()) || (t.def.category == ThingCategory.Pawn || (t.def.category == ThingCategory.Item && blue.def.entityDefToBuild.passability == Traversability.Impassable)) || (t.def.Fillage >= FillCategory.Partial && thingDef != null && thingDef.Fillage >= FillCategory.Partial)); }
public static bool BlocksConstruction(Thing constructible, Thing t) { if (t == constructible) { return(false); } ThingDef thingDef; if (constructible is Blueprint) { thingDef = constructible.def; } else if (constructible is Frame) { thingDef = constructible.def.entityDefToBuild.blueprintDef; } else { thingDef = constructible.def.blueprintDef; } if (t.def.category == ThingCategory.Building && GenSpawn.SpawningWipes(thingDef.entityDefToBuild, t.def)) { return(true); } if (t.def.category == ThingCategory.Plant) { if (t.def.plant.harvestWork > ThingDefOf.Plant_Dandelion.plant.harvestWork) { bool flag = thingDef.entityDefToBuild is TerrainDef && t.Spawned && t.Position.GetEdifice(t.Map) is IPlantToGrowSettable; return(!flag); } return(false); } else { if (!thingDef.clearBuildingArea) { return(false); } if (t.def == ThingDefOf.SteamGeyser && thingDef.entityDefToBuild.ForceAllowPlaceOver(t.def)) { return(false); } ThingDef thingDef2 = thingDef.entityDefToBuild as ThingDef; if (thingDef2 != null) { if (thingDef2.EverTransmitsPower && t.def == ThingDefOf.PowerConduit && thingDef2 != ThingDefOf.PowerConduit) { return(false); } if (t.def == ThingDefOf.Wall && thingDef2.building != null && thingDef2.building.canPlaceOverWall) { return(false); } } return((t.def.IsEdifice() && thingDef2.IsEdifice()) || (t.def.category == ThingCategory.Pawn || (t.def.category == ThingCategory.Item && thingDef.entityDefToBuild.passability == Traversability.Impassable)) || t.def.Fillage >= FillCategory.Partial); } }
public static bool TryFindSpawnCell(this HediffComp_RandySpawnUponDeath comp, Thing refThing, int randomQuantity, Map map, out IntVec3 result) { ThingDef thingDef = comp.ChosenItem.thingToSpawn; if (refThing.Negligible()) { result = IntVec3.Invalid; if (comp.MyDebug) { Log.Warning("TryFindSpawnCell Null - pawn null"); } return(false); } foreach (IntVec3 current in GenAdj.CellsAdjacent8Way(refThing).InRandomOrder(null)) { if (current.Walkable(map)) { Building edifice = current.GetEdifice(map); if (edifice == null || !thingDef.IsEdifice()) { if (!(edifice is Building_Door building_Door) || building_Door.FreePassage) { if (GenSight.LineOfSight(refThing.Position, current, map, false, null, 0, 0)) { bool flag = false; List <Thing> thingList = current.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category == ThingCategory.Item) { if (thing.def != thingDef || thing.stackCount > thingDef.stackLimit - randomQuantity) { flag = true; break; } } } if (!flag) { result = current; return(true); } } } } } } if (comp.MyDebug) { Log.Warning("TryFindSpawnCell Null - no spawn cell found"); } result = IntVec3.Invalid; return(false); }
public static bool BlocksConstruction(Thing constructible, Thing t) { if (t == constructible) { return(false); } ThingDef thingDef = (!(constructible is Blueprint)) ? ((!(constructible is Frame)) ? constructible.def.blueprintDef : constructible.def.entityDefToBuild.blueprintDef) : constructible.def; if (t.def.category == ThingCategory.Building && GenSpawn.SpawningWipes(thingDef.entityDefToBuild, t.def)) { return(true); } if (t.def.category == ThingCategory.Plant) { if (t.def.plant.harvestWork >= 200.0) { return(true); } return(false); } if (!thingDef.clearBuildingArea) { return(false); } if (t.def == ThingDefOf.SteamGeyser && thingDef.entityDefToBuild.ForceAllowPlaceOver(t.def)) { return(false); } ThingDef thingDef2 = thingDef.entityDefToBuild as ThingDef; if (thingDef2 != null) { if (thingDef2.EverTransmitsPower && t.def == ThingDefOf.PowerConduit && thingDef2 != ThingDefOf.PowerConduit) { return(false); } if (t.def == ThingDefOf.Wall && thingDef2.building != null && thingDef2.building.canPlaceOverWall) { return(false); } } if (t.def.IsEdifice() && thingDef2.IsEdifice()) { return(true); } if (t.def.category != ThingCategory.Pawn && (t.def.category != ThingCategory.Item || thingDef.entityDefToBuild.passability != Traversability.Impassable)) { if ((int)t.def.Fillage >= 1) { return(true); } return(false); } return(true); }
// Token: 0x06005757 RID: 22359 RVA: 0x001D4668 File Offset: 0x001D2868 public static bool TryFindSpawnCell(Thing parent, CompProperties_SpawnerTerrainDependant PropsSpawner, out IntVec3 result) { ThingDef thingToSpawn = PropsSpawner.thingToSpawn; int spawnCount = PropsSpawner.spawnCount; foreach (IntVec3 intVec in GenAdj.CellsAdjacent8Way(parent).InRandomOrder(null)) { if (intVec.Walkable(parent.Map)) { if (!PropsSpawner.allowedTerrain.NullOrEmpty()) { if (!PropsSpawner.allowedTerrain.Contains(intVec.GetTerrain(parent.Map))) { continue; } } if (!PropsSpawner.allowedAffordances.NullOrEmpty()) { if (!PropsSpawner.allowedAffordances.Any(x => intVec.GetTerrain(parent.Map).affordances.Contains(x))) { continue; } } Building edifice = intVec.GetEdifice(parent.Map); if (edifice == null || !thingToSpawn.IsEdifice()) { Building_Door building_Door = edifice as Building_Door; if ((building_Door == null || building_Door.FreePassage) && (parent.def.passability == Traversability.Impassable || GenSight.LineOfSight(parent.Position, intVec, parent.Map, false, null, 0, 0))) { bool flag = false; List <Thing> thingList = intVec.GetThingList(parent.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category == ThingCategory.Item && (thing.def != thingToSpawn || thing.stackCount > thingToSpawn.stackLimit - spawnCount)) { flag = true; break; } } if (!flag) { result = intVec; return(true); } } } } } result = IntVec3.Invalid; return(false); }
public static bool TryFindSpawnCell(this HediffComp_RandySpawner comp, out IntVec3 result) { Pawn p = comp.Pawn; ThingDef thingDef = comp.CurIP.thingToSpawn; if (p.Negligible()) { result = IntVec3.Invalid; Tools.Warn("TryFindSpawnCell Null - pawn null", comp.MyDebug); return(false); } foreach (IntVec3 current in GenAdj.CellsAdjacent8Way(p).InRandomOrder(null)) { if (current.Walkable(p.Map)) { Building edifice = current.GetEdifice(p.Map); if (edifice == null || !thingDef.IsEdifice()) { if (!(edifice is Building_Door building_Door) || building_Door.FreePassage) { if (GenSight.LineOfSight(p.Position, current, p.Map, false, null, 0, 0)) { bool flag = false; List <Thing> thingList = current.GetThingList(p.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category == ThingCategory.Item) { if (thing.def != thingDef || thing.stackCount > thingDef.stackLimit - comp.calculatedQuantity) { flag = true; break; } } } if (!flag) { result = current; return(true); } } } } } } Tools.Warn("TryFindSpawnCell Null - no spawn cell found", comp.MyDebug); result = IntVec3.Invalid; return(false); }
public static bool CanPlaceBlueprintAt(IntVec3 spot, ThingDef def, Rot4 rot = default(Rot4)) { if (!spot.IsValid) { return(false); } // Cheaty cheaty bool isEdifice = def.IsEdifice(); def.building.isEdifice = true; bool result = GenConstruct.CanPlaceBlueprintAt(def, spot, rot, info.map, false, null).Accepted; def.building.isEdifice = isEdifice; return(result); }
public static bool BlocksConstruction(Thing constructible, Thing t) { if (t == constructible) { return(false); } ThingDef thingDef = !(constructible is Blueprint) ? (!(constructible is Frame) ? constructible.def.blueprintDef : constructible.def.entityDefToBuild.blueprintDef) : constructible.def; if (t.def.category == ThingCategory.Building && GenSpawn.SpawningWipes(thingDef.entityDefToBuild, (BuildableDef)t.def)) { return(true); } if (t.def.category == ThingCategory.Plant) { return((double)t.def.plant.harvestWork >= 200.0); } if (!thingDef.clearBuildingArea || t.def == ThingDefOf.SteamGeyser && thingDef.entityDefToBuild.ForceAllowPlaceOver((BuildableDef)t.def)) { return(false); } ThingDef entityDefToBuild = thingDef.entityDefToBuild as ThingDef; return((entityDefToBuild == null || (!entityDefToBuild.EverTransmitsPower || t.def != ThingDefOf.PowerConduit || entityDefToBuild == ThingDefOf.PowerConduit) && (!walls.Contains(t.def.defName) || entityDefToBuild.building == null || !entityDefToBuild.building.canPlaceOverWall)) && (t.def.IsEdifice() && entityDefToBuild.IsEdifice() || t.def.category == ThingCategory.Pawn || (t.def.category == ThingCategory.Item && thingDef.entityDefToBuild.passability == Traversability.Impassable || t.def.Fillage >= FillCategory.Partial))); }
public static bool SpawningWipesPrefix(ref bool __result, BuildableDef newEntDef, BuildableDef oldEntDef) { ThingDef thingDef = newEntDef as ThingDef; ThingDef thingDef2 = oldEntDef as ThingDef; if (thingDef == null || thingDef2 == null) { __result = false; return(false); } if (thingDef.category == ThingCategory.Attachment || thingDef.category == ThingCategory.Mote || thingDef.category == ThingCategory.Filth || thingDef.category == ThingCategory.Projectile) { __result = false; return(false); } if (!thingDef2.destroyable) { __result = false; return(false); } if (thingDef.category == ThingCategory.Plant) { __result = false; return(false); } if (thingDef2.category == ThingCategory.Filth && thingDef.passability != Traversability.Standable) { __result = true; return(false); } if (thingDef2.category == ThingCategory.Item && thingDef.passability == Traversability.Impassable && thingDef.surfaceType == SurfaceType.None) { __result = true; return(false); } if (thingDef.EverTransmitsPower && thingDef2 == ThingDefOf.PowerConduit) { __result = true; return(false); } if (thingDef.IsFrame && GenSpawn.SpawningWipes(thingDef.entityDefToBuild, oldEntDef)) { __result = true; return(false); } BuildableDef buildableDef = GenConstruct.BuiltDefOf(thingDef); BuildableDef buildableDef2 = GenConstruct.BuiltDefOf(thingDef2); if (buildableDef == null || buildableDef2 == null) { __result = false; return(false); } ThingDef thingDef3 = thingDef.entityDefToBuild as ThingDef; if (thingDef2.IsBlueprint) { if (thingDef.IsBlueprint) { if (thingDef3 != null && thingDef3.building != null && thingDef3.building.canPlaceOverWall && thingDef2.entityDefToBuild is ThingDef && ((ThingDef)thingDef2.entityDefToBuild == ThingDefOf.Wall || ((ThingDef)thingDef2.entityDefToBuild).thingClass == typeof(GL_Building))) { __result = true; return(false); } if (thingDef2.entityDefToBuild is TerrainDef) { if (thingDef.entityDefToBuild is ThingDef && ((ThingDef)thingDef.entityDefToBuild).coversFloor) { __result = true; return(false); } if (thingDef.entityDefToBuild is TerrainDef) { __result = true; return(false); } } } __result = thingDef2.entityDefToBuild == ThingDefOf.PowerConduit && thingDef.entityDefToBuild is ThingDef && (thingDef.entityDefToBuild as ThingDef).EverTransmitsPower; return(false); } if ((thingDef2.IsFrame || thingDef2.IsBlueprint) && thingDef2.entityDefToBuild is TerrainDef) { ThingDef thingDef4 = buildableDef as ThingDef; if (thingDef4 != null && !thingDef4.CoexistsWithFloors) { __result = true; return(false); } } if (thingDef2 == ThingDefOf.ActiveDropPod) { __result = false; return(false); } if (thingDef == ThingDefOf.ActiveDropPod) { __result = thingDef2 != ThingDefOf.ActiveDropPod && (thingDef2.category == ThingCategory.Building && thingDef2.passability == Traversability.Impassable); return(false); } if (thingDef.IsEdifice()) { if (thingDef.BlockPlanting && thingDef2.category == ThingCategory.Plant) { __result = true; return(false); } if (!(buildableDef is TerrainDef) && buildableDef2.IsEdifice()) { __result = true; return(false); } } __result = false; return(false); }
public static bool BlocksConstruction(Thing constructible, Thing t) { bool result; if (t == constructible) { result = false; } else { ThingDef thingDef; if (constructible is Blueprint) { thingDef = constructible.def; } else if (constructible is Frame) { thingDef = constructible.def.entityDefToBuild.blueprintDef; } else { thingDef = constructible.def.blueprintDef; } if (t.def.category == ThingCategory.Building && GenSpawn.SpawningWipes(thingDef.entityDefToBuild, t.def)) { result = true; } else if (t.def.category == ThingCategory.Plant) { result = (t.def.plant.harvestWork >= 200f); } else if (!thingDef.clearBuildingArea) { result = false; } else if (t.def == ThingDefOf.SteamGeyser && thingDef.entityDefToBuild.ForceAllowPlaceOver(t.def)) { result = false; } else { ThingDef thingDef2 = thingDef.entityDefToBuild as ThingDef; if (thingDef2 != null) { if (thingDef2.EverTransmitsPower) { if (t.def == ThingDefOf.PowerConduit && thingDef2 != ThingDefOf.PowerConduit) { return(false); } } if (t.def == ThingDefOf.Wall && thingDef2.building != null && thingDef2.building.canPlaceOverWall) { return(false); } } result = ((t.def.IsEdifice() && thingDef2.IsEdifice()) || (t.def.category == ThingCategory.Pawn || (t.def.category == ThingCategory.Item && thingDef.entityDefToBuild.passability == Traversability.Impassable)) || t.def.Fillage >= FillCategory.Partial); } } return(result); }
public static bool SpawningWipes(BuildableDef newEntDef, BuildableDef oldEntDef) { ThingDef thingDef = newEntDef as ThingDef; ThingDef thingDef2 = oldEntDef as ThingDef; if (thingDef == null || thingDef2 == null) { return(false); } if (thingDef.category == ThingCategory.Attachment || thingDef.category == ThingCategory.Mote || thingDef.category == ThingCategory.Filth || thingDef.category == ThingCategory.Projectile) { return(false); } if (!thingDef2.destroyable) { return(false); } if (thingDef.category == ThingCategory.Plant) { return(false); } if (thingDef2.category == ThingCategory.Filth && thingDef.passability != Traversability.Standable) { return(true); } //if (thingDef.EverTransmitsPower && thingDef2 == ThingDefOf.PowerConduit) if (thingDef.EverTransmitsPower && GenConstruct_JT.conduits.Contains(thingDef2.defName)) { return(true); } if (thingDef.IsFrame && GenSpawn.SpawningWipes(thingDef.entityDefToBuild, oldEntDef)) { return(true); } BuildableDef buildableDef = GenConstruct.BuiltDefOf(thingDef); BuildableDef buildableDef2 = GenConstruct.BuiltDefOf(thingDef2); if (buildableDef == null || buildableDef2 == null) { return(false); } ThingDef thingDef3 = thingDef.entityDefToBuild as ThingDef; if (thingDef2.IsBlueprint) { if (thingDef.IsBlueprint) { if (thingDef3 != null && thingDef3.building != null && thingDef3.building.canPlaceOverWall && thingDef2.entityDefToBuild is ThingDef && (ThingDef)thingDef2.entityDefToBuild == ThingDefOf.Wall) { return(true); } if (thingDef2.entityDefToBuild is TerrainDef) { if (thingDef.entityDefToBuild is ThingDef && ((ThingDef)thingDef.entityDefToBuild).coversFloor) { return(true); } if (thingDef.entityDefToBuild is TerrainDef) { return(true); } } } return(thingDef2.entityDefToBuild == ThingDefOf.PowerConduit && thingDef.entityDefToBuild is ThingDef && (thingDef.entityDefToBuild as ThingDef).EverTransmitsPower); } if ((thingDef2.IsFrame || thingDef2.IsBlueprint) && thingDef2.entityDefToBuild is TerrainDef) { ThingDef thingDef4 = buildableDef as ThingDef; if (thingDef4 != null && !thingDef4.CoexistsWithFloors) { return(true); } } if (thingDef2 == ThingDefOf.ActiveDropPod) { return(false); } if (thingDef == ThingDefOf.ActiveDropPod) { return(thingDef2 != ThingDefOf.ActiveDropPod && (thingDef2.category == ThingCategory.Building && thingDef2.passability == Traversability.Impassable)); } if (thingDef.IsEdifice()) { if (thingDef.BlockPlanting && thingDef2.category == ThingCategory.Plant) { return(true); } if (!(buildableDef is TerrainDef) && buildableDef2.IsEdifice()) { return(true); } } return(false); }
// Token: 0x060000E4 RID: 228 RVA: 0x0000799C File Offset: 0x00005B9C public static bool CanPlaceBlueprintOver(BuildableDef newDef, ThingDef oldDef) { bool everHaulable = oldDef.EverHaulable; bool result; if (everHaulable) { result = true; } else { TerrainDef terrainDef = newDef as TerrainDef; bool flag = terrainDef != null; if (flag) { bool flag2 = oldDef.category == ThingCategory.Building && !terrainDef.affordances.Contains(oldDef.terrainAffordanceNeeded); if (flag2) { return(false); } bool flag3 = (oldDef.IsBlueprint || oldDef.IsFrame) && !terrainDef.affordances.Contains(oldDef.entityDefToBuild.terrainAffordanceNeeded); if (flag3) { return(false); } } ThingDef thingDef = newDef as ThingDef; BuildableDef buildableDef = WPGenConstruct.BuiltDefOf(oldDef); ThingDef thingDef2 = buildableDef as ThingDef; bool flag4 = oldDef == ThingDefOf.SteamGeyser && !newDef.ForceAllowPlaceOver(oldDef); if (flag4) { result = false; } else { bool flag5 = oldDef.category == ThingCategory.Plant && oldDef.passability == Traversability.Impassable && thingDef != null && thingDef.category == ThingCategory.Building && !thingDef.building.canPlaceOverImpassablePlant; if (flag5) { result = false; } else { bool flag6 = oldDef.category == ThingCategory.Building || oldDef.IsBlueprint || oldDef.IsFrame; if (flag6) { bool flag7 = thingDef != null; if (flag7) { bool flag8 = !thingDef.IsEdifice(); if (flag8) { return((oldDef.building == null || oldDef.building.canBuildNonEdificesUnder) && (!thingDef.EverTransmitsPower || !oldDef.EverTransmitsPower)); } bool flag9 = thingDef.IsEdifice() && oldDef != null && oldDef.category == ThingCategory.Building && !oldDef.IsEdifice(); if (flag9) { return(thingDef.building == null || thingDef.building.canBuildNonEdificesUnder); } bool flag10 = thingDef2 != null && thingDef2 == ThingDefOf.Wall && thingDef.building != null && thingDef.building.canPlaceOverWall; if (flag10) { return(true); } bool flag11 = newDef != ThingDefOf.PowerConduit && buildableDef == ThingDefOf.PowerConduit; if (flag11) { return(true); } } result = ((newDef is TerrainDef && buildableDef is ThingDef && ((ThingDef)buildableDef).CoexistsWithFloors) || (buildableDef is TerrainDef && !(newDef is TerrainDef))); } else { result = true; } } } } return(result); }