示例#1
0
			// Token: 0x060000D3 RID: 211 RVA: 0x00007AE0 File Offset: 0x00005CE0
			private static void CheckDRDrugDefinitions2()
			{
				List<string> newMSDRValues = new List<string>();
				if (DRSettings.MSDRValues2 != null && DRSettings.MSDRValues2.Count > 0)
				{
					foreach (string value in DRSettings.MSDRValues2)
					{
						string mal = MSDRUtility.HValuePart(value);
						if (MSDRUtility.MaladyUsed(mal))
						{
							int end = 1;
							if (value.EndsWith("2"))
							{
								end = 2;
							}
							string drug = MSDRUtility.DValuePart(value);
							if (DefDatabase<ThingDef>.GetNamed(drug, false) != null)
							{
								int t = MSDRUtility.TValuePart(value);
								bool b = MSDRUtility.BValuePart(value);
								string oldValue = MSDRUtility.ConvertToDRValue(t, mal, drug, b, end);
								GenCollection.AddDistinct<string>(newMSDRValues, oldValue);
							}
							else
							{
								string newValue = MSDRUtility.ConvertToDRValue(24, mal, null, true, end);
								GenCollection.AddDistinct<string>(newMSDRValues, newValue);
							}
						}
					}
				}
				DRSettings.MSDRValues2 = newMSDRValues;
			}
示例#2
0
        // Token: 0x06000056 RID: 86 RVA: 0x000059CC File Offset: 0x00003BCC
        public static void SetDRValues(string m, string d, int t, bool b, int numof, List <string> master, out List <string> newMaster)
        {
            newMaster = new List <string>();
            string newValue = MSDRUtility.ConvertToDRValue(t, m, d, b, numof);

            if (master != null)
            {
                bool beenSet = false;
                if (master.Count > 0)
                {
                    foreach (string value in master)
                    {
                        string a   = MSDRUtility.HValuePart(value);
                        int    num = MSDRUtility.NumValuePart(value);
                        if (a != m)
                        {
                            GenCollection.AddDistinct <string>(newMaster, value);
                        }
                        else if (num != numof)
                        {
                            GenCollection.AddDistinct <string>(newMaster, value);
                        }
                        else
                        {
                            GenCollection.AddDistinct <string>(newMaster, newValue);
                            beenSet = true;
                        }
                    }
                }
                if (!beenSet)
                {
                    GenCollection.AddDistinct <string>(newMaster, newValue);
                }
            }
        }
