Files
tbd-station-14/Content.Server/GameObjects/Components/Observer/GhostRoleComponent.cs
Vera Aguilera Puerto 9ee0ec4106 Holiday System (#3122)
2021-02-12 10:45:22 +01:00

75 lines
2.0 KiB
C#

using Content.Server.GameObjects.EntitySystems;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Observer
{
public abstract class GhostRoleComponent : Component
{
private string _roleName;
private string _roleDescription;
// We do this so updating RoleName and RoleDescription in VV updates the open EUIs.
[ViewVariables(VVAccess.ReadWrite)]
public string RoleName
{
get
{
return _roleName;
}
private set
{
_roleName = value;
EntitySystem.Get<GhostRoleSystem>().UpdateAllEui();
}
}
[ViewVariables(VVAccess.ReadWrite)]
public string RoleDescription
{
get
{
return _roleDescription;
}
private set
{
_roleDescription = value;
EntitySystem.Get<GhostRoleSystem>().UpdateAllEui();
}
}
[ViewVariables(VVAccess.ReadOnly)]
public bool Taken { get; protected set; }
[ViewVariables]
public uint Identifier { get; set; }
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _roleName, "name", "Unknown");
serializer.DataField(ref _roleDescription, "description", "Unknown");
}
public override void Initialize()
{
base.Initialize();
EntitySystem.Get<GhostRoleSystem>().RegisterGhostRole(this);
}
protected override void Shutdown()
{
base.Shutdown();
EntitySystem.Get<GhostRoleSystem>().UnregisterGhostRole(this);
}
public abstract bool Take(IPlayerSession session);
}
}