Un-revert IPlayerManager refactor (#21244)

This commit is contained in:
Leon Friedrich
2023-10-28 09:59:53 +11:00
committed by GitHub
parent c55e1dcafd
commit e685cb626b
245 changed files with 781 additions and 943 deletions

View File

@@ -2,7 +2,6 @@ using Content.Server.Station.Systems;
using Content.Shared.Administration;
using Content.Shared.GameTicking;
using Content.Shared.Roles;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
@@ -30,7 +29,7 @@ namespace Content.Server.GameTicking.Commands
return;
}
var player = shell.Player as IPlayerSession;
var player = shell.Player;
if (player == null)
{

View File

@@ -1,6 +1,5 @@
using Content.Shared.Administration;
using Content.Shared.GameTicking;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.GameTicking.Commands
@@ -14,7 +13,7 @@ namespace Content.Server.GameTicking.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not IPlayerSession player)
if (shell.Player is not { } player)
{
return;
}

View File

@@ -14,7 +14,7 @@ namespace Content.Server.GameTicking.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var player = shell.Player;
if (args.Length > 1)
{
shell.WriteLine("Must provide <= 1 argument.");

View File

@@ -1,5 +1,4 @@
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.GameTicking.Commands
@@ -13,7 +12,7 @@ namespace Content.Server.GameTicking.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var player = shell.Player;
if (args.Length != 1)
{
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));

View File

