Update trivial components to use auto comp states (#20539)
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using Content.Shared.Conveyor;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
@@ -26,8 +25,6 @@ public abstract class SharedConveyorController : VirtualController
|
||||
public override void Initialize()
|
||||
{
|
||||
UpdatesAfter.Add(typeof(SharedMoverController));
|
||||
SubscribeLocalEvent<ConveyorComponent, ComponentGetState>(OnConveyorGetState);
|
||||
SubscribeLocalEvent<ConveyorComponent, ComponentHandleState>(OnConveyorHandleState);
|
||||
|
||||
SubscribeLocalEvent<ConveyorComponent, StartCollideEvent>(OnConveyorStartCollide);
|
||||
SubscribeLocalEvent<ConveyorComponent, EndCollideEvent>(OnConveyorEndCollide);
|
||||
@@ -35,22 +32,6 @@ public abstract class SharedConveyorController : VirtualController
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
private void OnConveyorGetState(EntityUid uid, ConveyorComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new ConveyorComponentState(component.Angle, component.Speed, component.State, component.Powered);
|
||||
}
|
||||
|
||||
private void OnConveyorHandleState(EntityUid uid, ConveyorComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not ConveyorComponentState state)
|
||||
return;
|
||||
|
||||
component.Powered = state.Powered;
|
||||
component.Angle = state.Angle;
|
||||
component.Speed = state.Speed;
|
||||
component.State = state.State;
|
||||
}
|
||||
|
||||
private void OnConveyorStartCollide(EntityUid uid, ConveyorComponent component, ref StartCollideEvent args)
|
||||
{
|
||||
var otherUid = args.OtherEntity;
|
||||
|
||||
@@ -1,24 +1,14 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Physics;
|
||||
|
||||
/// <summary>
|
||||
/// Use this to allow a specific UID to prevent collides
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class PreventCollideComponent : Component
|
||||
{
|
||||
[AutoNetworkedField]
|
||||
public EntityUid Uid;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class PreventCollideComponentState : ComponentState
|
||||
{
|
||||
public NetEntity Uid;
|
||||
|
||||
public PreventCollideComponentState(NetEntity netEntity)
|
||||
{
|
||||
Uid = netEntity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Physics.Events;
|
||||
|
||||
namespace Content.Shared.Physics;
|
||||
|
||||
@@ -10,24 +8,9 @@ public sealed class SharedPreventCollideSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PreventCollideComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<PreventCollideComponent, ComponentHandleState>(OnHandleState);
|
||||
SubscribeLocalEvent<PreventCollideComponent, PreventCollideEvent>(OnPreventCollide);
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, PreventCollideComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new PreventCollideComponentState(GetNetEntity(component.Uid));
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, PreventCollideComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not PreventCollideComponentState state)
|
||||
return;
|
||||
|
||||
component.Uid = EnsureEntity<PreventCollideComponent>(state.Uid, uid);
|
||||
}
|
||||
|
||||
private void OnPreventCollide(EntityUid uid, PreventCollideComponent component, ref PreventCollideEvent args)
|
||||
{
|
||||
if (component.Uid == args.OtherEntity)
|
||||
|
||||
Reference in New Issue
Block a user