Skip to content

Commit

Permalink
cleanup + fixed maintenance not being performed
Browse files Browse the repository at this point in the history
  • Loading branch information
rheirman committed Apr 19, 2020
1 parent ecc5738 commit fd92dc0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
Binary file modified 1.1/Assemblies/WhatTheHack.dll
Binary file not shown.
8 changes: 0 additions & 8 deletions 1.1/Source/WhatTheHack/Harmony/HealthCardUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ class HealthCardUtility_GenerateSurgeryOption
{
static bool Prefix(Pawn pawn, RecipeDef recipe, BodyPartRecord part, ref FloatMenuOption __result)
{
Log.Message("generateSurgeryOption called for: " + recipe.defName);
if(recipe.Worker is Recipe_Hacking worker)
{
if (!worker.CanApplyOn(pawn, out string reason)){
if(reason == "")
{
Log.Message("no reason for: " + recipe.defName);
return false;
}
Log.Message("generating option for: " + recipe.defName);
string text = recipe.Worker.GetLabelWhenUsedOn(pawn, part).CapitalizeFirst();
if (part != null && !recipe.hideBodyPartNames)
{
Expand All @@ -37,12 +34,7 @@ static bool Prefix(Pawn pawn, RecipeDef recipe, BodyPartRecord part, ref FloatMe
__result = floatMenuOption;
return false;
}
else
{
Log.Message("cannot apply: " + recipe.defName);
}
}
Log.Message("GenerateSurgeryOption failed for: " + recipe.defName);
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion 1.1/Source/WhatTheHack/Harmony/StatWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
var instructionsList = new List<CodeInstruction>(instructions);
foreach (CodeInstruction instruction in instructionsList)
{
if (instruction.operand as MethodInfo == typeof(Pawn).GetField("skills"))
if (instruction.operand as MethodInfo == AccessTools.Field(typeof(Pawn), "skills"))
{
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StatWorker), "stat"));
Expand Down
9 changes: 5 additions & 4 deletions 1.1/Source/WhatTheHack/Jobs/WorkGiver_PerformMaintenance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ public override bool ShouldSkip(Pawn pawn, bool forced = false)
return false;
}

private static bool PawnNeedsMaintenance(Pawn mech)
private bool PawnNeedsMaintenance(Pawn mech)
{
if (mech.needs != null && mech.needs.TryGetNeed(WTH_DefOf.WTH_Mechanoid_Maintenance) is Need_Maintenance need && need.CurLevel < need.maintenanceThreshold)
{
return true;
if (mech.needs != null && mech.needs.TryGetNeed(WTH_DefOf.WTH_Mechanoid_Maintenance) is Need_Maintenance need){
if(need.CurLevel < GetThresHold(need)){
return true;
}
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion About/Version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
but no minimum version will be required -->

<!-- Optional. This specifies the version of your mod for the library. Otherwise, the version of your mod's assembly will be used. -->
<overrideVersion>2.1.1</overrideVersion>
<overrideVersion>2.1.2</overrideVersion>
<!-- Optional. Use this to specify the version of HugsLib you are targeting.
See https://github.com/UnlimitedHugs/RimworldHugsLib/releases for the current version of the library.-->
<requiredLibraryVersion>5.0.0</requiredLibraryVersion>
Expand Down

0 comments on commit fd92dc0

Please sign in to comment.