RevolverAmmoProviderComponent.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Content.Shared.Whitelist;
  2. using Robust.Shared.Audio;
  3. using Robust.Shared.Containers;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Prototypes;
  6. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  7. namespace Content.Shared.Weapons.Ranged.Components;
  8. [RegisterComponent, NetworkedComponent]
  9. public sealed partial class RevolverAmmoProviderComponent : AmmoProviderComponent
  10. {
  11. /*
  12. * Revolver has an array of its slots of which we can fire from any index.
  13. * We also keep a separate array of slots we haven't spawned entities for, Chambers. This means that rather than creating
  14. * for example 7 entities when revolver spawns (1 for the revolver and 6 cylinders) we can instead defer it.
  15. */
  16. [DataField("whitelist")]
  17. public EntityWhitelist? Whitelist;
  18. public Container AmmoContainer = default!;
  19. [DataField("currentSlot")]
  20. public int CurrentIndex;
  21. [DataField("capacity")]
  22. public int Capacity = 6;
  23. // Like BallisticAmmoProvider we defer spawning until necessary
  24. // AmmoSlots is the instantiated ammo and Chambers is the unspawned ammo (that may or may not have been shot).
  25. // TODO: Using an array would be better but this throws!
  26. [DataField("ammoSlots")]
  27. public List<EntityUid?> AmmoSlots = new();
  28. [DataField("chambers")]
  29. public bool?[] Chambers = Array.Empty<bool?>();
  30. [DataField("proto", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
  31. public string? FillPrototype = "CartridgeMagnum";
  32. [DataField("soundEject")]
  33. public SoundSpecifier? SoundEject = new SoundPathSpecifier("/Audio/Weapons/Guns/MagOut/revolver_magout.ogg");
  34. [DataField("soundInsert")]
  35. public SoundSpecifier? SoundInsert = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/revolver_magin.ogg");
  36. [DataField("soundSpin")]
  37. public SoundSpecifier? SoundSpin = new SoundPathSpecifier("/Audio/Weapons/Guns/Misc/revolver_spin.ogg");
  38. }