35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using Verse;
|
|
using Verse.AI;
|
|
|
|
namespace ArachnaeSwarm
|
|
{
|
|
public class JobDriver_AddToQueue : JobDriver
|
|
{
|
|
private const TargetIndex IncubatorInd = TargetIndex.A;
|
|
|
|
public override bool TryMakePreToilReservations(bool errorOnFailed)
|
|
{
|
|
return pawn.Reserve(job.GetTarget(IncubatorInd), job, 1, -1, null, errorOnFailed);
|
|
}
|
|
|
|
protected override IEnumerable<Toil> MakeNewToils()
|
|
{
|
|
this.FailOnDespawnedNullOrForbidden(IncubatorInd);
|
|
|
|
yield return Toils_Goto.GotoThing(IncubatorInd, PathEndMode.Touch);
|
|
|
|
Toil addToQueue = new Toil();
|
|
addToQueue.initAction = () =>
|
|
{
|
|
CompQueuedPawnSpawner comp = job.GetTarget(IncubatorInd).Thing.TryGetComp<CompQueuedPawnSpawner>();
|
|
if (comp != null)
|
|
{
|
|
comp.AddToQueue();
|
|
}
|
|
};
|
|
addToQueue.defaultCompleteMode = ToilCompleteMode.Instant;
|
|
yield return addToQueue;
|
|
}
|
|
}
|
|
} |