Forwarded CommandRange Drawing incompatible mod check to prepare.

Source separated from Assemblies folder,Build target fix.
This commit is contained in:
MADxingjin 2025-04-13 18:31:09 +08:00
parent 36977d9928
commit e7c989431b
4 changed files with 446 additions and 430 deletions

View File

@ -21,21 +21,27 @@ namespace LTS_Implants
static class static class
Pawn_MechanitorTracker_CanCommandTo_Patch //increases the mechanitor's range by MechRemoteControlDistanceOffset Pawn_MechanitorTracker_CanCommandTo_Patch //increases the mechanitor's range by MechRemoteControlDistanceOffset
{ {
/// <summary>
/// default value of mechanitor command range.
/// </summary>
private static float defaultRange = 24.9f; private static float defaultRange = 24.9f;
[HarmonyPrepare] [HarmonyPrepare]
static bool Prepare() static bool Prepare()
{ {
//If CE,use CE value as default instead.unpatching is done in main patchBootstrap.
if (LTS_Implants.HarmonyPatches.IsCombatExtended) if (LTS_Implants.HarmonyPatches.IsCombatExtended)
{ {
defaultRange = 43.9f; defaultRange = 43.9f;
Verse.Log.Warning("[LTS-II-Forked]Pawn_MechanitorTracker.CanCommandTo Patch Recognized CE,default Range changed from 24.9 to 43.9"); Verse.Log.Warning(
"[LTS-II-Forked]Pawn_MechanitorTracker.CanCommandTo Patch Recognized CE,default Range changed from 24.9 to 43.9");
} }
return true; return true;
} }
/// <summary> /// <summary>
/// pushed always commandable check to front to reduct compute. /// pushed always commandable check to front to reduce compute overhead.
/// TODO perhaps need a custom patch order to make sure this logic always works. /// TODO:perhaps need a custom patch order to make sure this logic always works.
/// </summary> /// </summary>
/// <param name="target">target mech to command</param> /// <param name="target">target mech to command</param>
/// <param name="__instance">should be mechanitor, but not always the mechanitor for example like Dead man switch ctrl mechs </param> /// <param name="__instance">should be mechanitor, but not always the mechanitor for example like Dead man switch ctrl mechs </param>
@ -55,15 +61,27 @@ namespace LTS_Implants
SignalBoosterRange); //last line should mean that if something else makes it true, then it is(?) SignalBoosterRange); //last line should mean that if something else makes it true, then it is(?)
} }
} }
[HarmonyPatch(typeof(Pawn_MechanitorTracker))] [HarmonyPatch(typeof(Pawn_MechanitorTracker))]
[HarmonyPatch(nameof(Pawn_MechanitorTracker.DrawCommandRadius))] [HarmonyPatch(nameof(Pawn_MechanitorTracker.DrawCommandRadius))]
static class static class
Pawn_MechanitorTracker_DrawCommandRadius_Patch //increases the displayed mechanitor range by MechRemoteControlDistanceOffset Pawn_MechanitorTracker_DrawCommandRadius_Patch //increases the displayed mechanitor range by MechRemoteControlDistanceOffset
{ {
private static float defaultRange = 24.9f; private static float defaultRange = 24.9f;
[HarmonyPrepare] [HarmonyPrepare]
static bool Prepare() static bool Prepare()
{ {
//For conflict mods, disable the rendering patch entirely.
//TODO:make this a list.
if (ModsConfig.IsActive("swwu.MechanitorCommandRange") ||
ModsConfig.IsActive("Neronix17.TweaksGalore"))
{
Verse.Log.Message(
"[LTS-II-Forked/Biotech]Pawn_MechanitorTracker.DrawCommandRadius Patch Encountered Hard Incompatible mods,aborting patch");
return false;
}
if (LTS_Implants.HarmonyPatches.IsCombatExtended) if (LTS_Implants.HarmonyPatches.IsCombatExtended)
{ {
defaultRange = 43.9f; defaultRange = 43.9f;
@ -73,9 +91,11 @@ namespace LTS_Implants
return true; return true;
} }
/// <summary> /// <summary>
/// Skip original draw radius using a prefix. /// Skip original draw radius using a prefix.
/// TODO may need specify fixed patch order to make sure this works. /// TODO may need specify fixed patch order to make sure this works.
/// TODO:may need unpatch other conflict mods to make this work.
/// </summary> /// </summary>
/// <returns>return false to skip original draw.</returns> /// <returns>return false to skip original draw.</returns>
[HarmonyPrefix] [HarmonyPrefix]
@ -94,10 +114,6 @@ namespace LTS_Implants
if (__instance.Pawn.Spawned && __instance.AnySelectedDraftedMechs) if (__instance.Pawn.Spawned && __instance.AnySelectedDraftedMechs)
{ {
//GenDraw.DrawRadiusRing(___pawn.Position, 24.9f + (3f*___pawn.health?.hediffSet?.GetFirstHediffOfDef(HediffDef.Named("SignalBoosterImplant"))?.Severity ?? 0f), Color.white, (IntVec3 c) => __instance.CanCommandTo(c)); //GenDraw.DrawRadiusRing(___pawn.Position, 24.9f + (3f*___pawn.health?.hediffSet?.GetFirstHediffOfDef(HediffDef.Named("SignalBoosterImplant"))?.Severity ?? 0f), Color.white, (IntVec3 c) => __instance.CanCommandTo(c));
if (!ModsConfig.IsActive("swwu.MechanitorCommandRange") &&
!ModsConfig.IsActive(
"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; IntVec3 position = __instance.Pawn.Position;
float radius = defaultRange + float radius = defaultRange +
(__instance.Pawn?.GetStatValue( (__instance.Pawn?.GetStatValue(
@ -109,14 +125,14 @@ namespace LTS_Implants
} }
} }
} }
} }
#endregion #endregion
#region Resurrect #region Resurrect
public class CompProperties_MechanitorResurrectMech : CompProperties_AbilityEffect public class CompProperties_MechanitorResurrectMech : CompProperties_AbilityEffect
{ {
public CompProperties_MechanitorResurrectMech() public CompProperties_MechanitorResurrectMech()
{ {
this.compClass = typeof(CompAbilityEffect_MechanitorResurrectMech); this.compClass = typeof(CompAbilityEffect_MechanitorResurrectMech);
@ -129,10 +145,10 @@ namespace LTS_Implants
public EffecterDef resolveEffecterDef; public EffecterDef resolveEffecterDef;
//public EffecterDef centerEffecterDef; //public EffecterDef centerEffecterDef;
} }
public class CompAbilityEffect_MechanitorResurrectMech : CompAbilityEffect public class CompAbilityEffect_MechanitorResurrectMech : CompAbilityEffect
{ {
public new CompProperties_MechanitorResurrectMech Props public new CompProperties_MechanitorResurrectMech Props
{ {
get { return (CompProperties_MechanitorResurrectMech)this.props; } get { return (CompProperties_MechanitorResurrectMech)this.props; }
@ -237,22 +253,22 @@ namespace LTS_Implants
this.Props.resolveEffecterDef.Spawn(intVec, map, 1f).EffectTick(new TargetInfo(intVec, map, false), this.Props.resolveEffecterDef.Spawn(intVec, map, 1f).EffectTick(new TargetInfo(intVec, map, false),
new TargetInfo(intVec, map, false)); new TargetInfo(intVec, map, false));
} }
} }
#endregion #endregion
#region Remote Dominate #region Remote Dominate
public class CompProperties_MechanitorDominateMech : CompProperties_AbilityEffect public class CompProperties_MechanitorDominateMech : CompProperties_AbilityEffect
{ {
public CompProperties_MechanitorDominateMech() public CompProperties_MechanitorDominateMech()
{ {
this.compClass = typeof(CompAbilityEffect_MechanitorDominateMech); this.compClass = typeof(CompAbilityEffect_MechanitorDominateMech);
} }
} }
public class CompAbilityEffect_MechanitorDominateMech : CompAbilityEffect public class CompAbilityEffect_MechanitorDominateMech : CompAbilityEffect
{ {
public new CompProperties_MechanitorDominateMech Props public new CompProperties_MechanitorDominateMech Props
{ {
get { return (CompProperties_MechanitorDominateMech)this.props; } get { return (CompProperties_MechanitorDominateMech)this.props; }
@ -345,14 +361,14 @@ namespace LTS_Implants
//IntVec3 intVec = vector.ToIntVec3(); //IntVec3 intVec = vector.ToIntVec3();
//this.Props.resolveEffecterDef.Spawn(intVec, map, 1f).EffectTick(new TargetInfo(intVec, map, false), new TargetInfo(intVec, map, false)); //this.Props.resolveEffecterDef.Spawn(intVec, map, 1f).EffectTick(new TargetInfo(intVec, map, false), new TargetInfo(intVec, map, false));
} }
} }
#endregion #endregion
#region Mech carrier #region Mech carrier
public class CompProperties_MechanitorMechCarrier : CompProperties_AbilityEffect public class CompProperties_MechanitorMechCarrier : CompProperties_AbilityEffect
{ {
public CompProperties_MechanitorMechCarrier() public CompProperties_MechanitorMechCarrier()
{ {
this.compClass = typeof(CompAbilityEffect_MechanitorMechCarrier); this.compClass = typeof(CompAbilityEffect_MechanitorMechCarrier);
@ -365,10 +381,10 @@ namespace LTS_Implants
public EffecterDef spawnedMechEffecter; public EffecterDef spawnedMechEffecter;
public bool attachSpawnedEffecter; public bool attachSpawnedEffecter;
public bool attachSpawnedMechEffecter; public bool attachSpawnedMechEffecter;
} }
public class CompAbilityEffect_MechanitorMechCarrier : CompAbilityEffect public class CompAbilityEffect_MechanitorMechCarrier : CompAbilityEffect
{ {
public new CompProperties_MechanitorMechCarrier Props public new CompProperties_MechanitorMechCarrier Props
{ {
get { return (CompProperties_MechanitorMechCarrier)this.props; } get { return (CompProperties_MechanitorMechCarrier)this.props; }
@ -473,20 +489,20 @@ namespace LTS_Implants
private int cooldownTicksRemaining; private int cooldownTicksRemaining;
private List<Pawn> spawnedPawns = new List<Pawn>(); private List<Pawn> spawnedPawns = new List<Pawn>();
public SoundDef soundReload; public SoundDef soundReload;
} }
public class HediffCompProperties_KillSpawnedPawns : HediffCompProperties public class HediffCompProperties_KillSpawnedPawns : HediffCompProperties
{ {
public AbilityDef abilityDef; public AbilityDef abilityDef;
public HediffCompProperties_KillSpawnedPawns() public HediffCompProperties_KillSpawnedPawns()
{ {
compClass = typeof(HediffComp_KillSpawnedPawns); compClass = typeof(HediffComp_KillSpawnedPawns);
} }
} }
public class HediffComp_KillSpawnedPawns : HediffComp public class HediffComp_KillSpawnedPawns : HediffComp
{ {
public HediffCompProperties_KillSpawnedPawns Props => (HediffCompProperties_KillSpawnedPawns)props; public HediffCompProperties_KillSpawnedPawns Props => (HediffCompProperties_KillSpawnedPawns)props;
public override void Notify_PawnKilled() public override void Notify_PawnKilled()
@ -500,24 +516,24 @@ namespace LTS_Implants
} }
} }
} }
} }
#endregion #endregion
#region Call a cluster #region Call a cluster
public class CompProperties_AbilityMechCluster : CompProperties_AbilityEffect public class CompProperties_AbilityMechCluster : CompProperties_AbilityEffect
{ {
public CompProperties_AbilityMechCluster() public CompProperties_AbilityMechCluster()
{ {
this.compClass = typeof(CompAbilityEffect_MechCluster); this.compClass = typeof(CompAbilityEffect_MechCluster);
} }
public float displayRadius; public float displayRadius;
} }
public class CompAbilityEffect_MechCluster : CompAbilityEffect public class CompAbilityEffect_MechCluster : CompAbilityEffect
{ {
public new CompProperties_AbilityMechCluster Props public new CompProperties_AbilityMechCluster Props
{ {
get { return (CompProperties_AbilityMechCluster)this.props; } get { return (CompProperties_AbilityMechCluster)this.props; }
@ -575,7 +591,8 @@ namespace LTS_Implants
return "AbilityMechSmokepopRecharging".Translate( return "AbilityMechSmokepopRecharging".Translate(
this.parent.CooldownTicksRemaining.ToStringTicksToPeriod(true, false, true, true, false)); this.parent.CooldownTicksRemaining.ToStringTicksToPeriod(true, false, true, true, false));
} }
} }
#endregion #endregion
} }

View File

@ -10,11 +10,11 @@
<FileVersion>1.0.0.0</FileVersion> <FileVersion>1.0.0.0</FileVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\</OutputPath> <OutputPath>..\1.5\Assemblies\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<DocumentationFile>..\Implants.xml</DocumentationFile> <DocumentationFile>..\1.5\Assemblies\Implants.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />

View File

@ -264,6 +264,8 @@ namespace LTS_Implants
} }
} }
#region Mech Carrier
//public class CompProperties_MechanitorMechCarrier : CompProperties_AbilityEffect //public class CompProperties_MechanitorMechCarrier : CompProperties_AbilityEffect
//{ //{
// public CompProperties_MechanitorMechCarrier() // public CompProperties_MechanitorMechCarrier()
@ -448,9 +450,6 @@ namespace LTS_Implants
// } // }
// } // }
// public override bool GizmoDisabled(out string reason) // public override bool GizmoDisabled(out string reason)
// { // {
// //Log.Warning(ingredientCountRemaining + " out of "+ Props.costPerPawn + " steel."); // //Log.Warning(ingredientCountRemaining + " out of "+ Props.costPerPawn + " steel.");
@ -463,14 +462,6 @@ namespace LTS_Implants
// return base.GizmoDisabled(out reason); // return base.GizmoDisabled(out reason);
// } // }
// public int remainingCharges // public int remainingCharges
// { // {
// get // get
@ -589,6 +580,10 @@ namespace LTS_Implants
// // } // // }
// //} // //}
//} //}
#endregion
#region Psychic Shield
//public class LTS_ShieldHediff : Hediff_Implant //public class LTS_ShieldHediff : Hediff_Implant
//{ //{
@ -663,7 +658,7 @@ namespace LTS_Implants
// } // }
//} //}
#endregion
public class LTS_HediffCompProperties_Mote : HediffCompProperties public class LTS_HediffCompProperties_Mote : HediffCompProperties
{ {
//public AbilityDef abilityDef; //public AbilityDef abilityDef;

View File

@ -9,20 +9,24 @@ namespace LTS_Implants
public static class HarmonyPatches public static class HarmonyPatches
{ {
public static bool IsCombatExtended = false; public static bool IsCombatExtended = false;
public static bool IsSarg = false;
static HarmonyPatches() static HarmonyPatches()
{ {
Verse.Log.Message("[LTS-II-Forked]Unpatching CE patches to reduce overlap");
Harmony harmony = new Harmony("rimworld.LTS.implants"); Harmony harmony = new Harmony("rimworld.LTS.implants");
Harmony.DEBUG = false; Harmony.DEBUG = false;
//Check if we are in a CE enabled env //Check if we are in a CE enabled env
if(ModLister.GetModWithIdentifier("ceteam.combatextended")!=null) if (ModLister.GetModWithIdentifier("ceteam.combatextended") != null)
{
IsCombatExtended = true; IsCombatExtended = true;
Verse.Log.Message("[LTS-II-Forked]Found CombatExtended,Will unpatch some harmony patches to reduce overlap");
}
//TODO Detect Sarg`s mod and unpatch accordingly.
if (ModLister.BiotechInstalled) if (ModLister.BiotechInstalled)
{ {
Verse.Log.Message("[LTS-II-Forked]Biotech found, harmony patch running"); Verse.Log.Message("[LTS-II-Forked]Biotech found, harmony patch running");
if (IsCombatExtended) if (IsCombatExtended)
{ {
Verse.Log.Message("[LTS-II-Forked]Unpatching CE patches to reduce overlap"); Verse.Log.Message("[LTS-II-Forked]Unpatching CE Biotech Mechanitor Command Range patches to reduce overlap,CE range is used instead vanilla range");
var mechanitorCanCommand = typeof(Pawn_MechanitorTracker).GetMethod("CanCommandTo"); var mechanitorCanCommand = typeof(Pawn_MechanitorTracker).GetMethod("CanCommandTo");
harmony.Unpatch(mechanitorCanCommand,HarmonyPatchType.All,"CombatExtended.HarmonyCE"); harmony.Unpatch(mechanitorCanCommand,HarmonyPatchType.All,"CombatExtended.HarmonyCE");
var mechanitorDrawCommandRange = typeof(Pawn_MechanitorTracker).GetMethod("DrawCommandRadius"); var mechanitorDrawCommandRange = typeof(Pawn_MechanitorTracker).GetMethod("DrawCommandRadius");