Exemplo n.º 1
0
        // Token: 0x0600007E RID: 126 RVA: 0x00007018 File Offset: 0x00005218
        public static Job DoPainReliefResponse(Pawn pawn)
        {
            if ((pawn?.CurJob) != null && pawn.CurJob.def == JobDefOf.Ingest)
            {
                return(null);
            }
            if (MSPainlessData.GetLastPainReliefTick(pawn) + 2500 * DRSettings.PainReliefWaitPeriod > Find.TickManager.TicksGame)
            {
                return(null);
            }
            ThingDef painDrugDef = MSPainUtility.NeedsPainReliefNow(pawn, out bool highpain);

            if (painDrugDef != null && MSDrugUtility.IsOKtoAdmin(pawn, null, painDrugDef) && !MSDrugUtility.IsViolation(pawn, painDrugDef))
            {
                Thing drug = MSDrugUtility.FindDrugFor(pawn, painDrugDef);
                if (drug != null)
                {
                    if (DRSettings.ShowReliefMsg)
                    {
                        Messages.Message(TranslatorFormattedStringExtensions.Translate("MSPainless.ReliefMsg", GenText.CapitalizeFirst(pawn.LabelShort), GenText.CapitalizeFirst(drug.def.label)), pawn, MessageTypeDefOf.NeutralEvent, false);
                    }
                    Job job = new Job(JobDefOf.Ingest, drug)
                    {
                        count = Mathf.Min(new int[]
                        {
                            drug.stackCount,
                            drug.def.ingestible.maxNumToIngestAtOnce,
                            1
                        })
                    };
                    if (drug.Spawned && pawn.drugs != null && !pawn.inventory.innerContainer.Contains(drug.def))
                    {
                        DrugPolicyEntry drugPolicyEntry = pawn.drugs.CurrentPolicy[drug.def];
                        if (drugPolicyEntry.takeToInventory > 0)
                        {
                            job.takeExtraIngestibles = drugPolicyEntry.takeToInventory;
                        }
                    }
                    if (MSPainResponse.IsUsingPainJob(pawn, highpain) && !pawn.IsPrisoner)
                    {
                        MSPainlessData.MSPainlessDataTickSet(pawn);
                        return(job);
                    }
                    if (MSAddDrugBill.GenDrugResponse(false, pawn, null, painDrugDef, null, null, 1))
                    {
                        MSPainlessData.MSPainlessDataTickSet(pawn);
                        return(null);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        // Token: 0x0600007D RID: 125 RVA: 0x00006F64 File Offset: 0x00005164
        public static void DoCaravanPainReliefResponse(Caravan car, Pawn pawn)
        {
            if (MSPainlessData.GetLastPainReliefTick(pawn) + 2500 * DRSettings.PainReliefWaitPeriod > Find.TickManager.TicksGame)
            {
                return;
            }
            ThingDef painDrugDef = MSPainUtility.NeedsPainReliefNow(pawn, out bool highpain);

            if (painDrugDef != null && MSDrugUtility.IsOKtoAdmin(pawn, null, painDrugDef) && !MSDrugUtility.IsViolation(pawn, painDrugDef) && MSCaravanUtility.CaravanHasDrug(car, painDrugDef, out Thing drug, out Pawn owner))
            {
                MSPainlessData.MSPainlessDataTickSet(pawn);
                MSCaravanUtility.PawnOnCaravanTakeDrug(car, pawn, drug, owner);
                if (DRSettings.ShowReliefMsg)
                {
                    Messages.Message(TranslatorFormattedStringExtensions.Translate("MSPainless.ReliefMsg", GenText.CapitalizeFirst(pawn.LabelShort), GenText.CapitalizeFirst(drug.def.label)), pawn, MessageTypeDefOf.NeutralEvent, false);
                }
            }
        }