Beispiel #1
0
        public static bool getWeaponAlwaysIndirectVisuals(Weapon weapon)
        {
            bool result = false;

            if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.AmmoIdStatName) == true)
            {
                string           CurrentAmmoId = weapon.StatCollection.GetStatistic(CustomAmmoCategories.AmmoIdStatName).Value <string>();
                ExtAmmunitionDef extAmmoDef    = CustomAmmoCategories.findExtAmmo(CurrentAmmoId);
                if (extAmmoDef.AlwaysIndirectVisuals != TripleBoolean.NotSet)
                {
                    result = (extAmmoDef.AlwaysIndirectVisuals == TripleBoolean.True);
                }
            }
            if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.WeaponModeStatisticName) == true)
            {
                ExtWeaponDef extWeapon = CustomAmmoCategories.getExtWeaponDef(weapon.defId);
                string       modeId    = weapon.StatCollection.GetStatistic(CustomAmmoCategories.WeaponModeStatisticName).Value <string>();
                if (extWeapon.Modes.ContainsKey(modeId))
                {
                    WeaponMode mode = extWeapon.Modes[modeId];
                    if (mode.AlwaysIndirectVisuals != TripleBoolean.NotSet)
                    {
                        result = (mode.AlwaysIndirectVisuals == TripleBoolean.True);
                    }
                }
            }
            return(result);
        }
        public static HashSet <string> getWeaponAvaibleAmmoForMode(Weapon weapon, string modeId)
        {
            HashSet <string>   result       = new HashSet <string>();
            CustomAmmoCategory ammoCategory = CustomAmmoCategories.find(weapon.AmmoCategory.ToString());
            ExtWeaponDef       extWeapon    = CustomAmmoCategories.getExtWeaponDef(weapon.defId);

            if (extWeapon.AmmoCategory.BaseCategory == weapon.AmmoCategory)
            {
                ammoCategory = extWeapon.AmmoCategory;
            }
            if (extWeapon.Modes.Count < 1)
            {
                CustomAmmoCategoriesLog.Log.LogWrite("WARNING! " + weapon.defId + " has no modes. Even base mode. This means something is very very wrong\n", true);
                return(result);
            }
            if (extWeapon.Modes.ContainsKey(modeId) == false)
            {
                CustomAmmoCategoriesLog.Log.LogWrite("WARNING! " + weapon.defId + " has no mode " + modeId + ".\n", true);
                return(result);
            }
            WeaponMode weaponMode = extWeapon.Modes[modeId];

            if (weaponMode.AmmoCategory.Index != ammoCategory.Index)
            {
                ammoCategory = weaponMode.AmmoCategory;
            }
            ;
            if (ammoCategory.Index == CustomAmmoCategories.NotSetCustomAmmoCategoty.Index)
            {
                result.Add(""); return(result);
            }
            ;
            foreach (AmmunitionBox box in weapon.ammoBoxes)
            {
                if (box.IsFunctional == false)
                {
                    continue;
                }
                if (box.CurrentAmmo <= 0)
                {
                    continue;
                }
                CustomAmmoCategory boxAmmoCategory = CustomAmmoCategories.getAmmoAmmoCategory(box.ammoDef);
                if (boxAmmoCategory.Index == ammoCategory.Index)
                {
                    if (result.Contains(box.ammoDef.Description.Id) == false)
                    {
                        result.Add(box.ammoDef.Description.Id);
                    }
                }
            }
            return(result);
        }
Beispiel #3
0
        public static CustomAmmoCategory getWeaponCustomAmmoCategory(Weapon weapon)
        {
            WeaponMode mode = CustomAmmoCategories.getWeaponMode(weapon);

            if (mode.AmmoCategory == null)
            {
                ExtWeaponDef extWeapon = CustomAmmoCategories.getExtWeaponDef(weapon.defId);
                if (extWeapon.AmmoCategory.BaseCategory != weapon.AmmoCategory)
                {
                    return(CustomAmmoCategories.find(weapon.AmmoCategory.ToString()));
                }
                return(extWeapon.AmmoCategory);
            }
            return(mode.AmmoCategory);
        }