35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using RimWorld;
|
|
using Verse;
|
|
using Verse.AI;
|
|
|
|
namespace ArachnaeSwarm
|
|
{
|
|
public class JobDriver_StartProduction : JobDriver
|
|
{
|
|
private const TargetIndex BuildingInd = TargetIndex.A;
|
|
|
|
protected Building Building => (Building)job.GetTarget(BuildingInd).Thing;
|
|
|
|
public override bool TryMakePreToilReservations(bool errorOnFailed)
|
|
{
|
|
return pawn.Reserve(Building, job, 1, -1, null, errorOnFailed);
|
|
}
|
|
|
|
protected override IEnumerable<Toil> MakeNewToils()
|
|
{
|
|
this.FailOnDespawnedNullOrForbidden(BuildingInd);
|
|
this.FailOnBurningImmobile(BuildingInd);
|
|
|
|
yield return Toils_Goto.GotoThing(BuildingInd, PathEndMode.InteractionCell);
|
|
|
|
Toil work = ToilMaker.MakeToil("MakeNewToils");
|
|
work.initAction = delegate
|
|
{
|
|
Building.GetComp<CompInteractiveProducer>().StartProduction();
|
|
};
|
|
work.defaultCompleteMode = ToilCompleteMode.Instant;
|
|
yield return work;
|
|
}
|
|
}
|
|
} |