protected override void IngestedCalculateAmounts(Pawn ingester, float nutritionWanted, out int numTaken, out float nutritionIngested) { BodyPartRecord bodyPartRecord = GetBestBodyPartToEat(ingester, nutritionWanted); if (bodyPartRecord == null) { Log.Error(ingester + " ate " + this + " but no body part was found. Replacing with core part."); bodyPartRecord = InnerPawn.RaceProps.body.corePart; } float bodyPartNutrition = FoodUtility.GetBodyPartNutrition(this, bodyPartRecord); if (bodyPartRecord == InnerPawn.RaceProps.body.corePart) { if (PawnUtility.ShouldSendNotificationAbout(InnerPawn) && InnerPawn.RaceProps.Humanlike) { Messages.Message("MessageEatenByPredator".Translate(InnerPawn.LabelShort, ingester.Named("PREDATOR"), InnerPawn.Named("EATEN")).CapitalizeFirst(), ingester, MessageTypeDefOf.NegativeEvent); } numTaken = 1; } else { Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, InnerPawn, bodyPartRecord); hediff_MissingPart.lastInjury = HediffDefOf.Bite; hediff_MissingPart.IsFresh = true; InnerPawn.health.AddHediff(hediff_MissingPart); numTaken = 0; } nutritionIngested = bodyPartNutrition; }
protected override void IngestedCalculateAmounts(Pawn ingester, float nutritionWanted, out int numTaken, out float nutritionIngested) { //Determine part to take var part = GetBestBodyPartToEat(ingester, nutritionWanted); if (part == null) { Log.Error(ingester + " ate " + this + " but no body part was found. Replacing with core part."); part = InnerPawn.RaceProps.body.corePart; } //Determine the nutrition to gain float nut = FoodUtility.GetBodyPartNutrition(this, part); //Affect this thing //If ate core part, remove the whole corpse //Otherwise, remove the eaten body part if (part == InnerPawn.RaceProps.body.corePart) { if (PawnUtility.ShouldSendNotificationAbout(InnerPawn) && InnerPawn.RaceProps.Humanlike) { Messages.Message("MessageEatenByPredator".Translate(InnerPawn.LabelShort, ingester.Named("PREDATOR"), InnerPawn.Named("EATEN")).CapitalizeFirst(), ingester, MessageTypeDefOf.NegativeEvent); } numTaken = 1; } else { var missing = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, InnerPawn, part); missing.lastInjury = HediffDefOf.Bite; missing.IsFresh = true; InnerPawn.health.AddHediff(missing); numTaken = 0; } nutritionIngested = nut; }