public static bool HasJobOnTransporter(Pawn pawn, CompTransporter transporter)
        {
            if (transporter.parent.IsForbidden(pawn))
            {
                return(false);
            }
            if (!transporter.AnythingLeftToLoad)
            {
                return(false);
            }
            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                return(false);
            }
            if (!pawn.CanReserveAndReach(transporter.parent, PathEndMode.Touch, pawn.NormalMaxDanger(), 1, -1, null, false))
            {
                return(false);
            }
            Thing thing = LoadTransportersJobUtility.FindThingToLoad(pawn, transporter);

            if (thing == null)
            {
                return(false);
            }
            return(true);
        }
Exemple #2
0
        public override void Notify_Starting()
        {
            base.Notify_Starting();
            ThingCount thingCount = ((!job.targetA.IsValid) ? LoadTransportersJobUtility.FindThingToLoad(pawn, base.Container.TryGetComp <CompTransporter>()) : new ThingCount(job.targetA.Thing, job.targetA.Thing.stackCount));

            job.targetA  = thingCount.Thing;
            job.count    = thingCount.Count;
            initialCount = thingCount.Count;
            pawn.Reserve(thingCount.Thing, job);
        }
Exemple #3
0
        public override void Notify_Starting()
        {
            base.Notify_Starting();
            ThingCount thingCount = LoadTransportersJobUtility.FindThingToLoad(this.pawn, base.Container.TryGetComp <CompTransporter>());

            this.job.targetA  = thingCount.Thing;
            this.job.count    = thingCount.Count;
            this.initialCount = thingCount.Count;
            this.pawn.Reserve(thingCount.Thing, this.job, 1, -1, null, true);
        }
        public static Job JobOnTransporter(Pawn p, CompTransporter transporter)
        {
            Thing thing           = LoadTransportersJobUtility.FindThingToLoad(p, transporter);
            Job   job             = new Job(JobDefOf.HaulToContainer, thing, transporter.parent);
            int   countToTransfer = TransferableUtility.TransferableMatchingDesperate(thing, transporter.leftToLoad).CountToTransfer;

            job.count           = Mathf.Min(countToTransfer, thing.stackCount);
            job.ignoreForbidden = true;
            return(job);
        }
 protected override Job TryGiveJob(Pawn pawn)
 {
     TransporterUtility.GetTransportersInGroup(pawn.mindState.duty.transportersGroup, pawn.Map, tmpTransporters);
     for (int i = 0; i < tmpTransporters.Count; i++)
     {
         CompTransporter transporter = tmpTransporters[i];
         if (LoadTransportersJobUtility.HasJobOnTransporter(pawn, transporter))
         {
             return(LoadTransportersJobUtility.JobOnTransporter(pawn, transporter));
         }
     }
     return(null);
 }
Exemple #6
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            CompTransporter transporter = t.TryGetComp <CompTransporter>();

            return(LoadTransportersJobUtility.JobOnTransporter(pawn, transporter));
        }
Exemple #7
0
 public static bool HasJobOnTransporter(Pawn pawn, CompTransporter transporter)
 {
     return(!transporter.parent.IsForbidden(pawn) && transporter.AnythingLeftToLoad && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) && pawn.CanReach(transporter.parent, PathEndMode.Touch, pawn.NormalMaxDanger(), false, TraverseMode.ByPawn) && LoadTransportersJobUtility.FindThingToLoad(pawn, transporter).Thing != null);
 }