public static void ThoughtsFromIngestingPostfix(Pawn ingester, Thing foodSource, ref List <ThoughtDef> __result) { if (ingester.story.traits.HasTrait(tDef: AlienDefOf.Xenophobia) && ingester.story.traits.DegreeOfTrait(tDef: AlienDefOf.Xenophobia) == 1) { if (__result.Contains(item: ThoughtDefOf.AteHumanlikeMeatDirect) && foodSource.def.ingestible.sourceDef != ingester.def) { __result.Remove(item: ThoughtDefOf.AteHumanlikeMeatDirect); } else if (__result.Contains(item: ThoughtDefOf.AteHumanlikeMeatAsIngredient) && (foodSource.TryGetComp <CompIngredients>()?.ingredients.Any(predicate: td => FoodUtility.IsHumanlikeMeat(def: td) && td.ingestible.sourceDef != ingester.def) ?? false)) { __result.Remove(item: ThoughtDefOf.AteHumanlikeMeatAsIngredient); } } if (!(ingester.def is ThingDef_AlienRace alienProps)) { return; } bool cannibal = ingester.story.traits.HasTrait(tDef: TraitDefOf.Cannibal); for (int i = 0; i < __result.Count; i++) { ThoughtDef thoughtDef = __result[index : i]; ThoughtSettings settings = alienProps.alienRace.thoughtSettings; thoughtDef = settings.ReplaceIfApplicable(def: thoughtDef); if (thoughtDef == ThoughtDefOf.AteHumanlikeMeatDirect || thoughtDef == ThoughtDefOf.AteHumanlikeMeatDirectCannibal) { thoughtDef = settings.GetAteThought(race: foodSource.def.ingestible.sourceDef, cannibal: cannibal, ingredient: false); } if (thoughtDef == ThoughtDefOf.AteHumanlikeMeatAsIngredient || thoughtDef == ThoughtDefOf.AteHumanlikeMeatAsIngredientCannibal) { ThingDef race = null; if (foodSource.TryGetComp <CompIngredients>() != null && foodSource.TryGetComp <CompIngredients>() is CompIngredients ingeds) { foreach (var item in ingeds.ingredients) { if (item.ingestible.sourceDef != null && item.ingestible.sourceDef.race != null && item.ingestible.sourceDef.race.Humanlike) { race = (item.ingestible.sourceDef); } } } if (race != null) { thoughtDef = settings.GetAteThought(race: race, cannibal: cannibal, ingredient: true); } } __result[index : i] = thoughtDef; } }
/// <summary> /// generate AlienRace thought settings with the given morph def /// </summary> /// <param name="humanDefault"></param> /// <param name="morphDef"></param> /// <returns></returns> public ThoughtSettings GenerateThoughtSettings(ThoughtSettings humanDefault, MorphDef morphDef) { if (thoughtSettings == null) { return(humanDefault); } var animalRace = morphDef.race; List <AteThought> spc = new List <AteThought>(thoughtSettings.ateThoughtsSpecifics); List <ButcherThought> butcherSpc = new List <ButcherThought>(thoughtSettings.butcherThoughtsSpecifics); //make copies if (thoughtSettings.ateAnimalThought != null) { spc.Add(new AteThought { thought = thoughtSettings.ateAnimalThought.thought, ingredientThought = thoughtSettings.ateAnimalThought.ingredientThought, raceList = new List <ThingDef> { animalRace } }); } if (thoughtSettings.butcheredAnimalThought != null) { butcherSpc.Add(new ButcherThought() { thought = thoughtSettings.butcheredAnimalThought.thought, knowThought = thoughtSettings.butcheredAnimalThought.knowThought, raceList = new List <ThingDef> { animalRace } }); } List <ThoughtDef> blackList; if (thoughtSettings.thoughtsBlackList != null) { blackList = new List <ThoughtDef>(thoughtSettings.thoughtsBlackList); } else { blackList = null; } if (thoughtSettings.suppressHumanlikeCannibalThoughts) //add in the default cannibal thoughts to the black list { blackList = blackList ?? new List <ThoughtDef>(); blackList.Add(ThoughtDefOf.AteHumanlikeMeatDirect); blackList.Add(ThoughtDefOf.AteHumanlikeMeatAsIngredient); blackList.Add(ThoughtDefOf.ButcheredHumanlikeCorpse); blackList.Add(ThoughtDefOf.KnowButcheredHumanlikeCorpse); } if (thoughtSettings.canEatRaw) { blackList = blackList ?? new List <ThoughtDef>(); blackList.Add(ThoughtDefOf.AteRawFood); } return(new ThoughtSettings { replacerList = thoughtSettings.replacerList, butcherThoughtSpecific = butcherSpc, ateThoughtSpecific = spc, cannotReceiveThoughts = blackList }); }