为乌拉族引入了新的“机体维护”需求,通过`WULA_Maintenance_Neglect`健康状况(Hediff)体现。该状况会随时间推移而恶化,影响角色能力。 新增建筑“维护舱”(`WULA_MaintenancePod`),乌拉族成员可进入其中进行维护,以清除“维护疏忽”的负面效果。维护过程需要消耗电力和零部件,所需零部件数量与负面效果的严重程度相关。 实现了配套的自动化工作逻辑: - 当维护需求达到阈值时,角色会自动进入维护舱。 - 当维护舱缺少零部件时,搬运工会自动为其装填。 此外,事件系统中增加了一个新的条件 `Condition_FactionExists`。
53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using RimWorld;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Verse;
|
|
using Verse.AI;
|
|
|
|
namespace WulaFallenEmpire
|
|
{
|
|
public class JobDriver_LoadComponents : JobDriver
|
|
{
|
|
private const TargetIndex PodIndex = TargetIndex.A;
|
|
private const TargetIndex ComponentIndex = TargetIndex.B;
|
|
|
|
protected Thing Pod => job.GetTarget(PodIndex).Thing;
|
|
protected Thing Component => job.GetTarget(ComponentIndex).Thing;
|
|
|
|
public override bool TryMakePreToilReservations(bool errorOnFailed)
|
|
{
|
|
if (pawn.Reserve(Pod, job, 1, -1, null, errorOnFailed))
|
|
{
|
|
return pawn.Reserve(Component, job, 1, -1, null, errorOnFailed);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
protected override IEnumerable<Toil> MakeNewToils()
|
|
{
|
|
this.FailOnDespawnedNullOrForbidden(PodIndex);
|
|
this.FailOnBurningImmobile(PodIndex);
|
|
|
|
var podComp = Pod.TryGetComp<CompMaintenancePod>();
|
|
this.FailOn(() => podComp == null || podComp.State != MaintenancePodState.Idle);
|
|
|
|
// Go and get the components
|
|
yield return Toils_Goto.GotoThing(ComponentIndex, PathEndMode.OnCell).FailOnSomeonePhysicallyInteracting(ComponentIndex);
|
|
yield return Toils_Haul.StartCarryThing(ComponentIndex);
|
|
|
|
// Carry them to the pod
|
|
yield return Toils_Goto.GotoThing(PodIndex, PathEndMode.InteractionCell);
|
|
|
|
// Load the components
|
|
yield return Toils_General.WaitWith(60, TargetIndex.A, true, true, false, PodIndex);
|
|
yield return new Toil
|
|
{
|
|
initAction = () =>
|
|
{
|
|
podComp.AddComponents(this.GetActor().carryTracker.CarriedThing);
|
|
},
|
|
defaultCompleteMode = ToilCompleteMode.Instant
|
|
};
|
|
}
|
|
}
|
|
} |