Gun auto state handlers (#15186)

* battery auto state

* basic entity autostate

* ballistic autostate

* flyby

* cartridge ammo

* gun

* Revert "battery auto state"

This reverts commit 35b7d62f303fddb0edd9eb7a922e3c26b7a5f7fb.

* silly
This commit is contained in:
Kara
2023-04-13 20:08:56 -05:00
committed by GitHub
parent ccf81a6be9
commit 47262a6998
10 changed files with 31 additions and 173 deletions

View File

@@ -6,31 +6,8 @@ namespace Content.Shared.Weapons.Ranged.Systems;
public abstract partial class SharedGunSystem
{
// needed for server system
protected virtual void InitializeCartridge()
{
SubscribeLocalEvent<CartridgeAmmoComponent, ComponentGetState>(OnCartridgeGetState);
SubscribeLocalEvent<CartridgeAmmoComponent, ComponentHandleState>(OnCartridgeHandleState);
}
private void OnCartridgeHandleState(EntityUid uid, CartridgeAmmoComponent component, ref ComponentHandleState args)
{
if (args.Current is not CartridgeAmmoComponentState state)
return;
component.Spent = state.Spent;
}
private void OnCartridgeGetState(EntityUid uid, CartridgeAmmoComponent component, ref ComponentGetState args)
{
args.State = new CartridgeAmmoComponentState()
{
Spent = component.Spent,
};
}
[Serializable, NetSerializable]
private sealed class CartridgeAmmoComponentState : ComponentState
{
public bool Spent;
}
}