Update trivial components to use auto comp states (#20539)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user