Example #1
0
        internal static float weightForType(Pawn pawn, WeaponSearchType type)
        {
            float        total   = 0;
            List <Thing> weapons = GettersFilters.getWeaponsOfType(pawn, type);

            foreach (Thing thing in weapons)
            {
                switch (type)
                {
                case WeaponSearchType.MeleeCapable:
                    if ((thing.def.IsMeleeWeapon || (thing.def.tools != null && thing.def.tools.Any((Tool x) => x.VerbsProperties.Any((VerbProperties y) => y.IsMeleeAttack)))))
                    {
                        total += thing.GetStatValue(StatDefOf.Mass);
                    }
                    break;

                case WeaponSearchType.Melee:
                    if (thing.def.IsMeleeWeapon)
                    {
                        total += thing.GetStatValue(StatDefOf.Mass);
                    }
                    break;

                case WeaponSearchType.Ranged:
                    if (thing.def.IsRangedWeapon)
                    {
                        total += thing.GetStatValue(StatDefOf.Mass);
                    }
                    break;

                case WeaponSearchType.Both:
                default:
                    if (thing.def.IsWeapon)
                    {
                        total += thing.GetStatValue(StatDefOf.Mass);
                    }
                    break;
                }
            }
            return(total);
        }
Example #2
0
        public static float weightForLimitType(Pawn pawn, WeaponSearchType type)
        {
            float total = 0;
            IEnumerable <ThingWithComps> weapons = GettersFilters.filterForWeaponKind(pawn.getCarriedWeapons(), type);

            foreach (ThingWithComps thing in weapons)
            {
                switch (type)
                {
                case WeaponSearchType.MeleeCapable:
                    if ((thing.def.IsMeleeWeapon || (thing.def.tools != null && thing.def.tools.Any((Tool x) => x.VerbsProperties.Any((VerbProperties y) => y.IsMeleeAttack)))))
                    {
                        total += thing.GetStatValue(StatDefOf.Mass);
                    }
                    break;

                case WeaponSearchType.Melee:
                    if (thing.def.IsMeleeWeapon)
                    {
                        total += thing.GetStatValue(StatDefOf.Mass);
                    }
                    break;

                case WeaponSearchType.Ranged:
                    if (thing.def.IsRangedWeapon)
                    {
                        total += thing.GetStatValue(StatDefOf.Mass);
                    }
                    break;

                case WeaponSearchType.Both:
                default:
                    if (thing.def.IsWeapon)
                    {
                        total += thing.GetStatValue(StatDefOf.Mass);
                    }
                    break;
                }
            }
            return(total);
        }
Example #3
0
        internal static List <Thing> getWeaponsOfType(Pawn pawn, WeaponSearchType type)
        {
            List <Thing> things = new List <Thing>();

            foreach (Thing thing in pawn.inventory.innerContainer)
            {
                float weight = thing.def.BaseMass;
                switch (type)
                {
                case WeaponSearchType.MeleeCapable:
                    if ((thing.def.IsMeleeWeapon || (thing.def.tools != null && thing.def.tools.Any((Tool x) => (x.VerbsProperties != null && x.VerbsProperties.Any((VerbProperties y) => y.IsMeleeAttack))))))
                    {
                        things.Add(thing);
                    }
                    break;

                case WeaponSearchType.Melee:
                    if (thing.def.IsMeleeWeapon)
                    {
                        things.Add(thing);
                    }
                    break;

                case WeaponSearchType.Ranged:
                    if (thing.def.IsRangedWeapon)
                    {
                        things.Add(thing);
                    }
                    break;

                case WeaponSearchType.Both:
                default:
                    if (thing.def.IsWeapon)
                    {
                        things.Add(thing);
                    }
                    break;
                }
            }
            return(things);
        }
        internal static float weightForType(Pawn pawn, WeaponSearchType type)
        {
            float total = 0;

            foreach (Thing thing in pawn.inventory.innerContainer)
            {
                float weight = thing.def.BaseMass;
                if (thing.def.IsRangedWeapon)
                {
                    if (type == WeaponSearchType.Both || type == WeaponSearchType.Ranged)
                    {
                        total += weight;
                    }
                }
                else if (thing.def.IsMeleeWeapon)
                {
                    if (type == WeaponSearchType.Both || type == WeaponSearchType.Melee)
                    {
                        total += weight;
                    }
                }
            }
            return(total);
        }
