各种修改
This commit is contained in:
@@ -10,7 +10,6 @@ namespace ArachnaeSwarm
|
||||
public CompProperties_RefuelableNutrition()
|
||||
{
|
||||
compClass = typeof(CompRefuelableNutrition);
|
||||
// 默认启用这些Gizmo,除非在XML中明确设置为false
|
||||
this.targetFuelLevelConfigurable = true;
|
||||
this.showAllowAutoRefuelToggle = true;
|
||||
}
|
||||
@@ -23,10 +22,44 @@ namespace ArachnaeSwarm
|
||||
public float NutritionStored => Fuel;
|
||||
public new CompProperties_RefuelableNutrition Props => (CompProperties_RefuelableNutrition)props;
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
base.PostSpawnSetup(respawningAfterLoad);
|
||||
|
||||
// 确保自动补充目标燃料水平正确设置
|
||||
if (TargetFuelLevel <= 0f || respawningAfterLoad)
|
||||
{
|
||||
SetTargetFuelLevelFromAutoRefuelPercent();
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostExposeData()
|
||||
{
|
||||
base.PostExposeData();
|
||||
|
||||
// 在加载后确保目标燃料水平正确
|
||||
if (Scribe.mode == LoadSaveMode.PostLoadInit)
|
||||
{
|
||||
SetTargetFuelLevelFromAutoRefuelPercent();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetTargetFuelLevelFromAutoRefuelPercent()
|
||||
{
|
||||
// 使用 autoRefuelPercent 设置目标燃料水平
|
||||
if (Props.autoRefuelPercent > 0f)
|
||||
{
|
||||
TargetFuelLevel = Props.fuelCapacity * Props.autoRefuelPercent;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 默认设置为满容量
|
||||
TargetFuelLevel = Props.fuelCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
public override void CompTick()
|
||||
{
|
||||
// 调用基类的Tick,让它处理真空等情况。
|
||||
// 基类的燃料消耗逻辑将因为 fuelConsumptionRate 为0而无效。
|
||||
base.CompTick();
|
||||
|
||||
// 我们自己的动态消耗逻辑
|
||||
@@ -92,6 +125,7 @@ namespace ArachnaeSwarm
|
||||
if (Props.targetFuelLevelConfigurable)
|
||||
{
|
||||
text += "\n" + "ConfiguredTargetFuelLevel".Translate(TargetFuelLevel.ToStringDecimalIfSmall());
|
||||
text += " (" + "AutoRefuelPercent".Translate((Props.autoRefuelPercent * 100f).ToString("F0") + "%)");
|
||||
}
|
||||
|
||||
return text;
|
||||
@@ -105,4 +139,4 @@ namespace ArachnaeSwarm
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user