Exemplo n.º 1
0
        void SetAutoMountIfExceededLimit(MyMwcObjectBuilder_SmallShip_Weapon weaponObjectBuilder)
        {
            if (!weaponObjectBuilder.IsNormalWeapon)
            {
                return;
            }

            const int universalLauncherCount    = 2;
            var       maxNormalWeapons          = Ship.ShipTypeProperties.GamePlay.MaxWeapons - universalLauncherCount;
            var       maxNormalWeaponsOnOneWing = maxNormalWeapons / 2;

            var tooManyLeft  = GetNormalWeaponCount(MySlotLocationEnum.LeftSide) >= maxNormalWeaponsOnOneWing;
            var tooManyRight = GetNormalWeaponCount(MySlotLocationEnum.RightSide) >= maxNormalWeaponsOnOneWing;

            if (tooManyLeft && tooManyRight)
            {
                weaponObjectBuilder.SetAutoMount();
                return;
            }

            if (tooManyLeft)
            {
                weaponObjectBuilder.SetAutoMountRight();
            }

            if (tooManyRight)
            {
                weaponObjectBuilder.SetAutoMountLeft();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds weapon
        /// </summary>
        /// <param name="weapon">Weapon</param>
        /// <param name="weaponObjectBuilder">Weapon's object builder</param>
        /// <param name="maxWeapons"> </param>
        private void AddWeapon(MySmallShipGunBase weapon, MyMwcObjectBuilder_SmallShip_Weapon weaponObjectBuilder)
        {
            SetAutoMountIfExceededLimit(weaponObjectBuilder);

            MyWeaponSlot emptyWeaponSlot = GetEmptySlotToAdd(weaponObjectBuilder);

            if (emptyWeaponSlot != null)
            {
                switch (emptyWeaponSlot.SlotLocation)
                {
                case MySlotLocationEnum.None:
                    break;

                case MySlotLocationEnum.LeftSide:
                    weaponObjectBuilder.SetAutoMountLeft();
                    break;

                case MySlotLocationEnum.RightSide:
                    weaponObjectBuilder.SetAutoMountRight();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                AddWeaponToSlot(emptyWeaponSlot, weapon, weaponObjectBuilder);
            }
        }