2020-03-03 19:10:07 +01:00
|
|
|
using System;
|
2020-03-03 18:04:16 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-07-12 01:32:10 -07:00
|
|
|
using Robust.Shared.GameStates;
|
2021-06-18 09:56:23 +02:00
|
|
|
using Robust.Shared.Players;
|
2020-03-03 19:10:07 +01:00
|
|
|
using Robust.Shared.Serialization;
|
2021-06-18 09:56:23 +02:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
|
|
|
using Robust.Shared.ViewVariables;
|
2020-03-03 18:04:16 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Ghost
|
2020-03-03 18:04:16 +01:00
|
|
|
{
|
2021-07-12 01:32:10 -07:00
|
|
|
[NetworkedComponent()]
|
2022-02-16 00:23:23 -07:00
|
|
|
public abstract class SharedGhostComponent : Component
|
2020-03-03 18:04:16 +01:00
|
|
|
{
|
2021-08-22 20:14:52 -07:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public bool CanGhostInteract
|
|
|
|
|
{
|
|
|
|
|
get => _canGhostInteract;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_canGhostInteract == value) return;
|
|
|
|
|
_canGhostInteract = value;
|
|
|
|
|
Dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataField("canInteract")]
|
|
|
|
|
private bool _canGhostInteract;
|
|
|
|
|
|
2021-06-18 09:56:23 +02:00
|
|
|
/// <summary>
|
2021-08-06 00:02:36 -07:00
|
|
|
/// Changed by <see cref="SharedGhostSystem.SetCanReturnToBody"/>
|
2021-06-18 09:56:23 +02:00
|
|
|
/// </summary>
|
2021-08-06 00:02:36 -07:00
|
|
|
// TODO MIRROR change this to use friend classes when thats merged
|
2021-06-18 09:56:23 +02:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-08-22 20:14:52 -07:00
|
|
|
public bool CanReturnToBody
|
|
|
|
|
{
|
|
|
|
|
get => _canReturnToBody;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_canReturnToBody == value) return;
|
|
|
|
|
_canReturnToBody = value;
|
|
|
|
|
Dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataField("canReturnToBody")]
|
|
|
|
|
private bool _canReturnToBody;
|
2021-06-18 09:56:23 +02:00
|
|
|
|
2021-11-30 15:20:38 +01:00
|
|
|
public override ComponentState GetComponentState()
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
2021-08-22 20:14:52 -07:00
|
|
|
return new GhostComponentState(CanReturnToBody, CanGhostInteract);
|
2021-06-18 09:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
|
|
|
|
{
|
|
|
|
|
base.HandleComponentState(curState, nextState);
|
|
|
|
|
|
|
|
|
|
if (curState is not GhostComponentState state)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CanReturnToBody = state.CanReturnToBody;
|
2021-08-22 20:14:52 -07:00
|
|
|
CanGhostInteract = state.CanGhostInteract;
|
2021-06-18 09:56:23 +02:00
|
|
|
}
|
2020-03-03 19:10:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class GhostComponentState : ComponentState
|
2020-03-03 19:10:07 +01:00
|
|
|
{
|
|
|
|
|
public bool CanReturnToBody { get; }
|
2021-08-22 20:14:52 -07:00
|
|
|
public bool CanGhostInteract { get; }
|
2020-10-16 13:36:20 -05:00
|
|
|
|
2021-06-18 09:56:23 +02:00
|
|
|
public GhostComponentState(
|
|
|
|
|
bool canReturnToBody,
|
2021-08-22 20:14:52 -07:00
|
|
|
bool canGhostInteract)
|
2020-10-16 13:36:20 -05:00
|
|
|
{
|
2021-06-18 09:56:23 +02:00
|
|
|
CanReturnToBody = canReturnToBody;
|
2021-08-22 20:14:52 -07:00
|
|
|
CanGhostInteract = canGhostInteract;
|
2020-10-16 13:36:20 -05:00
|
|
|
}
|
2020-03-03 18:04:16 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-10-16 13:36:20 -05:00
|
|
|
|
|
|
|
|
|