@@ -11,7 +11,7 @@ using Content.Shared.Ghost;
using Content.Shared.Mind;
using Content.Shared.Mobs.Components;
using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.Player;
namespace Content.Server.GameTicking
{
@@ -29,7 +29,7 @@ namespace Content.Server.GameTicking
/// </summary>
public GamePresetPrototype? CurrentPreset { get; private set; }
private bool StartPreset(IPlayerSession[] origReadyPlayers, bool force)
private bool StartPreset(ICommonSession[] origReadyPlayers, bool force)
{
var startAttempt = new RoundStartAttemptEvent(origReadyPlayers, force);
RaiseLocalEvent(startAttempt);
@@ -214,7 +214,7 @@ namespace Content.Server.GameTicking
{
if (mind.Session != null) // Logging is suppressed to prevent spam from ghost attempts caused by movement attempts
{
_chatManager.DispatchServerMessage((IPlayerSession) mind.Session, Loc.GetString("comp-mind-ghosting-prevented"),
_chatManager.DispatchServerMessage(mind.Session, Loc.GetString("comp-mind-ghosting-prevented"),
true);
}

View File

@@ -1,10 +1,8 @@
using System.Linq;
using Content.Shared.GameTicking;
using Content.Server.Station.Components;
using Robust.Server.Player;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Players;
using System.Text;
namespace Content.Server.GameTicking
@@ -79,7 +77,7 @@ namespace Content.Server.GameTicking
("roundId", RoundId), ("playerCount", playerCount), ("readyCount", readyCount), ("mapName", stationNames.ToString()),("gmTitle", gmTitle),("desc", desc));
}
private TickerLobbyStatusEvent GetStatusMsg(IPlayerSession session)
private TickerLobbyStatusEvent GetStatusMsg(ICommonSession session)
{
_playerGameStatuses.TryGetValue(session.UserId, out var status);
return new TickerLobbyStatusEvent(RunLevel != GameRunLevel.PreRoundLobby, LobbySong, LobbyBackground,status == PlayerGameStatus.ReadyToPlay, _roundStartTime, RoundPreloadTime, _roundStartTimeSpan, Paused);
@@ -87,7 +85,7 @@ namespace Content.Server.GameTicking
private void SendStatusToAll()
{
foreach (var player in _playerManager.ServerSessions)
foreach (var player in _playerManager.Sessions)
{
RaiseNetworkEvent(GetStatusMsg(player), player.ConnectedClient);
}
@@ -148,7 +146,7 @@ namespace Content.Server.GameTicking
}
}
public void ToggleReady(IPlayerSession player, bool ready)
public void ToggleReady(ICommonSession player, bool ready)
{
if (!_playerGameStatuses.ContainsKey(player.UserId))
return;

View File

@@ -1,12 +1,13 @@
using Content.Server.Database;
using Content.Server.Players;
using Content.Shared.GameTicking;
using Content.Shared.GameWindow;
using Content.Shared.Players;
using Content.Shared.Preferences;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Enums;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -17,6 +18,7 @@ namespace Content.Server.GameTicking
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IServerDbManager _dbManager = default!;
[Dependency] private readonly ActorSystem _actor = default!;
private void InitializePlayer()
{
@@ -49,14 +51,14 @@ namespace Content.Server.GameTicking
// Always make sure the client has player data.
if (session.Data.ContentDataUncast == null)
{
var data = new PlayerData(session.UserId, args.Session.Name);
var data = new ContentPlayerData(session.UserId, args.Session.Name);
data.Mind = mindId;
session.Data.ContentDataUncast = data;
}
// Make the player actually join the game.
// timer time must be > tick length
Timer.Spawn(0, args.Session.JoinGame);
Timer.Spawn(0, () => _playerManager.JoinGame(args.Session));
var record = await _dbManager.GetPlayerRecordByUserId(args.Session.UserId);
var firstConnection = record != null &&
@@ -100,9 +102,16 @@ namespace Content.Server.GameTicking
}
else
{
// Simply re-attach to existing entity.
session.AttachToEntity(mind.CurrentEntity);
PlayerJoinGame(session);
if (_actor.Attach(mind.CurrentEntity, session))
{
PlayerJoinGame(session);
}
else
{
Log.Error(
$"Failed to attach player {session} with mind {ToPrettyString(mindId)} to its current entity {ToPrettyString(mind.CurrentEntity)}");
SpawnObserverWaitDb();
}
}
break;
@@ -146,12 +155,12 @@ namespace Content.Server.GameTicking
}
}
private HumanoidCharacterProfile GetPlayerProfile(IPlayerSession p)
private HumanoidCharacterProfile GetPlayerProfile(ICommonSession p)
{
return (HumanoidCharacterProfile) _prefsManager.GetPreferences(p.UserId).SelectedCharacter;
}
public void PlayerJoinGame(IPlayerSession session, bool silent = false)
public void PlayerJoinGame(ICommonSession session, bool silent = false)
{
if (!silent)
_chatManager.DispatchServerMessage(session, Loc.GetString("game-ticker-player-join-game-message"));
@@ -162,7 +171,7 @@ namespace Content.Server.GameTicking
RaiseNetworkEvent(new TickerJoinGameEvent(), session.ConnectedClient);
}
private void PlayerJoinLobby(IPlayerSession session)
private void PlayerJoinLobby(ICommonSession session)
{
_playerGameStatuses[session.UserId] = LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay;
_db.AddRoundPlayers(RoundId, session.UserId);
@@ -182,9 +191,9 @@ namespace Content.Server.GameTicking
public sealed class PlayerJoinedLobbyEvent : EntityEventArgs
{
public readonly IPlayerSession PlayerSession;
public readonly ICommonSession PlayerSession;
public PlayerJoinedLobbyEvent(IPlayerSession playerSession)
public PlayerJoinedLobbyEvent(ICommonSession playerSession)
{
PlayerSession = playerSession;
}

View File

@@ -12,7 +12,6 @@ using Content.Shared.Preferences;
using JetBrains.Annotations;
using Prometheus;
using Robust.Server.Maps;
using Robust.Server.Player;
using Robust.Shared.Asynchronous;
using Robust.Shared.Audio;
using Robust.Shared.Map;
@@ -205,7 +204,7 @@ namespace Content.Server.GameTicking
var startingEvent = new RoundStartingEvent(RoundId);
RaiseLocalEvent(startingEvent);
var readyPlayers = new List<IPlayerSession>();
var readyPlayers = new List<ICommonSession>();
var readyPlayerProfiles = new Dictionary<NetUserId, HumanoidCharacterProfile>();
foreach (var (userId, status) in _playerGameStatuses)
@@ -344,7 +343,7 @@ namespace Content.Server.GameTicking
{
connected = true;
}
PlayerData? contentPlayerData = null;
ContentPlayerData? contentPlayerData = null;
if (userId != null && _playerManager.TryGetPlayerData(userId.Value, out var playerData))
{
contentPlayerData = playerData.ContentData();
@@ -493,7 +492,7 @@ namespace Content.Server.GameTicking
private void ResettingCleanup()
{
// Move everybody currently in the server to lobby.
foreach (var player in _playerManager.ServerSessions)
foreach (var player in _playerManager.Sessions)
{
PlayerJoinLobby(player);
}
@@ -541,7 +540,7 @@ namespace Content.Server.GameTicking
DisallowLateJoin = false;
_playerGameStatuses.Clear();
foreach (var session in _playerManager.ServerSessions)
foreach (var session in _playerManager.Sessions)
{
_playerGameStatuses[session.UserId] = LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay;
}
@@ -735,10 +734,10 @@ namespace Content.Server.GameTicking
/// </summary>
public sealed class RoundStartAttemptEvent : CancellableEntityEventArgs
{
public IPlayerSession[] Players { get; }
public ICommonSession[] Players { get; }
public bool Forced { get; }
public RoundStartAttemptEvent(IPlayerSession[] players, bool forced)
public RoundStartAttemptEvent(ICommonSession[] players, bool forced)
{
Players = players;
Forced = forced;
@@ -757,11 +756,11 @@ namespace Content.Server.GameTicking
/// If you want to handle a specific player being spawned, remove it from this list and do what you need.
/// </summary>
/// <remarks>If you spawn a player by yourself from this event, don't forget to call <see cref="GameTicker.PlayerJoinGame"/> on them.</remarks>
public List<IPlayerSession> PlayerPool { get; }
public List<ICommonSession> PlayerPool { get; }
public IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> Profiles { get; }
public bool Forced { get; }
public RulePlayerSpawningEvent(List<IPlayerSession> playerPool, IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> profiles, bool forced)
public RulePlayerSpawningEvent(List<ICommonSession> playerPool, IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> profiles, bool forced)
{
PlayerPool = playerPool;
Profiles = profiles;
@@ -775,11 +774,11 @@ namespace Content.Server.GameTicking
/// </summary>
public sealed class RulePlayerJobsAssignedEvent
{
public IPlayerSession[] Players { get; }
public ICommonSession[] Players { get; }
public IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> Profiles { get; }
public bool Forced { get; }
public RulePlayerJobsAssignedEvent(IPlayerSession[] players, IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> profiles, bool forced)
public RulePlayerJobsAssignedEvent(ICommonSession[] players, IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> profiles, bool forced)
{
Players = players;
Profiles = profiles;

View File

@@ -3,20 +3,20 @@ using System.Linq;
using System.Numerics;
using Content.Server.Administration.Managers;
using Content.Server.Ghost;
using Content.Server.Players;
using Content.Server.Spawners.Components;
using Content.Server.Speech.Components;
using Content.Server.Station.Components;
using Content.Shared.CCVar;
using Content.Shared.Database;
using Content.Shared.Players;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
@@ -29,7 +29,7 @@ namespace Content.Server.GameTicking
[Dependency] private readonly SharedJobSystem _jobs = default!;
[ValidatePrototypeId<EntityPrototype>]
private const string ObserverPrototypeName = "MobObserver";
public const string ObserverPrototypeName = "MobObserver";
/// <summary>
/// How many players have joined the round through normal methods.
@@ -52,7 +52,7 @@ namespace Content.Server.GameTicking
return spawnableStations;
}
private void SpawnPlayers(List<IPlayerSession> readyPlayers, Dictionary<NetUserId, HumanoidCharacterProfile> profiles, bool force)
private void SpawnPlayers(List<ICommonSession> readyPlayers, Dictionary<NetUserId, HumanoidCharacterProfile> profiles, bool force)
{
// Allow game rules to spawn players by themselves if needed. (For example, nuke ops or wizard)
RaiseLocalEvent(new RulePlayerSpawningEvent(readyPlayers, profiles, force));
@@ -116,7 +116,7 @@ namespace Content.Server.GameTicking
RaiseLocalEvent(new RulePlayerJobsAssignedEvent(assignedJobs.Keys.Select(x => _playerManager.GetSessionByUserId(x)).ToArray(), profiles, force));
}
private void SpawnPlayer(IPlayerSession player, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false)
private void SpawnPlayer(ICommonSession player, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false)
{
var character = GetPlayerProfile(player);
@@ -129,7 +129,7 @@ namespace Content.Server.GameTicking
SpawnPlayer(player, character, station, jobId, lateJoin, silent);
}
private void SpawnPlayer(IPlayerSession player, HumanoidCharacterProfile character, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false)
private void SpawnPlayer(ICommonSession player, HumanoidCharacterProfile character, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false)
{
// Can't spawn players with a dummy ticker!
if (DummyTicker)
@@ -271,7 +271,7 @@ namespace Content.Server.GameTicking
RaiseLocalEvent(mob, aev, true);
}
public void Respawn(IPlayerSession player)
public void Respawn(ICommonSession player)
{
_mind.WipeMind(player);
_adminLogger.Add(LogType.Respawn, LogImpact.Medium, $"Player {player} was respawned.");
@@ -289,7 +289,7 @@ namespace Content.Server.GameTicking
/// <param name="station">The station they're spawning on</param>
/// <param name="jobId">An optional job for them to spawn as</param>
/// <param name="silent">Whether or not the player should be greeted upon joining</param>
public void MakeJoinGame(IPlayerSession player, EntityUid station, string? jobId = null, bool silent = false)
public void MakeJoinGame(ICommonSession player, EntityUid station, string? jobId = null, bool silent = false)
{
if (!_playerGameStatuses.ContainsKey(player.UserId))
return;
@@ -303,7 +303,7 @@ namespace Content.Server.GameTicking
/// <summary>
/// Causes the given player to join the current game as observer ghost. See also <see cref="SpawnObserver"/>
/// </summary>
public void JoinAsObserver(IPlayerSession player)
public void JoinAsObserver(ICommonSession player)
{
// Can't spawn players with a dummy ticker!
if (DummyTicker)
@@ -317,7 +317,7 @@ namespace Content.Server.GameTicking
/// Spawns an observer ghost and attaches the given player to it. If the player does not yet have a mind, the
/// player is given a new mind with the observer role. Otherwise, the current mind is transferred to the ghost.
/// </summary>
public void SpawnObserver(IPlayerSession player)
public void SpawnObserver(ICommonSession player)
{
if (DummyTicker)
return;
@@ -430,13 +430,13 @@ namespace Content.Server.GameTicking
[PublicAPI]
public sealed class PlayerBeforeSpawnEvent : HandledEntityEventArgs
{
public IPlayerSession Player { get; }
public ICommonSession Player { get; }
public HumanoidCharacterProfile Profile { get; }
public string? JobId { get; }
public bool LateJoin { get; }
public EntityUid Station { get; }
public PlayerBeforeSpawnEvent(IPlayerSession player, HumanoidCharacterProfile profile, string? jobId, bool lateJoin, EntityUid station)
public PlayerBeforeSpawnEvent(ICommonSession player, HumanoidCharacterProfile profile, string? jobId, bool lateJoin, EntityUid station)
{
Player = player;
Profile = profile;
@@ -455,7 +455,7 @@ namespace Content.Server.GameTicking
public sealed class PlayerSpawnCompleteEvent : EntityEventArgs
{
public EntityUid Mob { get; }
public IPlayerSession Player { get; }
public ICommonSession Player { get; }
public string? JobId { get; }
public bool LateJoin { get; }
public EntityUid Station { get; }
@@ -464,7 +464,7 @@ namespace Content.Server.GameTicking
// Ex. If this is the 27th person to join, this will be 27.
public int JoinOrder { get; }
public PlayerSpawnCompleteEvent(EntityUid mob, IPlayerSession player, string? jobId, bool lateJoin, int joinOrder, EntityUid station, HumanoidCharacterProfile profile)
public PlayerSpawnCompleteEvent(EntityUid mob, ICommonSession player, string? jobId, bool lateJoin, int joinOrder, EntityUid station, HumanoidCharacterProfile profile)
{
Mob = mob;
Player = player;

View File

@@ -1,7 +1,7 @@
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.GameTicking.Rules.Components;
@@ -26,7 +26,7 @@ public sealed partial class TraitorRuleComponent : Component
public SelectionState SelectionStatus = SelectionState.WaitingForSpawn;
public TimeSpan AnnounceAt = TimeSpan.Zero;
public Dictionary<IPlayerSession, HumanoidCharacterProfile> StartCandidates = new();
public Dictionary<ICommonSession, HumanoidCharacterProfile> StartCandidates = new();
/// <summary>
/// Path to antagonist alert sound.

View File

@@ -2,6 +2,7 @@ using System.Threading;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Components;
using Robust.Server.Player;
using Robust.Shared.Player;
using Timer = Robust.Shared.Timing.Timer;
namespace Content.Server.GameTicking.Rules;

View File

@@ -602,11 +602,11 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
var maxOperatives = nukeops.MaxOps;
// Dear lord what is happening HERE.
var everyone = new List<IPlayerSession>(ev.PlayerPool);
var prefList = new List<IPlayerSession>();
var medPrefList = new List<IPlayerSession>();
var cmdrPrefList = new List<IPlayerSession>();
var operatives = new List<IPlayerSession>();
var everyone = new List<ICommonSession>(ev.PlayerPool);
var prefList = new List<ICommonSession>();
var medPrefList = new List<ICommonSession>();
var cmdrPrefList = new List<ICommonSession>();
var operatives = new List<ICommonSession>();
// The LINQ expression ReSharper keeps suggesting is completely unintelligible so I'm disabling it
// ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator
@@ -637,7 +637,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
for (var i = 0; i < numNukies; i++)
{
// TODO: Please fix this if you touch it.
IPlayerSession nukeOp;
ICommonSession nukeOp;
// Only one commander, so we do it at the start
if (i == 0)
{
@@ -908,7 +908,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
_npcFaction.AddFaction(mob, "Syndicate");
}
private void SpawnOperatives(int spawnCount, List<IPlayerSession> sessions, bool addSpawnPoints, NukeopsRuleComponent component)
private void SpawnOperatives(int spawnCount, List<ICommonSession> sessions, bool addSpawnPoints, NukeopsRuleComponent component)
{
if (component.NukieOutpost == null)
return;
@@ -987,10 +987,10 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
var playersPerOperative = component.PlayersPerOperative;
var maxOperatives = component.MaxOps;
var playerPool = _playerManager.ServerSessions.ToList();
var playerPool = _playerManager.Sessions.ToList();
var numNukies = MathHelper.Clamp(playerPool.Count / playersPerOperative, 1, maxOperatives);
var operatives = new List<IPlayerSession>();
var operatives = new List<ICommonSession>();
SpawnOperatives(numNukies, operatives, true, component);
}

View File

@@ -15,10 +15,10 @@ using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Server.GameObjects;
using Robust.Server.Maps;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
@@ -141,7 +141,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem<PiratesRuleComponent>
(int) Math.Min(
Math.Floor((double) ev.PlayerPool.Count / _cfg.GetCVar(CCVars.PiratesPlayersPerOp)),
_cfg.GetCVar(CCVars.PiratesMaxOps)));
var ops = new IPlayerSession[numOps];
var ops = new ICommonSession[numOps];
for (var i = 0; i < numOps; i++)
{
ops[i] = _random.PickAndTake(ev.PlayerPool);

View File

@@ -6,6 +6,7 @@ using Content.Shared.Chat;
using Content.Shared.Interaction.Events;
using Content.Shared.Mind;
using Content.Shared.Mobs;
using Content.Shared.Players;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Network;

View File

@@ -17,9 +17,8 @@ using Content.Shared.PDA;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Players;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
@@ -151,9 +150,9 @@ public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
}
}
private List<IPlayerSession> FindPotentialTraitors(in Dictionary<IPlayerSession, HumanoidCharacterProfile> candidates, TraitorRuleComponent component)
private List<ICommonSession> FindPotentialTraitors(in Dictionary<ICommonSession, HumanoidCharacterProfile> candidates, TraitorRuleComponent component)
{
var list = new List<IPlayerSession>();
var list = new List<ICommonSession>();
var pendingQuery = GetEntityQuery<PendingClockInComponent>();
foreach (var player in candidates.Keys)
@@ -171,7 +170,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
list.Add(player);
}
var prefList = new List<IPlayerSession>();
var prefList = new List<ICommonSession>();
foreach (var player in list)
{
@@ -189,9 +188,9 @@ public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
return prefList;
}
private List<IPlayerSession> PickTraitors(int traitorCount, List<IPlayerSession> prefList)
private List<ICommonSession> PickTraitors(int traitorCount, List<ICommonSession> prefList)
{
var results = new List<IPlayerSession>(traitorCount);
var results = new List<ICommonSession>(traitorCount);
if (prefList.Count == 0)
{
Log.Info("Insufficient ready players to fill up with traitors, stopping the selection.");

View File

@@ -23,7 +23,7 @@ using Content.Shared.Zombies;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Timing;
@@ -264,9 +264,9 @@ public sealed class ZombieRuleSystem : GameRuleSystem<ZombieRuleComponent>
return;
component.InfectedChosen = true;
var allPlayers = _playerManager.ServerSessions.ToList();
var playerList = new List<IPlayerSession>();
var prefList = new List<IPlayerSession>();
var allPlayers = _playerManager.Sessions.ToList();
var playerList = new List<ICommonSession>();
var prefList = new List<ICommonSession>();
foreach (var player in allPlayers)
{
if (player.AttachedEntity == null || !HasComp<HumanoidAppearanceComponent>(player.AttachedEntity) || HasComp<ZombieImmuneComponent>(player.AttachedEntity))
@@ -288,7 +288,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem<ZombieRuleComponent>
var totalInfected = 0;
while (totalInfected < numInfected)
{
IPlayerSession zombie;
ICommonSession zombie;
if (prefList.Count == 0)
{
if (playerList.Count == 0)