public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; Faction faction; if ((faction = rp.faction) == null) { faction = (Find.FactionManager.RandomEnemyFaction(false, false, true, TechLevel.Industrial) ?? Find.FactionManager.RandomEnemyFaction(false, false, true, TechLevel.Undefined)); } Faction faction2 = faction; Rot4? thingRot = rp.thingRot; Rot4 rot = (thingRot == null) ? Rot4.Random : thingRot.Value; ThingDef thingDef; if ((thingDef = rp.mortarDef) == null) { thingDef = (from x in DefDatabase <ThingDef> .AllDefsListForReading where x.category == ThingCategory.Building && x.building.IsMortar select x).RandomElement <ThingDef>(); } ThingDef thingDef2 = thingDef; IntVec3 intVec; if (this.TryFindMortarSpawnCell(rp.rect, rot, thingDef2, out intVec)) { if (thingDef2.HasComp(typeof(CompMannable))) { IntVec3 c = ThingUtility.InteractionCellWhenAt(thingDef2, intVec, rot, map); Lord singlePawnLord = LordMaker.MakeNewLord(faction2, new LordJob_ManTurrets(), map, null); PawnKindDef kind = faction2.RandomPawnKind(); Faction faction3 = faction2; int tile = map.Tile; PawnGenerationRequest value = new PawnGenerationRequest(kind, faction3, PawnGenerationContext.NonPlayer, tile, false, false, false, false, true, true, 1f, false, true, true, true, false, false, false, null, null, null, null, null, null, null, null); ResolveParams resolveParams = rp; resolveParams.faction = faction2; resolveParams.singlePawnGenerationRequest = new PawnGenerationRequest?(value); resolveParams.rect = CellRect.SingleCell(c); resolveParams.singlePawnLord = singlePawnLord; BaseGen.symbolStack.Push("pawn", resolveParams); } ThingDef turret = thingDef2; bool allowEMP = false; TechLevel techLevel = faction2.def.techLevel; ThingDef thingDef3 = TurretGunUtility.TryFindRandomShellDef(turret, allowEMP, true, techLevel, false, 250f); if (thingDef3 != null) { ResolveParams resolveParams2 = rp; resolveParams2.faction = faction2; resolveParams2.singleThingDef = thingDef3; resolveParams2.singleThingStackCount = new int?(Rand.RangeInclusive(5, Mathf.Min(8, thingDef3.stackLimit))); BaseGen.symbolStack.Push("thing", resolveParams2); } ResolveParams resolveParams3 = rp; resolveParams3.faction = faction2; resolveParams3.singleThingDef = thingDef2; resolveParams3.rect = CellRect.SingleCell(intVec); resolveParams3.thingRot = new Rot4?(rot); BaseGen.symbolStack.Push("thing", resolveParams3); } }
private bool TryFindMortarSpawnCell(CellRect rect, Rot4 rot, ThingDef mortarDef, out IntVec3 cell) { Map map = BaseGen.globalSettings.map; Predicate <CellRect> edgeTouchCheck; if (rot == Rot4.North) { edgeTouchCheck = ((CellRect x) => x.Cells.Any((IntVec3 y) => y.z == rect.maxZ)); } else if (rot == Rot4.South) { edgeTouchCheck = ((CellRect x) => x.Cells.Any((IntVec3 y) => y.z == rect.minZ)); } else if (rot == Rot4.West) { edgeTouchCheck = ((CellRect x) => x.Cells.Any((IntVec3 y) => y.x == rect.minX)); } else { edgeTouchCheck = ((CellRect x) => x.Cells.Any((IntVec3 y) => y.x == rect.maxX)); } return(CellFinder.TryFindRandomCellInsideWith(rect, delegate(IntVec3 x) { CellRect obj = GenAdj.OccupiedRect(x, rot, mortarDef.size); return ThingUtility.InteractionCellWhenAt(mortarDef, x, rot, map).Standable(map) && obj.FullyContainedWithin(rect) && edgeTouchCheck(obj); }, out cell)); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null) { var def = checkingDef as ThingDef; if (def == null) { return(false); } bool cond_building = false; var terrainLoc = map.terrainGrid.TerrainAt(loc); if (terrainLoc.IsIce()) { cond_building = true; } bool cond_interaction = true; if (def.hasInteractionCell) { var terrainInteraction = map.terrainGrid.TerrainAt(ThingUtility.InteractionCellWhenAt(def, loc, rot, map)); if (terrainInteraction.passability != Traversability.Standable) { cond_interaction = false; } } return(cond_building && cond_interaction); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; Faction faction = rp.faction ?? Find.FactionManager.RandomEnemyFaction(allowHidden: false, allowDefeated: false, allowNonHumanlike: true, TechLevel.Industrial) ?? Find.FactionManager.RandomEnemyFaction(); Rot4? thingRot = rp.thingRot; Rot4 rot = (!thingRot.HasValue) ? Rot4.Random : thingRot.Value; ThingDef thingDef = rp.mortarDef ?? (from x in DefDatabase <ThingDef> .AllDefsListForReading where x.category == ThingCategory.Building && x.building.IsMortar select x).RandomElement(); if (TryFindMortarSpawnCell(rp.rect, rot, thingDef, out IntVec3 cell)) { if (thingDef.HasComp(typeof(CompMannable))) { IntVec3 c = ThingUtility.InteractionCellWhenAt(thingDef, cell, rot, map); Lord singlePawnLord = LordMaker.MakeNewLord(faction, new LordJob_ManTurrets(), map); PawnKindDef kind = faction.RandomPawnKind(); Faction faction2 = faction; int tile = map.Tile; PawnGenerationRequest value = new PawnGenerationRequest(kind, faction2, PawnGenerationContext.NonPlayer, tile, forceGenerateNewPawn: false, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, mustBeCapableOfViolence: true, 1f, forceAddFreeWarmLayerIfNeeded: false, allowGay: true, allowFood: true, inhabitant: true); ResolveParams resolveParams = rp; resolveParams.faction = faction; resolveParams.singlePawnGenerationRequest = value; resolveParams.rect = CellRect.SingleCell(c); resolveParams.singlePawnLord = singlePawnLord; BaseGen.symbolStack.Push("pawn", resolveParams); } ThingDef turret = thingDef; bool allowEMP = false; TechLevel techLevel = faction.def.techLevel; ThingDef thingDef2 = TurretGunUtility.TryFindRandomShellDef(turret, allowEMP, mustHarmHealth: true, techLevel, allowAntigrainWarhead: false, 250f); if (thingDef2 != null) { ResolveParams resolveParams2 = rp; resolveParams2.faction = faction; resolveParams2.singleThingDef = thingDef2; resolveParams2.singleThingStackCount = Rand.RangeInclusive(5, Mathf.Min(8, thingDef2.stackLimit)); BaseGen.symbolStack.Push("thing", resolveParams2); } ResolveParams resolveParams3 = rp; resolveParams3.faction = faction; resolveParams3.singleThingDef = thingDef; resolveParams3.rect = CellRect.SingleCell(cell); resolveParams3.thingRot = rot; BaseGen.symbolStack.Push("thing", resolveParams3); } }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { TerrainDef terrainDef = map.terrainGrid.TerrainAt(loc); if (!terrainDef.defName.Contains("Water") && !terrainDef.defName.Equals("Marsh")) { return(new AcceptanceReport("RBB.FishingSpot1".Translate())); } ThingDef thingDef = checkingDef as ThingDef; IntVec3 intVec3 = ThingUtility.InteractionCellWhenAt(thingDef, loc, rot, map); if (!intVec3.InBounds(map)) { return(new AcceptanceReport("InteractionSpotOutOfBounds".Translate())); } List <Thing> things = map.thingGrid.ThingsListAtFast(intVec3); for (int j = 0; j < things.Count; j++) { if (things[j] != thingToIgnore) { if (things[j].def.passability == Traversability.Impassable) { return(new AcceptanceReport(TranslatorFormattedStringExtensions.Translate("InteractionSpotBlocked", things[j].LabelNoCount).CapitalizeFirst())); } Blueprint blueprint = things[j] as Blueprint; if (blueprint != null && blueprint.def.entityDefToBuild.passability == Traversability.Impassable) { return(new AcceptanceReport(TranslatorFormattedStringExtensions.Translate("InteractionSpotWillBeBlocked", blueprint.LabelNoCount).CapitalizeFirst())); } } } TerrainDef landCheck = map.terrainGrid.TerrainAt(intVec3); if (!landCheck.defName.Contains("Water") && landCheck != TerrainDef.Named("Marsh")) { return(true); } if (landCheck.defName.Contains("Bridge")) { return(true); } return(new AcceptanceReport("RBB.FishingSpot2".Translate())); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thingToPlace = null) { ThingDef thingDef = checkingDef as ThingDef; if (thingDef == null || !thingDef.hasInteractionCell) { return(true); } IntVec3 intVec = ThingUtility.InteractionCellWhenAt(thingDef, loc, rot, map); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { IntVec3 c = intVec; c.x += i; c.z += j; if (!c.InBounds(map)) { continue; } foreach (Thing item in map.thingGrid.ThingsListAtFast(c)) { if (item != thingToIgnore) { ThingDef thingDef2 = item.def; if (item.def.entityDefToBuild != null) { thingDef2 = item.def.entityDefToBuild as ThingDef; } if (thingDef2 != null && thingDef2.hasInteractionCell && ThingUtility.InteractionCellWhenAt(thingDef2, item.Position, item.Rotation, item.Map) == intVec) { return(new AcceptanceReport(((item.def.entityDefToBuild == null) ? "InteractionSpotOverlaps" : "InteractionSpotWillOverlap").Translate(item.LabelNoCount, item))); } } } } } return(true); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; int num = (rp.rect.Width + Mathf.Max(-1, 0)) / (StandardAncientShrineSize.x + -1); int num2 = (rp.rect.Height + Mathf.Max(-1, 0)) / (StandardAncientShrineSize.z + -1); IntVec3 bottomLeft = rp.rect.BottomLeft; PodContentsType?podContentsType = rp.podContentsType; if (!podContentsType.HasValue) { float value = Rand.Value; podContentsType = ((value < 0.5f) ? null : ((value < 0.7f) ? new PodContentsType?(PodContentsType.Slave) : new PodContentsType?(PodContentsType.AncientHostile))); } int value2 = rp.ancientCryptosleepCasketGroupID ?? Find.UniqueIDsManager.GetNextAncientCryptosleepCasketGroupID(); int num3 = 0; for (int i = 0; i < num2; i++) { for (int j = 0; j < num; j++) { if (!Rand.Chance(0.25f)) { if (num3 >= 6) { break; } CellRect rect = new CellRect(bottomLeft.x + j * (StandardAncientShrineSize.x + -1), bottomLeft.z + i * (StandardAncientShrineSize.z + -1), StandardAncientShrineSize.x, StandardAncientShrineSize.z); if (rect.FullyContainedWithin(rp.rect) && ThingUtility.InteractionCellWhenAt(center: new IntVec3(rect.minX + rect.Width / 2 - 1, 0, rect.minZ + rect.Height / 2), def: ThingDefOf.AncientCryptosleepCasket, rot: Rot4.East, map: map).Standable(map)) { ResolveParams resolveParams = rp; resolveParams.rect = rect; resolveParams.ancientCryptosleepCasketGroupID = value2; resolveParams.podContentsType = podContentsType; BaseGen.symbolStack.Push("ancientShrine", resolveParams); num3++; } } } } }
public static AcceptanceReport CanPlaceBlueprintAt(BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode = false, Thing thingToIgnore = null) { CellRect cellRect = GenAdj.OccupiedRect(center, rot, entDef.Size); CellRect.CellRectIterator iterator = cellRect.GetIterator(); while (!iterator.Done()) { IntVec3 c = iterator.Current; if (!c.InBounds(map)) { return(new AcceptanceReport("OutOfBounds".Translate())); } if (c.InNoBuildEdgeArea(map) && !DebugSettings.godMode) { return("TooCloseToMapEdge".Translate()); } iterator.MoveNext(); } if (center.Fogged(map)) { return("CannotPlaceInUndiscovered".Translate()); } List <Thing> thingList = center.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing != thingToIgnore) { if (thing.Position == center && thing.Rotation == rot) { if (thing.def == entDef) { return(new AcceptanceReport("IdenticalThingExists".Translate())); } if (thing.def.entityDefToBuild == entDef) { if (thing is Blueprint) { return(new AcceptanceReport("IdenticalBlueprintExists".Translate())); } return(new AcceptanceReport("IdenticalThingExists".Translate())); } } } } ThingDef thingDef = entDef as ThingDef; if (thingDef != null && thingDef.hasInteractionCell) { IntVec3 c2 = ThingUtility.InteractionCellWhenAt(thingDef, center, rot, map); if (!c2.InBounds(map)) { return(new AcceptanceReport("InteractionSpotOutOfBounds".Translate())); } List <Thing> list = map.thingGrid.ThingsListAtFast(c2); for (int j = 0; j < list.Count; j++) { if (list[j] != thingToIgnore) { if (list[j].def.passability == Traversability.Impassable) { return(new AcceptanceReport("InteractionSpotBlocked".Translate(new object[] { list[j].LabelNoCount }).CapitalizeFirst())); } Blueprint blueprint = list[j] as Blueprint; if (blueprint != null && blueprint.def.entityDefToBuild.passability == Traversability.Impassable) { return(new AcceptanceReport("InteractionSpotWillBeBlocked".Translate(new object[] { blueprint.LabelNoCount }).CapitalizeFirst())); } } } } if (entDef.passability == Traversability.Impassable) { foreach (IntVec3 c3 in GenAdj.CellsAdjacentCardinal(center, rot, entDef.Size)) { if (c3.InBounds(map)) { thingList = c3.GetThingList(map); for (int k = 0; k < thingList.Count; k++) { Thing thing2 = thingList[k]; if (thing2 != thingToIgnore) { Blueprint blueprint2 = thing2 as Blueprint; ThingDef thingDef3; if (blueprint2 != null) { ThingDef thingDef2 = blueprint2.def.entityDefToBuild as ThingDef; if (thingDef2 == null) { goto IL_37F; } thingDef3 = thingDef2; } else { thingDef3 = thing2.def; } if (thingDef3.hasInteractionCell && cellRect.Contains(ThingUtility.InteractionCellWhenAt(thingDef3, thing2.Position, thing2.Rotation, thing2.Map))) { return(new AcceptanceReport("WouldBlockInteractionSpot".Translate(new object[] { entDef.label, thingDef3.label }).CapitalizeFirst())); } } IL_37F :; } } } } TerrainDef terrainDef = entDef as TerrainDef; if (terrainDef != null) { if (map.terrainGrid.TerrainAt(center) == terrainDef) { return(new AcceptanceReport("TerrainIsAlready".Translate(new object[] { terrainDef.label }))); } if (map.designationManager.DesignationAt(center, DesignationDefOf.SmoothFloor) != null) { return(new AcceptanceReport("SpaceBeingSmoothed".Translate())); } } if (!GenConstruct.CanBuildOnTerrain(entDef, center, map, rot, thingToIgnore)) { return(new AcceptanceReport("TerrainCannotSupport".Translate())); } if (!godMode) { CellRect.CellRectIterator iterator2 = cellRect.GetIterator(); while (!iterator2.Done()) { thingList = iterator2.Current.GetThingList(map); for (int l = 0; l < thingList.Count; l++) { Thing thing3 = thingList[l]; if (thing3 != thingToIgnore) { if (!GenConstruct.CanPlaceBlueprintOver(entDef, thing3.def)) { return(new AcceptanceReport("SpaceAlreadyOccupied".Translate())); } } } iterator2.MoveNext(); } } if (entDef.PlaceWorkers != null) { for (int m = 0; m < entDef.PlaceWorkers.Count; m++) { AcceptanceReport result = entDef.PlaceWorkers[m].AllowsPlacing(entDef, center, rot, map, thingToIgnore); if (!result.Accepted) { return(result); } } } return(AcceptanceReport.WasAccepted); }
internal bool <> m__4(IntVec3 x) { CellRect obj = GenAdj.OccupiedRect(x, this.rot, this.mortarDef.size); return(ThingUtility.InteractionCellWhenAt(this.mortarDef, x, this.rot, this.map).Standable(this.map) && obj.FullyContainedWithin(this.rect) && this.edgeTouchCheck(obj)); }
public static AcceptanceReport CanPlaceBlueprintAt(BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, ThingDef stuff, bool godMode = false, Thing thingToIgnore = null) { CellRect cellRect = GenAdj.OccupiedRect(center, rot, entDef.Size); CellRect.CellRectIterator iterator = cellRect.GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; if (!current.InBounds(map)) { return(new AcceptanceReport("OutOfBounds".Translate())); } if (current.InNoBuildEdgeArea(map) && !DebugSettings.godMode) { return("TooCloseToMapEdge".Translate()); } iterator.MoveNext(); } if (center.Fogged(map)) { return("CannotPlaceInUndiscovered".Translate()); } List <Thing> thingList = center.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing != thingToIgnore) { if (thing.Position == center && thing.Rotation == rot) { if (thing.def == entDef) { //Start my code, this code allows blueprint to be placed, so canPlaceOverWall can do it's thing. if (((walls.Contains(thing.def.defName) && walls.Contains(entDef.defName)) || (doors.Contains(thing.def.defName) && doors.Contains(entDef.defName))) && thing.Stuff != stuff) { return(AcceptanceReport.WasAccepted); } //End my code return(new AcceptanceReport("IdenticalThingExists".Translate())); } if (thing.def.entityDefToBuild == entDef) { if (thing is Blueprint) { return(new AcceptanceReport("IdenticalBlueprintExists".Translate())); } return(new AcceptanceReport("IdenticalThingExists".Translate())); } } } } ThingDef thingDef = entDef as ThingDef; if (thingDef != null && thingDef.hasInteractionCell) { IntVec3 c = ThingUtility.InteractionCellWhenAt(thingDef, center, rot, map); if (!c.InBounds(map)) { return(new AcceptanceReport("InteractionSpotOutOfBounds".Translate())); } List <Thing> list = map.thingGrid.ThingsListAtFast(c); for (int j = 0; j < list.Count; j++) { if (list[j] != thingToIgnore) { if (list[j].def.passability == Traversability.Impassable) { return(new AcceptanceReport("InteractionSpotBlocked".Translate(new object[] { list[j].LabelNoCount }).CapitalizeFirst())); } Blueprint blueprint = list[j] as Blueprint; if (blueprint != null && blueprint.def.entityDefToBuild.passability == Traversability.Impassable) { return(new AcceptanceReport("InteractionSpotWillBeBlocked".Translate(new object[] { blueprint.LabelNoCount }).CapitalizeFirst())); } } } } if (entDef.passability != Traversability.Standable) { foreach (IntVec3 current2 in GenAdj.CellsAdjacentCardinal(center, rot, entDef.Size)) { if (current2.InBounds(map)) { thingList = current2.GetThingList(map); for (int k = 0; k < thingList.Count; k++) { Thing thing2 = thingList[k]; if (thing2 != thingToIgnore) { Blueprint blueprint2 = thing2 as Blueprint; ThingDef thingDef3; if (blueprint2 != null) { ThingDef thingDef2 = blueprint2.def.entityDefToBuild as ThingDef; if (thingDef2 == null) { goto IL_37E; } thingDef3 = thingDef2; } else { thingDef3 = thing2.def; } if (thingDef3.hasInteractionCell && cellRect.Contains(ThingUtility.InteractionCellWhenAt(thingDef3, thing2.Position, thing2.Rotation, thing2.Map))) { return(new AcceptanceReport("WouldBlockInteractionSpot".Translate(new object[] { entDef.label, thingDef3.label }).CapitalizeFirst())); } } IL_37E :; } } } } TerrainDef terrainDef = entDef as TerrainDef; if (terrainDef != null) { if (map.terrainGrid.TerrainAt(center) == terrainDef) { return(new AcceptanceReport("TerrainIsAlready".Translate(new object[] { terrainDef.label }))); } if (map.designationManager.DesignationAt(center, DesignationDefOf.SmoothFloor) != null) { return(new AcceptanceReport("BeingSmoothed".Translate())); } } if (!GenConstruct.CanBuildOnTerrain(entDef, center, map, rot, thingToIgnore)) { return(new AcceptanceReport("TerrainCannotSupport".Translate())); } if (!godMode) { CellRect.CellRectIterator iterator2 = cellRect.GetIterator(); while (!iterator2.Done()) { thingList = iterator2.Current.GetThingList(map); for (int l = 0; l < thingList.Count; l++) { Thing thing3 = thingList[l]; if (thing3 != thingToIgnore) { if (!GenConstruct.CanPlaceBlueprintOver(entDef, thing3.def)) { //Start my code, entDef is new, thing3 is old //Allows for doors to replace each other only if different stuff or door <--> autodoor if (thing3?.def?.defName != null) { if ((doors.Contains(entDef.defName) && doors.Contains(thing3.def.defName)) && //New and old are both doors (thing3.Stuff != stuff || !entDef.defName.Equals(thing3.def.defName))) //Not the same stuff or not same thing { return(AcceptanceReport.WasAccepted); } //Allow placing over mineable if (thing3 is Mineable && (doors.Contains(entDef.defName) || walls.Contains(entDef.defName))) { return(AcceptanceReport.WasAccepted); } //Allow walls and doors to be placed over walls if ((walls.Contains(entDef.defName) || doors.Contains(entDef.defName)) && walls.Contains(thing3.def.defName)) { return(AcceptanceReport.WasAccepted); } //Allow replacing invisible power lines from PowerSwitch by Haplo if (conduits.Contains(entDef.defName) && conduits.Contains(thing3.def.defName)) { return(AcceptanceReport.WasAccepted); } } //End my code return(new AcceptanceReport("SpaceAlreadyOccupied".Translate())); } } } iterator2.MoveNext(); } } if (entDef.PlaceWorkers != null) { for (int m = 0; m < entDef.PlaceWorkers.Count; m++) { AcceptanceReport result = entDef.PlaceWorkers[m].AllowsPlacing(entDef, center, rot, map, thingToIgnore); if (!result.Accepted) { return(result); } } } return(AcceptanceReport.WasAccepted); }
public static AcceptanceReport CanPlaceBlueprintAt(BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode = false, Thing thingToIgnore = null, Thing thing = null, ThingDef stuffDef = null) { CellRect cellRect = GenAdj.OccupiedRect(center, rot, entDef.Size); if (stuffDef == null && thing != null) { stuffDef = thing.Stuff; } foreach (IntVec3 item in cellRect) { if (!item.InBounds(map)) { return(new AcceptanceReport("OutOfBounds".Translate())); } if (item.InNoBuildEdgeArea(map) && !godMode) { return("TooCloseToMapEdge".Translate()); } } if (center.Fogged(map)) { return("CannotPlaceInUndiscovered".Translate()); } List <Thing> thingList = center.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Thing thing2 = thingList[i]; if (thing2 == thingToIgnore || !(thing2.Position == center) || !(thing2.Rotation == rot)) { continue; } if (thing2.def == entDef) { return(new AcceptanceReport("IdenticalThingExists".Translate())); } if (thing2.def.entityDefToBuild == entDef) { if (thing2 is Blueprint) { return(new AcceptanceReport("IdenticalBlueprintExists".Translate())); } return(new AcceptanceReport("IdenticalThingExists".Translate())); } } ThingDef thingDef = entDef as ThingDef; if (thingDef != null && thingDef.hasInteractionCell) { IntVec3 c = ThingUtility.InteractionCellWhenAt(thingDef, center, rot, map); if (!c.InBounds(map)) { return(new AcceptanceReport("InteractionSpotOutOfBounds".Translate())); } List <Thing> list = map.thingGrid.ThingsListAtFast(c); for (int j = 0; j < list.Count; j++) { if (list[j] != thingToIgnore) { if (list[j].def.passability == Traversability.Impassable || list[j].def == thingDef) { return(new AcceptanceReport("InteractionSpotBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst())); } BuildableDef entityDefToBuild = list[j].def.entityDefToBuild; if (entityDefToBuild != null && (entityDefToBuild.passability == Traversability.Impassable || entityDefToBuild == thingDef)) { return(new AcceptanceReport("InteractionSpotWillBeBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst())); } } } } foreach (IntVec3 item2 in GenAdj.CellsAdjacentCardinal(center, rot, entDef.Size)) { if (item2.InBounds(map)) { thingList = item2.GetThingList(map); for (int k = 0; k < thingList.Count; k++) { Thing thing3 = thingList[k]; if (thing3 != thingToIgnore) { ThingDef thingDef2 = null; Blueprint blueprint = thing3 as Blueprint; if (blueprint != null) { ThingDef thingDef3 = blueprint.def.entityDefToBuild as ThingDef; if (thingDef3 == null) { continue; } thingDef2 = thingDef3; } else { thingDef2 = thing3.def; } if (thingDef2.hasInteractionCell && (entDef.passability == Traversability.Impassable || entDef == thingDef2) && cellRect.Contains(ThingUtility.InteractionCellWhenAt(thingDef2, thing3.Position, thing3.Rotation, thing3.Map))) { return(new AcceptanceReport("WouldBlockInteractionSpot".Translate(entDef.label, thingDef2.label).CapitalizeFirst())); } } } } } TerrainDef terrainDef = entDef as TerrainDef; if (terrainDef != null) { if (map.terrainGrid.TerrainAt(center) == terrainDef) { return(new AcceptanceReport("TerrainIsAlready".Translate(terrainDef.label))); } if (map.designationManager.DesignationAt(center, DesignationDefOf.SmoothFloor) != null) { return(new AcceptanceReport("SpaceBeingSmoothed".Translate())); } } if (!CanBuildOnTerrain(entDef, center, map, rot, thingToIgnore, stuffDef)) { if (entDef.GetTerrainAffordanceNeed(stuffDef) != null) { if (entDef.useStuffTerrainAffordance && stuffDef != null) { return(new AcceptanceReport("TerrainCannotSupport_TerrainAffordanceFromStuff".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef), stuffDef).CapitalizeFirst())); } return(new AcceptanceReport("TerrainCannotSupport_TerrainAffordance".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef)).CapitalizeFirst())); } return(new AcceptanceReport("TerrainCannotSupport".Translate(entDef).CapitalizeFirst())); } if (ModsConfig.RoyaltyActive) { List <Thing> list2 = map.listerThings.ThingsOfDef(ThingDefOf.MonumentMarker); for (int l = 0; l < list2.Count; l++) { MonumentMarker monumentMarker = (MonumentMarker)list2[l]; if (!monumentMarker.complete && !monumentMarker.AllowsPlacingBlueprint(entDef, center, rot, stuffDef)) { return(new AcceptanceReport("BlueprintWouldCollideWithMonument".Translate())); } } } if (!godMode) { foreach (IntVec3 item3 in cellRect) { thingList = item3.GetThingList(map); for (int m = 0; m < thingList.Count; m++) { Thing thing4 = thingList[m]; if (thing4 != thingToIgnore && !CanPlaceBlueprintOver(entDef, thing4.def)) { return(new AcceptanceReport("SpaceAlreadyOccupied".Translate())); } } } } if (entDef.PlaceWorkers != null) { for (int n = 0; n < entDef.PlaceWorkers.Count; n++) { AcceptanceReport result = entDef.PlaceWorkers[n].AllowsPlacing(entDef, center, rot, map, thingToIgnore, thing); if (!result.Accepted) { return(result); } } } return(AcceptanceReport.WasAccepted); }
// Token: 0x060000E2 RID: 226 RVA: 0x000071D4 File Offset: 0x000053D4 public static AcceptanceReport CanPlaceBlueprintAt(BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode = false, Thing thingToIgnore = null, Thing thing = null, ThingDef stuffDef = null) { CellRect cellRect = GenAdj.OccupiedRect(center, rot, entDef.Size); bool flag = stuffDef == null && thing != null; if (flag) { stuffDef = thing.Stuff; } foreach (IntVec3 c in cellRect) { bool flag2 = !c.InBounds(map); if (flag2) { return(new AcceptanceReport("OutOfBounds".Translate())); } bool flag3 = c.InNoBuildEdgeArea(map) && !godMode; if (flag3) { return("TooCloseToMapEdge".Translate()); } } bool flag4 = center.Fogged(map); AcceptanceReport result; if (flag4) { result = "CannotPlaceInUndiscovered".Translate(); } else { List <Thing> thingList = center.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Thing thing2 = thingList[i]; bool flag5 = thing2 != thingToIgnore && thing2.Position == center && thing2.Rotation == rot; if (flag5) { bool flag6 = thing2.def == entDef; if (flag6) { return(new AcceptanceReport("IdenticalThingExists".Translate())); } bool flag7 = thing2.def.entityDefToBuild == entDef; if (flag7) { bool flag8 = thing2 is Blueprint; if (flag8) { return(new AcceptanceReport("IdenticalBlueprintExists".Translate())); } return(new AcceptanceReport("IdenticalThingExists".Translate())); } } } ThingDef thingDef = entDef as ThingDef; bool flag9 = thingDef != null && thingDef.hasInteractionCell; if (flag9) { IntVec3 c2 = ThingUtility.InteractionCellWhenAt(thingDef, center, rot, map); bool flag10 = !c2.InBounds(map); if (flag10) { return(new AcceptanceReport("InteractionSpotOutOfBounds".Translate())); } List <Thing> list = map.thingGrid.ThingsListAtFast(c2); for (int j = 0; j < list.Count; j++) { bool flag11 = list[j] != thingToIgnore; if (flag11) { bool flag12 = list[j].def.passability == Traversability.Impassable || list[j].def == thingDef; if (flag12) { return(new AcceptanceReport("InteractionSpotBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst())); } BuildableDef entityDefToBuild = list[j].def.entityDefToBuild; bool flag13 = entityDefToBuild != null && (entityDefToBuild.passability == Traversability.Impassable || entityDefToBuild == thingDef); if (flag13) { return(new AcceptanceReport("InteractionSpotWillBeBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst())); } } } } foreach (IntVec3 c3 in GenAdj.CellsAdjacentCardinal(center, rot, entDef.Size)) { bool flag14 = c3.InBounds(map); if (flag14) { thingList = c3.GetThingList(map); for (int k = 0; k < thingList.Count; k++) { Thing thing3 = thingList[k]; bool flag15 = thing3 != thingToIgnore; if (flag15) { Blueprint blueprint = thing3 as Blueprint; bool flag16 = blueprint != null; ThingDef thingDef3; if (flag16) { ThingDef thingDef2 = blueprint.def.entityDefToBuild as ThingDef; bool flag17 = thingDef2 == null; if (flag17) { goto IL_48F; } thingDef3 = thingDef2; } else { thingDef3 = thing3.def; } bool flag18 = thingDef3.hasInteractionCell && (entDef.passability == Traversability.Impassable || entDef == thingDef3) && cellRect.Contains(ThingUtility.InteractionCellWhenAt(thingDef3, thing3.Position, thing3.Rotation, thing3.Map)); if (flag18) { return(new AcceptanceReport("WouldBlockInteractionSpot".Translate(entDef.label, thingDef3.label).CapitalizeFirst())); } } IL_48F :; } } } TerrainDef terrainDef = entDef as TerrainDef; bool flag19 = terrainDef != null; if (flag19) { bool flag20 = map.terrainGrid.TerrainAt(center) == terrainDef; if (flag20) { return(new AcceptanceReport("TerrainIsAlready".Translate(terrainDef.label))); } bool flag21 = map.designationManager.DesignationAt(center, DesignationDefOf.SmoothFloor) != null; if (flag21) { return(new AcceptanceReport("SpaceBeingSmoothed".Translate())); } } bool flag22 = WPGenConstruct.CanBuildOnTerrain(entDef, center, map, rot, thingToIgnore, stuffDef); if (flag22) { bool flag23 = !godMode; if (flag23) { foreach (IntVec3 c4 in cellRect) { thingList = c4.GetThingList(map); for (int l = 0; l < thingList.Count; l++) { Thing thing4 = thingList[l]; bool flag24 = thing4 != thingToIgnore && !WPGenConstruct.CanPlaceBlueprintOver(entDef, thing4.def); if (flag24) { return(new AcceptanceReport("SpaceAlreadyOccupied".Translate())); } } } } bool flag25 = entDef.PlaceWorkers != null; if (flag25) { for (int m = 0; m < entDef.PlaceWorkers.Count; m++) { AcceptanceReport result2 = entDef.PlaceWorkers[m].AllowsPlacing(entDef, center, rot, map, thingToIgnore, thing); bool flag26 = !result2.Accepted; if (flag26) { return(result2); } } } result = AcceptanceReport.WasAccepted; } else { bool flag27 = entDef.GetTerrainAffordanceNeed(stuffDef) == null; if (flag27) { result = new AcceptanceReport("TerrainCannotSupport".Translate(entDef).CapitalizeFirst()); } else { bool flag28 = entDef.useStuffTerrainAffordance && stuffDef != null; if (flag28) { result = new AcceptanceReport("TerrainCannotSupport_TerrainAffordanceFromStuff".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef), stuffDef).CapitalizeFirst()); } else { result = new AcceptanceReport("TerrainCannotSupport_TerrainAffordance".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef)).CapitalizeFirst()); } } } } return(result); }