-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Significant optimisations made to loading times
- Loading branch information
XeoNovaDan
committed
Jul 4, 2019
1 parent
935ab33
commit e611141
Showing
27 changed files
with
621 additions
and
344 deletions.
There are no files selected for viewing
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
Binary file not shown.
Binary file modified
BIN
+4 KB
(100%)
Source/SurvivalTools/.vs/SurvivalTools/v16/Server/sqlite3/storage.ide
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
40 changes: 40 additions & 0 deletions
40
Source/SurvivalTools/Harmony/Patch_JobDriver_Mine_ResetTicksToPickHit - Copy.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,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using Verse; | ||
using RimWorld; | ||
using RimWorld.BaseGen; | ||
using Harmony; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
namespace SurvivalTools.Harmony | ||
{ | ||
|
||
[HarmonyPatch(typeof(Mineable))] | ||
[HarmonyPatch(nameof(Mineable.Notify_TookMiningDamage))] | ||
public static class Patch_Mineable_Notify_TookMiningDamage | ||
{ | ||
|
||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
List<CodeInstruction> instructionList = instructions.ToList(); | ||
|
||
for (int i = 0; i < instructionList.Count; i++) | ||
{ | ||
CodeInstruction instruction = instructionList[i]; | ||
|
||
if (instruction.opcode == OpCodes.Ldsfld && instruction.operand == AccessTools.Field(typeof(StatDefOf), nameof(StatDefOf.MiningYield))) | ||
{ | ||
instruction.operand = AccessTools.Field(typeof(ST_StatDefOf), nameof(ST_StatDefOf.MiningYieldDigging)); | ||
} | ||
|
||
yield return instruction; | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
Source/SurvivalTools/Harmony/Patch_JobDriver_Mine_ResetTicksToPickHit.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,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using Verse; | ||
using RimWorld; | ||
using RimWorld.BaseGen; | ||
using Harmony; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
namespace SurvivalTools.Harmony | ||
{ | ||
|
||
[HarmonyPatch(typeof(JobDriver_Mine))] | ||
[HarmonyPatch("ResetTicksToPickHit")] | ||
public static class Patch_JobDriver_Mine_ResetTicksToPickHit | ||
{ | ||
|
||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
List<CodeInstruction> instructionList = instructions.ToList(); | ||
|
||
for (int i = 0; i < instructionList.Count; i++) | ||
{ | ||
CodeInstruction instruction = instructionList[i]; | ||
|
||
if (instruction.opcode == OpCodes.Ldsfld && instruction.operand == AccessTools.Field(typeof(StatDefOf), nameof(StatDefOf.MiningSpeed))) | ||
{ | ||
instruction.operand = AccessTools.Field(typeof(ST_StatDefOf), nameof(ST_StatDefOf.DiggingSpeed)); | ||
} | ||
|
||
yield return instruction; | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
Source/SurvivalTools/Harmony/Patch_MassUtility_CountToPickUpUntilOverEncumbered.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,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using Verse; | ||
using RimWorld; | ||
using RimWorld.BaseGen; | ||
using Harmony; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
namespace SurvivalTools.Harmony | ||
{ | ||
|
||
[HarmonyPatch(typeof(MassUtility))] | ||
[HarmonyPatch(nameof(MassUtility.CountToPickUpUntilOverEncumbered))] | ||
public static class Patch_MassUtility_CountToPickUpUntilOverEncumbered | ||
{ | ||
|
||
public static void Postfix(ref int __result, Pawn pawn, Thing thing) | ||
{ | ||
if (__result > 0 && pawn.RaceProps.Humanlike && thing as SurvivalTool != null && !pawn.CanCarryAnyMoreSurvivalTools()) | ||
__result = 0; | ||
} | ||
|
||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
Source/SurvivalTools/Harmony/Patch_MassUtility_WillBeOverEncumberedAfterPickingUp.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,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using Verse; | ||
using RimWorld; | ||
using RimWorld.BaseGen; | ||
using Harmony; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
namespace SurvivalTools.Harmony | ||
{ | ||
|
||
[HarmonyPatch(typeof(MassUtility))] | ||
[HarmonyPatch(nameof(MassUtility.WillBeOverEncumberedAfterPickingUp))] | ||
public static class Patch_MassUtility_WillBeOverEncumberedAfterPickingUp | ||
{ | ||
|
||
// Another janky hack | ||
public static void Postfix(ref bool __result, Pawn pawn, Thing thing) | ||
{ | ||
if (pawn.RaceProps.Humanlike && thing as SurvivalTool != null && !pawn.CanCarryAnyMoreSurvivalTools()) | ||
__result = true; | ||
} | ||
|
||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
Source/SurvivalTools/Harmony/Patch_Pawn_InventoryTracker_FirstUnloadableThing.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,44 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using Verse; | ||
using RimWorld; | ||
using RimWorld.BaseGen; | ||
using Harmony; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
namespace SurvivalTools.Harmony | ||
{ | ||
|
||
[HarmonyPatch(typeof(Pawn_InventoryTracker))] | ||
[HarmonyPatch(nameof(Pawn_InventoryTracker.FirstUnloadableThing), MethodType.Getter)] | ||
public static class Patch_Pawn_InventoryTracker_FirstUnloadableThing | ||
{ | ||
|
||
public static void Postfix(Pawn_InventoryTracker __instance, ref ThingCount __result) | ||
{ | ||
if (__result.Thing is SurvivalTool tool && tool.InUse) | ||
{ | ||
bool foundNewThing = false; | ||
// Had to iterate through because a lambda expression in this case isn't possible | ||
for (int i = 0; i < __instance.innerContainer.Count; i++) | ||
{ | ||
Thing newThing = __instance.innerContainer[i]; | ||
if (newThing as SurvivalTool == null || !((SurvivalTool)newThing).InUse) | ||
{ | ||
__result = new ThingCount(newThing, newThing.stackCount); | ||
foundNewThing = true; | ||
break; | ||
} | ||
} | ||
if (!foundNewThing) | ||
__result = default; | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
Source/SurvivalTools/Harmony/Patch_Pawn_InventoryTracker_InventoryTrackerTickRare.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,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using Verse; | ||
using Verse.AI; | ||
using RimWorld; | ||
using RimWorld.BaseGen; | ||
using Harmony; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
namespace SurvivalTools.Harmony | ||
{ | ||
|
||
[HarmonyPatch(typeof(Pawn_InventoryTracker))] | ||
[HarmonyPatch(nameof(Pawn_InventoryTracker.InventoryTrackerTickRare))] | ||
public static class Patch_Pawn_InventoryTracker_InventoryTrackerTickRare | ||
{ | ||
|
||
public static void Postfix(Pawn_InventoryTracker __instance) | ||
{ | ||
if (SurvivalToolsSettings.toolLimit) | ||
{ | ||
Pawn pawn = __instance.pawn; | ||
if (pawn.CanUseSurvivalTools() && pawn.GetHeldSurvivalTools().Count() > pawn.GetStatValue(ST_StatDefOf.SurvivalToolCarryCapacity) && pawn.CanRemoveExcessSurvivalTools()) | ||
{ | ||
Thing tool = pawn.GetHeldSurvivalTools().Last(); | ||
Job job = pawn.DequipAndTryStoreSurvivalTool(tool); | ||
pawn.jobs.StartJob(job, JobCondition.InterruptForced, cancelBusyStances: false); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
Source/SurvivalTools/Harmony/Patch_Pawn_InventoryTracker_Notify_ItemRemoved.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 System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using Verse; | ||
using RimWorld; | ||
using RimWorld.BaseGen; | ||
using Harmony; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
namespace SurvivalTools.Harmony | ||
{ | ||
|
||
[HarmonyPatch(typeof(Pawn_InventoryTracker))] | ||
[HarmonyPatch(nameof(Pawn_InventoryTracker.Notify_ItemRemoved))] | ||
public static class Patch_Pawn_InventoryTracker_Notify_ItemRemoved | ||
{ | ||
|
||
public static void Postfix(Pawn_InventoryTracker __instance, Thing item) | ||
{ | ||
if (item is SurvivalTool && __instance.pawn.TryGetComp<Pawn_SurvivalToolAssignmentTracker>() is Pawn_SurvivalToolAssignmentTracker assignmentTracker) | ||
{ | ||
assignmentTracker.forcedHandler.SetForced(item, false); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
Source/SurvivalTools/Harmony/Patch_RoofUtility_CanHandleBlockingThing.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,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using Verse; | ||
using RimWorld; | ||
using RimWorld.BaseGen; | ||
using Harmony; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
namespace SurvivalTools.Harmony | ||
{ | ||
|
||
[HarmonyPatch(typeof(RoofUtility))] | ||
[HarmonyPatch(nameof(RoofUtility.CanHandleBlockingThing))] | ||
public static class Patch_RoofUtility_CanHandleBlockingThing | ||
{ | ||
|
||
public static void Postfix(ref bool __result, Thing blocker, Pawn worker) | ||
{ | ||
if (blocker?.def.plant?.IsTree == true && !worker.MeetsWorkGiverStatRequirements(ST_WorkGiverDefOf.FellTrees.GetModExtension<WorkGiverExtension>().requiredStats)) | ||
__result = false; | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.