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:
@@ -1,5 +1,5 @@
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Mind;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
@@ -26,25 +26,27 @@ namespace Content.Server.Chat.Commands
|
||||
|
||||
if (player.Status != SessionStatus.InGame || player.AttachedEntity == null)
|
||||
return;
|
||||
var mind = player.ContentData()?.Mind;
|
||||
|
||||
var minds = IoCManager.Resolve<IEntityManager>().System<MindSystem>();
|
||||
// This check also proves mind not-null for at the end when the mob is ghosted.
|
||||
if (mind?.OwnedEntity is not { Valid: true } victim)
|
||||
if (!minds.TryGetMind(player, out var mindId, out var mind) ||
|
||||
mind.OwnedEntity is not { Valid: true } victim)
|
||||
{
|
||||
shell.WriteLine("You don't have a mind!");
|
||||
return;
|
||||
}
|
||||
|
||||
var gameTicker = EntitySystem.Get<GameTicker>();
|
||||
var suicideSystem = EntitySystem.Get<SuicideSystem>();
|
||||
if (suicideSystem.Suicide(victim))
|
||||
{
|
||||
// Prevent the player from returning to the body.
|
||||
// Note that mind cannot be null because otherwise victim would be null.
|
||||
gameTicker.OnGhostAttempt(mind, false);
|
||||
gameTicker.OnGhostAttempt(mindId, false, mind: mind);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameTicker.OnGhostAttempt(mind, true))
|
||||
if (gameTicker.OnGhostAttempt(mindId, true, mind: mind))
|
||||
return;
|
||||
|
||||
shell.WriteLine("You can't ghost right now.");
|
||||
|
||||
@@ -2,17 +2,15 @@ using System.Linq;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Administration.Systems;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.MoMMI;
|
||||
using Content.Server.Preferences.Managers;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Database;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Replays;
|
||||
@@ -116,19 +114,19 @@ namespace Content.Server.Chat.Managers
|
||||
ChatMessageToMany(ChatChannel.AdminAlert, message, wrappedMessage, default, false, true, clients);
|
||||
}
|
||||
|
||||
public void SendAdminAlert(EntityUid player, string message, MindContainerComponent? mindContainerComponent = null)
|
||||
public void SendAdminAlert(EntityUid player, string message)
|
||||
{
|
||||
if ((mindContainerComponent == null && !_entityManager.TryGetComponent(player, out mindContainerComponent)) || !mindContainerComponent.HasMind)
|
||||
var mindSystem = _entityManager.System<MindSystem>();
|
||||
if (!mindSystem.TryGetMind(player, out var mindId, out var mind))
|
||||
{
|
||||
SendAdminAlert(message);
|
||||
return;
|
||||
}
|
||||
|
||||
var adminSystem = _entityManager.System<AdminSystem>();
|
||||
var antag = mindContainerComponent.Mind!.UserId != null
|
||||
&& (adminSystem.GetCachedPlayerInfo(mindContainerComponent.Mind!.UserId.Value)?.Antag ?? false);
|
||||
var antag = mind.UserId != null && (adminSystem.GetCachedPlayerInfo(mind.UserId.Value)?.Antag ?? false);
|
||||
|
||||
SendAdminAlert($"{mindContainerComponent.Mind!.Session?.Name}{(antag ? " (ANTAG)" : "")} {message}");
|
||||
SendAdminAlert($"{mind.Session?.Name}{(antag ? " (ANTAG)" : "")} {message}");
|
||||
}
|
||||
|
||||
public void SendHookOOC(string sender, string message)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Shared.Chat;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Network;
|
||||
@@ -24,7 +23,7 @@ namespace Content.Server.Chat.Managers
|
||||
void SendHookOOC(string sender, string message);
|
||||
void SendAdminAnnouncement(string message);
|
||||
void SendAdminAlert(string message);
|
||||
void SendAdminAlert(EntityUid player, string message, MindContainerComponent? mindContainerComponent = null);
|
||||
void SendAdminAlert(EntityUid player, string message);
|
||||
|
||||
void ChatMessageToOne(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat,
|
||||
INetChannel client, Color? colorOverride = null, bool recordReplay = false, string? audioPath = null, float audioVolume = 0);
|
||||
|
||||
Reference in New Issue
Block a user