public TriggerThreshold(ManagerJobProduction job) { Op = Ops.LowerThan; MaxUpperThreshold = job.MainProduct.MaxUpperThreshold; Count = MaxUpperThreshold / 5; ThresholdFilter = new ThingFilter(); ThresholdFilter.SetDisallowAll(); if (job.MainProduct.ThingDef != null) ThresholdFilter.SetAllow(job.MainProduct.ThingDef, true); if (job.MainProduct.CategoryDef != null) ThresholdFilter.SetAllow(job.MainProduct.CategoryDef, true); }
public ThingOrderRequest(ThingDef thingDef, int amount = 1) { ThingFilter filter = new ThingFilter(); filter.SetAllow(thingDef, true); thingFilter = filter; this.amount = amount; Initialize(); }
public Trigger_Threshold(ManagerJob_Forestry job) : base(job.manager) { Op = Ops.LowerThan; MaxUpperThreshold = DefaultMaxUpperThreshold; TargetCount = DefaultCount; ThresholdFilter = new ThingFilter(); ThresholdFilter.SetDisallowAll(); ThresholdFilter.SetAllow(ThingDefOf.WoodLog, true); }
public Trigger_Threshold( ManagerJob_Production job ) : base(job.manager) { Op = Ops.LowerThan; MaxUpperThreshold = job.MainProduct.MaxUpperThreshold; // TODO: Better way of setting sensible defaults? Count = MaxUpperThreshold / 20; ThresholdFilter = new ThingFilter(); ThresholdFilter.SetDisallowAll(); if ( job.MainProduct.ThingDef != null ) { ThresholdFilter.SetAllow( job.MainProduct.ThingDef, true ); } if ( job.MainProduct.CategoryDef != null ) { ThresholdFilter.SetAllow( job.MainProduct.CategoryDef, true ); } }
public static ThingFilter DefaultFilter_MedZone() { ThingFilter filter = new ThingFilter(); filter.SetDisallowAll(); filter.SetAllow(ThingCategoryDefOf.Medicine, true); return(filter); }
public static void Postfix(ref ThingFilter __instance, StorageSettingsPreset preset) { if (preset != StorageSettingsPreset.DefaultStockpile) { return; } __instance.SetAllow(ThingCategoryDef.Named("RoadEquipment"), true); }
public static Thing FindBestFuel(Pawn pawn) { var filter = new ThingFilter(); filter.SetAllow(RSDefOf.RSPowerCell, true); bool validator(Thing x) => !x.IsForbidden(pawn) && pawn.CanReserve(x, 1, -1, null, false) && filter.Allows(x); return(GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, filter.BestThingRequest, PathEndMode.ClosestTouch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, null, 0, -1, false, RegionType.Set_Passable, false)); }
public Trigger_Threshold( ManagerJob_Production job ) : base(job.manager) { Op = Ops.LowerThan; MaxUpperThreshold = job.MainProduct.MaxUpperThreshold; // TODO: Better way of setting sensible defaults? Count = MaxUpperThreshold / 20; ThresholdFilter = new ThingFilter(); ThresholdFilter.SetDisallowAll(); if ( job.MainProduct.ThingDef != null ) { ThresholdFilter.SetAllow( job.MainProduct.ThingDef, true ); } if ( job.MainProduct.CategoryDef != null ) { ThresholdFilter.SetAllow( job.MainProduct.CategoryDef, true ); } }
public static ThingFilter DefaultFilter_MedZone() { List <ThingDef> database = DefDatabase <ThingDef> .AllDefsListForReading; ThingFilter filter = new ThingFilter(); filter.SetDisallowAll(); filter.SetAllow(ThingCategoryDefOf.Medicine, true); return(filter); }
public Trigger_Threshold( ManagerJob_Forestry job ) : base(job.manager) { Op = Ops.LowerThan; MaxUpperThreshold = DefaultMaxUpperThreshold; Count = DefaultCount; ThresholdFilter = new ThingFilter(); ThresholdFilter.SetDisallowAll(); ThresholdFilter.SetAllow( Utilities_Forestry.Wood, true ); }
public Trigger_Threshold( ManagerJob_Hunting job ) : base(job.manager) { Op = Ops.LowerThan; MaxUpperThreshold = DefaultMaxUpperThreshold; Count = DefaultCount; ThresholdFilter = new ThingFilter(); ThresholdFilter.SetDisallowAll(); ThresholdFilter.SetAllow( Utilities_Hunting.RawMeat, true ); }
//private bool InViewArea => true; #region Drawers private void DoSpecialFilter(SpecialThingFilterDef sfDef, int nestLevel) { if (!sfDef.configurable) { return; } if (InViewArea) { LabelLeft("*" + sfDef.LabelCap, sfDef.description, nestLevel); var flag = filter.Allows(sfDef); var flag2 = flag; Widgets.Checkbox(new Vector2(LabelWidth, curY), ref flag, lineHeight, false, true); if (flag != flag2) { filter.SetAllow(sfDef, flag); } } EndLine(); }
private void MergeExceptionsIntoFilter(ThingFilter filter, ThingFilter exceptionFilter) { //Log.Message( string.Format( "{0}.CompHopperUser.MergeExceptionsIntoFilter( ThingFilter, ThingFilter )", this.parent.ThingID ) ); if (!exceptionFilter.ExceptedCategories().NullOrEmpty()) { foreach (var category in exceptionFilter.ExceptedCategories()) { var categoryDef = DefDatabase <ThingCategoryDef> .GetNamed(category, true); filter.SetAllow(categoryDef, false); } } if (!exceptionFilter.ExceptedThingDefs().NullOrEmpty()) { foreach (var thingDef in exceptionFilter.ExceptedThingDefs()) { filter.SetAllow(thingDef, false); } } }
public override void GenerateRewards(ThingFilter filter, FloatRange totalValue, IntRange countRange, TechLevel?techLevel, float?totalMass) { base.GenerateRewards(filter, totalValue, countRange, techLevel, totalMass); filter.SetDisallowAll(); filter.SetAllow(ThingCategoryDefOf.ResourcesRaw, true); filter.SetAllow(ThingCategoryDefOf.Items, true); ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms2 = default; parms2.totalMarketValueRange = new FloatRange(300, 800); parms2.countRange = new IntRange(2, 4); parms2.filter = filter; maker.fixedParams = parms2; List <Thing> items = maker.Generate(); items.ForEach(i => Rewards.Add(i)); }
public override void FromString(string settingValue) { List <ThingDef> defList = settingValue.Replace(", ", ",").Split(',').ToList().ConvertAll(e => DefDatabase <ThingDef> .GetNamedSilentFail(e)); foreach (ThingDef def in defList) { if (def != null) { masterFuelSettings.SetAllow(def, true); } } }
// Will return null if recipe requires no components private RecipeDef TryMakeRecipeVariantWithSteel(RecipeDef recipeOriginal) { var recipeCopy = (RecipeDef)objectCloneMethod.Invoke(recipeOriginal, null); recipeCopy.shortHash = 0; InjectedDefHasher.GiveShortHasToDef(recipeCopy, typeof(RecipeDef)); recipeCopy.defName += RemoteExplosivesUtility.InjectedRecipeNameSuffix; var newFixedFilter = new ThingFilter(); foreach (var allowedThingDef in recipeOriginal.fixedIngredientFilter.AllowedThingDefs) { if (allowedThingDef == ThingDefOf.Component) { continue; } newFixedFilter.SetAllow(allowedThingDef, true); } newFixedFilter.SetAllow(ThingDefOf.Steel, true); recipeCopy.fixedIngredientFilter = newFixedFilter; recipeCopy.defaultIngredientFilter = null; float numComponentsRequired = 0; var newIngredientList = new List <IngredientCount>(recipeOriginal.ingredients); foreach (var ingredientCount in newIngredientList) { if (ingredientCount.filter.Allows(ThingDefOf.Component)) { numComponentsRequired = ingredientCount.GetBaseCount(); newIngredientList.Remove(ingredientCount); break; } } if (numComponentsRequired == 0) { return(null); } var steelFilter = new ThingFilter(); steelFilter.SetAllow(ThingDefOf.Steel, true); var steelIngredient = new IngredientCount { filter = steelFilter }; steelIngredient.SetBaseCount(ComponentValueInSteel * numComponentsRequired); newIngredientList.Add(steelIngredient); recipeCopy.ingredients = newIngredientList; recipeCopy.ResolveReferences(); return(recipeCopy); }
private static void RemoveZombielandFromFilter(ThingFilter filter) { if (filter == null) { return; } var defs = filter.AllowedThingDefs.Where(def => def.defName.StartsWith("Zombie_")).ToList(); foreach (var def in defs) { filter.SetAllow(def, false); } }
static void RemoveFromFilter(ThingFilter filter) { if (filter == null) { return; } var defs = filter.AllowedThingDefs.Where(def => def.IsZombieDef()).ToList(); foreach (var def in defs) { filter.SetAllow(def, false); } }
public Trigger_Threshold(ManagerJob_Hunting job) : base(job.manager) { Op = Ops.LowerThan; MaxUpperThreshold = DefaultMaxUpperThreshold; TargetCount = DefaultCount; ThresholdFilter = new ThingFilter(); ThresholdFilter.SetDisallowAll(); // limit selection to food only. ParentFilter = new ThingFilter(); ParentFilter.SetDisallowAll(); ParentFilter.SetAllow(Utilities_Hunting.FoodRaw, true); }
public static void CreateStuff(this ResearchProjectDef tech, ThingFilter filter, UnlockManager unlocked) { string name = "Tech_" + tech.defName; ThingCategoryDef tCat = DefDatabase<ThingCategoryDef>.GetNamed(tech.techLevel.ToString()); StuffCategoryDef sCat = DefDatabase<StuffCategoryDef>.GetNamed(tech.techLevel.ToString()); string label = "KnowledgeLabel".Translate(tech.label); ThingDef techStuff = new ThingDef { thingClass = typeof(ThingWithComps), defName = name, label = label, description = tech.description, category = ThingCategory.Item, thingCategories = new List<ThingCategoryDef>() { tCat }, techLevel = tech.techLevel, menuHidden = true, stuffProps = new StuffProperties() { categories = new List<StuffCategoryDef>() { sCat/*TechDefOf.Technic*/ }, color = ResearchTree_Assets.ColorCompleted[tech.techLevel], stuffAdjective = tech.LabelCap, statOffsets = new List<StatModifier>() { new StatModifier { stat = StatDefOf.MarketValue, value = MarketValueOffset } }, statFactors = new List<StatModifier>() { new StatModifier { stat = StatDefOf.WorkToMake, value = StuffCostFactor(tech) }, new StatModifier { stat = StatDefOf.MarketValue, value = StuffMarketValueFactor(tech) } } } }; techStuff.ResolveReferences(); MethodInfo GiveShortHashInfo = AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash"); GiveShortHashInfo.Invoke(tech, new object[] { techStuff, typeof(ThingDef) }); DefDatabase<ThingDef>.Add(techStuff); filter.SetAllow(techStuff, true); unlocked.stuffByTech.Add(tech, techStuff); }
private static FloatRange CalculateStatRange(StatDef stat) { var statRange = FloatRange.Zero; var apparelFilter = new ThingFilter(); apparelFilter.SetAllow(ThingCategoryDefOf.Apparel, true); var apparels = ThingCategoryNodeDatabase.RootNode.catDef.DescendantThingDefs .Where(t => apparelFilter.Allows(t) && !apparelFilter.IsAlwaysDisallowedDueToSpecialFilters(t)).ToList() .Where(a => a.statBases != null && a.StatBaseDefined(stat) || a.equippedStatOffsets != null && a.equippedStatOffsets.Any(o => o.stat == stat)).ToList(); if (apparels.Any()) { foreach (var apparel in apparels) { var statBase = apparel.statBases?.Find(sm => sm.stat == stat); var baseStatValue = statBase?.value ?? stat.defaultBaseValue; float statOffsetValue = 0; var statOffset = apparel.equippedStatOffsets?.Find(sm => sm.stat == stat); if (statOffset != null) { statOffsetValue = statOffset.value; } var totalStatValue = baseStatValue + statOffsetValue - stat.defaultBaseValue; if (Math.Abs(statRange.min) < 0.0001 && Math.Abs(statRange.max) < 0.0001) { statRange.min = totalStatValue; statRange.max = totalStatValue; } else { if (statRange.min > totalStatValue) { statRange.min = totalStatValue; } if (statRange.max < totalStatValue) { statRange.max = totalStatValue; } } } } else { statRange.min = stat.defaultBaseValue; statRange.max = stat.defaultBaseValue; } StatRanges.Add(stat, statRange); return(statRange); }
public Dialog_ManageOutfits(Outfit selectedOutfit) { forcePause = true; doCloseX = true; doCloseButton = true; closeOnClickedOutside = true; absorbInputAroundWindow = true; if (apparelGlobalFilter == null) { apparelGlobalFilter = new ThingFilter(); apparelGlobalFilter.SetAllow(ThingCategoryDefOf.Apparel, allow: true); } SelectedOutfit = selectedOutfit; }
public Dialog_ManageToolAssignments(ToolAssignment selectedToolAssignment) { forcePause = true; doCloseX = true; doCloseButton = true; closeOnClickedOutside = true; absorbInputAroundWindow = true; if (globalFilter == null) { globalFilter = new ThingFilter(); globalFilter.SetAllow(ThingCategoryDefOf.Tools, true); } ToolAssignment = selectedToolAssignment; }
private void MergeIngredientIntoFilter(ThingFilter filter, IngredientCount ingredient) { //Log.Message( string.Format( "{0}.CompHopperUser.MergeIngredientIntoFilter( ThingFilter, IngredientCount )", this.parent.ThingID ) ); if (ingredient.filter != null) { if (!ingredient.filter.Categories().NullOrEmpty()) { foreach (var category in ingredient.filter.Categories()) { var categoryDef = DefDatabase <ThingCategoryDef> .GetNamed(category, true); filter.SetAllow(categoryDef, true); } } if (!ingredient.filter.ThingDefs().NullOrEmpty()) { foreach (var thingDef in ingredient.filter.ThingDefs()) { filter.SetAllow(thingDef, true); } } } }
public static ThingFilter DefaultFilter_OutdoorZone() { var filter = new ThingFilter(); filter.SetDisallowAll(null, DefDatabase <SpecialThingFilterDef> .AllDefs); DefDatabase <ThingDef> .AllDefs .Where(d => !d.HasComp(typeof(CompRottable))) .Where(d => d.GetStatValueAbstract(StatDefOf.DeteriorationRate) == 0f) .ToList() .ForEach(d => filter.SetAllow(d, true)); return(filter); }
public Dialog_ManageSurvivalToolAssignments(SurvivalToolAssignment selectedToolAssignment) { forcePause = true; doCloseX = true; doCloseButton = true; closeOnClickedOutside = true; absorbInputAroundWindow = true; if (survivalToolGlobalFilter == null) { survivalToolGlobalFilter = new ThingFilter(); survivalToolGlobalFilter.SetAllow(ST_ThingCategoryDefOf.SurvivalTools, true); } SelectedSurvivalToolAssignment = selectedToolAssignment; }
public CategorizedOpenSave(Game game) { if (CategoryFilterGlobal == null) { CategoryFilterGlobal = new ThingFilter(); } foreach (ThingDef def in DefDatabase <ThingDef> .AllDefsListForReading) { if (def.CountAsResource) { CategoryFilterGlobal.SetAllow(def, true); } } }
public static ThingFilter DefaultFilter_MealZone() { List <ThingDef> database = DefDatabase <ThingDef> .AllDefsListForReading; ThingFilter filter = new ThingFilter(); filter.SetDisallowAll(); for (int t = 0; t < database.Count; t++) { if (database[t].comps.Any(c => c is CompProperties_Rottable) && database[t].IsIngestible && ((database[t].ingestible.foodType & FoodTypeFlags.Meal) != 0)) { filter.SetAllow(database[t], true); } } return(filter); }
public static ThingFilter DefaultFilter_JoyZone() { List <ThingDef> database = DefDatabase <ThingDef> .AllDefsListForReading; ThingFilter filter = new ThingFilter(); filter.SetDisallowAll(); for (int t = 0; t < database.Count; t++) { if (database[t].IsIngestible && database[t].ingestible.joyKind != null && database[t].ingestible.joy > 0) { filter.SetAllow(database[t], true); } } return(filter); }
public SingleThingSelector(SingleThingSelector other) { ValidateArg.NotNull(other, nameof(other)); _allowedStuff = other._allowedStuff; _allowedStackCount = other._allowedStackCount; _thingFilter = new ThingFilter(); _thingFilter.SetAllow(other.AllowedThing, true); _thingFilter.allowedQualitiesConfigurable = other._thingFilter.allowedQualitiesConfigurable; _thingFilter.AllowedQualityLevels = other._thingFilter.AllowedQualityLevels; _thingFilter.allowedHitPointsConfigurable = other._thingFilter.allowedHitPointsConfigurable; _thingFilter.AllowedHitPointsPercents = other._thingFilter.AllowedHitPointsPercents; }
public static ThingFilter GetThingFilter(List <DarkNetGood> goods) { ThingFilter filter = new ThingFilter(); foreach (var good in goods) { if (Rand.Chance(good.Commonality)) //good.Commonality { foreach (var thing in good.ThingFilter.AllowedThingDefs) { filter.SetAllow(thing, true); } } } return(filter); }
public override void ResolveReferences() { filter.ResolveReferences(); if (filterPerishables) { foreach (var def in filter.AllowedThingDefs.ToList()) { if (def.EverHaulable && def.CanEverDeteriorate && def.GetStatValueAbstract(StatDefOf.DeteriorationRate) > 0f) { continue; } filter.SetAllow(def, false); } } }
private void GenerateItems() { ThingFilter filter = new ThingFilter(); filter.SetAllow(ThingCategoryDefOf.ResourcesRaw, true); ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms = default; parms.totalMarketValueRange = new FloatRange(1600, 3000); parms.countRange = new IntRange(10, 25); parms.filter = filter; maker.fixedParams = parms; items = maker.Generate(); }
private void MergeExceptionsIntoFilter( ThingFilter filter, ThingFilter exceptionFilter ) { //Log.Message( string.Format( "{0}.CompHopperUser.MergeExceptionsIntoFilter( ThingFilter, ThingFilter )", this.parent.ThingID ) ); if( !exceptionFilter.ExceptedCategories().NullOrEmpty() ) { foreach( var category in exceptionFilter.ExceptedCategories() ) { var categoryDef = DefDatabase<ThingCategoryDef>.GetNamed( category, true ); filter.SetAllow( categoryDef, false ); } } if( !exceptionFilter.ExceptedThingDefs().NullOrEmpty() ) { foreach( var thingDef in exceptionFilter.ExceptedThingDefs() ) { filter.SetAllow( thingDef, false ); } } }
private void MergeIngredientIntoFilter( ThingFilter filter, IngredientCount ingredient ) { //Log.Message( string.Format( "{0}.CompHopperUser.MergeIngredientIntoFilter( ThingFilter, IngredientCount )", this.parent.ThingID ) ); if( ingredient.filter != null ) { if( !ingredient.filter.Categories().NullOrEmpty() ) { foreach( var category in ingredient.filter.Categories() ) { var categoryDef = DefDatabase<ThingCategoryDef>.GetNamed( category, true ); filter.SetAllow( categoryDef, true ); } } if( !ingredient.filter.ThingDefs().NullOrEmpty() ) { foreach( var thingDef in ingredient.filter.ThingDefs() ) { filter.SetAllow( thingDef, true ); } } } }
public Trigger_Threshold( ManagerJob_Hunting job ) { Op = Ops.LowerThan; MaxUpperThreshold = DefaultMaxUpperThreshold; Count = DefaultCount; ThresholdFilter = new ThingFilter(); ThresholdFilter.SetDisallowAll(); ThresholdFilter.SetAllow( Utilities_Hunting.RawMeat, true ); }