-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82a8b04
commit e3b6715
Showing
12 changed files
with
135 additions
and
23 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
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
49 changes: 49 additions & 0 deletions
49
ResearchReinvented/Source/ModCompat/ResearchData/_ResearchData.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,49 @@ | ||
using HarmonyLib; | ||
using PeteTimesSix.ResearchReinvented.Rimworld.WorkGivers; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Verse; | ||
|
||
namespace PeteTimesSix.ResearchReinvented.ModCompat | ||
{ | ||
[StaticConstructorOnStartup] | ||
public static class ResearchData | ||
{ | ||
public delegate float ConsumptionRatePerTickGetter(CompRefuelable instance); | ||
|
||
public static ConsumptionRatePerTickGetter getter_ConsumptionRatePerTick; | ||
|
||
public enum ResearchDataCompatMode | ||
{ | ||
TheoryOnly, | ||
AllBenchResearch | ||
} | ||
|
||
public static bool active = false; | ||
|
||
static ResearchData() | ||
{ | ||
active = ModLister.GetActiveModWithIdentifier("kongkim.ResearchData") != null; | ||
|
||
getter_ConsumptionRatePerTick = AccessTools.MethodDelegate<ConsumptionRatePerTickGetter>(AccessTools.PropertyGetter(typeof(CompRefuelable), "ConsumptionRatePerTick")); | ||
} | ||
|
||
public static void PatchDelayed(Harmony harmony) | ||
{ | ||
//these patches generate refuel jobs | ||
var workGiverHasJobOnThingPrefix = new HarmonyMethod(AccessTools.TypeByName("ResearchData.WorkGiver_Researcher_HasJobOnThing_Patch").GetMethod("Prefix")); | ||
harmony.Patch(AccessTools.Method(typeof(WorkGiver_ResearcherRR), nameof(WorkGiver_ResearcherRR.HasJobOnThing)), prefix: workGiverHasJobOnThingPrefix); | ||
var workGiverJobOnThingPrefix = new HarmonyMethod(AccessTools.TypeByName("ResearchData.WorkGiver_Researcher_JobOnThing_Patch").GetMethod("Prefix")); | ||
harmony.Patch(AccessTools.Method(typeof(WorkGiver_ResearcherRR), nameof(WorkGiver_ResearcherRR.JobOnThing)), prefix: workGiverJobOnThingPrefix); | ||
} | ||
|
||
public static void ConsumeTickFuel(this CompRefuelable comp) | ||
{ | ||
comp.ConsumeFuel(getter_ConsumptionRatePerTick(comp)); | ||
} | ||
} | ||
} |
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
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