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,6 +1,5 @@
using Content.Server.Administration;
using Content.Server.Mind;
using Content.Server.Players;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
@@ -12,7 +11,7 @@ namespace Content.Server.Objectives.Commands
public sealed class AddObjectiveCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entityManager = default!;
public string Command => "addobjective";
public string Description => "Adds an objective to the player's mind.";
public string Help => "addobjective <username> <objectiveID>";
@@ -25,15 +24,14 @@ namespace Content.Server.Objectives.Commands
}
var mgr = IoCManager.Resolve<IPlayerManager>();
if (!mgr.TryGetPlayerDataByUsername(args[0], out var data))
if (!mgr.TryGetSessionByUsername(args[0], out var data))
{
shell.WriteLine("Can't find the playerdata.");
return;
}
var mind = data.ContentData()?.Mind;
if (mind == null)
var minds = _entityManager.System<MindSystem>();
if (!minds.TryGetMind(data, out var mindId, out var mind))
{
shell.WriteLine("Can't find the mind.");
return;
@@ -45,14 +43,12 @@ namespace Content.Server.Objectives.Commands
shell.WriteLine($"Can't find matching ObjectivePrototype {objectivePrototype}");
return;
}
var mindSystem = _entityManager.System<MindSystem>();
if (!mindSystem.TryAddObjective(mind, objectivePrototype))
var mindSystem = _entityManager.System<MindSystem>();
if (!mindSystem.TryAddObjective(mindId, mind, objectivePrototype))
{
shell.WriteLine("Objective requirements dont allow that objective to be added.");
}
}
}
}