2022-07-29 14:13:12 +12:00
|
|
|
using Robust.Shared.Audio;
|
2022-06-01 19:59:58 +10:00
|
|
|
using Robust.Shared.GameStates;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.Weapons.Ranged.Components;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Allows the entity to be fired from a gun.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RegisterComponent, Virtual]
|
2023-08-22 18:14:33 -07:00
|
|
|
public partial class AmmoComponent : Component, IShootable
|
2022-06-01 19:59:58 +10:00
|
|
|
{
|
|
|
|
|
// Muzzle flash stored on ammo because if we swap a gun to whatever we may want to override it.
|
|
|
|
|
|
2022-07-14 23:03:48 +10:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("muzzleFlash", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
|
|
|
|
|
public string? MuzzleFlash = "MuzzleFlashEffect";
|
2022-06-01 19:59:58 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Spawns another prototype to be shot instead of itself.
|
|
|
|
|
/// </summary>
|
2023-09-01 07:33:28 +10:00
|
|
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
2023-04-13 20:08:56 -05:00
|
|
|
public sealed partial class CartridgeAmmoComponent : AmmoComponent
|
2022-06-01 19:59:58 +10:00
|
|
|
{
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("proto", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
|
|
|
|
public string Prototype = default!;
|
|
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("spent")]
|
2023-04-13 20:08:56 -05:00
|
|
|
[AutoNetworkedField]
|
2022-06-01 19:59:58 +10:00
|
|
|
public bool Spent = false;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// How much the ammo spreads when shot, in degrees. Does nothing if count is 0.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("spread")]
|
2022-06-03 17:57:39 +10:00
|
|
|
public Angle Spread = Angle.FromDegrees(5);
|
2022-06-01 19:59:58 +10:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// How many prototypes are spawned when shot.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("count")]
|
|
|
|
|
public int Count = 1;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Caseless ammunition.
|
|
|
|
|
/// </summary>
|
2022-11-16 20:22:11 +01:00
|
|
|
[DataField("deleteOnSpawn")]
|
2022-06-01 19:59:58 +10:00
|
|
|
public bool DeleteOnSpawn;
|
|
|
|
|
|
2022-11-16 20:22:11 +01:00
|
|
|
[DataField("soundEject")]
|
2022-06-01 19:59:58 +10:00
|
|
|
public SoundSpecifier? EjectSound = new SoundCollectionSpecifier("CasingEject");
|
|
|
|
|
}
|