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:
@@ -19,8 +19,6 @@ public abstract partial class SharedGunSystem
|
||||
SubscribeLocalEvent<BallisticAmmoProviderComponent, MapInitEvent>(OnBallisticMapInit);
|
||||
SubscribeLocalEvent<BallisticAmmoProviderComponent, TakeAmmoEvent>(OnBallisticTakeAmmo);
|
||||
SubscribeLocalEvent<BallisticAmmoProviderComponent, GetAmmoCountEvent>(OnBallisticAmmoCount);
|
||||
SubscribeLocalEvent<BallisticAmmoProviderComponent, ComponentGetState>(OnBallisticGetState);
|
||||
SubscribeLocalEvent<BallisticAmmoProviderComponent, ComponentHandleState>(OnBallisticHandleState);
|
||||
|
||||
SubscribeLocalEvent<BallisticAmmoProviderComponent, ExaminedEvent>(OnBallisticExamine);
|
||||
SubscribeLocalEvent<BallisticAmmoProviderComponent, GetVerbsEvent<Verb>>(OnBallisticVerb);
|
||||
@@ -175,32 +173,6 @@ public abstract partial class SharedGunSystem
|
||||
|
||||
protected abstract void Cycle(BallisticAmmoProviderComponent component, MapCoordinates coordinates);
|
||||
|
||||
private void OnBallisticGetState(EntityUid uid, BallisticAmmoProviderComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new BallisticAmmoProviderComponentState()
|
||||
{
|
||||
UnspawnedCount = component.UnspawnedCount,
|
||||
Entities = component.Entities,
|
||||
Cycled = component.Cycled,
|
||||
};
|
||||
}
|
||||
|
||||
private void OnBallisticHandleState(EntityUid uid, BallisticAmmoProviderComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not BallisticAmmoProviderComponentState state)
|
||||
return;
|
||||
|
||||
component.Cycled = state.Cycled;
|
||||
component.UnspawnedCount = state.UnspawnedCount;
|
||||
|
||||
component.Entities.Clear();
|
||||
|
||||
foreach (var ent in state.Entities)
|
||||
{
|
||||
component.Entities.Add(ent);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBallisticInit(EntityUid uid, BallisticAmmoProviderComponent component, ComponentInit args)
|
||||
{
|
||||
component.Container = Containers.EnsureContainer<Container>(uid, "ballistic-ammo");
|
||||
@@ -292,12 +264,4 @@ public abstract partial class SharedGunSystem
|
||||
Appearance.SetData(uid, AmmoVisuals.AmmoCount, GetBallisticShots(component), appearance);
|
||||
Appearance.SetData(uid, AmmoVisuals.AmmoMax, component.Capacity, appearance);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class BallisticAmmoProviderComponentState : ComponentState
|
||||
{
|
||||
public int UnspawnedCount;
|
||||
public List<EntityUid> Entities = default!;
|
||||
public bool Cycled;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user