Improve hands & pulling (#4389)
This commit is contained in:
committed by
GitHub
parent
73e4946e27
commit
632e72b817
50
Content.Shared/Hands/Components/HandVirtualPullComponent.cs
Normal file
50
Content.Shared/Hands/Components/HandVirtualPullComponent.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Hands.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent]
|
||||
public sealed class HandVirtualPullComponent : Component
|
||||
{
|
||||
private EntityUid _pulledEntity;
|
||||
public override string Name => "HandVirtualPull";
|
||||
|
||||
public EntityUid PulledEntity
|
||||
{
|
||||
get => _pulledEntity;
|
||||
set
|
||||
{
|
||||
_pulledEntity = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState(ICommonSession player)
|
||||
{
|
||||
return new VirtualPullComponentState(_pulledEntity);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (curState is not VirtualPullComponentState pullState)
|
||||
return;
|
||||
|
||||
_pulledEntity = pullState.PulledEntity;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class VirtualPullComponentState : ComponentState
|
||||
{
|
||||
public readonly EntityUid PulledEntity;
|
||||
|
||||
public VirtualPullComponentState(EntityUid pulledEntity)
|
||||
{
|
||||
PulledEntity = pulledEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user