Suspicion improvements:
1. pull settings from cvars. 2. Fix greet. Fixes #1823
This commit is contained in:
@@ -13,6 +13,7 @@ using System.Linq;
|
||||
using Content.Server.GameObjects.Components.Suspicion;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.Configuration;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
@@ -24,20 +25,32 @@ namespace Content.Server.GameTicking.GamePresets
|
||||
[Dependency] private readonly IChatManager _chatManager;
|
||||
[Dependency] private readonly IGameTicker _gameTicker;
|
||||
[Dependency] private readonly IRobustRandom _random;
|
||||
[Dependency] private readonly IConfigurationManager _cfg;
|
||||
[Dependency] private IPrototypeManager _prototypeManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
public int MinPlayers { get; set; } = 5;
|
||||
public int MinTraitors { get; set; } = 2;
|
||||
public int PlayersPerTraitor { get; set; } = 5;
|
||||
public int MinPlayers { get; set; }
|
||||
public int MinTraitors { get; set; }
|
||||
public int PlayersPerTraitor { get; set; }
|
||||
|
||||
public override bool DisallowLateJoin => true;
|
||||
|
||||
private static string TraitorID = "SuspicionTraitor";
|
||||
private static string InnocentID = "SuspicionInnocent";
|
||||
|
||||
public static void RegisterCVars(IConfigurationManager cfg)
|
||||
{
|
||||
cfg.RegisterCVar("game.suspicion_min_players", 5);
|
||||
cfg.RegisterCVar("game.suspicion_min_traitors", 2);
|
||||
cfg.RegisterCVar("game.suspicion_players_per_traitor", 5);
|
||||
}
|
||||
|
||||
public override bool Start(IReadOnlyList<IPlayerSession> readyPlayers, bool force = false)
|
||||
{
|
||||
MinPlayers = _cfg.GetCVar<int>("game.suspicion_min_players");
|
||||
MinTraitors = _cfg.GetCVar<int>("game.suspicion_min_traitors");
|
||||
PlayersPerTraitor = _cfg.GetCVar<int>("game.suspicion_players_per_traitor");
|
||||
|
||||
if (!force && readyPlayers.Count < MinPlayers)
|
||||
{
|
||||
_chatManager.DispatchServerAnnouncement($"Not enough players readied up for the game! There were {readyPlayers.Count} players readied up out of {MinPlayers} needed.");
|
||||
@@ -71,6 +84,8 @@ namespace Content.Server.GameTicking.GamePresets
|
||||
var numTraitors = MathHelper.Clamp(readyPlayers.Count / PlayersPerTraitor,
|
||||
MinTraitors, readyPlayers.Count);
|
||||
|
||||
var traitors = new List<SuspicionTraitorRole>();
|
||||
|
||||
for (var i = 0; i < numTraitors; i++)
|
||||
{
|
||||
IPlayerSession traitor;
|
||||
@@ -87,7 +102,9 @@ namespace Content.Server.GameTicking.GamePresets
|
||||
}
|
||||
var mind = traitor.Data.ContentData().Mind;
|
||||
var antagPrototype = _prototypeManager.Index<AntagPrototype>(TraitorID);
|
||||
mind.AddRole(new SuspicionTraitorRole(mind, antagPrototype));
|
||||
var traitorRole = new SuspicionTraitorRole(mind, antagPrototype);
|
||||
mind.AddRole(traitorRole);
|
||||
traitors.Add(traitorRole);
|
||||
}
|
||||
|
||||
foreach (var player in list)
|
||||
@@ -97,6 +114,11 @@ namespace Content.Server.GameTicking.GamePresets
|
||||
mind.AddRole(new SuspicionInnocentRole(mind, antagPrototype));
|
||||
}
|
||||
|
||||
foreach (var traitor in traitors)
|
||||
{
|
||||
traitor.GreetSuspicion(traitors, _chatManager);
|
||||
}
|
||||
|
||||
_gameTicker.AddGameRule<RuleSuspicion>();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user