예제 #1
0
 static void Postfix(Thing t, Pawn pawn, ref bool __result)
 {
     //if the normal forbid did not trigger we check custom restrictions
     if (!__result && ThingForbiddenContext.checkIntent)
     {
         __result = ThingForbiddenContext.IsForbidden(t.def);
     }
 }
예제 #2
0
 static void Postfix()
 {
     ThingForbiddenContext.ReleaseIntent();
 }
예제 #3
0
 static bool Prefix(Pawn getter, Pawn eater)
 {
     //TryFindBestFoodSourceFor(Pawn getter, Pawn eater, bool desperate, out Thing foodSource, out ThingDef foodDef, bool canRefillDispenser = true, bool canUseInventory = true, bool allowForbidden = false, bool allowCorpse = true, bool allowSociallyImproper = false, bool allowHarvest = false)
     ThingForbiddenContext.RecordIntent("QOL.food", new IntentContext_Food(eater, getter));
     return(true);
 }
예제 #4
0
 static bool Prefix(Pawn getter, Pawn eater)
 {
     //public static Thing BestFoodSourceOnMap(Pawn getter, Pawn eater, bool desperate, out ThingDef foodDef, FoodPreferability maxPref = FoodPreferability.MealLavish, bool allowPlant = true, bool allowDrug = true, bool allowCorpse = true, bool allowDispenserFull = true, bool allowDispenserEmpty = true, bool allowForbidden = false, bool allowSociallyImproper = false, bool allowHarvest = false)
     ThingForbiddenContext.RecordIntent("QOL.food", new IntentContext_Food(eater, getter));
     return(true);
 }
