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

@@ -1,35 +1,15 @@
using Content.Shared.Interaction.Components;
using Robust.Shared.GameStates;
namespace Content.Shared.Interaction;
public abstract partial class SharedInteractionSystem
{
public void InitializeRelay()
{
SubscribeLocalEvent<InteractionRelayComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<InteractionRelayComponent, ComponentHandleState>(OnHandleState);
}
private void OnGetState(EntityUid uid, InteractionRelayComponent component, ref ComponentGetState args)
{
args.State = new InteractionRelayComponentState(GetNetEntity(component.RelayEntity));
}
private void OnHandleState(EntityUid uid, InteractionRelayComponent component, ref ComponentHandleState args)
{
if (args.Current is not InteractionRelayComponentState state)
return;
component.RelayEntity = EnsureEntity<InteractionRelayComponent>(state.RelayEntity, uid);
}
public void SetRelay(EntityUid uid, EntityUid? relayEntity, InteractionRelayComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
component.RelayEntity = relayEntity;
Dirty(component);
Dirty(uid, component);
}
}