Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/VFECore/Furniture/Comps/CompRockSpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public static bool TryFindSpawnCell(Thing parent, ThingDef thingToSpawn, int spa

private void ResetCountdown()
{
if (ModLister.HasActiveModWithName("Vanilla Factions Expanded - Mechanoids"))
if (VFECore.ModCompatibilityCheck.VFEMechanoids)
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ public void Notify_StartProcessing()
}
else
{
if (this.def.defName.Contains("VFEM_")&&ModLister.HasActiveModWithName("Vanilla Factions Expanded - Mechanoids") ) {
if (this.def.defName.Contains("VFEM_") && VFECore.ModCompatibilityCheck.VFEMechanoids ) {
try
{
((Action)(() =>
Expand Down
13 changes: 13 additions & 0 deletions Source/VFECore/VFECore/HarmonyPatches/Mechanoids/ITab_Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public static class NoBioForMachines
public delegate Pawn PawnToShowInfoAbout(ITab_Pawn_Character __instance);
public static readonly PawnToShowInfoAbout pawnToShowInfoAbout = AccessTools.MethodDelegate<PawnToShowInfoAbout>
(AccessTools.Method(typeof(ITab_Pawn_Character), "get_PawnToShowInfoAbout"));
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}

public static void Postfix(ITab_Pawn_Character __instance, ref bool __result)
{
Pawn pawn = pawnToShowInfoAbout(__instance);
Expand All @@ -33,6 +38,10 @@ public static void Postfix(ITab_Pawn_Character __instance, ref bool __result)
public static class ITab_Pawn_Gear_Patch
{
public static bool drawingThingRow;
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static void Prefix()
{
drawingThingRow = true;
Expand All @@ -49,6 +58,10 @@ public static class ITab_Pawn_Gear_CanControl
public delegate Pawn PawnToShowInfoAbout(ITab_Pawn_Gear __instance);
public static readonly PawnToShowInfoAbout pawnToShowInfoAbout = AccessTools.MethodDelegate<PawnToShowInfoAbout>
(AccessTools.Method(typeof(ITab_Pawn_Gear), "get_SelPawnForGear"));
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static void Postfix(ITab_Pawn_Gear __instance, ref bool __result)
{
if (ITab_Pawn_Gear_Patch.drawingThingRow)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public static MethodBase TargetMethod()
{
return typeof(JobDriver_Flee).GetMethods(AccessTools.all).First(x => x.Name.Contains("<MakeNewToils>"));
}
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var codes = instructions.ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ namespace VFE.Mechanoids.HarmonyPatches
[HarmonyPatch(typeof(Pawn), "Kill")]
public static class MachinesDie
{
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static void Postfix(Pawn __instance)
{
if (__instance is Machine && __instance.Faction == Faction.OfPlayer && __instance.def.butcherProducts != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ namespace VFE.Mechanoids.HarmonyPatches
[HarmonyPatch(typeof(MainTabWindow_Inspect), nameof(MainTabWindow_Inspect.DoInspectPaneButtons))]
public static class MainTabWindow_Inspect_Renaming
{
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
/// Show a rename button in the inspect pane when a single drone is selected.
public static void Postfix(Rect rect, ref float lineEndWidth)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ namespace VFE.Mechanoids.HarmonyPatches
[HarmonyPatch(typeof(JobGiver_Work), "PawnCanUseWorkGiver")]
public static class MechanoidsAreCapable
{
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static void Postfix(ref bool __result, Pawn pawn, WorkGiver giver)
{
if (pawn is Machine && CompMachine.cachedMachinesPawns.TryGetValue(pawn, out CompMachine comp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ static MechanoidDraftCompInitializer()
[HarmonyPatch(typeof(MechanitorUtility), "InMechanitorCommandRange")]
public static class MechanitorUtility_InMechanitorCommandRange_Patch
{
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static void Postfix(Pawn mech, ref bool __result)
{
if (mech is Machine)
Expand All @@ -47,6 +51,10 @@ public static void Postfix(Pawn mech, ref bool __result)
[HarmonyPatch(typeof(FloatMenuMakerMap), "CanTakeOrder")]
public static class MechanoidsObeyOrders
{
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static void Postfix(Pawn pawn, ref bool __result)
{
if (!__result && pawn.drafter != null && pawn is Machine && pawn.Faction != null && pawn.Faction.IsPlayer)
Expand All @@ -59,6 +67,10 @@ public static void Postfix(Pawn pawn, ref bool __result)
[HarmonyPatch(typeof(Selector), "SelectInsideDragBox")]
public static class Selector_SelectInsideDragBox_Patch
{
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> codeInstructions)
{
var codes = codeInstructions.ToList();
Expand Down Expand Up @@ -99,6 +111,10 @@ bool wrappedPredicate(Thing t)
[HarmonyPatch(typeof(Selector), "SelectAllMatchingObjectUnderMouseOnScreen")]
public static class Selector_SelectAllMatchingObjectUnderMouseOnScreen_Patch
{
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> codeInstructions)
{
var codes = codeInstructions.ToList();
Expand Down Expand Up @@ -143,6 +159,10 @@ bool wrappedPredicate(Thing t)
[HarmonyPatch(typeof(FloatMenuMakerMap), "AddDraftedOrders")]
public static class AddDraftedOrders_Patch
{
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static bool Prefix(Vector3 clickPos, Pawn pawn, List<FloatMenuOption> opts)
{
if (pawn is Machine && pawn.needs.TryGetNeed<Need_Power>() is Need_Power need && need.CurLevel <= 0f)
Expand All @@ -160,7 +180,7 @@ public static class SimpleSidearmsPatch
static SimpleSidearmsPatch()
{
SimpleSidearmsActive = ModsConfig.IsActive("PeteTimesSix.SimpleSidearms");
if (SimpleSidearmsActive)
if (SimpleSidearmsActive && VFECore.ModCompatibilityCheck.VFEMechanoids)
{
var type = AccessTools.TypeByName("PeteTimesSix.SimpleSidearms.Extensions");
if (type != null)
Expand Down Expand Up @@ -247,6 +267,10 @@ public static bool GetMemoryCompForPawnPrefix(ref object __result, Pawn pawn, bo
[HarmonyPatch(typeof(FloatMenuMakerMap), "ChoicesAtFor")]
public static class FloatMenuMakerMap_ChoicesAtFor_Patch
{
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static void Postfix(ref List<FloatMenuOption> __result, Vector3 clickPos, Pawn pawn, bool suppressAutoTakeableGoto = false)
{
if (!pawn.RaceProps.Humanlike)
Expand Down Expand Up @@ -392,6 +416,10 @@ public static void AppendSidearmsOptions(Pawn pawn, ThingWithComps equipment, re
[HarmonyPatch(typeof(WanderUtility), "GetColonyWanderRoot")]
public static class GetColonyWanderRoot_Patch
{
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static void Postfix(ref IntVec3 __result, Pawn pawn)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ namespace VFE.Mechanoids.HarmonyPatches
[HarmonyPatch(typeof(PawnRenderer), "CarryWeaponOpenly")]
public static class MobileTurretsShowTurrets
{

static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static void Postfix(PawnRenderer __instance, ref bool __result)
{
if (CompMachine.cachedMachines.TryGetValue(__instance, out CompMachine value) && (value.turretAttached != null || value.Props.violent))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ namespace VFE.Mechanoids.HarmonyPatches
[HarmonyPatch(typeof(Pawn), nameof(Pawn.MainDesc))]
public static class Pawn_MainDesc_Patch
{
static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static void Postfix(ref string __result)
{
var substringToRemove = " ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public static class RenderTurretCentered
static Vector3 east = new Vector3(0.2f, 0f, -0.22f);
static Vector3 west = new Vector3(-0.2f, 0, -0.22f);

static bool Prepare()
{
return VFECore.ModCompatibilityCheck.VFEMechanoids;
}
public static bool Prefix(PawnRenderer __instance)
{
if (CompMachine.cachedMachines.TryGetValue(__instance, out CompMachine compMachine))
Expand Down
29 changes: 16 additions & 13 deletions Source/VFECore/VFECore/ModCompatibilityCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,42 @@ public static class ModCompatibilityCheck
public static bool CombatExtended;

public static bool HumanAlienRace;
public static bool VFEMechanoids;

static ModCompatibilityCheck()
{
var allMods = ModsConfig.ActiveModsInLoadOrder.ToList();
for (var i = 0; i < allMods.Count; i++)
for (var i = allMods.Count; i-- > 0;)
{
var curMod = allMods[i];
var curModName = allMods[i].Name;

if (curMod.Name == "Dual Wield")
if (curModName == "Dual Wield")
DualWield = true;
else if (curMod.Name == "Facial Stuff 1.1")
else if (curModName == "Facial Stuff 1.1")
FacialStuff = true;
else if (curMod.Name == "Research Tree")
else if (curModName == "Research Tree")
ResearchTree = true;
else if (curMod.Name == "ResearchPal")
else if (curModName == "ResearchPal")
ResearchPal = true;
else if (curMod.Name == "RimCities")
else if (curModName == "RimCities")
RimCities = true;
else if (curMod.Name == "RPG Style Inventory Revamped")
else if (curModName == "RPG Style Inventory Revamped")
RPGStyleInventoryRevamped = true;
// Uncomment this once RPG Style Inventory updates to 1.3:
// else if (curMod.Name == "RPG Style Inventory")
// RPGStyleInventory = true;
else if (curMod.Name == "RunAndGun")
else if (curModName == "RunAndGun")
RunAndGun = true;
else if (curMod.Name == "Faction Discovery")
else if (curModName == "Faction Discovery")
FactionDiscovery = true;
else if (curMod.Name == "What the hack?!")
else if (curModName == "What the hack?!")
WhatTheHack = true;
else if (curMod.Name == "Combat Extended")
else if (curModName == "Combat Extended")
CombatExtended = true;
else if (curMod.Name == "Humanoid Alien Races" || curMod.Name == "Humanoid Alien Races ~ Dev")
else if (curModName == "Humanoid Alien Races" || curModName == "Humanoid Alien Races ~ Dev")
HumanAlienRace = true;
else if (curModName == "Vanilla Factions Expanded - Mechanoids")
VFEMechanoids = true;
}
}
}
Expand Down