From aaf25e5b7eeac17fab065f1586fe994dbf639570 Mon Sep 17 00:00:00 2001 From: user Date: Wed, 8 Jan 2025 05:58:37 +0300 Subject: [PATCH] Support wall attachments on unpowered hull (XML) and on inacive sides of vents and solar panels (XML and Harmony patch) --- .../ThingDefs_Buildings/Buildings_Ship.xml | 3 ++ .../Buildings_ShipMech.xml | 3 ++ .../Buildings_ShipTechArcho.xml | 3 ++ Source/1.5/HarmonyPatches.cs | 28 +++++++++++++++++++ 4 files changed, 37 insertions(+) diff --git a/1.5/Defs/ThingDefs_Buildings/Buildings_Ship.xml b/1.5/Defs/ThingDefs_Buildings/Buildings_Ship.xml index 4a64489a..785ce466 100644 --- a/1.5/Defs/ThingDefs_Buildings/Buildings_Ship.xml +++ b/1.5/Defs/ThingDefs_Buildings/Buildings_Ship.xml @@ -75,6 +75,7 @@ Things/Building/Linked/Wall_Blueprint_Atlas true + true 14 @@ -341,6 +342,7 @@ Things/Building/Linked/Wall_Blueprint_Atlas true + true
  • @@ -472,6 +474,7 @@ Things/Building/Linked/Wall_Blueprint_Atlas true + true diff --git a/1.5/Defs/ThingDefs_Buildings/Buildings_ShipMech.xml b/1.5/Defs/ThingDefs_Buildings/Buildings_ShipMech.xml index d94897fc..371b3e4e 100644 --- a/1.5/Defs/ThingDefs_Buildings/Buildings_ShipMech.xml +++ b/1.5/Defs/ThingDefs_Buildings/Buildings_ShipMech.xml @@ -54,6 +54,7 @@ Things/Building/Linked/Wall_Blueprint_Atlas + true 14 @@ -282,6 +283,7 @@ Things/Building/Linked/Wall_Blueprint_Atlas + true
  • @@ -406,6 +408,7 @@ Things/Building/Linked/Wall_Blueprint_Atlas + true diff --git a/1.5/Defs/ThingDefs_Buildings/Buildings_ShipTechArcho.xml b/1.5/Defs/ThingDefs_Buildings/Buildings_ShipTechArcho.xml index 17eac531..b73e81d8 100644 --- a/1.5/Defs/ThingDefs_Buildings/Buildings_ShipTechArcho.xml +++ b/1.5/Defs/ThingDefs_Buildings/Buildings_ShipTechArcho.xml @@ -58,6 +58,7 @@ Things/Building/Linked/Wall_Blueprint_Atlas true + true 13 @@ -307,6 +308,7 @@ Things/Building/Linked/Wall_Blueprint_Atlas true + true
  • @@ -435,6 +437,7 @@ Things/Building/Linked/Wall_Blueprint_Atlas true + true diff --git a/Source/1.5/HarmonyPatches.cs b/Source/1.5/HarmonyPatches.cs index b5534fad..2d0a8b23 100644 --- a/Source/1.5/HarmonyPatches.cs +++ b/Source/1.5/HarmonyPatches.cs @@ -5209,6 +5209,34 @@ public static void Postfix(GameEnder __instance) } } + [HarmonyPatch(typeof(Placeworker_AttachedToWall), "AllowsPlacing")] + public static class AllowWallAttachmentsOnVentsAndSolarPanels + { + public static void Postfix(ref AcceptanceReport __result, BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map) + { + // Don't override out of bouds and in fully occupied tile cases + if (__result == false && __result.Reason == "") + { + return; + } + List thingList = (loc + GenAdj.CardinalDirections[rot.AsInt]).GetThingList(map); + foreach (Thing t in thingList) + { + if (t is Building_ShipVent) + { + // "active" side of vent is opposite + __result = t.Rotation != rot.Opposite; + return; + } + if (t.def.defName == "ShipInside_SolarGenerator" || t.def.defName == "ShipInside_SolarGeneratorMech" || t.def.defName == "ShipInside_SolarGeneratorArchotech") + { + __result = t.Rotation != rot; + return; + } + } + } + } + /*[HarmonyPatch(typeof(ActiveDropPod),"PodOpen")] public static class ActivePodFix{ public static bool Prefix (ref ActiveDropPod __instance)