public override bool StateCanOccur(Pawn pawn) { if (!base.StateCanOccur(pawn)) { return(false); } if (!pawn.Spawned) { return(false); } List <ChemicalDef> allDefsListForReading = DefDatabase <ChemicalDef> .AllDefsListForReading; for (int i = 0; i < allDefsListForReading.Count; i++) { if (AddictionUtility.CanBingeOnNow(pawn, allDefsListForReading[i], def.drugCategory)) { return(true); } if (def.drugCategory == DrugCategory.Hard && AddictionUtility.CanBingeOnNow(pawn, allDefsListForReading[i], DrugCategory.Social)) { return(true); } } return(false); }
private int BingeableAddictionsCount(Pawn pawn) { int num = 0; List <Hediff> hediffs = pawn.health.hediffSet.hediffs; for (int i = 0; i < hediffs.Count; i++) { Hediff_Addiction hediff_Addiction = hediffs[i] as Hediff_Addiction; if (hediff_Addiction != null && AddictionUtility.CanBingeOnNow(pawn, hediff_Addiction.Chemical, DrugCategory.Any)) { num++; } } return(num); }
private void ChooseRandomChemical() { addictions.Clear(); List <Hediff> hediffs = pawn.health.hediffSet.hediffs; for (int i = 0; i < hediffs.Count; i++) { Hediff_Addiction hediff_Addiction = hediffs[i] as Hediff_Addiction; if (hediff_Addiction != null && AddictionUtility.CanBingeOnNow(pawn, hediff_Addiction.Chemical, DrugCategory.Any)) { addictions.Add(hediff_Addiction.Chemical); } } if (addictions.Count > 0) { chemical = addictions.RandomElement(); drugCategory = DrugCategory.Any; addictions.Clear(); } else { chemical = (from x in DefDatabase <ChemicalDef> .AllDefsListForReading where AddictionUtility.CanBingeOnNow(pawn, x, def.drugCategory) select x).RandomElementWithFallback(); if (chemical != null) { drugCategory = def.drugCategory; } else { chemical = (from x in DefDatabase <ChemicalDef> .AllDefsListForReading where AddictionUtility.CanBingeOnNow(pawn, x, DrugCategory.Any) select x).RandomElementWithFallback(); if (chemical != null) { drugCategory = DrugCategory.Any; } else { chemical = DefDatabase <ChemicalDef> .AllDefsListForReading.RandomElement(); drugCategory = DrugCategory.Any; } } } }
private void ChooseRandomChemical() { MentalState_BingingDrug.addictions.Clear(); List <Hediff> hediffs = this.pawn.health.hediffSet.hediffs; for (int i = 0; i < hediffs.Count; i++) { Hediff_Addiction hediff_Addiction = hediffs[i] as Hediff_Addiction; if (hediff_Addiction != null && AddictionUtility.CanBingeOnNow(this.pawn, hediff_Addiction.Chemical, DrugCategory.Any)) { MentalState_BingingDrug.addictions.Add(hediff_Addiction.Chemical); } } if (MentalState_BingingDrug.addictions.Count > 0) { this.chemical = MentalState_BingingDrug.addictions.RandomElement <ChemicalDef>(); this.drugCategory = DrugCategory.Any; MentalState_BingingDrug.addictions.Clear(); } else { this.chemical = (from x in DefDatabase <ChemicalDef> .AllDefsListForReading where AddictionUtility.CanBingeOnNow(this.pawn, x, this.def.drugCategory) select x).RandomElementWithFallback(null); if (this.chemical != null) { this.drugCategory = this.def.drugCategory; } else { this.chemical = (from x in DefDatabase <ChemicalDef> .AllDefsListForReading where AddictionUtility.CanBingeOnNow(this.pawn, x, DrugCategory.Any) select x).RandomElementWithFallback(null); if (this.chemical != null) { this.drugCategory = DrugCategory.Any; } else { this.chemical = DefDatabase <ChemicalDef> .AllDefsListForReading.RandomElement <ChemicalDef>(); this.drugCategory = DrugCategory.Any; } } } }
private void ChooseRandomChemical() { addictions.Clear(); List <Hediff> hediffs = pawn.health.hediffSet.hediffs; for (var i = 0; i < hediffs.Count; i++) { var hediff_Addiction = hediffs[i] as Hediff_Addiction; if (hediff_Addiction != null && AddictionUtility.CanBingeOnNow(pawn, hediff_Addiction.Chemical, DrugCategory.Any)) { addictions.Add(hediff_Addiction.Chemical); } } if (addictions.Count > 0) { chemical = addictions.RandomElement(); drugCategory = DrugCategory.Any; addictions.Clear(); return; } chemical = DefDatabase <ChemicalDef> .AllDefsListForReading.Where(IsValidChemical).RandomElementWithFallback(); if (chemical != null) { drugCategory = def.drugCategory; return; } chemical = DefDatabase <ChemicalDef> .AllDefsListForReading.Where(IsValidChemical).RandomElementWithFallback(); if (chemical != null) { drugCategory = DrugCategory.Any; return; } chemical = DefDatabase <ChemicalDef> .AllDefsListForReading.RandomElement(); drugCategory = DrugCategory.Any; }
private bool <ChooseRandomChemical> m__1(ChemicalDef x) { return(AddictionUtility.CanBingeOnNow(this.pawn, x, DrugCategory.Any)); }