Files
tbd-station-14/Content.Shared/Ghost/SharedGhostComponent.cs
metalgearsloth 7beb363285 Deprecate a bunch of IActionBlocker (#4852)
* Deprecate IActionBlocker ChangeDirectionAttempt

* Woops

* Throw and interact

* Deperacte speech

* ActionBlocker in fucking shambles

* CanEmote go byebye

* CanAttack is GONE

* IActionBlocker finally ded

* DRY
2021-10-21 13:03:14 +11:00

86 lines
2.3 KiB
C#

using System;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Shared.Ghost
{
[NetworkedComponent()]
public class SharedGhostComponent : Component
{
public override string Name => "Ghost";
[ViewVariables(VVAccess.ReadWrite)]
public bool CanGhostInteract
{
get => _canGhostInteract;
set
{
if (_canGhostInteract == value) return;
_canGhostInteract = value;
Dirty();
}
}
[DataField("canInteract")]
private bool _canGhostInteract;
/// <summary>
/// Changed by <see cref="SharedGhostSystem.SetCanReturnToBody"/>
/// </summary>
// TODO MIRROR change this to use friend classes when thats merged
[ViewVariables(VVAccess.ReadWrite)]
public bool CanReturnToBody
{
get => _canReturnToBody;
set
{
if (_canReturnToBody == value) return;
_canReturnToBody = value;
Dirty();
}
}
[DataField("canReturnToBody")]
private bool _canReturnToBody;
public override ComponentState GetComponentState(ICommonSession player)
{
return new GhostComponentState(CanReturnToBody, CanGhostInteract);
}
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);
if (curState is not GhostComponentState state)
{
return;
}
CanReturnToBody = state.CanReturnToBody;
CanGhostInteract = state.CanGhostInteract;
}
}
[Serializable, NetSerializable]
public class GhostComponentState : ComponentState
{
public bool CanReturnToBody { get; }
public bool CanGhostInteract { get; }
public GhostComponentState(
bool canReturnToBody,
bool canGhostInteract)
{
CanReturnToBody = canReturnToBody;
CanGhostInteract = canGhostInteract;
}
}
}