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
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;
[HarmonyPrepare]
static bool Prepare()
{
//If CE,use CE value as default instead.unpatching is done in main patchBootstrap.
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");
Verse.Log.Warning(
"[LTS-II-Forked]Pawn_MechanitorTracker.CanCommandTo Patch Recognized CE,default Range changed from 24.9 to 43.9");
}
return true;
}
/// <summary>
/// pushed always commandable check to front to reduct compute.
/// TODO perhaps need a custom patch order to make sure this logic always works.
/// pushed always commandable check to front to reduce compute overhead.
/// TODO:perhaps need a custom patch order to make sure this logic always works.
/// </summary>
/// <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>
@ -55,15 +61,27 @@ namespace LTS_Implants
SignalBoosterRange); //last line should mean that if something else makes it true, then it is(?)
}
}
[HarmonyPatch(typeof(Pawn_MechanitorTracker))]
[HarmonyPatch(nameof(Pawn_MechanitorTracker.DrawCommandRadius))]
static class
Pawn_MechanitorTracker_DrawCommandRadius_Patch //increases the displayed mechanitor range by MechRemoteControlDistanceOffset
{
private static float defaultRange = 24.9f;
[HarmonyPrepare]
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)
{
defaultRange = 43.9f;
@ -73,9 +91,11 @@ namespace LTS_Implants
return true;
}
/// <summary>
/// Skip original draw radius using a prefix.
/// TODO may need specify fixed patch order to make sure this works.
/// TODO:may need unpatch other conflict mods to make this work.
/// </summary>
/// <returns>return false to skip original draw.</returns>
[HarmonyPrefix]
@ -94,10 +114,6 @@ namespace LTS_Implants
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));
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;
float radius = defaultRange +
(__instance.Pawn?.GetStatValue(
@ -578,4 +594,5 @@ namespace LTS_Implants
}
#endregion
}

View File

@ -10,11 +10,11 @@
<FileVersion>1.0.0.0</FileVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\</OutputPath>
<OutputPath>..\1.5\Assemblies\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<DocumentationFile>..\Implants.xml</DocumentationFile>
<DocumentationFile>..\1.5\Assemblies\Implants.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<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 CompProperties_MechanitorMechCarrier()
@ -448,9 +450,6 @@ namespace LTS_Implants
// }
// }
// public override bool GizmoDisabled(out string reason)
// {
// //Log.Warning(ingredientCountRemaining + " out of "+ Props.costPerPawn + " steel.");
@ -463,14 +462,6 @@ namespace LTS_Implants
// return base.GizmoDisabled(out reason);
// }
// public int remainingCharges
// {
// get
@ -589,6 +580,10 @@ namespace LTS_Implants
// // }
// //}
//}
#endregion
#region Psychic Shield
//public class LTS_ShieldHediff : Hediff_Implant
//{
@ -663,7 +658,7 @@ namespace LTS_Implants
// }
//}
#endregion
public class LTS_HediffCompProperties_Mote : HediffCompProperties
{
//public AbilityDef abilityDef;

View File

@ -9,20 +9,24 @@ namespace LTS_Implants
public static class HarmonyPatches
{
public static bool IsCombatExtended = false;
public static bool IsSarg = 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
if (ModLister.GetModWithIdentifier("ceteam.combatextended") != null)
{
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)
{
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");
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");
harmony.Unpatch(mechanitorCanCommand,HarmonyPatchType.All,"CombatExtended.HarmonyCE");
var mechanitorDrawCommandRange = typeof(Pawn_MechanitorTracker).GetMethod("DrawCommandRadius");