This commit is contained in:
ShadowCommander
2023-06-18 11:33:19 -07:00
committed by GitHub
parent 8a943fb374
commit dd7032a860
85 changed files with 1432 additions and 711 deletions

View File

@@ -92,13 +92,13 @@ namespace Content.Server.Ghost
if (EntityManager.HasComponent<VisitingMindComponent>(uid))
return;
if (!EntityManager.TryGetComponent<MindComponent>(uid, out var mind) || !mind.HasMind || mind.Mind!.IsVisitingEntity)
if (!EntityManager.TryGetComponent<MindContainerComponent>(uid, out var mind) || !mind.HasMind || mind.Mind.IsVisitingEntity)
return;
if (component.MustBeDead && (_mobState.IsAlive(uid) || _mobState.IsCritical(uid)))
return;
_ticker.OnGhostAttempt(mind.Mind!, component.CanReturn);
_ticker.OnGhostAttempt(mind.Mind, component.CanReturn);
}
private void OnGhostStartup(EntityUid uid, GhostComponent component, ComponentStartup args)
@@ -172,7 +172,7 @@ namespace Content.Server.Ghost
private void OnPlayerDetached(EntityUid uid, GhostComponent component, PlayerDetachedEvent args)
{
QueueDel(uid);
DeleteEntity(uid);
}
private void OnGhostWarpsRequest(GhostWarpsRequestEvent msg, EntitySessionEventArgs args)
@@ -199,7 +199,7 @@ namespace Content.Server.Ghost
return;
}
actor.PlayerSession.ContentData()!.Mind?.UnVisit();
_mindSystem.UnVisit(actor.PlayerSession.ContentData()!.Mind);
}
private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, EntitySessionEventArgs args)
@@ -236,9 +236,9 @@ namespace Content.Server.Ghost
if (Deleted(uid) || Terminating(uid))
return;
if (EntityManager.TryGetComponent<MindComponent?>(uid, out var mind))
if (EntityManager.TryGetComponent<MindContainerComponent?>(uid, out var mind))
_mindSystem.SetGhostOnShutdown(uid, false, mind);
EntityManager.DeleteEntity(uid);
QueueDel(uid);
}
private IEnumerable<GhostWarp> GetLocationWarps()
@@ -260,7 +260,7 @@ namespace Content.Server.Ghost
{
if (attached == except) continue;
TryComp<MindComponent>(attached, out var mind);
TryComp<MindContainerComponent>(attached, out var mind);
string playerInfo = $"{EntityManager.GetComponent<MetaDataComponent>(attached).EntityName} ({mind?.Mind?.CurrentJob?.Name ?? "Unknown"})";

View File

@@ -1,4 +1,5 @@
using Content.Server.EUI;
using Content.Server.Mind;
using Content.Server.Players;
using Content.Shared.Eui;
using Content.Shared.Ghost;
@@ -7,6 +8,8 @@ namespace Content.Server.Ghost;
public sealed class ReturnToBodyEui : BaseEui
{
[Dependency] private readonly MindSystem _mindSystem = default!;
private readonly Mind.Mind _mind;
public ReturnToBodyEui(Mind.Mind mind)
@@ -25,8 +28,8 @@ public sealed class ReturnToBodyEui : BaseEui
return;
}
if (_mind.TryGetSession(out var session))
session.ContentData()!.Mind?.UnVisit();
if (_mindSystem.TryGetSession(_mind, out var session))
_mindSystem.UnVisit(session.ContentData()!.Mind);
Close();
}
}

View File

@@ -6,7 +6,7 @@ namespace Content.Server.Ghost.Roles.Components
[Access(typeof(GhostRoleSystem))]
public sealed class GhostRoleComponent : Component
{
[DataField("name")] public string _roleName = "Unknown";
[DataField("name")] private string _roleName = "Unknown";
[DataField("description")] private string _roleDescription = "Unknown";

View File

@@ -5,6 +5,7 @@ using Content.Server.Ghost.Roles.Components;
using Content.Server.Ghost.Roles.Events;
using Content.Server.Ghost.Roles.UI;
using Content.Server.Mind.Commands;
using Content.Server.Mind;
using Content.Server.Mind.Components;
using Content.Server.Players;
using Content.Shared.Administration;
@@ -33,6 +34,7 @@ namespace Content.Server.Ghost.Roles
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly FollowerSystem _followerSystem = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
private uint _nextRoleIdentifier;
private bool _needsUpdateGhostRoleCount = true;
@@ -214,18 +216,14 @@ namespace Content.Server.Ghost.Roles
{
if (!Resolve(roleUid, ref role)) return;
var contentData = player.ContentData();
DebugTools.AssertNotNull(player.ContentData());
DebugTools.AssertNotNull(contentData);
var newMind = _mindSystem.CreateMind(player.UserId,
EntityManager.GetComponent<MetaDataComponent>(mob).EntityName);
_mindSystem.AddRole(newMind, new GhostRoleMarkerRole(newMind, role.RoleName));
var newMind = new Mind.Mind(player.UserId)
{
CharacterName = EntityManager.GetComponent<MetaDataComponent>(mob).EntityName
};
newMind.AddRole(new GhostRoleMarkerRole(newMind, role.RoleName));
newMind.ChangeOwningPlayer(player.UserId);
newMind.TransferTo(mob);
_mindSystem.ChangeOwningPlayer(newMind, player.UserId);
_mindSystem.TransferTo(newMind, mob);
}
public GhostRoleInfo[] GetGhostRolesInfo()
@@ -343,7 +341,7 @@ namespace Content.Server.Ghost.Roles
if (ghostRole.MakeSentient)
MakeSentientCommand.MakeSentient(mob, EntityManager, ghostRole.AllowMovement, ghostRole.AllowSpeech);
mob.EnsureComponent<MindComponent>();
mob.EnsureComponent<MindContainerComponent>();
GhostRoleInternalCreateMindAndTransfer(args.Player, uid, mob, ghostRole);
@@ -379,7 +377,7 @@ namespace Content.Server.Ghost.Roles
ghostRole.Taken = true;
var mind = EnsureComp<MindComponent>(uid);
var mind = EnsureComp<MindContainerComponent>(uid);
if (mind.HasMind)
{

View File

@@ -35,7 +35,7 @@ namespace Content.Server.Ghost.Roles
return;
}
if (entityManager.TryGetComponent(uid, out MindComponent? mind) &&
if (entityManager.TryGetComponent(uid, out MindContainerComponent? mind) &&
mind.HasMind)
{
shell.WriteLine($"Entity {metaData.EntityName} with id {uid} already has a mind.");