Exemplo n.º 1
0
        public static void Prefix(JobDriver_TendPatient __instance)
        {
            Job   job            = __instance.job;
            Pawn  healer         = __instance.pawn;
            Pawn  patient        = job.targetA.Thing as Pawn;
            Thing medicineToDrop = job.targetB.Thing;

            if (medicineToDrop == null)
            {
                return;
            }

            int needCount = Mathf.Min(medicineToDrop.stackCount, job.count);

            Log.Message($"{healer} Starting Tend with {medicineToDrop}");

            job.targetB = DropIt(medicineToDrop, needCount, healer, job);

            List <LocalTargetInfo> sharedMedicines      = job.targetQueueA;
            List <int>             sharedMedicineCounts = job.countQueue;

            if (sharedMedicines != null)
            {
                for (int i = 0; i < sharedMedicines.Count(); i++)
                {
                    Log.Message($"{healer} queuing medicine {sharedMedicines[i].Thing}");
                    DropIt(sharedMedicines[i].Thing, sharedMedicineCounts[i], healer, job);
                }
            }
        }
Exemplo n.º 2
0
        public static void Prefix(JobDriver_TendPatient __instance)
        {
            Job   job            = __instance.job;
            Pawn  healer         = __instance.pawn;
            Pawn  patient        = job.targetA.Thing as Pawn;
            Thing medicineToDrop = job.targetB.Thing;

            Log.Message(healer + " Starting Tend with  (" + medicineToDrop + ")");

            if (medicineToDrop == null || medicineToDrop.holdingOwner == null)
            {
                return;
            }

            int   needCount       = Mathf.Min(medicineToDrop.stackCount, job.count);
            Thing droppedMedicine = null;

            if (medicineToDrop.holdingOwner.Owner is Pawn_InventoryTracker holder)
            {
                Log.Message(holder.pawn + " dropping " + medicineToDrop + "x" + needCount);
                holder.innerContainer.TryDrop(medicineToDrop, ThingPlaceMode.Direct, needCount, out droppedMedicine);
            }
            else if (medicineToDrop.holdingOwner.Owner is Pawn_CarryTracker carrier)
            {
                Log.Message(carrier.pawn + " dropping carried " + medicineToDrop + "x" + needCount);
                carrier.innerContainer.TryDrop(medicineToDrop, ThingPlaceMode.Direct, needCount, out droppedMedicine);
            }

            if (droppedMedicine != null)
            {
                Log.Message(healer + " now tending with " + droppedMedicine);
                job.targetB = droppedMedicine;
                if (droppedMedicine.IsForbidden(healer))
                {
                    Log.Message(droppedMedicine + " is Forbidden, job will restart");
                }
            }

            Log.Message("Okay, doing reservations");
            if (healer.ReserveAsMuchAsPossible(job.targetB.Thing, job, FindBestMedicine.maxPawns, needCount) == 0)
            {
                Verse.Log.Warning("Needed medicine " + droppedMedicine + " for " + healer + " was dropped onto a reserved stack. Job will fail and try again, so ignore the error please.");
            }
        }
Exemplo n.º 3
0
 public static bool get_Deliveree(JobDriver_TendPatient __instance, ref Pawn __result)
 {
     __result = (Pawn)__instance?.job?.targetA.Thing;
     return(false);
 }