示例#3
0
        // Token: 0x0600003F RID: 63 RVA: 0x00004A60 File Offset: 0x00002C60
        public static bool GenDrugResponse(bool isDR, Pawn pawn, HediffDef hdef, ThingDef drugDef = null, BodyPartRecord part = null, List <string> Master = null, int num = 1)
        {
            bool result = false;

            if (drugDef != null)
            {
                if (MSAddDrugBill.GenMSRecipe(pawn, hdef, drugDef, part))
                {
                    result = true;
                }
            }
            else if (isDR)
            {
                string Hdefname = hdef?.defName;
                if (Hdefname != null)
                {
                    string drugdefname = MSDRUtility.GetValueDRDrug(Hdefname, Master, num);
                    if (drugdefname != null)
                    {
                        drugDef = DefDatabase <ThingDef> .GetNamed(drugdefname, false);

                        if (drugDef != null && MSAddDrugBill.GenMSRecipe(pawn, hdef, drugDef, part))
                        {
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }
示例#4
0
 // Token: 0x0600005B RID: 91 RVA: 0x00005C64 File Offset: 0x00003E64
 public static void ClearDRValues(string m, bool doAll, List <string> master, out List <string> newMaster)
 {
     newMaster = new List <string>();
     if (!doAll && master != null && master.Count > 0)
     {
         foreach (string value in master)
         {
             if (MSDRUtility.HValuePart(value) != m)
             {
                 GenCollection.AddDistinct <string>(newMaster, value);
             }
         }
     }
 }
示例#5
0
 // Token: 0x0600005A RID: 90 RVA: 0x00005BF4 File Offset: 0x00003DF4
 public static bool GetValueDRBills(string m, List <string> master)
 {
     if (m != null && master != null && master.Count > 0)
     {
         foreach (string value in master)
         {
             if (MSDRUtility.HValuePart(value) == m)
             {
                 return(MSDRUtility.BValuePart(value));
             }
         }
         return(true);
     }
     return(true);
 }
示例#6
0
 // Token: 0x06000057 RID: 87 RVA: 0x00005A84 File Offset: 0x00003C84
 public static int GetValueDRnumof(string m, List <string> master)
 {
     if (m != null && master != null && master.Count > 0)
     {
         foreach (string value in master)
         {
             if (MSDRUtility.HValuePart(value) == m)
             {
                 return(MSDRUtility.NumValuePart(value));
             }
         }
         return(1);
     }
     return(1);
 }
示例#7
0
 // Token: 0x06000059 RID: 89 RVA: 0x00005B74 File Offset: 0x00003D74
 public static string GetValueDRDrug(string m, List <string> master, int num)
 {
     if (m != null && master != null && master.Count > 0)
     {
         foreach (string value in master)
         {
             string Hdef  = MSDRUtility.HValuePart(value);
             int    numof = MSDRUtility.NumValuePart(value);
             if (Hdef == m && numof == num)
             {
                 return(MSDRUtility.DValuePart(value));
             }
         }
     }
     return(null);
 }
示例#8
0
 // Token: 0x06000054 RID: 84 RVA: 0x00005824 File Offset: 0x00003A24
 public static bool MaladyUsed(string defname)
 {
     if (MSDRUtility.Maladies().Count > 0)
     {
         foreach (string malstring in MSDRUtility.Maladies())
         {
             char[] divider = new char[]
             {
                 ';'
             };
             if (malstring.Split(divider)[1] == defname)
             {
                 return(true);
             }
         }
         return(false);
     }
     return(false);
 }
示例#9
0
        // Token: 0x0600006A RID: 106 RVA: 0x000062D4 File Offset: 0x000044D4
        public override void CompTick()
        {
            int responseTicks = 150;

            if (DRSettings.UsePainManagement && MSDrugUtility.IsValidPawnMod(this.Pawn, true) && Gen.IsHashIntervalTick(this.Pawn, responseTicks))
            {
                Pawn pawn = this.Pawn;
                if ((pawn?.Map) != null)
                {
                    Pawn pawn2 = this.Pawn;
                    if ((pawn2?.CurJob) != null && this.Pawn.CurJob.def != JobDefOf.Ingest)
                    {
                        MSPainResponse.CheckPainResponse(this.Pawn);
                    }
                }
                else if (CaravanUtility.IsCaravanMember(this.Pawn))
                {
                    MSPainResponse.CheckCaravanPainResponse(this.Pawn);
                }
            }
            if (DRSettings.UseDrugResponse && MSDrugUtility.IsValidPawnMod(this.Pawn, false) && Gen.IsHashIntervalTick(this.Pawn, responseTicks + 50))
            {
                Pawn pawn3 = this.Pawn;
                if ((pawn3?.Map) != null)
                {
                    Pawn pawn4 = this.Pawn;
                    if ((pawn4?.CurJob) == null || this.Pawn.CurJob.def == JobDefOf.Ingest)
                    {
                        return;
                    }
                    Pawn      pawn5 = this.Pawn;
                    HediffSet hediffSet;
                    if (pawn5 == null)
                    {
                        hediffSet = null;
                    }
                    else
                    {
                        Pawn_HealthTracker health = pawn5.health;
                        hediffSet = (health?.hediffSet);
                    }
                    HediffSet hedSet = hediffSet;
                    if (hedSet == null || hedSet == null || hedSet.hediffs.Count <= 0)
                    {
                        return;
                    }
                    using (List <Hediff> .Enumerator enumerator = hedSet.hediffs.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff hediff = enumerator.Current;
                            if (hediff.Visible && !MSPainlessData.IsProsthetic(hediff) && MSDRUtility.MaladyUsed(hediff.def.defName))
                            {
                                for (int i = 1; i <= 2; i++)
                                {
                                    if (MSPainlessData.CheckIfResponse(this.Pawn, hediff.def.defName, this.DRResponse, i, out ThingDef drugdef) && MSDrugUtility.IsOKtoAdmin(this.Pawn, hediff.def, drugdef) && !MSDrugUtility.IsViolation(this.Pawn, drugdef))
                                    {
                                        Thing drug = MSDrugUtility.FindDrugFor(this.Pawn, drugdef);
                                        if (drug != null)
                                        {
                                            if ((i < 2 && MSDRUtility.GetValueDRBills(hediff.def.defName, DRSettings.MSDRValues)) || (i > 1 && MSDRUtility.GetValueDRBills(hediff.def.defName, DRSettings.MSDRValues2)) || (this.Pawn.IsPrisoner && DRSettings.DoDRIfPrisoner))
                                            {
                                                if ((i < 2 && MSAddDrugBill.GenDrugResponse(true, this.Pawn, hediff.def, drugdef, null, DRSettings.MSDRValues, i)) || (i > 1 && MSAddDrugBill.GenDrugResponse(true, this.Pawn, hediff.def, drugdef, null, DRSettings.MSDRValues2, i)))
                                                {
                                                    MSPainlessData.SetDRResponseData(this.Pawn, hediff.def.defName, drugdef.defName, Find.TickManager.TicksGame, this.DRResponse, i, out List <string> newDRResponse);
                                                    this.DRResponse = newDRResponse;
                                                    MSPainlessData.DoDRResponseMsg(this.Pawn, hediff.def, drugdef);
                                                }
                                            }
                                            else if (MSPainlessData.IsDRCapable(this.Pawn))
                                            {
                                                Job job = new Job(JobDefOf.Ingest, drug)
                                                {
                                                    count = Mathf.Min(new int[]
                                                    {
                                                        drug.stackCount,
                                                        drug.def.ingestible.maxNumToIngestAtOnce,
                                                        1
                                                    })
                                                };
                                                if (drug.Spawned && this.Pawn.drugs != null && !this.Pawn.inventory.innerContainer.Contains(drug.def))
                                                {
                                                    DrugPolicyEntry drugPolicyEntry = this.Pawn.drugs.CurrentPolicy[drug.def];
                                                    if (drugPolicyEntry.takeToInventory > 0)
                                                    {
                                                        job.takeExtraIngestibles = drugPolicyEntry.takeToInventory;
                                                    }
                                                }
                                                if (this.Pawn.jobs != null && this.Pawn.jobs.curJob != null)
                                                {
                                                    this.Pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, true, true);
                                                    this.Pawn.jobs.ClearQueuedJobs(true);
                                                }
                                                MSPainlessData.SetDRResponseData(this.Pawn, hediff.def.defName, drugdef.defName, Find.TickManager.TicksGame, this.DRResponse, i, out List <string> newDRResponse2);
                                                this.DRResponse = newDRResponse2;
                                                MSPainlessData.DoDRResponseMsg(this.Pawn, hediff.def, drugdef);
                                                this.Pawn.jobs.TryTakeOrderedJob(job, 0);
                                            }
                                        }
                                    }
                                }
                                Pawn_JobTracker jobs = this.Pawn.jobs;
                                if ((jobs?.curJob) != null && this.Pawn.jobs.curJob.def == JobDefOf.Ingest)
                                {
                                    break;
                                }
                            }
                        }
                        return;
                    }
                }
                if (CaravanUtility.IsCaravanMember(this.Pawn))
                {
                    Pawn      pawn6 = this.Pawn;
                    HediffSet hediffSet2;
                    if (pawn6 == null)
                    {
                        hediffSet2 = null;
                    }
                    else
                    {
                        Pawn_HealthTracker health2 = pawn6.health;
                        hediffSet2 = (health2?.hediffSet);
                    }
                    HediffSet hedSet2 = hediffSet2;
                    if (hedSet2 != null && hedSet2 != null && hedSet2.hediffs.Count > 0)
                    {
                        foreach (Hediff hediff2 in hedSet2.hediffs)
                        {
                            if (hediff2.Visible && !MSPainlessData.IsProsthetic(hediff2) && MSDRUtility.MaladyUsed(hediff2.def.defName))
                            {
                                for (int j = 1; j <= 2; j++)
                                {
                                    if (MSPainlessData.CheckIfResponse(this.Pawn, hediff2.def.defName, this.DRResponse, j, out ThingDef drugdef2) && MSDrugUtility.IsOKtoAdmin(this.Pawn, hediff2.def, drugdef2) && !MSDrugUtility.IsViolation(this.Pawn, drugdef2))
                                    {
                                        Caravan car = CaravanUtility.GetCaravan(this.Pawn);
                                        if (car != null && MSCaravanUtility.CaravanHasDrug(car, drugdef2, out Thing drug2, out Pawn owner))
                                        {
                                            MSPainlessData.SetDRResponseData(this.Pawn, hediff2.def.defName, drugdef2.defName, Find.TickManager.TicksGame, this.DRResponse, j, out List <string> newDRResponse3);
                                            this.DRResponse = newDRResponse3;
                                            MSCaravanUtility.PawnOnCaravanTakeDrug(car, this.Pawn, drug2, owner);
                                            MSPainlessData.DoDRResponseMsg(this.Pawn, hediff2.def, drugdef2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#10
0
        // Token: 0x0600006D RID: 109 RVA: 0x000069D0 File Offset: 0x00004BD0
        public static bool CheckIfResponse(Pawn pawn, string hdefname, List <string> ResponseList, int num, out ThingDef drugdef)
        {
            bool result = false;

            drugdef = null;
            string drugdefname;

            if (num < 2)
            {
                drugdefname = MSDRUtility.GetValueDRDrug(hdefname, DRSettings.MSDRValues, num);
            }
            else
            {
                drugdefname = MSDRUtility.GetValueDRDrug(hdefname, DRSettings.MSDRValues2, num);
            }
            if (drugdefname != null)
            {
                int ticksDR;
                if (num < 2)
                {
                    ticksDR = MSDRUtility.GetValueDRTime(hdefname, DRSettings.MSDRValues, num) * 2500;
                }
                else
                {
                    ticksDR = MSDRUtility.GetValueDRTime(hdefname, DRSettings.MSDRValues2, num) * 2500;
                }
                int lasttick = MSPainlessData.GetDRResponseLastTick(pawn, hdefname, ResponseList, num);
                if (lasttick > 0)
                {
                    if (lasttick + ticksDR < Find.TickManager.TicksGame)
                    {
                        result = true;
                    }
                }
                else
                {
                    result = true;
                }
            }
            if (result)
            {
                ThingDef chkdef = DefDatabase <ThingDef> .GetNamed(drugdefname, false);

                if (chkdef != null)
                {
                    drugdef = chkdef;
                }
                else
                {
                    result = false;
                    Log.Message(string.Concat(new string[]
                    {
                        "Warning DR: Missing ThingDef for ",
                        drugdefname,
                        " as response to malady ",
                        hdefname,
                        "(Possible mod list change)"
                    }), false);
                }
            }
            return(result);
        }