static void WeaponsFromData(ShipData ship, int[] weapondata) { if (weapondata != null) { for (int i = 0; i < weapondata.Length; i++) { Vector3? freeSlot = FreeSlot(ship, ship.Nose); if (freeSlot != null) { ship.SetWeapon((Vector3)freeSlot, WeaponData.WeaponTypes[weapondata[i]].Copy()); continue; } freeSlot = FreeSlot(ship, ship.Core); if (freeSlot != null) { ship.SetWeapon((Vector3)freeSlot, WeaponData.WeaponTypes[weapondata[i]].Copy()); continue; } freeSlot = FreeSlot(ship, ship.Engine); if (freeSlot != null) { ship.SetWeapon((Vector3)freeSlot, WeaponData.WeaponTypes[weapondata[i]].Copy()); continue; } } } }