Beyond_Beyaan.Screens.ShipDesignScreen.OnSelectWeapon C# (CSharp) 메소드

OnSelectWeapon() 개인적인 메소드

private OnSelectWeapon ( Equipment equipment, int slotNum ) : void
equipment Equipment
slotNum int
리턴 void
        private void OnSelectWeapon(Equipment equipment, int slotNum)
        {
            if (equipment.Technology == null)
            {
                _shipDesign.Weapons[slotNum] = new KeyValuePair<Equipment, int>();
            }
            else
            {
                //Since weapons can stack, we need to take the available space, including the space used by previous weapon selection, then replace old weapon with new weapon, and reduce the number of mounts if necessary
                float availableSpace = _shipDesign.TotalSpace - _shipDesign.SpaceUsed;
                if (_shipDesign.Weapons[slotNum].Key != null)
                {
                    availableSpace += _shipDesign.Weapons[slotNum].Key.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower) * _shipDesign.Weapons[slotNum].Value;
                }
                int numOfMounts = (int)(availableSpace / equipment.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower));
                _shipDesign.Weapons[slotNum] = new KeyValuePair<Equipment, int>(equipment, Math.Max(Math.Min(numOfMounts, _shipDesign.Weapons[slotNum].Value), 1));
            }
            _shipDesign.UpdateEngineNumber();
            RefreshWeapons();
            RefreshStats();
            RefreshValidButtons();
            _selectionShowing = false;
            _equipmentSelection.OnSelectEquipment = null;
        }