Beispiel #1
0
        protected override TargetingParameters GetTargetingParameters()
        {
            return(new TargetingParameters
            {
                canTargetPawns = false,
                canTargetAnimals = false,
                canTargetHumans = false,
                canTargetMechs = false,
                mapObjectTargetsMustBeAutoAttackable = false,

                canTargetItems = true,
                canTargetBuildings = true,

                mustBeSelectable = true,

                validator = Validate
            });

            bool Validate(TargetInfo x)
            {
                var thing = x.Thing;

                if (thing == null)
                {
                    return(false);
                }

                if (thing.TryGetComp <CompQuality>() == null)
                {
                    return(false);
                }

                int infusionCount = thing.TryGetComp <CompInfused>()?.InfusionCount ?? 0;

                if (stealsInfusions && infusionCount > 0)
                {
                    return(true);
                }

                if (infusionCount >= Settings.max)
                {
                    return(false);
                }

                var def = x.Thing.def;

                if (allowance.Allows(def))
                {
                    return(true);
                }

                return(false);
            }
        }
 public bool Allows(Thing thing)
 {
     return(techLevel.Allows(thing.def.techLevel) &&
            allowance.Allows(thing.def) &&
            (match?.Allows(thing) ?? true));
 }