Mind ECS (#16826)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Ghost.Components;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Ghost;
|
||||
@@ -33,11 +34,15 @@ namespace Content.Server.Administration.Commands
|
||||
shell.WriteLine("You can't ghost here!");
|
||||
return;
|
||||
}
|
||||
|
||||
var mindSystem = _entities.System<MindSystem>();
|
||||
|
||||
if (mind.VisitingEntity != default && _entities.HasComponent<GhostComponent>(mind.VisitingEntity))
|
||||
if (mind.VisitingEntity != default && _entities.TryGetComponent<GhostComponent>(mind.VisitingEntity, out var oldGhostComponent))
|
||||
{
|
||||
player.ContentData()!.Mind?.UnVisit();
|
||||
return;
|
||||
mindSystem.UnVisit(mind);
|
||||
// If already an admin ghost, then return to body.
|
||||
if (oldGhostComponent.CanGhostInteract)
|
||||
return;
|
||||
}
|
||||
|
||||
var canReturn = mind.CurrentEntity != null
|
||||
@@ -56,12 +61,12 @@ namespace Content.Server.Administration.Commands
|
||||
else if (!string.IsNullOrWhiteSpace(mind.Session?.Name))
|
||||
_entities.GetComponent<MetaDataComponent>(ghost).EntityName = mind.Session.Name;
|
||||
|
||||
mind.Visit(ghost);
|
||||
mindSystem.Visit(mind, ghost);
|
||||
}
|
||||
else
|
||||
{
|
||||
_entities.GetComponent<MetaDataComponent>(ghost).EntityName = player.Name;
|
||||
mind.TransferTo(ghost);
|
||||
mindSystem.TransferTo(mind, ghost);
|
||||
}
|
||||
|
||||
var comp = _entities.GetComponent<GhostComponent>(ghost);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
@@ -44,7 +45,7 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_entities.HasComponent<MindComponent>(target))
|
||||
if (!_entities.HasComponent<MindContainerComponent>(target))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("shell-entity-is-not-mob"));
|
||||
return;
|
||||
@@ -54,7 +55,8 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
DebugTools.AssertNotNull(mind);
|
||||
|
||||
mind!.TransferTo(target);
|
||||
var mindSystem = _entities.System<MindSystem>();
|
||||
mindSystem.TransferTo(mind!, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
@@ -9,9 +10,10 @@ namespace Content.Server.Administration.Commands
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
sealed class SetMindCommand : IConsoleCommand
|
||||
{
|
||||
|
||||
public string Command => "setmind";
|
||||
|
||||
public string Description => Loc.GetString("set-mind-command-description", ("requiredComponent", nameof(MindComponent)));
|
||||
public string Description => Loc.GetString("set-mind-command-description", ("requiredComponent", nameof(MindContainerComponent)));
|
||||
|
||||
public string Help => Loc.GetString("set-mind-command-help-text", ("command", Command));
|
||||
|
||||
@@ -39,7 +41,7 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.HasComponent<MindComponent>(eUid))
|
||||
if (!entityManager.HasComponent<MindContainerComponent>(eUid))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("set-mind-command-target-has-no-mind-message"));
|
||||
return;
|
||||
@@ -59,16 +61,16 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
var mindSystem = entityManager.System<MindSystem>();
|
||||
|
||||
var mind = playerCData.Mind;
|
||||
if (mind == null)
|
||||
{
|
||||
mind = new Mind.Mind(session.UserId)
|
||||
{
|
||||
CharacterName = entityManager.GetComponent<MetaDataComponent>(eUid).EntityName
|
||||
};
|
||||
mind.ChangeOwningPlayer(session.UserId);
|
||||
mind = mindSystem.CreateMind(session.UserId);
|
||||
mind.CharacterName = entityManager.GetComponent<MetaDataComponent>(eUid).EntityName;
|
||||
}
|
||||
mind.TransferTo(eUid);
|
||||
|
||||
mindSystem.TransferTo(mind, eUid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public sealed partial class AdminVerbSystem
|
||||
if (!_adminManager.HasAdminFlag(player, AdminFlags.Fun))
|
||||
return;
|
||||
|
||||
var targetHasMind = TryComp(args.Target, out MindComponent? targetMindComp);
|
||||
var targetHasMind = TryComp(args.Target, out MindContainerComponent? targetMindComp);
|
||||
if (!targetHasMind || targetMindComp == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using Content.Server.Disposal.Tube;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Server.EUI;
|
||||
using Content.Server.Ghost.Roles;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Mind.Commands;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Players;
|
||||
@@ -53,6 +54,7 @@ namespace Content.Server.Administration.Systems
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
[Dependency] private readonly PrayerSystem _prayerSystem = default!;
|
||||
[Dependency] private readonly EuiManager _eui = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
|
||||
private readonly Dictionary<IPlayerSession, EditSolutionsEui> _openSolutionUis = new();
|
||||
|
||||
@@ -245,7 +247,12 @@ namespace Content.Server.Administration.Systems
|
||||
Act = () =>
|
||||
{
|
||||
MakeSentientCommand.MakeSentient(args.Target, EntityManager);
|
||||
player.ContentData()?.Mind?.TransferTo(args.Target, ghostCheckOverride: true);
|
||||
|
||||
var mind = player.ContentData()?.Mind;
|
||||
if (mind == null)
|
||||
return;
|
||||
|
||||
_mindSystem.TransferTo(mind, args.Target, ghostCheckOverride: true);
|
||||
},
|
||||
Impact = LogImpact.High,
|
||||
ConfirmationPopup = true
|
||||
@@ -279,7 +286,7 @@ namespace Content.Server.Administration.Systems
|
||||
// Make Sentient verb
|
||||
if (_groupController.CanCommand(player, "makesentient") &&
|
||||
args.User != args.Target &&
|
||||
!EntityManager.HasComponent<MindComponent>(args.Target))
|
||||
!EntityManager.HasComponent<MindContainerComponent>(args.Target))
|
||||
{
|
||||
Verb verb = new()
|
||||
{
|
||||
@@ -342,7 +349,7 @@ namespace Content.Server.Administration.Systems
|
||||
|
||||
// Make ghost role verb
|
||||
if (_groupController.CanCommand(player, "makeghostrole") &&
|
||||
!(EntityManager.GetComponentOrNull<MindComponent>(args.Target)?.HasMind ?? false))
|
||||
!(EntityManager.GetComponentOrNull<MindContainerComponent>(args.Target)?.HasMind ?? false))
|
||||
{
|
||||
Verb verb = new();
|
||||
verb.Text = Loc.GetString("make-ghost-role-verb-get-data-text");
|
||||
|
||||
Reference in New Issue
Block a user