/// <summary> /// Adds weapon. First try find first empty preferred slot and then try find first empty slot /// </summary> /// <param name="weaponObjectBuilder">Weapon's object builder</param> public MySmallShipGunBase AddWeapon(MyMwcObjectBuilder_SmallShip_Weapon weaponObjectBuilder) { if (!MySession.Is25DSector) { if (weaponObjectBuilder.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Nuclear) { weaponObjectBuilder.WeaponType = MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Crusher; } } MySmallShipGunBase newWeapon = MySmallShipWeaponFactory.GenerateWeapon(weaponObjectBuilder.WeaponType); if (newWeapon is MyDrillBase) { AddDrill(newWeapon as MyDrillBase, weaponObjectBuilder); } else if (newWeapon is MyHarvestingDevice) { AddHarvestingDevice(newWeapon as MyHarvestingDevice, weaponObjectBuilder); } else { AddWeapon(newWeapon, weaponObjectBuilder); } var parentShip = newWeapon.Parent as MySmallShip; if (parentShip != null) { newWeapon.NearFlag = parentShip.IsCameraInsideMinerShip(); } return(newWeapon); }
/// <summary> /// Adds harvesting device to harvesting device's slot /// </summary> /// <param name="harvestingDeviceObjectBuilder">Harvesting device's object builder</param> public void AddHarvestingDevice(MyMwcObjectBuilder_SmallShip_Weapon harvestingDeviceObjectBuilder) { MyHarvestingDevice newHarvestingDevice = MySmallShipWeaponFactory.GenerateWeapon(harvestingDeviceObjectBuilder.WeaponType) as MyHarvestingDevice; if (newHarvestingDevice == null) { throw new ArgumentException("Object builder is not harvesting device object builder"); } AddHarvestingDevice(newHarvestingDevice, harvestingDeviceObjectBuilder); }
/// <summary> /// Adds drill to drill's slot /// </summary> /// <param name="drillObjectBuilder">Drill's object builder</param> public void AddDrill(MyMwcObjectBuilder_SmallShip_Weapon drillObjectBuilder) { MyDrillBase newDrill = MySmallShipWeaponFactory.GenerateWeapon(drillObjectBuilder.WeaponType) as MyDrillBase; if (newDrill == null) { throw new ArgumentException("Object builder is not drill object builder"); } AddDrill(newDrill, drillObjectBuilder); }