-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from Aviuz/fixes-tweakses
Version 1.1.10
- Loading branch information
Showing
19 changed files
with
347 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ public enum Version | |
v1_1_6, | ||
v1_1_7, | ||
v1_1_8, | ||
v1_1_9 | ||
v1_1_9, | ||
v1_1_10 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Source/HarmonyPatches/Patches_Construction/Patch_BlueprintsForPlayerFAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using HarmonyLib; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Management.Instrumentation; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Verse; | ||
|
||
namespace PrisonLabor.HarmonyPatches.Patches_Construction | ||
{ | ||
[HarmonyPatch(typeof(Blueprint), "TryReplaceWithSolidThing")] | ||
class Patch_BlueprintsForPlayerFaction | ||
{ | ||
|
||
public static void Postfix(Pawn workerPawn, Thing createdThing, bool __result) | ||
{ | ||
|
||
if (__result && createdThing != null && createdThing.def.CanHaveFaction && workerPawn.IsPrisonerOfColony) | ||
{ | ||
#if DEBUG | ||
Log.Message($"Setting faction for: {createdThing}"); | ||
#endif | ||
createdThing.SetFactionDirect(Faction.OfPlayer); | ||
} | ||
|
||
} | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Source/HarmonyPatches/Patches_Construction/Patch_Smoothing.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using HarmonyLib; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Verse; | ||
using Verse.AI; | ||
|
||
namespace PrisonLabor.HarmonyPatches.Patches_Construction | ||
{ | ||
[HarmonyPatch()] | ||
class Patch_Smoothing | ||
{ | ||
static IEnumerable<MethodBase> TargetMethods() | ||
{ | ||
yield return (MethodBase)typeof(WorkGiver_ConstructSmoothWall).GetMethod("HasJobOnCell"); | ||
yield return (MethodBase)typeof(WorkGiver_ConstructAffectFloor).GetMethod("HasJobOnCell"); | ||
} | ||
|
||
public static bool Postfix(bool __result, Pawn pawn, IntVec3 c) | ||
{ | ||
if(__result && pawn.IsPrisonerOfColony) | ||
{ | ||
return pawn.CanReach(c, PathEndMode.Touch, pawn.NormalMaxDanger()); | ||
} | ||
|
||
return __result; | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
.../HarmonyPatches/Patches_Construction/Patch_WorkGiver_ConstructDeliverResourcesToFrames.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using HarmonyLib; | ||
using PrisonLabor.WorkUtils; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Verse; | ||
using Verse.AI; | ||
|
||
namespace PrisonLabor.HarmonyPatches.Patches_Construction | ||
{ | ||
[HarmonyPatch(typeof(WorkGiver_ConstructDeliverResourcesToFrames))] | ||
[HarmonyPatch("JobOnThing")] | ||
[HarmonyPatch(new[] { typeof(Pawn), typeof(Thing), typeof(bool) })] | ||
class Patch_WorkGiver_ConstructDeliverResourcesToFrames | ||
{ | ||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
|
||
OpCode[] opCodes1 = | ||
{ | ||
OpCodes.Ldarg_2, | ||
OpCodes.Callvirt, | ||
OpCodes.Ldarg_1, | ||
OpCodes.Callvirt, | ||
OpCodes.Beq_S, | ||
}; | ||
string[] operands1 = | ||
{ | ||
"", | ||
"RimWorld.Faction get_Faction()", | ||
"", | ||
"RimWorld.Faction get_Faction()", | ||
"System.Reflection.Emit.Label", | ||
}; | ||
|
||
|
||
var label = HPatcher.FindOperandAfter(opCodes1, operands1, instructions, true); | ||
|
||
//Add If(pawn.IsPrisonerOfColony) {jump next condition} | ||
yield return new CodeInstruction(OpCodes.Ldarg_2); | ||
yield return new CodeInstruction(OpCodes.Ldarg_1); | ||
yield return new CodeInstruction(OpCodes.Call, typeof(ConstructionUtils).GetMethod("isPrisonerWork")); | ||
yield return new CodeInstruction(OpCodes.Brtrue, label); | ||
|
||
foreach (var instr in instructions) | ||
{ | ||
yield return instr; | ||
} | ||
|
||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
Source/HarmonyPatches/Patches_Construction/Patch_WorkGiver_Repair.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using HarmonyLib; | ||
using PrisonLabor.WorkUtils; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Verse; | ||
using Verse.AI; | ||
|
||
namespace PrisonLabor.HarmonyPatches.Patches_Construction | ||
{ | ||
[HarmonyPatch(typeof(WorkGiver_Repair))] | ||
class Patch_WorkGiver_Repair | ||
{ | ||
[HarmonyPrefix] | ||
[HarmonyPatch("ShouldSkip")] | ||
[HarmonyPatch(new[] { typeof(Pawn), typeof(bool) })] | ||
static bool ShouldSKipPrefix(ref bool __result, Pawn pawn, bool forced) | ||
{ | ||
if(pawn.IsPrisonerOfColony) | ||
{ | ||
__result = pawn.Map.listerBuildingsRepairable.RepairableBuildings(Faction.OfPlayer).Count == 0; | ||
return false; | ||
} | ||
return true; | ||
|
||
} | ||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch("PotentialWorkThingsGlobal")] | ||
[HarmonyPatch(new[] { typeof(Pawn) })] | ||
static bool PotentialWorkThingsGlobalPrefix(ref IEnumerable<Thing> __result, Pawn pawn) | ||
{ | ||
if (pawn.IsPrisonerOfColony) | ||
{ | ||
__result = pawn.Map.listerBuildingsRepairable.RepairableBuildings(Faction.OfPlayer); | ||
return false; | ||
} | ||
return true; | ||
|
||
} | ||
|
||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch("HasJobOnThing")] | ||
[HarmonyPatch(new[] { typeof(Pawn), typeof(Thing), typeof(bool) })] | ||
static bool HasJobOnThingPrefix(ref bool __result, Pawn pawn,Thing t, bool forced) | ||
{ | ||
if (pawn.IsPrisonerOfColony) | ||
{ | ||
__result = ConstructionUtils.HasJobOnThingFixed(pawn, t, forced); | ||
return false; | ||
} | ||
return true; | ||
|
||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...ce/HarmonyPatches/Patches_Construction/WorkGiver_ConstructDeliverResourcesToBlueprints.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using HarmonyLib; | ||
using PrisonLabor.WorkUtils; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Verse; | ||
using Verse.AI; | ||
|
||
namespace PrisonLabor.HarmonyPatches.Patches_Construction | ||
{ | ||
[HarmonyPatch(typeof(WorkGiver_ConstructDeliverResourcesToBlueprints))] | ||
[HarmonyPatch("JobOnThing")] | ||
[HarmonyPatch(new[] { typeof(Pawn), typeof(Thing), typeof(bool) })] | ||
class Patch_WorkGiver_ConstructDeliverResourcesToBlueprints | ||
{ | ||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
|
||
OpCode[] opCodes1 = | ||
{ | ||
OpCodes.Ldarg_2, | ||
OpCodes.Callvirt, | ||
OpCodes.Ldarg_1, | ||
OpCodes.Callvirt, | ||
OpCodes.Beq_S, | ||
}; | ||
string[] operands1 = | ||
{ | ||
"", | ||
"RimWorld.Faction get_Faction()", | ||
"", | ||
"RimWorld.Faction get_Faction()", | ||
"System.Reflection.Emit.Label", | ||
}; | ||
|
||
|
||
var label = HPatcher.FindOperandAfter(opCodes1, operands1, instructions, true); | ||
|
||
//Add If(pawn.IsPrisonerOfColony) {jump next condition} | ||
yield return new CodeInstruction(OpCodes.Ldarg_2); | ||
yield return new CodeInstruction(OpCodes.Ldarg_1); | ||
yield return new CodeInstruction(OpCodes.Call, typeof(ConstructionUtils).GetMethod("isPrisonerWork")); | ||
yield return new CodeInstruction(OpCodes.Brtrue, label); | ||
|
||
foreach (var instr in instructions) | ||
{ | ||
yield return instr; | ||
} | ||
|
||
} | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
Source/HarmonyPatches/Patches_NPR/ListerBuildingsRepairable_Patch.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.