static void ExcludeFromStartingRestrictions(FoodRestrictionDatabase __instance) { foreach (var restriction in __instance.AllFoodRestrictions) { foreach (var food in cannibalFoods) { restriction.filter.SetAllow(food, false); } foreach (var food in insectFoods) { restriction.filter.SetAllow(food, false); } } }
static FoodRestriction getDefaultFoodRestriction(FoodRestrictionDatabase database, Pawn_FoodRestrictionTracker tracker) { if (tracker.pawn.RaceProps.Animal) { var comp = Current.Game.GetComponent <AnimalControlsRestrictions>(); if (comp.DefaultRestriction == null) { return(database.DefaultFoodRestriction()); } return(comp.DefaultRestriction); } else { return(database.DefaultFoodRestriction()); } }
public static void FixFoodRestruction(FoodRestrictionDatabase __instance, ref FoodRestriction __result, ref List <FoodRestriction> ___foodRestrictions) { int num; if (___foodRestrictions.Any <FoodRestriction>()) { num = ___foodRestrictions.Max((FoodRestriction o) => o.id) + 1; } else { num = 1; } int id = num; FoodRestriction foodRestriction = new FoodRestriction(id, "FoodRestriction".Translate() + " " + id.ToString()); ThingFilterPatch.thingFilterCallerStack.Push(foodRestriction); foodRestriction.filter.SetAllow(ThingCategoryDefOf.Foods, true, null, null); foodRestriction.filter.SetAllow(ThingCategoryDefOf.CorpsesHumanlike, true, null, null); foodRestriction.filter.SetAllow(ThingCategoryDefOf.CorpsesAnimal, true, null, null); ThingFilterPatch.thingFilterCallerStack.Pop(); ___foodRestrictions.Add(foodRestriction); __result = foodRestriction; }
public static bool Prefix(FoodRestrictionDatabase __instance) { FixFoodRestrictions(__instance); return(false); }
public static void FixFoodRestrictions(FoodRestrictionDatabase __instance) { FoodRestriction lavishRestriction = __instance.MakeNewFoodRestriction(); lavishRestriction.label = "FoodRestrictionLavish".Translate(); FoodRestriction fineRestriction = __instance.MakeNewFoodRestriction(); fineRestriction.label = "FoodRestrictionFine".Translate(); ThingFilterPatch.thingFilterCallerStack.Push(fineRestriction); foreach (ThingDef thingDef in DefDatabase <ThingDef> .AllDefs) { if (thingDef.ingestible != null && thingDef.ingestible.preferability >= FoodPreferability.MealLavish && thingDef != ThingDefOf.InsectJelly) { fineRestriction.filter.SetAllow(thingDef, false); } } ThingFilterPatch.thingFilterCallerStack.Pop(); FoodRestriction simpleRestriction = __instance.MakeNewFoodRestriction(); simpleRestriction.label = "FoodRestrictionSimple".Translate(); ThingFilterPatch.thingFilterCallerStack.Push(simpleRestriction); foreach (ThingDef thingDef2 in DefDatabase <ThingDef> .AllDefs) { if (thingDef2.ingestible != null && thingDef2.ingestible.preferability >= FoodPreferability.MealFine && thingDef2 != ThingDefOf.InsectJelly) { simpleRestriction.filter.SetAllow(thingDef2, false); } } simpleRestriction.filter.SetAllow(ThingDefOf.MealSurvivalPack, false); ThingFilterPatch.thingFilterCallerStack.Pop(); FoodRestriction pasteRestriction = __instance.MakeNewFoodRestriction(); pasteRestriction.label = "FoodRestrictionPaste".Translate(); ThingFilterPatch.thingFilterCallerStack.Push(pasteRestriction); foreach (ThingDef thingDef3 in DefDatabase <ThingDef> .AllDefs) { if (thingDef3.ingestible != null && thingDef3.ingestible.preferability >= FoodPreferability.MealSimple && thingDef3 != ThingDefOf.MealNutrientPaste && thingDef3 != ThingDefOf.InsectJelly && thingDef3 != ThingDefOf.Pemmican) { pasteRestriction.filter.SetAllow(thingDef3, false); } } ThingFilterPatch.thingFilterCallerStack.Pop(); FoodRestriction rawRestriction = __instance.MakeNewFoodRestriction(); rawRestriction.label = "FoodRestrictionRaw".Translate(); ThingFilterPatch.thingFilterCallerStack.Push(rawRestriction); foreach (ThingDef thingDef4 in DefDatabase <ThingDef> .AllDefs) { if (thingDef4.ingestible != null && thingDef4.ingestible.preferability >= FoodPreferability.MealAwful) { rawRestriction.filter.SetAllow(thingDef4, false); } } rawRestriction.filter.SetAllow(ThingDefOf.Chocolate, false); ThingFilterPatch.thingFilterCallerStack.Pop(); FoodRestriction foodRestriction6 = __instance.MakeNewFoodRestriction(); foodRestriction6.label = "FoodRestrictionNothing".Translate(); ThingFilterPatch.thingFilterCallerStack.Push(foodRestriction6); foodRestriction6.filter.SetDisallowAll(null, null); ThingFilterPatch.thingFilterCallerStack.Pop(); }
public override void PostExposeData(object obj) { if (Scribe.mode == LoadSaveMode.LoadingVars) { Game game = obj as Game; if (game != null && game.questManager == null) { game.questManager = new QuestManager(); } Zone zone = obj as Zone; if (zone != null && zone.ID == -1) { zone.ID = Find.UniqueIDsManager.GetNextZoneID(); } } if (Scribe.mode != LoadSaveMode.PostLoadInit) { return; } Pawn pawn = obj as Pawn; if (pawn != null && pawn.royalty == null) { pawn.royalty = new Pawn_RoyaltyTracker(pawn); } Pawn_NativeVerbs pawn_NativeVerbs = obj as Pawn_NativeVerbs; if (pawn_NativeVerbs != null && pawn_NativeVerbs.verbTracker == null) { pawn_NativeVerbs.verbTracker = new VerbTracker(pawn_NativeVerbs); } Thing thing = obj as Thing; if (thing != null) { if (thing.def.defName == "Sandbags" && thing.Stuff == null) { thing.SetStuffDirect(ThingDefOf.Cloth); } if (thing.def == ThingDefOf.MechCapsule) { foreach (XmlNode oldCrashedShipPart in oldCrashedShipParts) { XmlElement xmlElement = oldCrashedShipPart["def"]; XmlElement xmlElement2 = oldCrashedShipPart["id"]; if (xmlElement != null && xmlElement2 != null && Thing.IDNumberFromThingID(xmlElement2.InnerText) == thing.thingIDNumber) { upgradedCrashedShipParts.Add(new UpgradedCrashedShipPart { originalDefName = xmlElement.InnerText, thing = thing }); } } } } StoryWatcher storyWatcher = obj as StoryWatcher; if (storyWatcher != null) { if (storyWatcher.watcherAdaptation == null) { storyWatcher.watcherAdaptation = new StoryWatcher_Adaptation(); } if (storyWatcher.watcherPopAdaptation == null) { storyWatcher.watcherPopAdaptation = new StoryWatcher_PopAdaptation(); } } FoodRestrictionDatabase foodRestrictionDatabase = obj as FoodRestrictionDatabase; if (foodRestrictionDatabase != null && VersionControl.BuildFromVersionString(ScribeMetaHeaderUtility.loadedGameVersion) < 2057) { List <FoodRestriction> allFoodRestrictions = foodRestrictionDatabase.AllFoodRestrictions; for (int i = 0; i < allFoodRestrictions.Count; i++) { allFoodRestrictions[i].filter.SetAllow(ThingCategoryDefOf.CorpsesHumanlike, allow: true); allFoodRestrictions[i].filter.SetAllow(ThingCategoryDefOf.CorpsesAnimal, allow: true); } } SitePart sitePart = obj as SitePart; if (sitePart != null) { sitePart.hidden = sitePart.def.defaultHidden; } }
public static bool Prefix(ref FoodRestriction __result, FoodRestrictionDatabase __instance, ref List <FoodRestriction> ___foodRestrictions) { FixFoodRestruction(__instance, ref __result, ref ___foodRestrictions); return(false); }