Refactor minds to be entities with components, make roles components (#19591)

Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
DrSmugleaf
2023-08-28 16:53:24 -07:00
committed by GitHub
parent e0ee397af7
commit 15c0211fb2
119 changed files with 1445 additions and 1289 deletions

View File

@@ -1,10 +1,9 @@
using System.Globalization;
using System.Linq;
using Content.Server.Administration.Managers;
using Content.Server.GameTicking.Events;
using Content.Server.IdentityManagement;
using Content.Server.Players;
using Content.Server.Mind;
using Content.Server.Roles;
using Content.Server.Roles.Jobs;
using Content.Shared.Administration;
using Content.Shared.Administration.Events;
using Content.Shared.GameTicking;
@@ -20,6 +19,9 @@ namespace Content.Server.Administration.Systems
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly JobSystem _jobs = default!;
[Dependency] private readonly MindSystem _minds = default!;
[Dependency] private readonly RoleSystem _role = default!;
private readonly Dictionary<NetUserId, PlayerInfo> _playerList = new();
@@ -102,10 +104,10 @@ namespace Content.Server.Administration.Systems
private void OnRoleEvent(RoleEvent ev)
{
if (!ev.Role.Antagonist || ev.Role.Mind.Session == null)
if (!ev.Antagonist || ev.Mind.Session == null)
return;
UpdatePlayerList(ev.Role.Mind.Session);
UpdatePlayerList(ev.Mind.Session);
}
private void OnAdminPermsChanged(AdminPermsChangedEventArgs obj)
@@ -169,12 +171,13 @@ namespace Content.Server.Administration.Systems
identityName = Identity.Name(session.AttachedEntity.Value, EntityManager);
}
var mind = data.ContentData()?.Mind;
var job = mind?.AllRoles.FirstOrDefault(role => role is Job);
var startingRole = job != null ? CultureInfo.CurrentCulture.TextInfo.ToTitleCase(job.Name) : string.Empty;
var antag = mind?.AllRoles.Any(r => r.Antagonist) ?? false;
var antag = false;
var startingRole = string.Empty;
if (_minds.TryGetMind(session, out var mindId, out _))
{
antag = _role.MindIsAntagonist(mindId);
startingRole = _jobs.MindTryGetJobName(mindId);
}
var connected = session != null && session.Status is SessionStatus.Connected or SessionStatus.InGame;