Skip to content

Commit

Permalink
fixed problem caused by auto-assign food/medicine function
Browse files Browse the repository at this point in the history
  • Loading branch information
rheirman committed Aug 16, 2020
1 parent 9161db8 commit aed1919
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
Binary file modified 1.2/Assemblies/WhatTheHack.dll
Binary file not shown.
2 changes: 0 additions & 2 deletions 1.2/Source/WhatTheHack/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ public Base()

public override void DefsLoaded()
{
Log.Message("loaded WTH for v1.2");

base.DefsLoaded();
//TODO: Store this somewhere global.
allowedMechWork.Add(WorkTypeDefOf.Hauling);
Expand Down
25 changes: 24 additions & 1 deletion 1.2/Source/WhatTheHack/Harmony/Dialog_FormCaravan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,30 @@ static void Postfix(Dialog_FormCaravan __instance)
{
Utilities.CalcDaysOfFuel(__instance.transferables);
}
}


[HarmonyPatch(typeof(Dialog_FormCaravan), "SelectApproximateBestFoodAndMedicine")]
static class Dialog_FormCaravan_SelectApproximateBestFoodAndMedicine
{
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var instructionsList = new List<CodeInstruction>(instructions);
for (var i = 0; i < instructionsList.Count; i++)
{
CodeInstruction instruction = instructionsList[i];
if (instruction.operand as MethodInfo == AccessTools.Method(typeof(WildManUtility), "AnimalOrWildMan"))
{
yield return new CodeInstruction(OpCodes.Call, typeof(Dialog_FormCaravan_SelectApproximateBestFoodAndMedicine).GetMethod("AnimalOrWildManOrHacked"));
}
else
{
yield return instruction;
}
}
}
public static bool AnimalOrWildManOrHacked(Pawn pawn)
{
return WildManUtility.AnimalOrWildMan(pawn) || pawn.IsHacked();
}
}
}
17 changes: 1 addition & 16 deletions 1.2/Source/WhatTheHack/Harmony/ThingDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,8 @@

namespace WhatTheHack.Harmony
{
//Make sure mech parts don't spawn as meteorites.
[HarmonyPatch(typeof(ThingDef), "get_IsSmoothed")]
static class ThingDef_get_IsSmoothed
{
static void Postfix(ThingDef __instance, ref bool __result)
{
Log.Message("get_IsSmoothed called");
if(__instance == WTH_DefOf.WTH_MineableMechanoidParts || __instance == WTH_DefOf.WTH_MechanoidParts)
{
Log.Message("WTH_MineableMechanoidParts found, return true");
__result = true;
}
}
}

//Make sure stat info for the hediffs of upgrade module items are shown
[HarmonyPatch(typeof(ThingDef), "SpecialDisplayStats")]
[HarmonyPatch(typeof(ThingDef), "SpecialDisplayStats")]
static class ThingDef_SpecialDisplayStats
{
static void Postfix(StatRequest req, ThingDef __instance, ref IEnumerable<StatDrawEntry> __result)
Expand Down

0 comments on commit aed1919

Please sign in to comment.