Gunify pneumatic cannon (#13296)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.PneumaticCannon;
|
||||
|
||||
public abstract class SharedPneumaticCannonSystem : EntitySystem
|
||||
{
|
||||
[Dependency] protected readonly SharedContainerSystem Container = default!;
|
||||
[Dependency] protected readonly SharedPopupSystem Popup = default!;
|
||||
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PneumaticCannonComponent, AttemptShootEvent>(OnAttemptShoot);
|
||||
}
|
||||
|
||||
private void OnAttemptShoot(EntityUid uid, PneumaticCannonComponent component, ref AttemptShootEvent args)
|
||||
{
|
||||
// we don't have atmos on shared, so just predict by the existence of a slot item
|
||||
// server will handle auto ejecting/not adding the slot item if it doesnt have enough gas,
|
||||
// so this won't mispredict
|
||||
if (!Container.TryGetContainer(uid, PneumaticCannonComponent.TankSlotId, out var container) ||
|
||||
container is not ContainerSlot slot || slot.ContainedEntity is null)
|
||||
{
|
||||
args.Cancelled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user