예제 #5
0
 public void SynchronizeRules()
 {
     /*
      * 2. Restrict non starving faction members from eating preserved food to allow stockpiling travel rations.
      * 3. Restrict non starving colonists with mood above x from eating meals better than simple.
      * 4. Restrict non starving colonists with ascetics trait from eating better than simple.
      * 5. Restrict non starving faction animals from eating meals.
      * 6. Restrict non starving non colonist prisoners not marked for recruiting from eating meals better than simple.
      * 7. Restrict non starving non colonist prisoners marked for recruiting with mood above 0.8f from eating meals better than simple. (mood 0.5,1.0f -> 1.0,1.5f)
      *
      * taming only uses raw tasty
      */
     if (restrictEatingIngredients)
     {
         ThingForbiddenContext.SetRule("QOL.restrictEatingIngredients", new [] { "QOL.food" }, (con) => {
             IntentContext_Food icf = con as IntentContext_Food;
             if (icf != null)
             {
                 return(icf.eater.IsColonist);
             }
             return(false);
         },
                                       DefDatabase <ThingDef> .AllDefsListForReading.Where(t => t.IsNutritionGivingIngestible && !t.ingestible.IsMeal &&
                                                                                           (!HasThingCategory(t, ThingCategoryDefOf.Foods) || HasThingCategory(t, DefDatabase <ThingCategoryDef> .GetNamed("FoodRaw"))) &&
                                                                                           (t.plant == null || t.plant.Harvestable)));
         ThingForbiddenContext.SetRule("QOL.restrictEatingIngredientsNonHumanlike", new [] { "QOL.food" }, (con) => {
             IntentContext_Food icf = con as IntentContext_Food;
             if (icf != null)
             {
                 return(icf.eater.Faction != null && icf.eater.Faction.IsPlayer && icf.eater.RaceProps.Animal);
             }
             return(false);
         },
                                       DefDatabase <ThingDef> .AllDefsListForReading.Where(t => t.IsNutritionGivingIngestible && !t.ingestible.IsMeal &&
                                                                                           (!HasThingCategory(t, ThingCategoryDefOf.Foods) || HasThingCategory(t, DefDatabase <ThingCategoryDef> .GetNamed("FoodRaw"))) &&
                                                                                           !(t.IsCorpse && t.race != null && t.race.Humanlike) &&
                                                                                           (t.plant == null || t.plant.Harvestable)));
     }
     else
     {
         ThingForbiddenContext.RemoveRule("QOL.restrictEatingIngredients");
         ThingForbiddenContext.RemoveRule("QOL.restrictEatingIngredientsNonHumanlike");
     }
     if (restrictEatingPreservedFood)
     {
         ThingForbiddenContext.SetRule("QOL.restrictEatingPreservedFood", new [] { "QOL.food" }, (con) => {
             IntentContext_Food icf = con as IntentContext_Food;
             if (icf != null)
             {
                 return(icf.eater.needs.food.CurLevelPercentage > icf.eater.needs.food.PercentageThreshUrgentlyHungry &&
                        icf.getter.Faction != null && icf.getter.Faction.IsPlayer);
             }
             return(false);
         },
                                       DefDatabase <ThingDef> .AllDefsListForReading.Where(t => t.IsNutritionGivingIngestible && !t.HasComp(typeof(CompRottable))));
     }
     else
     {
         ThingForbiddenContext.RemoveRule("QOL.restrictEatingPreservedFood");
     }
     if (restrictMoodBoostFood)
     {
         ThingForbiddenContext.SetRule("QOL.restrictMoodBoostFood", new [] { "QOL.food" }, (con) => {
             IntentContext_Food icf = con as IntentContext_Food;
             if (icf != null)
             {
                 return(icf.eater.IsColonist && icf.eater.needs.food.CurLevelPercentage > icf.eater.needs.food.PercentageThreshUrgentlyHungry &&
                        icf.eater.needs.mood.CurLevel > icf.eater.mindState.mentalBreaker.BreakThresholdMinor);
             }
             return(false);
         },
                                       DefDatabase <ThingDef> .AllDefsListForReading.Where(t => t.IsNutritionGivingIngestible && t.ingestible.preferability > FoodPreferability.MealSimple));
     }
     else
     {
         ThingForbiddenContext.RemoveRule("QOL.restrictMoodBoostFood");
     }
     if (restrictAscetics)
     {
         ThingForbiddenContext.SetRule("QOL.restrictAscetics", new [] { "QOL.food" }, (con) => {
             IntentContext_Food icf = con as IntentContext_Food;
             if (icf != null)
             {
                 return(icf.eater.IsColonist && icf.eater.needs.food.CurLevelPercentage > icf.eater.needs.food.PercentageThreshUrgentlyHungry &&
                        icf.eater.story != null && icf.eater.story.traits.HasTrait(TraitDefOf.Ascetic));
             }
             return(false);
         },
                                       DefDatabase <ThingDef> .AllDefsListForReading.Where(t => t.IsNutritionGivingIngestible && t.ingestible.preferability > FoodPreferability.MealSimple));
     }
     else
     {
         ThingForbiddenContext.RemoveRule("QOL.restrictAscetics");
     }
     if (restrictAnimals)
     {
         ThingForbiddenContext.SetRule("QOL.restrictAnimals", new [] { "QOL.food" }, (con) => {
             IntentContext_Food icf = con as IntentContext_Food;
             if (icf != null)
             {
                 return(icf.eater.Faction != null && icf.eater.Faction.IsPlayer && icf.eater.RaceProps.Animal &&
                        icf.eater.needs.food.CurLevelPercentage > icf.eater.needs.food.PercentageThreshUrgentlyHungry);
             }
             return(false);
         },
                                       DefDatabase <ThingDef> .AllDefsListForReading.Where(t => t.IsNutritionGivingIngestible && t.ingestible.IsMeal));
     }
     else
     {
         ThingForbiddenContext.RemoveRule("QOL.restrictAnimals");
     }
     if (restrictPrisoners)
     {
         ThingForbiddenContext.SetRule("QOL.restrictPrisoners", new [] { "QOL.food" }, (con) => {
             IntentContext_Food icf = con as IntentContext_Food;
             if (icf != null)
             {
                 return(icf.eater.IsPrisoner && !icf.eater.IsColonist && icf.eater.guest.interactionMode != PrisonerInteractionModeDefOf.AttemptRecruit &&
                        icf.eater.needs.food.CurLevelPercentage > icf.eater.needs.food.PercentageThreshUrgentlyHungry);
             }
             return(false);
         },
                                       DefDatabase <ThingDef> .AllDefsListForReading.Where(t => t.IsNutritionGivingIngestible && t.ingestible.preferability > FoodPreferability.MealSimple));
     }
     else
     {
         ThingForbiddenContext.RemoveRule("QOL.restrictPrisoners");
     }
     if (restrictPrisonerRecruits)
     {
         ThingForbiddenContext.SetRule("QOL.restrictPrisonerRecruits", new [] { "QOL.food" }, (con) => {
             IntentContext_Food icf = con as IntentContext_Food;
             if (icf != null)
             {
                 return(icf.eater.IsPrisoner && !icf.eater.IsColonist && icf.eater.guest.interactionMode == PrisonerInteractionModeDefOf.AttemptRecruit &&
                        icf.eater.needs.food.CurLevelPercentage > icf.eater.needs.food.PercentageThreshUrgentlyHungry && icf.eater.needs.mood.CurLevel > 0.8f);
             }
             return(false);
         },
                                       DefDatabase <ThingDef> .AllDefsListForReading.Where(t => t.IsNutritionGivingIngestible && t.ingestible.preferability > FoodPreferability.MealSimple));
     }
     else
     {
         ThingForbiddenContext.RemoveRule("QOL.restrictPrisonerRecruits");
     }
 }