Fix SSS role being repeated in the examine tooltip (#1714)
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
|
using Content.Server.Mobs.Roles;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.Components.Suspicion
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
public class SuspicionRoleComponent : Component, IExamine
|
||||||
|
{
|
||||||
|
public override string Name => "SuspicionRole";
|
||||||
|
|
||||||
|
public bool IsDead()
|
||||||
|
{
|
||||||
|
return Owner.TryGetComponent(out SpeciesComponent species) &&
|
||||||
|
species.CurrentDamageState is DeadState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsTraitor()
|
||||||
|
{
|
||||||
|
return Owner.TryGetComponent(out MindComponent mind) &&
|
||||||
|
mind.HasMind &&
|
||||||
|
mind.Mind!.HasRole<SuspicionTraitorRole>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
|
||||||
|
{
|
||||||
|
if (!IsDead())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tooltip = IsTraitor()
|
||||||
|
? Loc.GetString($"They were a [color=red]traitor[/color]!")
|
||||||
|
: Loc.GetString($"They were an [color=green]innocent[/color]!");
|
||||||
|
|
||||||
|
message.AddMarkup(tooltip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,11 +10,12 @@ using Robust.Shared.Prototypes;
|
|||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Server.GameObjects.Components.Suspicion;
|
||||||
using Content.Shared.Roles;
|
using Content.Shared.Roles;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
|
||||||
|
|
||||||
namespace Content.Server.GameTicking.GamePresets
|
namespace Content.Server.GameTicking.GamePresets
|
||||||
{
|
{
|
||||||
public class PresetSuspicion : GamePreset
|
public class PresetSuspicion : GamePreset
|
||||||
@@ -54,6 +55,8 @@ namespace Content.Server.GameTicking.GamePresets
|
|||||||
{
|
{
|
||||||
prefList.Add(player);
|
prefList.Add(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.AttachedEntity?.EnsureComponent<SuspicionRoleComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var numTraitors = FloatMath.Clamp(readyPlayers.Count % PlayersPerTraitor,
|
var numTraitors = FloatMath.Clamp(readyPlayers.Count % PlayersPerTraitor,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Content.Server.GameObjects.Components.Mobs;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
using Content.Server.Interfaces.Chat;
|
using Content.Server.Interfaces.Chat;
|
||||||
@@ -7,7 +7,6 @@ using Content.Server.Mobs.Roles;
|
|||||||
using Content.Server.Players;
|
using Content.Server.Players;
|
||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Timer = Robust.Shared.Timers.Timer;
|
using Timer = Robust.Shared.Timers.Timer;
|
||||||
|
|
||||||
@@ -24,7 +23,6 @@ namespace Content.Server.GameTicking.GameRules
|
|||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly IPlayerManager _playerManager;
|
[Dependency] private readonly IPlayerManager _playerManager;
|
||||||
[Dependency] private readonly IChatManager _chatManager;
|
[Dependency] private readonly IChatManager _chatManager;
|
||||||
[Dependency] private readonly IEntityManager _entityManager;
|
|
||||||
[Dependency] private readonly IGameTicker _gameTicker;
|
[Dependency] private readonly IGameTicker _gameTicker;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
@@ -32,28 +30,9 @@ namespace Content.Server.GameTicking.GameRules
|
|||||||
|
|
||||||
public override void Added()
|
public override void Added()
|
||||||
{
|
{
|
||||||
_entityManager.EventBus.SubscribeEvent<MobDamageStateChangedMessage>(EventSource.Local, this, _onMobDamageStateChanged);
|
|
||||||
|
|
||||||
Timer.SpawnRepeating(DeadCheckDelay, _checkWinConditions, _checkTimerCancel.Token);
|
Timer.SpawnRepeating(DeadCheckDelay, _checkWinConditions, _checkTimerCancel.Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _onMobDamageStateChanged(MobDamageStateChangedMessage message)
|
|
||||||
{
|
|
||||||
var owner = message.Species.Owner;
|
|
||||||
|
|
||||||
if (!(message.Species.CurrentDamageState is DeadState))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!owner.TryGetComponent<MindComponent>(out var mind))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!mind.HasMind)
|
|
||||||
return;
|
|
||||||
|
|
||||||
message.Species.Owner.Description +=
|
|
||||||
mind.Mind.HasRole<SuspicionTraitorRole>() ? "\nThey were a traitor!" : "\nThey were an innocent!";
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Removed()
|
public override void Removed()
|
||||||
{
|
{
|
||||||
base.Removed();
|
base.Removed();
|
||||||
@@ -78,6 +57,7 @@ namespace Content.Server.GameTicking.GameRules
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerSession.ContentData().Mind.HasRole<SuspicionTraitorRole>())
|
if (playerSession.ContentData().Mind.HasRole<SuspicionTraitorRole>())
|
||||||
traitorsAlive++;
|
traitorsAlive++;
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user