Update trivial components to use auto comp states (#20539)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Interaction.Components;
|
||||
|
||||
@@ -10,27 +9,13 @@ namespace Content.Shared.Interaction.Components;
|
||||
///
|
||||
/// Note that extreme caution should be taken when using this, as this will probably bypass many normal can-interact checks.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
[Access(typeof(SharedInteractionSystem))]
|
||||
public sealed partial class InteractionRelayComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The entity the interactions are being relayed to.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[ViewVariables, AutoNetworkedField]
|
||||
public EntityUid? RelayEntity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains network state for <see cref="InteractionRelayComponent"/>
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class InteractionRelayComponentState : ComponentState
|
||||
{
|
||||
public NetEntity? RelayEntity;
|
||||
|
||||
public InteractionRelayComponentState(NetEntity? relayEntity)
|
||||
{
|
||||
RelayEntity = relayEntity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Shared.ActionBlocker;
|
||||
@@ -7,7 +6,6 @@ using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Administration.Managers;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Ghost;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Input;
|
||||
@@ -28,7 +26,6 @@ using Content.Shared.Verbs;
|
||||
using Content.Shared.Wall;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Map;
|
||||
@@ -99,7 +96,6 @@ namespace Content.Shared.Interaction
|
||||
new PointerInputCmdHandler(HandleTryPullObject))
|
||||
.Register<SharedInteractionSystem>();
|
||||
|
||||
InitializeRelay();
|
||||
InitializeBlocking();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user