CatStation/Content.Shared/PneumaticCannon/SharedPneumaticCannonSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

39 lines
1.4 KiB
C#

using Content.Shared.Popups;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Serialization;
namespace Content.Shared.PneumaticCannon;
public abstract partial class SharedPneumaticCannonSystem : EntitySystem
{
[Dependency] protected SharedContainerSystem Container = default!;
[Dependency] protected SharedPopupSystem Popup = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PneumaticCannonComponent, AttemptShootEvent>(OnAttemptShoot);
}
private void OnAttemptShoot(EntityUid uid, PneumaticCannonComponent component, ref AttemptShootEvent args)
{
// if the cannon doesn't need gas then it will always predict firing
if (component.GasUsage == 0f)
return;
// pneumatic cannon usually doesn't shoot bullets
args.ThrowItems = component.ThrowItems;
// 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;
}
}
}