暂存feat(maintenance): 实现维护舱功能及可配置性

This commit is contained in:
2025-08-09 12:47:50 +08:00
parent a1998ba80e
commit f4fe41e24e
10 changed files with 49 additions and 31 deletions

View File

@@ -24,6 +24,8 @@ namespace WulaFallenEmpire
public float componentCostPerSeverity = 1f; // How many components per 1.0 severity
public int baseComponentCost = 0; // A flat cost in addition to severity cost
public float minSeverityToMaintain = 0.75f; // The hediff severity required to trigger maintenance
public int capacity = 50;
public float hediffSeverityAfterCycle = 0.01f;
public CompProperties_MaintenancePod()
{
@@ -39,7 +41,6 @@ namespace WulaFallenEmpire
private CompPowerTrader powerComp;
private StorageSettings allowedComponentSettings;
public float storedComponents = 0f;
public int capacity = 50; // Let's define a capacity
private int ticksRemaining;
private MaintenancePodState state = MaintenancePodState.Idle;
@@ -59,7 +60,7 @@ namespace WulaFallenEmpire
return Props.baseComponentCost + (int)(hediff.Severity * Props.componentCostPerSeverity);
}
public bool CanAcceptComponents(int count) => storedComponents + count <= capacity;
public bool CanAcceptComponents(int count) => storedComponents + count <= Props.capacity;
// ===================== Setup =====================
public CompMaintenancePod()
@@ -172,7 +173,7 @@ namespace WulaFallenEmpire
Hediff hediff = occupant.health.hediffSet.GetFirstHediffOfDef(Props.hediffToRemove);
if (hediff != null)
{
hediff.Severity = 0.01f;
hediff.Severity = Props.hediffSeverityAfterCycle;
Messages.Message("WULA_MaintenanceComplete".Translate(occupant.Named("PAWN")), occupant, MessageTypeDefOf.PositiveEvent);
}
}
@@ -215,7 +216,7 @@ namespace WulaFallenEmpire
sb.AppendLine("TimeLeft".Translate() + ": " + ticksRemaining.ToStringTicksToPeriod());
}
sb.AppendLine("WULA_MaintenancePod_StoredComponents".Translate() + ": " + storedComponents.ToString("F0") + " / " + capacity.ToString("F0"));
sb.AppendLine("WULA_MaintenancePod_StoredComponents".Translate() + ": " + storedComponents.ToString("F0") + " / " + Props.capacity.ToString("F0"));
if (!PowerOn)
{

View File

@@ -12,7 +12,7 @@ namespace WulaFallenEmpire
private const TargetIndex PodInd = TargetIndex.B;
protected Thing Component => job.GetTarget(ComponentInd).Thing;
protected Building_Storage Pod => (Building_Storage)job.GetTarget(PodInd).Thing;
protected Building Pod => (Building)job.GetTarget(PodInd).Thing;
public override bool TryMakePreToilReservations(bool errorOnFailed)
{

View File

@@ -29,7 +29,7 @@ namespace WulaFallenEmpire
}
// Check if it needs more components
if (comp.storedComponents >= comp.capacity)
if (comp.storedComponents >= comp.Props.capacity)
{
return false;
}
@@ -55,7 +55,7 @@ namespace WulaFallenEmpire
}
Job job = JobMaker.MakeJob(JobDefOf_WULA.WULA_HaulToMaintenancePod, component, t);
job.count = Math.Min(component.stackCount, (int)(comp.capacity - comp.storedComponents));
job.count = Math.Min(component.stackCount, (int)(comp.Props.capacity - comp.storedComponents));
return job;
}