Example #5
0
        internal static List <Thing> getWeaponsOfType(Pawn pawn, WeaponSearchType type)
        {
            List <Thing> things = new List <Thing>();

            foreach (Thing thing in pawn.inventory.innerContainer)
            {
                float weight = thing.def.BaseMass;
                if (type == WeaponSearchType.Both || type == WeaponSearchType.Ranged)
                {
                    if (thing.def.IsRangedWeapon)
                    {
                        things.Add(thing);
                    }
                }
                if (type == WeaponSearchType.Both || type == WeaponSearchType.Melee)
                {
                    if (thing.def.IsMeleeWeapon)
                    {
                        things.Add(thing);
                    }
                }
            }
            return(things);
        }
Example #6
0
        public static IEnumerable <ThingWithComps> filterForWeaponKind(IEnumerable <ThingWithComps> options, WeaponSearchType type)
        {
            switch (type)
            {
            case WeaponSearchType.Melee:
                return(options.Where(t => t.def.IsMeleeWeapon));

            case WeaponSearchType.Ranged:
                return(options.Where(t => t.def.IsRangedWeapon));

            case WeaponSearchType.MeleeCapable:
                return(options.Where(t => t.def.IsMeleeWeapon || (t.def.IsWeapon && !t.def.tools.NullOrEmpty())));

            case WeaponSearchType.Both:
            default:
                return(options.Where(t => t.def.IsWeapon));
            }
        }
Example #7
0
 internal static int countForType(Pawn pawn, WeaponSearchType type)
 {
     return(GettersFilters.getWeaponsOfType(pawn, type).Count);
 }
Example #8
0
        internal static List <ThingStuffPair> filterForType(List <ThingStuffPair> list, WeaponSearchType type, bool allowThingDuplicates)
        {
            List <ThingStuffPair> returnList = new List <ThingStuffPair>();
            List <ThingDef>       things     = new List <ThingDef>();

            foreach (ThingStuffPair weapon in list)
            {
                if (!weapon.thing.PlayerAcquirable)
                {
                    continue;
                }
                switch (type)
                {
                case WeaponSearchType.Melee:
                    if (weapon.thing.IsMeleeWeapon & (allowThingDuplicates | !things.Contains(weapon.thing)))
                    {
                        returnList.Add(weapon);
                        things.Add(weapon.thing);
                    }
                    break;

                case WeaponSearchType.Ranged:
                    if (weapon.thing.IsRangedWeapon & (allowThingDuplicates | !things.Contains(weapon.thing)))
                    {
                        returnList.Add(weapon);
                        things.Add(weapon.thing);
                    }
                    break;

                case WeaponSearchType.Both:
                default:
                    if ((allowThingDuplicates | !things.Contains(weapon.thing)))
                    {
                        returnList.Add(weapon);
                        things.Add(weapon.thing);
                    }
                    break;
                }
            }
            return(returnList);
        }
Example #9
0
 public static int countForLimitType(Pawn pawn, WeaponSearchType type)
 {
     return(GettersFilters.filterForWeaponKind(pawn.getCarriedWeapons(), type).Count());
 }
Example #10
0
        internal static List <ThingStuffPair> filterForType(List <ThingStuffPair> list, WeaponSearchType type, bool allowThingDuplicates)
        {
            List <ThingStuffPair> returnList = new List <ThingStuffPair>();
            List <ThingDef>       things     = new List <ThingDef>();

            foreach (ThingStuffPair weapon in list)
            {
                if (!weapon.thing.PlayerAcquirable)
                {
                    continue;
                }
                switch (type)
                {
                case WeaponSearchType.MeleeCapable:
                    if ((weapon.thing.IsMeleeWeapon || (weapon.thing.tools != null && weapon.thing.tools.Any((Tool x) => x.VerbsProperties.Any((VerbProperties y) => y.IsMeleeAttack)))) & (allowThingDuplicates || !things.Contains(weapon.thing)))
                    {
                        returnList.Add(weapon);
                        things.Add(weapon.thing);
                    }
                    break;

                case WeaponSearchType.Melee:
                    if (weapon.thing.IsMeleeWeapon & (allowThingDuplicates || !things.Contains(weapon.thing)))
                    {
                        returnList.Add(weapon);
                        things.Add(weapon.thing);
                    }
                    break;

                case WeaponSearchType.Ranged:
                    if (weapon.thing.IsRangedWeapon & (allowThingDuplicates || !things.Contains(weapon.thing)))
                    {
                        returnList.Add(weapon);
                        things.Add(weapon.thing);
                    }
                    break;

                case WeaponSearchType.Both:
                default:
                    if ((allowThingDuplicates || !things.Contains(weapon.thing)))
                    {
                        returnList.Add(weapon);
                        things.Add(weapon.thing);
                    }
                    break;
                }
            }
            return(returnList);
        }