Update trivial components to use auto comp states (#20539)

This commit is contained in:
DrSmugleaf
2023-09-28 16:20:29 -07:00
committed by GitHub
parent 14cfe44ece
commit a44fa86b68
158 changed files with 806 additions and 2866 deletions

View File

@@ -16,7 +16,6 @@ using Content.Shared.Movement.Systems;
using Content.Shared.Popups;
using Content.Shared.Weapons.Melee;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Network;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
@@ -42,11 +41,6 @@ public abstract class SharedMechSystem : EntitySystem
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<MechComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<MechComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<MechPilotComponent, ComponentGetState>(OnPilotGetState);
SubscribeLocalEvent<MechPilotComponent, ComponentHandleState>(OnPilotHandleState);
SubscribeLocalEvent<MechComponent, MechToggleEquipmentEvent>(OnToggleEquipmentAction);
SubscribeLocalEvent<MechComponent, MechEjectPilotEvent>(OnEjectPilotEvent);
SubscribeLocalEvent<MechComponent, InteractNoHandEvent>(RelayInteractionEvent);
@@ -59,52 +53,6 @@ public abstract class SharedMechSystem : EntitySystem
SubscribeLocalEvent<MechPilotComponent, AttackAttemptEvent>(OnAttackAttempt);
}
#region State Handling
private void OnGetState(EntityUid uid, MechComponent component, ref ComponentGetState args)
{
args.State = new MechComponentState
{
Integrity = component.Integrity,
MaxIntegrity = component.MaxIntegrity,
Energy = component.Energy,
MaxEnergy = component.MaxEnergy,
CurrentSelectedEquipment = GetNetEntity(component.CurrentSelectedEquipment),
Broken = component.Broken
};
}
private void OnHandleState(EntityUid uid, MechComponent component, ref ComponentHandleState args)
{
if (args.Current is not MechComponentState state)
return;
component.Integrity = state.Integrity;
component.MaxIntegrity = state.MaxIntegrity;
component.Energy = state.Energy;
component.MaxEnergy = state.MaxEnergy;
component.CurrentSelectedEquipment = EnsureEntity<MechComponent>(state.CurrentSelectedEquipment, uid);
component.Broken = state.Broken;
}
private void OnPilotGetState(EntityUid uid, MechPilotComponent component, ref ComponentGetState args)
{
args.State = new MechPilotComponentState
{
Mech = GetNetEntity(component.Mech)
};
}
private void OnPilotHandleState(EntityUid uid, MechPilotComponent component, ref ComponentHandleState args)
{
if (args.Current is not MechPilotComponentState state)
return;
component.Mech = EnsureEntity<MechPilotComponent>(state.Mech, uid);
}
#endregion
private void OnToggleEquipmentAction(EntityUid uid, MechComponent component, MechToggleEquipmentEvent args)
{
if (args.Handled)