/// <summary> /// Sets the mounted weapon to the specified instance. Only works when called from the server. /// If the weapon is null, the current weapon is removed instantly. /// </summary> /// <param name="spot">The spot. Should be on this vehicle, and not null!</param> /// <param name="weapon">The weapon instance, not prefab!</param> public void SetWeapon(MountedWeaponSpot spot, MountedWeapon weapon) { if (!JNet.IsServer) { Debug.LogError("Cannot set mounted weapon when not on server."); return; } if (spot == null) { Debug.LogError("Spot is null."); return; } if (spot.Vehicle != this) { Debug.LogError($"This spot is not on the current vehicle ({this.gameObject.name}), cannot set mounted weapon."); return; } if (spot.Size != weapon.Size) { Debug.LogError($"Size is not correct. Expected {spot.Size}, got {weapon.Size}... Weapon will not be placed."); return; } spot.SetMountedWeapon(weapon); }
public void Close() { if (MountedWeapon != null) { MountedWeapon.Close(); MountedWeapon = null; } WeaponSubObject = null; }
/// <summary> /// Returns weapon's object builder /// </summary> /// <returns></returns> public MyMwcObjectBuilder_SmallShip_Weapon GetWeaponObjectBuilder(bool getExactCopy) { if (MountedWeapon == null) { return(null); } else { return((MyMwcObjectBuilder_SmallShip_Weapon)MountedWeapon.GetObjectBuilder(getExactCopy)); } }
/// <summary> /// Sets the mounted weapon to the mounted weapon with the specified prefab name. Only works when called from the server. /// If the weapon is null, the current weapon is removed instantly. /// </summary> /// <param name="spotIndex">The mount index.</param> /// <param name="weapon">The weapon instance to place on the mount. May be null to remove the current weapon..</param> public void SetWeapon(int spotIndex, MountedWeapon weapon) { if (spotIndex >= 0 && spotIndex < Spots.Length) { SetWeapon(Spots[spotIndex], weapon); } else { Debug.LogError($"Spot index {spotIndex} is out of bounds! Min {0}, max {Spots.Length}."); return; } }