暂存
This commit is contained in:
Binary file not shown.
@@ -1787,6 +1787,8 @@
|
||||
<!-- 食物列表 -->
|
||||
<whiteFoodList>
|
||||
<li>ARA_InsectJelly</li>
|
||||
<li>ARA_NutrientPasteMeal</li>
|
||||
<li>ARA_PheromoneSolvent</li>
|
||||
</whiteFoodList>
|
||||
<onlyEatRaceRestrictedFood>true</onlyEatRaceRestrictedFood>
|
||||
<!-- 可以驯服的宠物,主要是防止小虫由别人驯服 -->
|
||||
|
||||
@@ -299,7 +299,8 @@
|
||||
<terrainAffordanceNeeded>Heavy</terrainAffordanceNeeded>
|
||||
<comps>
|
||||
<li Class="CompProperties_Forbiddable" />
|
||||
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition">
|
||||
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition_WithKey">
|
||||
<saveKeysPrefix>nutrition</saveKeysPrefix>
|
||||
<fuelCapacity>5.0</fuelCapacity>
|
||||
<fuelFilter>
|
||||
<thingDefs>
|
||||
@@ -451,7 +452,8 @@
|
||||
<terrainAffordanceNeeded>Heavy</terrainAffordanceNeeded>
|
||||
<comps>
|
||||
<li Class="CompProperties_Forbiddable" />
|
||||
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition">
|
||||
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition_WithKey">
|
||||
<saveKeysPrefix>nutrition</saveKeysPrefix>
|
||||
<fuelCapacity>5.0</fuelCapacity>
|
||||
<fuelFilter>
|
||||
<thingDefs>
|
||||
@@ -623,7 +625,8 @@
|
||||
</statBases>
|
||||
<tickerType>Normal</tickerType>
|
||||
<comps>
|
||||
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition">
|
||||
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition_WithKey">
|
||||
<saveKeysPrefix>nutrition</saveKeysPrefix>
|
||||
<fuelCapacity>5.0</fuelCapacity>
|
||||
<fuelFilter>
|
||||
<thingDefs>
|
||||
|
||||
@@ -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