コード例 #1
0
 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);
 }
コード例 #2
0
        public ThingOrderRequest(ThingDef thingDef, int amount = 1)
        {
            ThingFilter filter = new ThingFilter();

            filter.SetAllow(thingDef, true);
            thingFilter = filter;
            this.amount = amount;
            Initialize();
        }
コード例 #3
0
 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);
 }
コード例 #4
0
 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 );
     }
 }
コード例 #5
0
        public static ThingFilter DefaultFilter_MedZone()
        {
            ThingFilter filter = new ThingFilter();

            filter.SetDisallowAll();

            filter.SetAllow(ThingCategoryDefOf.Medicine, true);
            return(filter);
        }
コード例 #6
0
        public static void Postfix(ref ThingFilter __instance, StorageSettingsPreset preset)
        {
            if (preset != StorageSettingsPreset.DefaultStockpile)
            {
                return;
            }

            __instance.SetAllow(ThingCategoryDef.Named("RoadEquipment"), true);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
 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 );
     }
 }
コード例 #9
0
ファイル: DefaultFilters.cs プロジェクト: Proxyer/FZN
        public static ThingFilter DefaultFilter_MedZone()
        {
            List <ThingDef> database = DefDatabase <ThingDef> .AllDefsListForReading;
            ThingFilter     filter   = new ThingFilter();

            filter.SetDisallowAll();

            filter.SetAllow(ThingCategoryDefOf.Medicine, true);
            return(filter);
        }
コード例 #10
0
 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 );
 }
コード例 #11
0
 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();
        }
コード例 #13
0
        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);
                }
            }
        }
コード例 #14
0
        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));
        }
コード例 #15
0
            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);
        }
コード例 #17
0
ファイル: Tools.cs プロジェクト: DoctorVanGogh/zombieland
        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);
            }
        }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
        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);
        }
コード例 #20
0
 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);
 }
コード例 #21
0
        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);
        }
コード例 #22
0
 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;
 }
コード例 #23
0
 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;
 }
コード例 #24
0
        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);
                    }
                }
            }
        }
コード例 #25
0
        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);
        }
コード例 #26
0
 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;
 }
コード例 #27
0
        public CategorizedOpenSave(Game game)
        {
            if (CategoryFilterGlobal == null)
            {
                CategoryFilterGlobal = new ThingFilter();
            }

            foreach (ThingDef def in DefDatabase <ThingDef> .AllDefsListForReading)
            {
                if (def.CountAsResource)
                {
                    CategoryFilterGlobal.SetAllow(def, true);
                }
            }
        }
コード例 #28
0
        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);
        }
コード例 #29
0
        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);
        }
コード例 #30
0
        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;
        }
コード例 #31
0
        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);
        }
コード例 #32
0
 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);
         }
     }
 }
コード例 #33
0
        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();
        }
コード例 #34
0
 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 );
         }
     }
 }
コード例 #35
0
 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 );
             }
         }
     }
 }
コード例 #36
0
 public Trigger_Threshold( ManagerJob_Hunting job )
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     Count = DefaultCount;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     ThresholdFilter.SetAllow( Utilities_Hunting.RawMeat, true );
 }