Add access to gun components (#30688)
* Add access to gun components Found from an rmc14 PR. * Admin verbs proving why access needs to exist * Someone is probably going to post this pr to le reddit and complain about self-merges.
This commit is contained in:
@@ -724,15 +724,7 @@ public sealed partial class AdminVerbSystem
|
||||
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);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
@@ -6,7 +7,7 @@ using Robust.Shared.Prototypes;
|
||||
|
||||
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]
|
||||
@@ -32,6 +33,7 @@ public sealed partial class BallisticAmmoProviderComponent : Component
|
||||
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();
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Shared.Weapons.Ranged.Components;
|
||||
@@ -6,6 +7,7 @@ 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>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Weapons.Ranged.Components;
|
||||
|
||||
@@ -6,6 +7,7 @@ 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)]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Shared.Weapons.Ranged;
|
||||
@@ -7,6 +8,7 @@ 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")]
|
||||
|
||||
@@ -277,6 +277,17 @@ public abstract partial class SharedGunSystem
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user