Files
tbd-station-14/Content.Server/GameObjects/Components/Observer/GhostRoleComponent.cs
Vera Aguilera Puerto 4c419f85ce Ghost Roles (#3106)
* Add files for Ghost Roles.

* Work on Ghost Roles

* Improvements

* GHOST ROLES IS DONE

* mmm yes

* auto-update when setting rolename/roledescription

* well

* command graceful error

* Makes UI have a scrollbar when it has too many entries

* fix command fuckup

* Apply suggestions from code review

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2021-02-12 14:35:56 +11:00

76 lines
2.0 KiB
C#

using Content.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
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);
}
}