if (!int.TryParse(amount, out var result))
return;
- if (result > 0)
- {
- ballisticAmmo.UnspawnedCount = result;
- }
- else
- {
- ballisticAmmo.UnspawnedCount = 0;
- }
-
+ _gun.SetBallisticUnspawned((args.Target, ballisticAmmo), result);
_gun.UpdateBallisticAppearance(args.Target, ballisticAmmo);
});
},
+using Content.Shared.Weapons.Ranged.Systems;
using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
namespace Content.Shared.Weapons.Ranged.Components;
-[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedGunSystem))]
public sealed partial class BallisticAmmoProviderComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField]
public Container Container = default!;
// TODO: Make this use stacks when the typeserializer is done.
+ // Realistically just point to the container.
[DataField, AutoNetworkedField]
public List<EntityUid> Entities = new();
+using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Audio;
namespace Content.Shared.Weapons.Ranged.Components;
/// Chamber + mags in one package. If you need just magazine then use <see cref="MagazineAmmoProviderComponent"/>
/// </summary>
[RegisterComponent, AutoGenerateComponentState]
+[Access(typeof(SharedGunSystem))]
public sealed partial class ChamberMagazineAmmoProviderComponent : MagazineAmmoProviderComponent
{
/// <summary>
-using Robust.Shared.GameStates;
+using Content.Shared.Weapons.Ranged.Systems;
+using Robust.Shared.GameStates;
namespace Content.Shared.Weapons.Ranged.Components;
/// Handles pulling entities from the given container to use as ammunition.
/// </summary>
[RegisterComponent]
+[Access(typeof(SharedGunSystem))]
public sealed partial class ContainerAmmoProviderComponent : AmmoProviderComponent
{
[DataField("container", required: true)]
using Content.Shared.Weapons.Ranged.Components;
+using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Audio;
namespace Content.Shared.Weapons.Ranged;
/// Wrapper around a magazine (handled via ItemSlot). Passes all AmmoProvider logic onto it.
/// </summary>
[RegisterComponent, Virtual]
+[Access(typeof(SharedGunSystem))]
public partial class MagazineAmmoProviderComponent : AmmoProviderComponent
{
[ViewVariables(VVAccess.ReadWrite), DataField("soundAutoEject")]
Appearance.SetData(uid, AmmoVisuals.AmmoCount, GetBallisticShots(component), appearance);
Appearance.SetData(uid, AmmoVisuals.AmmoMax, component.Capacity, appearance);
}
+
+ public void SetBallisticUnspawned(Entity<BallisticAmmoProviderComponent> entity, int count)
+ {
+ if (entity.Comp.UnspawnedCount == count)
+ return;
+
+ entity.Comp.UnspawnedCount = count;
+ UpdateBallisticAppearance(entity.Owner, entity.Comp);
+ UpdateAmmoCount(entity.Owner);
+ Dirty(entity);
+ }
}
/// <summary>