Exemplo n.º 1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.B);
            //this.FailOnForbidden(TargetIndex.A);

            Toil gotoThing = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch);

            gotoThing.FailOnSomeonePhysicallyInteracting(TargetIndex.A);
            gotoThing.FailOn(delegate(Toil toil)
            {
                Job job      = toil.actor.CurJob;
                Thing thing  = job.GetTarget(TargetIndex.A).Thing;
                IntVec3 cell = job.GetTarget(TargetIndex.B).Cell;
                List <Thing> items_in_cell = HaulExplicitlyPosting.GetItemsIfValidItemSpot(
                    toil.actor.Map, cell);
                if (items_in_cell == null)
                {
                    return(true);
                }
                if (items_in_cell.Count == 0)
                {
                    return(false);
                }
                if (items_in_cell.Count == 1 && thing.CanStackWith(items_in_cell.First()))
                {
                    return(false);
                }
                return(true);
            });
            yield return(gotoThing);

            yield return(Toils_HaulExplicitly.PickUpThing(TargetIndex.A, gotoThing));

            Toil carryToDest = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToDest);

            yield return(Toils_HaulExplicitly.PlaceHauledThingAtDest(TargetIndex.B, carryToDest));
        }