using System.Collections.Generic;
using Robust.Shared.Analyzers;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Weapon.Ranged.Ammunition.Components
{
///
/// Stores ammo and can quickly transfer ammo into a magazine.
///
[RegisterComponent]
[Friend(typeof(GunSystem))]
public sealed class AmmoBoxComponent : Component
{
[DataField("caliber")]
public BallisticCaliber Caliber = BallisticCaliber.Unspecified;
[DataField("capacity")]
public int Capacity
{
get => _capacity;
set
{
_capacity = value;
SpawnedAmmo = new Stack(value);
}
}
private int _capacity = 30;
public int AmmoLeft => SpawnedAmmo.Count + UnspawnedCount;
public Stack SpawnedAmmo = new();
///
/// Container that holds any instantiated ammo.
///
public Container AmmoContainer = default!;
///
/// How many more deferred entities can be spawned. We defer these to avoid instantiating the entities until needed for performance reasons.
///
public int UnspawnedCount;
///
/// The prototype of the ammo to be retrieved when getting ammo.
///
[DataField("fillPrototype", customTypeSerializer:typeof(PrototypeIdSerializer))]
public string? FillPrototype;
}
}