public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { for (int i = 0; i < 4; i++) { IntVec3 c = loc + GenAdj.CardinalDirections[i]; if (!c.InBounds(map)) { continue; } List <Thing> thingList = c.GetThingList(map); foreach (Thing thingNearby in thingList) { // Check for an already-built pocket dimension building if (thingNearby as Building_PocketDimensionEntranceBase != null) { return(true); } // Might be a blueprint, this won't work with the premade boxes (unless we name them all here... and I'm not doing that because I'll never remember if I add more so :P) ThingDef thingDef = GenConstruct.BuiltDefOf(thingNearby.def) as ThingDef; if (thingDef != null && thingDef == PocketDimensionDefOf.CM_PocketDimensionBox || thingDef == PocketDimensionDefOf.CM_PocketDimensionExit) { return(true); } } } return("CM_MustPlaceNextToDimensionalHopperAccepter".Translate()); }
public static bool Prefix(BuildableDef newDef, ThingDef oldDef, ref bool __result) { var thingDef = newDef as ThingDef; var thingDef1 = oldDef; if (thingDef == null || thingDef1 == null) { return(true); } var buildableDef = GenConstruct.BuiltDefOf(oldDef); if (thingDef.building == null || !thingDef.building.canPlaceOverWall || buildableDef is not ThingDef thingDef2) { return(true); } if (!thingDef2.defName.Equals("RFFConcreteWall") && !thingDef2.defName.Equals("RFFReinforcedConcreteWall") && !thingDef2.defName.Equals("RFFPlasticreteWall")) { return(true); } __result = true; return(false); }
//public static AcceptanceReport CanPlaceBlueprintAt(BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode = false, Thing thingToIgnore = null) public static void Postfix(ref AcceptanceReport __result, BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode, Thing thingToIgnore) { if (__result.Reason != "IdenticalThingExists".Translate() && __result.Reason != "IdenticalBlueprintExists".Translate()) { return; } if (!entDef.MadeFromStuff) { return; } ThingDef newStuff = Designator_Build_Stuff.stuffDef; foreach (Thing thing in center.GetThingList(map)) { if (thing != thingToIgnore && thing.Position == center && thing.Rotation == rot && GenConstruct.BuiltDefOf(thing.def) == entDef) { ThingDef oldStuff = thing is Blueprint bp?bp.UIStuff() : thing.Stuff; if (thing is ReplaceFrame rf && oldStuff == newStuff) { __result = false; return; } if (newStuff != oldStuff) { __result = true; } } } }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { for (var i = 0; i < 4; i++) { var c = loc + GenAdj.CardinalDirections[i] + GenAdj.CardinalDirections[i]; if (!c.InBounds(map)) { continue; } var thingList = c.GetThingList(map); foreach (var groundThing in thingList) { if (!(GenConstruct.BuiltDefOf(groundThing.def) is ThingDef thingDef) || thingDef.building == null) { continue; } if (thingDef.defName == "ET_BiogenesisVat") { return(true); } } } return("MustPlaceNextToVatAccepter".Translate()); }
//public static bool SpawningWipes(BuildableDef newEntDef, BuildableDef oldEntDef) public static bool Prefix(BuildableDef oldEntDef, bool __result) { if (oldEntDef is ThingDef tdef && (GenConstruct.BuiltDefOf(tdef) ?? oldEntDef).IsBridgelike()) { __result = false; return(false); } return(true); }
public static bool IsNewThingReplacement(this Thing newThing, out Thing oldThing) { if (newThing.Spawned && GenConstruct.BuiltDefOf(newThing.def) is ThingDef newDef) { return(newDef.IsNewThingReplacement(newThing.Position, newThing.Rotation, newThing.Map, out oldThing)); } oldThing = null; return(false); }
public static bool ToBeSmoothed(Thing thing, ThingDef constructibleDef) { ThingDef smoothedThing = thing.def.building?.smoothedThing; return(smoothedThing != null && !GenSpawn.SpawningWipes(GenConstruct.BuiltDefOf(constructibleDef), smoothedThing) && thing.Map.edificeGrid[thing.Position] == thing && thing.Map.designationManager.DesignationAt(thing.Position, DesignationDefOf.SmoothWall) != null); }
public static void Postfix(Thing t, Map ___map) { if (___map == Find.CurrentMap) { if (GenConstruct.BuiltDefOf(t.def) == MoreThingDefOf.MoisturePump) { BaseOverlay.SetDirty(typeof(BuildableOverlay)); } } }
public static void Postfix(Thing t, Map ___map) { if (___map == Find.CurrentMap) { if (CoverageOverlay.activeType != null && GenConstruct.BuiltDefOf(t.def) == CoverageOverlay.activeType.CoverageDef()) { BaseOverlay.SetDirty(typeof(CoverageOverlay)); } } }
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; IntVec3 c = loc + GenAdj.CardinalDirections[i]; if (i == 0) { c = loc; } else if (i == 1) { c = loc; } else if (i == 2) { c = loc; } else if (i == 3) { c = loc + GenAdj.CardinalDirections[3]; } 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) { if (thingDef.building.wantsHopperAdjacent) { CompBeeHouse comp = thing.TryGetComp <CompBeeHouse>(); if (comp != null) { if (comp.GetIsBeehouse) { return(true); } } else { return("RB_BeehouseNotYetBuilt".Translate()); } } } } } } return("GU_PlaceNextToBeeHouse".Translate()); }
public override void Update() { TerrainAffordanceDef newAffordance = OverrideAffordance(); if (newAffordance != curAffordance) { Log.Message($"newAffordance is {newAffordance}"); curAffordance = newAffordance; SetDirty(); } bool newGeo = PlacingGeothermal(); if (newGeo != placingGeothermal) { Log.Message($"newGeo is {newGeo}"); placingGeothermal = newGeo; SetDirty(); } bool newPump = PlacingMoisturePump(); if (newPump != placingMoisturePump) { Log.Message($"newPump is {newPump}"); placingMoisturePump = newPump; SetDirty(); } if (placingMoisturePump && dirty) { HashSet <IntVec3> centers = new HashSet <IntVec3>(Find.CurrentMap.listerThings.ThingsOfDef(MoreThingDefOf.MoisturePump).Select(t => t.Position)); centers.AddRange(Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.Blueprint) .Where(bp => GenConstruct.BuiltDefOf(bp.def) == MoreThingDefOf.MoisturePump).Select(t => t.Position).ToList()); centers.AddRange(Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.BuildingFrame) .Where(frame => GenConstruct.BuiltDefOf(frame.def) == MoreThingDefOf.MoisturePump).Select(t => t.Position).ToList()); moisturePumpCells.Clear(); float radius = MoreThingDefOf.MoisturePump.specialDisplayRadius; foreach (IntVec3 center in centers) { int num = GenRadial.NumCellsInRadius(radius); for (int i = 0; i < num; i++) { moisturePumpCells.Add(center + GenRadial.RadialPattern[i]); } } } base.Update(); }
static HashSet <string> GetWipeCategories(ThingDef thingDef) { var buildingExtension = GenConstruct.BuiltDefOf(thingDef)?.GetBuildingExtension(); if (buildingExtension == null) { return(null); } var wipeCategorySet = buildingExtension.WipeCategories; return(wipeCategorySet == null || wipeCategorySet.Count == 0 ? null : wipeCategorySet); }
public static bool CanReplaceStuffFor(ThingDef stuff, Thing thing, ThingDef matchDef = null) { if (thing.Faction != Faction.OfPlayer && thing.Faction != null) //can't replace enemy things { return(false); } BuildableDef builtDef = GenConstruct.BuiltDefOf(thing.def); if (matchDef != null && builtDef != matchDef) { return(false); } if (thing is Blueprint bp) { if (bp.EntityToBuildStuff() == stuff) { return(false); } } else if (thing is Frame frame) { if (frame.EntityToBuildStuff() == stuff) { return(false); } } else if (thing.def.HasReplaceFrame()) { if (thing.Stuff == stuff) { return(false); } } else { return(false); } if (!GenConstruct.CanBuildOnTerrain(builtDef, thing.Position, thing.Map, thing.Rotation, thing, stuff)) { return(false); //TODO: place bridges under && } if (thing.BeingReplacedByNewThing() != null) { return(false); //being upgraded. } return(GenStuff.AllowedStuffsFor(builtDef).Contains(stuff)); }
//public static bool SpawningWipes(BuildableDef newEntDef, BuildableDef oldEntDef) public static bool Prefix(BuildableDef oldEntDef, bool __result) { if (oldEntDef as ThingDef == null) { return(true); } if ((GenConstruct.BuiltDefOf(oldEntDef as ThingDef) ?? oldEntDef) == TerrainDefOf.Bridge) { __result = false; return(false); } return(true); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { var checkThingDef = checkingDef as ThingDef; var prop = checkThingDef?.GetCompProperties <CompProperties_FlammableLink>(); if (prop == null) { return(true); } var things = loc.GetThingList(map); foreach (var thing1 in things) { if (thing1.def == ThingDefOf.Wall || thing1.def.passability == Traversability.PassThroughOnly && thing1.def.category == ThingCategory.Item) { return(false); } var prop2 = thing1.def.GetCompProperties <CompProperties_FlammableLink>(); if (prop2 != null && prop.connectionID == prop2.connectionID) { return(false); } var curBuildDef = GenConstruct.BuiltDefOf(thing1.def); if (curBuildDef is not ThingDef) { continue; } var curDef = (ThingDef)curBuildDef; if (curDef == ThingDefOf.Wall) { return(false); } prop2 = curDef.GetCompProperties <CompProperties_FlammableLink>(); if (prop2 != null && prop.connectionID == prop2.connectionID) { return(false); } } return(true); }
public static void BlocksConstruction_PostFix(Thing constructible, Thing t, ref bool __result) { ThingDef thingDef = constructible.def; ThingDef thingDef2 = t.def; if (thingDef == null || thingDef2 == null) { return; } if (thingDef.HasModExtension <BuildingExtension>() || thingDef2.HasModExtension <BuildingExtension>()) { BuildableDef buildableDef = GenConstruct.BuiltDefOf(thingDef); BuildableDef buildableDef2 = GenConstruct.BuiltDefOf(thingDef2); __result = ShouldWipe(buildableDef, buildableDef2, t.PositionHeld, t.MapHeld); } }
public static void _Postfix(BuildableDef newDef, ThingDef oldDef, ref bool __result) { //if (__result) return; ThingDef thingDef = newDef as ThingDef; BuildableDef buildableDef = GenConstruct.BuiltDefOf(oldDef); ThingDef thingDef2 = buildableDef as ThingDef; if (thingDef != null) { if (thingDef2 != null && thingDef2.graphicData != null && ((thingDef2.graphicData.linkFlags & (LinkFlags.Wall)) != 0 || thingDef2.IsSmoothed) && thingDef.building != null && thingDef.building.canPlaceOverWall) { __result = true; } } }
public static void SpawningWipes_PostFix(BuildableDef newEntDef, BuildableDef oldEntDef, ref bool __result) { ThingDef thingDef = newEntDef as ThingDef; ThingDef thingDef2 = oldEntDef as ThingDef; if (thingDef == null || thingDef2 == null) { return; } if (thingDef.HasModExtension <BuildingExtension>() || thingDef2.HasModExtension <BuildingExtension>()) { BuildableDef buildableDef = GenConstruct.BuiltDefOf(thingDef); BuildableDef buildableDef2 = GenConstruct.BuiltDefOf(thingDef2); __result = ShouldWipe(buildableDef, buildableDef2, IntVec3.Invalid, null); } }
static void Postfix(ref bool __result, BuildableDef newEntDef, BuildableDef oldEntDef) { ThingDef newDef = newEntDef as ThingDef; ThingDef oldDef = oldEntDef as ThingDef; if (newDef == null || oldDef == null) { return; } if (!newDef.IsBlueprint && oldDef.IsBlueprint && !GenConstruct.CanPlaceBlueprintOver(GenConstruct.BuiltDefOf(oldDef), newDef)) { __result = true; } }
// Token: 0x060000A0 RID: 160 RVA: 0x00005E9C File Offset: 0x0000409C public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thingy = null) { for (var i = 0; i < 4; i++) { var c = loc + NewMethod(i); if (!c.InBounds(map)) { continue; } var thingList = c.GetThingList(map); foreach (var thing in thingList) { if (GenConstruct.BuiltDefOf(thing.def) is ThingDef { building: { }, defName: "RPThingMaker"
//public static bool CanPlaceBlueprintOver(BuildableDef newDef, ThingDef oldDef) public static void Postfix(BuildableDef newDef, ThingDef oldDef, ref bool __result) { if (__result) { return; } BuildableDef oldBuildDef = GenConstruct.BuiltDefOf(oldDef); if (oldDef.category == ThingCategory.Building || oldDef.IsBlueprint || oldDef.IsFrame) { //Power conduit sharing is hardcoded, so cooler sharing is hardcoded too if ((newDef.IsOverWall() && oldBuildDef.IsWall()) || (newDef.IsWall() && oldBuildDef.IsOverWall())) { __result = true; } } }
//public static AcceptanceReport CanPlaceBlueprintAt(BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode = false, Thing thingToIgnore = null) public static void Postfix(ref AcceptanceReport __result, BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode, Thing thingToIgnore) { if (__result.Reason != "IdenticalThingExists".Translate() && __result.Reason != "IdenticalBlueprintExists".Translate()) { return; } if (!entDef.MadeFromStuff) { return; } ThingDef newStuff = DesignatorContext.stuffDef; //It would not be so easy to transpile this part //it doesn't simply change __result to true when a replace frame can be placed, //it also checks if the replace frame is already there and overrides that with false foreach (Thing thing in center.GetThingList(map)) { if (thing.IsNewThingReplacement(out Thing oldThing)) { __result = false; return; } if (thing != thingToIgnore && thing.Position == center && (thing.Rotation == rot || PlacingRotationDoesntMatter(entDef)) && GenConstruct.BuiltDefOf(thing.def) == entDef) { ThingDef oldStuff = thing is Blueprint bp?bp.EntityToBuildStuff() : thing.Stuff; if (thing is ReplaceFrame rf && oldStuff == newStuff) { __result = false; return; } if (newStuff != oldStuff && GenConstruct.CanBuildOnTerrain(entDef, center, map, rot, thing, newStuff)) { __result = true; } } } }
public static CompHopperUser FindHopperUser(IntVec3 cell) { //var str = string.Format( "CompHopper.FindHopperUser( {0} )", cell.ToString() ); if (!cell.InBounds()) { //Log.Message( str ); return(null); } List <Thing> thingList = null; if (Scribe.mode != LoadSaveMode.Inactive) { // Find hopper user in world matching cell if ( (Find.ThingGrid == null) || (Find.ThingGrid.ThingsAt(cell).Count() == 0) ) { //Log.Message( str ); return(null); } thingList = Find.ThingGrid.ThingsAt(cell).ToList(); } else { // Find hopper user in cell thingList = cell.GetThingList(); } if (!thingList.NullOrEmpty()) { var hopperUser = thingList.FirstOrDefault((thing) => { var thingDef = GenConstruct.BuiltDefOf(thing.def) as ThingDef; return((thingDef != null) && (thingDef.IsHopperUser())); }); if (hopperUser != null) { // Found a hopper user //str += " = " + hopperUser.ThingID; //Log.Message( str ); return(hopperUser.TryGetComp <CompHopperUser>()); } } // Nothing found //Log.Message( str ); return(null); }
public override void Update() { //Find selected thing or thing to build ThingDef def = null; if (Find.DesignatorManager.SelectedDesignator is Designator_Place des) { def = des.PlacingDef as ThingDef; } if (def == null) { def = Find.Selector.SingleSelectedThing.GetInnerIfMinified()?.def; } if (def != null) { def = GenConstruct.BuiltDefOf(def) as ThingDef; foreach (CoverageType cov in types) { if (cov.MakeActive(def)) { SetDirty(); if (cov.active) { activeType = cov; } else { Clear(); } } } if (dirty) //From MakeActive or otherwise { activeType?.Init(); } } else if (activeType != null) { Clear(); } base.Update(); }
static void Postfix(BuildableDef newDef, ThingDef oldDef, ref bool __result) { if (__result == false) { ThingDef thingDef = newDef as ThingDef; BuildableDef buildableDef = GenConstruct.BuiltDefOf(oldDef); ThingDef thingDef2 = buildableDef as ThingDef; if (oldDef.category == ThingCategory.Building || oldDef.IsBlueprint || oldDef.IsFrame) { if (thingDef != null) { if (thingDef2 != null && WallBehaviourPatch.defNameIsGoblinWall(thingDef2.defName) && thingDef.building != null && thingDef.building.canPlaceOverWall) { __result = true; } } } } }
public static bool CanReplaceStuffFor(ThingDef stuff, Thing thing) { if (thing.Faction != Faction.OfPlayer && thing.Faction != null) { return(false); } if (thing is Blueprint bp) { if (bp.UIStuff() == stuff) { return(false); } } else if (thing is Frame frame) { if (frame.UIStuff() == stuff) { return(false); } } else if (thing.def.HasReplaceFrame()) { if (thing.Stuff == stuff) { return(false); } } else { return(false); } foreach (ThingDef def in GenStuff.AllowedStuffsFor(GenConstruct.BuiltDefOf(thing.def))) { if (def == stuff) { return(true); } } return(false); }
//public static bool SpawningWipes(BuildableDef newEntDef, BuildableDef oldEntDef) public static void Postfix(BuildableDef newEntDef, BuildableDef oldEntDef, ref bool __result) { if (!__result) { return; } ThingDef newDef = newEntDef as ThingDef; ThingDef oldDef = oldEntDef as ThingDef; BuildableDef newBuiltDef = GenConstruct.BuiltDefOf(newDef); BuildableDef oldBuiltDef = GenConstruct.BuiltDefOf(oldDef); //Power conduit sharing is hardcoded, so cooler sharing is hardcoded too if ((newBuiltDef.IsOverWall() && oldBuiltDef.IsWall()) || (newBuiltDef.IsWall() && oldBuiltDef.IsOverWall())) { __result = false; } }
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; IntVec3 c = loc + GenAdj.CardinalDirections[i]; if (i == 0) { c = loc; } else if (i == 1) { c = loc + GenAdj.CardinalDirections[1]; } else if (i == 2) { c = loc; } else if (i == 3) { c = loc; } 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) { if (thingDef.building.wantsHopperAdjacent && ((thingDef.defName == "RB_Beehouse") || (thingDef.defName == "RB_ClimatizedBeehouse") || (thingDef.defName == "RB_AdvancedBeehouse"))) { return(true); } } } } } return("GU_PlaceNextToBeeHouseLeft".Translate()); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null) { ThingDef checkThingDef = checkingDef as ThingDef; CompProperties_FlammableLink prop = checkThingDef.GetCompProperties <CompProperties_FlammableLink>(); if (prop == null) { return(true); } List <Thing> things = loc.GetThingList(map); for (int i = 0; i < things.Count; i++) { if (things[i].def == ThingDefOf.Wall || (things[i].def.passability == Traversability.PassThroughOnly && things[i].def.category == ThingCategory.Item)) { return(false); } CompProperties_FlammableLink prop2 = things[i].def.GetCompProperties <CompProperties_FlammableLink>(); if (prop2 != null && prop.connectionID == prop2.connectionID) { return(false); } BuildableDef curBuildDef = GenConstruct.BuiltDefOf(things[i].def); if (curBuildDef != null && curBuildDef is ThingDef) { ThingDef curDef = (ThingDef)curBuildDef; if (curDef == ThingDefOf.Wall) { return(false); } prop2 = curDef.GetCompProperties <CompProperties_FlammableLink>(); if (prop2 != null && prop.connectionID == prop2.connectionID) { return(false); } } } return(true); }
// Token: 0x060000AF RID: 175 RVA: 0x00008EF0 File Offset: 0x000070F0 public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thingy = null) { for (int i = 0; i < 4; i++) { IntVec3 c = loc + PlaceWorker_MSDrugMixHopper.NewMethod(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.defName == "MSDrugMixer" && this.IsCorrectSide(thing, c, rot)) { return(true); } } } } return("MustPlaceNextToHopperAccepter".Translate()); }