public static string ToStringHuman(this FoodPoisonCause cause) { string result; switch (cause) { case FoodPoisonCause.Unknown: result = "Unknown".Translate(); break; case FoodPoisonCause.IncompetentCook: result = "FoodPoisonCause_IncompetentCook".Translate(); break; case FoodPoisonCause.FilthyKitchen: result = "FoodPoisonCause_FilthyKitchen".Translate(); break; case FoodPoisonCause.Rotten: result = "FoodPoisonCause_Rotten".Translate(); break; case FoodPoisonCause.DangerousFoodType: result = "FoodPoisonCause_DangerousFoodType".Translate(); break; default: result = cause.ToString(); break; } return(result); }
private static bool Prefix(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { if (pawn.HasTrait(VTEDefOf.VTE_IronStomach)) { return(false); } return(true); }
public override void PreAbsorbStack(Thing otherStack, int count) { base.PreAbsorbStack(otherStack, count); CompFoodPoisonable compFoodPoisonable = otherStack.TryGetComp <CompFoodPoisonable>(); this.poisonPct = GenMath.WeightedAverage(this.poisonPct, (float)this.parent.stackCount, compFoodPoisonable.poisonPct, (float)count); this.cause = ((count <= this.parent.stackCount) ? this.cause : compFoodPoisonable.cause); }
public static bool AddFoodPoisoningHediffPrefix(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { if (pawn.IsOrk()) { return(false); } return(true); }
public static void AddFoodPoisoningHediff(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { pawn.health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.FoodPoisoning, pawn)); if (PawnUtility.ShouldSendNotificationAbout(pawn) && MessagesRepeatAvoider.MessageShowAllowed("MessageFoodPoisoning-" + pawn.thingIDNumber, 0.1f)) { string text = "MessageFoodPoisoning".Translate(pawn.LabelShort, ingestible.LabelCapNoCount, cause.ToStringHuman().CapitalizeFirst(), pawn.Named("PAWN"), ingestible.Named("FOOD")).CapitalizeFirst(); Messages.Message(text, pawn, MessageTypeDefOf.NegativeEvent); } }
public static string ToStringHuman(this FoodPoisonCause cause) { return(cause switch { FoodPoisonCause.Unknown => "UnknownLower".Translate().CapitalizeFirst(), FoodPoisonCause.IncompetentCook => "FoodPoisonCause_IncompetentCook".Translate(), FoodPoisonCause.FilthyKitchen => "FoodPoisonCause_FilthyKitchen".Translate(), FoodPoisonCause.Rotten => "FoodPoisonCause_Rotten".Translate(), FoodPoisonCause.DangerousFoodType => "FoodPoisonCause_DangerousFoodType".Translate(), _ => cause.ToString(), });
public override void PreAbsorbStack(Thing otherStack, int count) { base.PreAbsorbStack(otherStack, count); CompFoodPoisonable compFoodPoisonable = otherStack.TryGetComp <CompFoodPoisonable>(); if (cause == FoodPoisonCause.Unknown && compFoodPoisonable.cause != 0) { cause = compFoodPoisonable.cause; } else if (compFoodPoisonable.cause != 0 || cause != 0) { float num = poisonPct * (float)parent.stackCount; float num2 = compFoodPoisonable.poisonPct * (float)count; cause = ((!(num > num2)) ? compFoodPoisonable.cause : cause); } poisonPct = GenMath.WeightedAverage(poisonPct, (float)parent.stackCount, compFoodPoisonable.poisonPct, (float)count); }
public override void PreAbsorbStack(Thing otherStack, int count) { base.PreAbsorbStack(otherStack, count); CompFoodPoisonable compFoodPoisonable = otherStack.TryGetComp <CompFoodPoisonable>(); if (this.cause == FoodPoisonCause.Unknown && compFoodPoisonable.cause != FoodPoisonCause.Unknown) { this.cause = compFoodPoisonable.cause; } else if (compFoodPoisonable.cause != FoodPoisonCause.Unknown || this.cause != FoodPoisonCause.Unknown) { float num = this.poisonPct * (float)this.parent.stackCount; float num2 = compFoodPoisonable.poisonPct * (float)count; this.cause = ((num <= num2) ? compFoodPoisonable.cause : this.cause); } this.poisonPct = GenMath.WeightedAverage(this.poisonPct, (float)this.parent.stackCount, compFoodPoisonable.poisonPct, (float)count); }
public static void AddFoodPoisoningHediff(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.FoodPoisoning); if (firstHediffOfDef != null) { if (firstHediffOfDef.CurStageIndex != 2) { firstHediffOfDef.Severity = HediffDefOf.FoodPoisoning.stages[2].minSeverity - 0.001f; } } else { pawn.health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.FoodPoisoning, pawn)); } if (PawnUtility.ShouldSendNotificationAbout(pawn) && MessagesRepeatAvoider.MessageShowAllowed("MessageFoodPoisoning-" + pawn.thingIDNumber, 0.1f)) { Messages.Message("MessageFoodPoisoning".Translate(pawn.LabelShort, ingestible.LabelCapNoCount, cause.ToStringHuman().CapitalizeFirst(), pawn.Named("PAWN"), ingestible.Named("FOOD")).CapitalizeFirst(), pawn, MessageTypeDefOf.NegativeEvent); } }
} // end method public static bool FoodUtility__AddFoodPoisoningHediffPrefix (Pawn pawn, Thing ingestible, FoodPoisonCause cause) { if // ... #region if-statement // Check if it's a Momu who just ate a dangerous food type. (pawn.def == MomuDefOf.Alien_Momu && cause == FoodPoisonCause.DangerousFoodType && // We only want to protect against food poisoning if the Momu ate plant matter or veggie food. ingestible.def.thingCategories.All( cat => cat == ThingCategoryDefOf.PlantFoodRaw || cat == ThingCategoryDefOf.PlantMatter)) #endregion if-statement { // We now know it's a Momu who ate some kind of raw vegetarian food, so we must stop this. return(false); } return(true); } // end method
static bool Prefix(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { if (cause == FoodPoisonCause.DangerousFoodType) { var ignoreChance = 1 - pawn.GetStatValue(PMStatDefOf.DangerousFoodSensitivity); if (Rand.Value < ignoreChance) { return(false); //do not add food poisoning } } else if (cause == FoodPoisonCause.Rotten) { var ignoreChance = 1 - pawn.GetStatValue(PMStatDefOf.RottenFoodSensitivity); if (Rand.Value < ignoreChance) { return(false); //do not add food poisoning } } return(true); }
public static string ToStringHuman(this FoodPoisonCause cause) { switch (cause) { case FoodPoisonCause.Unknown: return("UnknownLower".Translate().CapitalizeFirst()); case FoodPoisonCause.IncompetentCook: return("FoodPoisonCause_IncompetentCook".Translate()); case FoodPoisonCause.FilthyKitchen: return("FoodPoisonCause_FilthyKitchen".Translate()); case FoodPoisonCause.Rotten: return("FoodPoisonCause_Rotten".Translate()); case FoodPoisonCause.DangerousFoodType: return("FoodPoisonCause_DangerousFoodType".Translate()); default: return(cause.ToString()); } }
public static bool Prefix(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { // Log.Message(string.Format("checkin if {0} can get food poisioning from {1} because {2}", pawn.Name, ingestible, cause)); CompFoodPoisonProtection compFood = pawn.TryGetComp <CompFoodPoisonProtection>(); if (compFood != null) { if (!compFood.Props.Poisonable) { // Log.Message(string.Format("stopped {0} getting food poisioning from {1} because compFood.Props.Poisonable {2}", pawn.Name, ingestible, compFood.Props.Poisonable)); return(false); } if (!compFood.Props.FoodTypeFlags.NullOrEmpty <FoodTypeFlags>()) { foreach (var ftf in compFood.Props.FoodTypeFlags) { if (ftf == ingestible.def.ingestible.foodType) { // Log.Message(string.Format("stopped {0} getting food poisioning from {1} because {2}", pawn.Name, ingestible, ingestible.def.ingestible.foodType)); return(false); } } } if (!compFood.Props.FoodPoisonCause.NullOrEmpty <FoodPoisonCause>()) { foreach (var fpc in compFood.Props.FoodPoisonCause) { if (fpc == cause) { // Log.Message(string.Format("stopped {0} getting food poisioning from {1} because {2}", pawn.Name, ingestible, cause)); return(false); } } } } return(true); }
public static bool Pre_AddFoodPoisoningHediff_Orkoid(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { // Log.Message(string.Format("checkin if {0} can get food poisioning from {1} because {2}", pawn.Name, ingestible ,cause)); if (pawn.kindDef.race == OGOrkThingDefOf.Alien_Ork || pawn.kindDef.race == OGOrkThingDefOf.Alien_Grot || pawn.kindDef.race == OGOrkThingDefOf.Cyborg_Ork || pawn.kindDef.race == OGOrkThingDefOf.Snotling || pawn.kindDef.race == OGOrkThingDefOf.Squig || pawn.kindDef.race == OGOrkThingDefOf.AttackSquig) { if (ingestible.def.ingestible.foodType == FoodTypeFlags.Meat) { // Log.Message(string.Format("stopped {0} getting food poisioning from {1} because {2}", pawn.Name, ingestible, ingestible.def.ingestible.foodType)); return(false); } if (cause == FoodPoisonCause.DangerousFoodType) { // Log.Message(string.Format("stopped {0} getting food poisioning from {1} because {2}", pawn.Name, ingestible, cause)); return(false); } } return(true); }
public void SetPoisoned(FoodPoisonCause newCause) { this.poisonPct = 1f; this.cause = newCause; }
public static bool Prefix(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { return(!ImmuneToFP(pawn, HediffDefOf.FoodPoisoning)); }
public static bool Prefix(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { return(!FoodUtility_AddFoodPoisoningHediff_prepatch.ImmuneToFP(pawn, HediffDefOf.FoodPoisoning)); }
public static bool Prefix_AddFoodPoisoningHediff_Orkoid(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { if (pawn.kindDef.race == OGOrkThingDefOf.OG_Alien_Ork || pawn.kindDef.race == OGOrkThingDefOf.OG_Alien_Grot || pawn.kindDef.race == OGOrkThingDefOf.OG_Snotling || pawn.kindDef.race == OGOrkThingDefOf.OG_Squig || pawn.kindDef.race == OGOrkThingDefOf.OG_Squig_Ork) { if (ingestible.def.ingestible.foodType == FoodTypeFlags.Meat) { return(false); } if (cause == FoodPoisonCause.DangerousFoodType) { return(false); } } return(true); }
public void SetPoisoned(FoodPoisonCause newCause) { poisonPct = 1f; cause = newCause; }
private static bool PostSplitOff_Prefix(CompFoodPoisonable __instance, ref float ___poisonPct, FoodPoisonCause ___cause, Thing piece) { CompFoodPoisonable compFoodPoisonable = piece.TryGetComp <CompFoodPoisonable>(); if (__instance.parent.thingIDNumber == piece.thingIDNumber) { return(false); } var poisoned = (int)___poisonPct; var otherPoisoned = 0; if (poisoned < 1) { return(false); } for (int i = 0; i < piece.stackCount; i++) { float chance = (float)(poisoned - otherPoisoned) / (float)(__instance.parent.stackCount + piece.stackCount - i); if (Rand.Chance(chance)) { otherPoisoned++; poisoned--; } if (poisoned < 1) { break; } } if (otherPoisoned > 0) { Traverse.Create(compFoodPoisonable).Field("poisonPct").SetValue((float)(otherPoisoned)); compFoodPoisonable.cause = ___cause; ___poisonPct = (float)poisoned; } return(false); }
// Token: 0x06000018 RID: 24 RVA: 0x00002838 File Offset: 0x00000A38 public static bool Pre_AddFoodPoisoningHediff_CompCheck(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { CompFoodPoisonProtection compFoodPoisonProtection = pawn.TryGetComp <CompFoodPoisonProtection>(); bool flag = compFoodPoisonProtection != null; if (flag) { bool flag2 = !compFoodPoisonProtection.Props.Poisonable; if (flag2) { return(false); } bool flag3 = !compFoodPoisonProtection.Props.FoodTypeFlags.NullOrEmpty <FoodTypeFlags>(); if (flag3) { foreach (FoodTypeFlags foodTypeFlags in compFoodPoisonProtection.Props.FoodTypeFlags) { bool flag4 = foodTypeFlags == ingestible.def.ingestible.foodType; if (flag4) { return(false); } } } bool flag5 = !compFoodPoisonProtection.Props.FoodPoisonCause.NullOrEmpty <FoodPoisonCause>(); if (flag5) { foreach (FoodPoisonCause foodPoisonCause in compFoodPoisonProtection.Props.FoodPoisonCause) { bool flag6 = foodPoisonCause == cause; if (flag6) { return(false); } } } } return(true); }