暂存
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
@@ -17,6 +19,36 @@ namespace ArachnaeSwarm
|
||||
{
|
||||
public new CompProperties_RefuelableWithKey Props => (CompProperties_RefuelableWithKey)props;
|
||||
|
||||
public override void PostExposeData()
|
||||
{
|
||||
string prefix = Props.saveKeysPrefix;
|
||||
if (prefix.NullOrEmpty())
|
||||
{
|
||||
Log.ErrorOnce($"CompRefuelableWithKey on {parent.def.defName} has a null or empty saveKeysPrefix. Defaulting to standard save.", GetHashCode());
|
||||
base.PostExposeData();
|
||||
return;
|
||||
}
|
||||
|
||||
FieldInfo fuelField = AccessTools.Field(typeof(CompRefuelable), "fuel");
|
||||
FieldInfo configuredTargetFuelLevelField = AccessTools.Field(typeof(CompRefuelable), "configuredTargetFuelLevel");
|
||||
FieldInfo allowAutoRefuelField = AccessTools.Field(typeof(CompRefuelable), "allowAutoRefuel");
|
||||
|
||||
float currentFuel = (float)fuelField.GetValue(this);
|
||||
float currentConfiguredLevel = (float)configuredTargetFuelLevelField.GetValue(this);
|
||||
bool currentAllowAuto = (bool)allowAutoRefuelField.GetValue(this);
|
||||
|
||||
Scribe_Values.Look(ref currentFuel, prefix + "_fuel", 0f);
|
||||
Scribe_Values.Look(ref currentConfiguredLevel, prefix + "_configuredTargetFuelLevel", -1f);
|
||||
Scribe_Values.Look(ref currentAllowAuto, prefix + "_allowAutoRefuel", true);
|
||||
|
||||
if (Scribe.mode == LoadSaveMode.LoadingVars)
|
||||
{
|
||||
fuelField.SetValue(this, currentFuel);
|
||||
configuredTargetFuelLevelField.SetValue(this, currentConfiguredLevel);
|
||||
allowAutoRefuelField.SetValue(this, currentAllowAuto);
|
||||
}
|
||||
}
|
||||
|
||||
public new void Notify_UsedThisTick()
|
||||
{
|
||||
if (Props.consumeFuelOnlyWhenUsed)
|
||||
|
||||
Reference in New Issue
Block a user