public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (t == null)
            {
                return(false);
            }

            Pawn pawn2 = t as Pawn;

            if (pawn2 == null || pawn2 == pawn)
            {
                return(false);
            }
            if (!pawn.CanReserveAndReach(t, PathEndMode.ClosestTouch, Danger.Deadly, 1))
            {
                return(false);
            }

            CompTransporterPawn transporter = t.TryGetComp <CompTransporterPawn>();

            if (transporter == null)
            {
                return(false);
            }
            return(LoadTransportersPawnJobUtility.HasJobOnTransporter(pawn, transporter));
        }
Пример #2
0
        // RimWorld.LoadTransportersJobUtility
        public static bool HasJobOnTransporter(Pawn pawn, CompTransporterPawn transporter)
        {
            bool result = !transporter.parent.IsForbidden(pawn) && transporter.AnythingLeftToLoad &&
                          pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) &&
                          pawn.CanReserveAndReach(transporter.parent, PathEndMode.Touch, pawn.NormalMaxDanger(), 1) &&
                          LoadTransportersPawnJobUtility.FindThingToLoad(pawn, transporter) != null;

            Cthulhu.Utility.DebugReport(pawn.Label + " HasJobOnTransporter: " + result.ToString());
            return(result);
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            CompTransporterPawn transporter = t.TryGetComp <CompTransporterPawn>();

            if (t == null)
            {
                return(null);
            }
            return(LoadTransportersPawnJobUtility.JobOnTransporter(pawn, transporter));
        }
Пример #4
0
        public static Job JobOnTransporter(Pawn p, CompTransporterPawn transporter)
        {
            Cthulhu.Utility.DebugReport("JobOnTransporter Called");
            Thing thing = LoadTransportersPawnJobUtility.FindThingToLoad(p, transporter);

            return(new Job(JobDefOf.HaulToContainer, thing, transporter.parent)
            {
                count = Mathf.Min(
                    TransferableUtility.TransferableMatching <TransferableOneWay>(thing, transporter.leftToLoad,
                                                                                  TransferAsOneMode.PodsOrCaravanPacking).CountToTransfer, thing.stackCount),
                ignoreForbidden = true
            });
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            Utility.DebugReport("JobGiver_LoadTransportersPawn Called");
            var transportersGroup = pawn.mindState.duty.transportersGroup;

            LoadTransportersPawnJobUtility.GetTransportersInGroup(transportersGroup, pawn.Map, tmpTransporters);
            foreach (var transporter in tmpTransporters)
            {
                if (LoadTransportersPawnJobUtility.HasJobOnTransporter(pawn, transporter))
                {
                    return(LoadTransportersPawnJobUtility.JobOnTransporter(pawn, transporter));
                }
            }

            return(null);
        }
Пример #6
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Cthulhu.Utility.DebugReport("JobGiver_LoadTransportersPawn Called");
            int transportersGroup = pawn.mindState.duty.transportersGroup;

            LoadTransportersPawnJobUtility.GetTransportersInGroup(transportersGroup, pawn.Map, JobGiver_LoadTransportersPawn.tmpTransporters);
            for (int i = 0; i < JobGiver_LoadTransportersPawn.tmpTransporters.Count; i++)
            {
                CompTransporterPawn transporter = JobGiver_LoadTransportersPawn.tmpTransporters[i];
                if (LoadTransportersPawnJobUtility.HasJobOnTransporter(pawn, transporter))
                {
                    return(LoadTransportersPawnJobUtility.JobOnTransporter(pawn, transporter));
                }
            }
            return(null);
        }
Пример #7
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            var transporter = t.TryGetComp <CompTransporterPawn>();

            return(t == null ? null : LoadTransportersPawnJobUtility.JobOnTransporter(pawn, transporter));
        }