Ghost roles create new minds, better tracking of roles at round end screen (#5175)

* Ghost roles now get new Minds

* Some round start/end button stuff

* Mind tracking for better round end reports

* Make traitor kill objectives use mind CharacterName rather than actual occupied entity ("kill brain" prevention)

* Transition over to EntityUid for mind stuff because that's the only way to do it

* BrainSystem fix for PR rebase
This commit is contained in:
20kdc
2021-11-15 18:14:34 +00:00
committed by GitHub
parent c3a7548545
commit 4cce40bd9f
26 changed files with 229 additions and 68 deletions

View File

@@ -0,0 +1,18 @@
using Content.Server.Roles;
using Robust.Shared.Localization;
namespace Content.Server.Ghost
{
/// <summary>
/// This is used to mark Observers properly, as they get Minds
/// </summary>
public class ObserverRole : Role
{
public override string Name => Loc.GetString("observer-role-name");
public override bool Antagonist => false;
public ObserverRole(Mind.Mind mind) : base(mind)
{
}
}
}

View File

@@ -51,11 +51,8 @@ namespace Content.Server.Ghost.Roles.Components
mob.EnsureComponent<MindComponent>();
var mind = session.ContentData()?.Mind;
DebugTools.AssertNotNull(mind);
mind!.TransferTo(mob);
var ghostRoleSystem = EntitySystem.Get<GhostRoleSystem>();
ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, OwnerUid, mob.Uid, this);
if (++_currentTakeovers < _availableTakeovers)
return true;

View File

@@ -27,13 +27,10 @@ namespace Content.Server.Ghost.Roles.Components
if (mind.HasMind)
return false;
var sessionMind = session.ContentData()?.Mind;
var ghostRoleSystem = EntitySystem.Get<GhostRoleSystem>();
ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, OwnerUid, OwnerUid, this);
DebugTools.AssertNotNull(sessionMind);
sessionMind!.TransferTo(Owner);
EntitySystem.Get<GhostRoleSystem>().UnregisterGhostRole(this);
ghostRoleSystem.UnregisterGhostRole(this);
return true;
}

View File

@@ -0,0 +1,21 @@
using Content.Server.Roles;
using Robust.Shared.Localization;
namespace Content.Server.Ghost.Roles
{
/// <summary>
/// This is used for round end display of ghost roles.
/// It may also be used to ensure some ghost roles count as antagonists in future.
/// </summary>
public class GhostRoleMarkerRole : Role
{
private readonly string _name;
public override string Name => _name;
public override bool Antagonist => false;
public GhostRoleMarkerRole(Mind.Mind mind, string name) : base(mind)
{
_name = name;
}
}
}

View File

@@ -4,6 +4,7 @@ using Content.Server.EUI;
using Content.Server.Ghost.Components;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Ghost.Roles.UI;
using Content.Server.Players;
using Content.Shared.GameTicking;
using Content.Shared.Ghost.Roles;
using Content.Shared.Ghost;
@@ -14,6 +15,7 @@ using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.ViewVariables;
using Robust.Shared.Utility;
using Robust.Shared.Enums;
namespace Content.Server.Ghost.Roles
@@ -153,6 +155,24 @@ namespace Content.Server.Ghost.Roles
CloseEui(player);
}
public void GhostRoleInternalCreateMindAndTransfer(IPlayerSession player, EntityUid roleUid, EntityUid mob, GhostRoleComponent? role = null)
{
if (!Resolve(roleUid, ref role)) return;
var contentData = player.ContentData();
DebugTools.AssertNotNull(contentData);
var newMind = new Mind.Mind(player.UserId)
{
CharacterName = EntityManager.GetComponent<MetaDataComponent>(mob).EntityName
};
newMind.AddRole(new GhostRoleMarkerRole(newMind, role.RoleName));
newMind.ChangeOwningPlayer(player.UserId);
newMind.TransferTo(mob);
}
public GhostRoleInfo[] GetGhostRolesInfo()
{
var roles = new GhostRoleInfo[_ghostRoles.Count];