diff --git a/1.5/Assemblies/Implants.dll b/1.5/Assemblies/Implants.dll index 0e34e1c..41b7bd5 100644 Binary files a/1.5/Assemblies/Implants.dll and b/1.5/Assemblies/Implants.dll differ diff --git a/1.5/Assemblies/Implants.pdb b/1.5/Assemblies/Implants.pdb index 1dee527..7924969 100644 Binary files a/1.5/Assemblies/Implants.pdb and b/1.5/Assemblies/Implants.pdb differ diff --git a/1.5/Assemblies/Implants.xml b/1.5/Assemblies/Implants.xml index a7a13c4..34268fd 100644 --- a/1.5/Assemblies/Implants.xml +++ b/1.5/Assemblies/Implants.xml @@ -4,7 +4,7 @@ Implants - + pushed always commandable check to front to reduct compute. TODO perhaps need a custom patch order to make sure this logic always works. @@ -13,14 +13,14 @@ should be mechanitor, but not always the mechanitor for example like Dead man switch ctrl mechs Commandable result from original code. - + Skip original draw radius using a prefix. TODO may need specify fixed patch order to make sure this works. return false to skip original draw. - + Postfix the draw radius by apply our extended radius on top. diff --git a/1.5/Assemblies/Implants/.gitattributes b/Source/.gitattributes similarity index 100% rename from 1.5/Assemblies/Implants/.gitattributes rename to Source/.gitattributes diff --git a/1.5/Assemblies/Implants/.gitignore b/Source/.gitignore similarity index 100% rename from 1.5/Assemblies/Implants/.gitignore rename to Source/.gitignore diff --git a/1.5/Assemblies/Implants/Anomaly/AnomalyGeneral.cs b/Source/Anomaly/AnomalyGeneral.cs similarity index 99% rename from 1.5/Assemblies/Implants/Anomaly/AnomalyGeneral.cs rename to Source/Anomaly/AnomalyGeneral.cs index 3e923c5..286c59d 100644 --- a/1.5/Assemblies/Implants/Anomaly/AnomalyGeneral.cs +++ b/Source/Anomaly/AnomalyGeneral.cs @@ -8,7 +8,7 @@ using RimWorld; using UnityEngine; using Verse; -namespace Implants.Anomaly +namespace LTS_Implants { public class LTS_Hediff_PsychicReaper : Hediff diff --git a/1.5/Assemblies/Implants/Biotech/Gene_Deathrest.cs b/Source/Biotech/Gene_Deathrest.cs similarity index 99% rename from 1.5/Assemblies/Implants/Biotech/Gene_Deathrest.cs rename to Source/Biotech/Gene_Deathrest.cs index 4840382..7cb87c3 100644 --- a/1.5/Assemblies/Implants/Biotech/Gene_Deathrest.cs +++ b/Source/Biotech/Gene_Deathrest.cs @@ -8,7 +8,7 @@ using RimWorld; using UnityEngine; using Verse; -namespace Implants.Biotech +namespace LTS_Implants { [HarmonyPatch(typeof(Gene_Deathrest))] [HarmonyPatch(nameof(Gene_Deathrest.RemoveOldDeathrestBonuses))] diff --git a/1.5/Assemblies/Implants/Biotech/Mechanitor.cs b/Source/Biotech/Mechanitor.cs similarity index 94% rename from 1.5/Assemblies/Implants/Biotech/Mechanitor.cs rename to Source/Biotech/Mechanitor.cs index ff770b2..cdc4ca4 100644 --- a/1.5/Assemblies/Implants/Biotech/Mechanitor.cs +++ b/Source/Biotech/Mechanitor.cs @@ -9,18 +9,30 @@ using UnityEngine; using Verse; using Verse.AI.Group; -namespace Implants.Biotech +namespace LTS_Implants { #region Command Range [HarmonyPatchCategory("Biotech")] - class BiotechMechanitorPatches + static class BiotechMechanitorPatches { [HarmonyPatch(typeof(Pawn_MechanitorTracker))] [HarmonyPatch(nameof(Pawn_MechanitorTracker.CanCommandTo))] - class + static class Pawn_MechanitorTracker_CanCommandTo_Patch //increases the mechanitor's range by MechRemoteControlDistanceOffset { + private static float defaultRange = 24.9f; + [HarmonyPrepare] + static bool Prepare() + { + if (LTS_Implants.HarmonyPatches.IsCombatExtended) + { + defaultRange = 43.9f; + Verse.Log.Warning("[LTS-II-Forked]Pawn_MechanitorTracker.CanCommandTo Patch Recognized CE,default Range changed from 24.9 to 43.9"); + } + + return true; + } /// /// pushed always commandable check to front to reduct compute. /// TODO perhaps need a custom patch order to make sure this logic always works. @@ -38,17 +50,29 @@ namespace Implants.Biotech __instance.Pawn?.GetStatValue(StatDef.Named("MechRemoteControlDistanceOffset")) ?? 0f; __result = target.Cell.InBounds(__instance.Pawn.MapHeld) && (float)__instance.Pawn.Position.DistanceToSquared(target.Cell) < - (24.9f + SignalBoosterRange) * - (24.9f + + (defaultRange + SignalBoosterRange) * + (defaultRange + SignalBoosterRange); //last line should mean that if something else makes it true, then it is(?) } } - [HarmonyPatch(typeof(Pawn_MechanitorTracker))] [HarmonyPatch(nameof(Pawn_MechanitorTracker.DrawCommandRadius))] - class + static class Pawn_MechanitorTracker_DrawCommandRadius_Patch //increases the displayed mechanitor range by MechRemoteControlDistanceOffset { + private static float defaultRange = 24.9f; + [HarmonyPrepare] + static bool Prepare() + { + if (LTS_Implants.HarmonyPatches.IsCombatExtended) + { + defaultRange = 43.9f; + Verse.Log.Warning( + "[LTS-II-Forked]Pawn_MechanitorTracker.DrawCommandRadius Patch Recognized CE,default Range changed from 24.9 to 43.9"); + } + + return true; + } /// /// Skip original draw radius using a prefix. /// TODO may need specify fixed patch order to make sure this works. @@ -75,7 +99,7 @@ namespace Implants.Biotech "Neronix17.TweaksGalore")) //for tweaks galore, it'd be better to try to find the setting specifically, with an inverted result and a null check true { IntVec3 position = __instance.Pawn.Position; - float radius = 24.9f + + float radius = defaultRange + (__instance.Pawn?.GetStatValue( StatDef.Named("MechRemoteControlDistanceOffset")) ?? 0f); //Make our command circle yellow. And make sure this postfix implemented draw follows vanilla impl. diff --git a/1.5/Assemblies/Implants/CaptiveControl.cs b/Source/CaptiveControl.cs similarity index 99% rename from 1.5/Assemblies/Implants/CaptiveControl.cs rename to Source/CaptiveControl.cs index 42b9bc6..8eb9162 100644 --- a/1.5/Assemblies/Implants/CaptiveControl.cs +++ b/Source/CaptiveControl.cs @@ -7,7 +7,7 @@ using RimWorld; using Verse; using Verse.Sound; -namespace Implants +namespace LTS_Implants { public class LTS_CompProperties_CaptiveControl : CompProperties_AbilityEffect diff --git a/1.5/Assemblies/Implants/Implants.csproj b/Source/Implants.csproj similarity index 100% rename from 1.5/Assemblies/Implants/Implants.csproj rename to Source/Implants.csproj diff --git a/1.5/Assemblies/Implants/Implants.sln b/Source/Implants.sln similarity index 100% rename from 1.5/Assemblies/Implants/Implants.sln rename to Source/Implants.sln diff --git a/1.5/Assemblies/Implants/LTS_Implants.cs b/Source/LTS_Implants.cs similarity index 98% rename from 1.5/Assemblies/Implants/LTS_Implants.cs rename to Source/LTS_Implants.cs index 46aa25c..b446ad2 100644 --- a/1.5/Assemblies/Implants/LTS_Implants.cs +++ b/Source/LTS_Implants.cs @@ -264,76 +264,6 @@ namespace LTS_Implants } } - public class CompProperties_AbilityMechCluster : CompProperties_AbilityEffect - { - public CompProperties_AbilityMechCluster() - { - this.compClass = typeof(CompAbilityEffect_MechCluster); - } - - public float displayRadius; - } - - public class CompAbilityEffect_MechCluster : CompAbilityEffect - { - public new CompProperties_AbilityMechCluster Props - { - get - { - return (CompProperties_AbilityMechCluster)this.props; - } - } - - public bool ShouldHaveInspectString - { - get - { - return ModsConfig.BiotechActive && this.parent.pawn.RaceProps.IsMechanoid; - } - } - - public override void Apply(LocalTargetInfo target, LocalTargetInfo dest) - { - base.Apply(target, dest); - if (Faction.OfMechanoids == null) - { - Messages.Message("MessageNoFactionForVerbMechCluster".Translate(), this.parent.pawn, MessageTypeDefOf.RejectInput, null, false); - } - else - { - MechClusterUtility.SpawnCluster(target.Cell, this.parent.pawn.MapHeld, MechClusterGenerator.GenerateClusterSketch(2500f, this.parent.pawn.MapHeld, true, true), true, false, null); - - } - } - - public override void PostApplied(List targets, Map map) - { - base.PostApplied(targets, map); - if (this.parent.def.defName == "MechhiveSatelliteUplink") //add field for cooldownFactorStat. Change this if statement to if it's not null. change the contents of getstatvalue on the next line to that field. - { - this.parent.StartCooldown(Mathf.RoundToInt(this.parent.def.cooldownTicksRange.RandomInRange * this.parent.pawn?.GetStatValue(StatDef.Named("MechhiveSatelliteUplinkCooldownFactor")) ?? 1f)); - } - } - - public override void DrawEffectPreview(LocalTargetInfo target) - { - GenDraw.DrawRadiusRing(target.Cell, this.Props.displayRadius); - } - - public override string CompInspectStringExtra() - { - if (!this.ShouldHaveInspectString) - { - return null; - } - if (this.parent.CanCast) - { - return "AbilityMechSmokepopCharged".Translate(); - } - return "AbilityMechSmokepopRecharging".Translate(this.parent.CooldownTicksRemaining.ToStringTicksToPeriod(true, false, true, true, false)); - } - } - //public class CompProperties_MechanitorMechCarrier : CompProperties_AbilityEffect //{ // public CompProperties_MechanitorMechCarrier() diff --git a/1.5/Assemblies/Implants/PatchBootStrap.cs b/Source/PatchBootStrap.cs similarity index 62% rename from 1.5/Assemblies/Implants/PatchBootStrap.cs rename to Source/PatchBootStrap.cs index e62ac41..ecf6334 100644 --- a/1.5/Assemblies/Implants/PatchBootStrap.cs +++ b/Source/PatchBootStrap.cs @@ -1,5 +1,6 @@ using System.Reflection; using HarmonyLib; +using RimWorld; using Verse; namespace LTS_Implants @@ -10,6 +11,7 @@ namespace LTS_Implants public static bool IsCombatExtended = false; static HarmonyPatches() { + Verse.Log.Message("[LTS-II-Forked]Unpatching CE patches to reduce overlap"); Harmony harmony = new Harmony("rimworld.LTS.implants"); Harmony.DEBUG = false; //Check if we are in a CE enabled env @@ -17,15 +19,22 @@ namespace LTS_Implants IsCombatExtended = true; if (ModLister.BiotechInstalled) { - Verse.Log.Message("[LTS Intrgated Implants Forked]Biotech found, harmony patch running"); - harmony.PatchCategory("Biotech"); + Verse.Log.Message("[LTS-II-Forked]Biotech found, harmony patch running"); + if (IsCombatExtended) + { + Verse.Log.Message("[LTS-II-Forked]Unpatching CE patches to reduce overlap"); + var mechanitorCanCommand = typeof(Pawn_MechanitorTracker).GetMethod("CanCommandTo"); + harmony.Unpatch(mechanitorCanCommand,HarmonyPatchType.All,"CombatExtended.HarmonyCE"); + var mechanitorDrawCommandRange = typeof(Pawn_MechanitorTracker).GetMethod("DrawCommandRadius"); + harmony.Unpatch(mechanitorDrawCommandRange,HarmonyPatchType.All,"CombatExtended.HarmonyCE"); + } + harmony.PatchCategory(Assembly.GetExecutingAssembly(), "Biotech"); } - harmony.PatchAllUncategorized(Assembly.GetExecutingAssembly()); #if DEBUG foreach (var method in harmony.GetPatchedMethods()) { - Verse.Log.Message($"[LTS Implants]Patched Method {method.Name}"); + Verse.Log.Message($"[LTSIIF]Patched Method {method.Name}"); var patchinfo = Harmony.GetPatchInfo(method); foreach (var VARIABLE in patchinfo.Owners) { diff --git a/1.5/Assemblies/Implants/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs similarity index 100% rename from 1.5/Assemblies/Implants/Properties/AssemblyInfo.cs rename to Source/Properties/AssemblyInfo.cs