diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index 3c781f42..269e1068 100644 Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/1.6/1.6/Defs/ThingDefs_Buildings/Buildings_WULA.xml b/1.6/1.6/Defs/ThingDefs_Buildings/Buildings_WULA.xml index add332f2..3f5ba72c 100644 --- a/1.6/1.6/Defs/ThingDefs_Buildings/Buildings_WULA.xml +++ b/1.6/1.6/Defs/ThingDefs_Buildings/Buildings_WULA.xml @@ -679,6 +679,7 @@
  • MechTurretBig_Call
  • +
  • PassThroughOnly 50 diff --git a/1.6/Odyssey/Defs/ThingDefs_Buildings/Building_WULA_Shuttle.xml b/1.6/Odyssey/Defs/ThingDefs_Buildings/Building_WULA_Shuttle.xml index a41fb20c..a153adc2 100644 --- a/1.6/Odyssey/Defs/ThingDefs_Buildings/Building_WULA_Shuttle.xml +++ b/1.6/Odyssey/Defs/ThingDefs_Buildings/Building_WULA_Shuttle.xml @@ -281,6 +281,7 @@ -1 0
  • +
  • diff --git a/Source/WulaFallenEmpire/CompForceTargetable.cs b/Source/WulaFallenEmpire/CompForceTargetable.cs new file mode 100644 index 00000000..cda89e73 --- /dev/null +++ b/Source/WulaFallenEmpire/CompForceTargetable.cs @@ -0,0 +1,25 @@ +using Verse; + +namespace WulaFallenEmpire +{ + /// + /// This CompProperties class is used in the XML defs to add the CompForceTargetable to a Thing. + /// + public class CompProperties_ForceTargetable : CompProperties + { + public CompProperties_ForceTargetable() + { + this.compClass = typeof(CompForceTargetable); + } + } + + /// + /// A simple marker component. Any Building_TurretGun that has this component + /// will be forcefully made targetable by players via a Harmony patch. + /// + public class CompForceTargetable : ThingComp + { + // This component doesn't need any specific logic. + // Its mere presence on a turret is checked by the Harmony patch. + } +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/Patch_ArmedShuttle_ForceTargetable.cs b/Source/WulaFallenEmpire/Patch_ArmedShuttle_ForceTargetable.cs new file mode 100644 index 00000000..c0f75cd2 --- /dev/null +++ b/Source/WulaFallenEmpire/Patch_ArmedShuttle_ForceTargetable.cs @@ -0,0 +1,28 @@ +using HarmonyLib; +using Verse; +using RimWorld; + +namespace WulaFallenEmpire +{ + [HarmonyPatch(typeof(Building_ArmedShuttle), "get_CanSetForcedTarget")] + public static class Patch_Building_ArmedShuttle_CanSetForcedTarget + { + /// + /// Postfix patch to allow armed shuttles with CompForceTargetable to be manually targeted. + /// + public static void Postfix(Building_ArmedShuttle __instance, ref bool __result) + { + // If the result is already true, no need to do anything. + if (__result) + { + return; + } + + // Check if the shuttle has our marker component and belongs to the player. + if (__instance.GetComp() != null && __instance.Faction == Faction.OfPlayer) + { + __result = true; + } + } + } +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/Patch_ForceTargetable.cs b/Source/WulaFallenEmpire/Patch_ForceTargetable.cs new file mode 100644 index 00000000..fe3edaaf --- /dev/null +++ b/Source/WulaFallenEmpire/Patch_ForceTargetable.cs @@ -0,0 +1,28 @@ +using HarmonyLib; +using Verse; +using RimWorld; + +namespace WulaFallenEmpire +{ + [HarmonyPatch(typeof(Building_TurretGun), "get_CanSetForcedTarget")] + public static class Patch_Building_TurretGun_CanSetForcedTarget + { + /// + /// Postfix patch to allow turrets with CompForceTargetable to be manually targeted. + /// + public static void Postfix(Building_TurretGun __instance, ref bool __result) + { + // If the result is already true, no need to do anything. + if (__result) + { + return; + } + + // Check if the turret has our marker component and belongs to the player. + if (__instance.GetComp() != null && __instance.Faction == Faction.OfPlayer) + { + __result = true; + } + } + } +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj index 21b7957f..5db85c5c 100644 --- a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj +++ b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj @@ -187,6 +187,9 @@ + + +