Mind ecs (#14412)
This commit is contained in:
@@ -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)
|
||||
@@ -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,7 +236,7 @@ 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);
|
||||
}
|
||||
@@ -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"})";
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Content.Server.Ghost.Roles.Components
|
||||
if (MakeSentient)
|
||||
MakeSentientCommand.MakeSentient(mob, _entMan, AllowMovement, AllowSpeech);
|
||||
|
||||
mob.EnsureComponent<MindComponent>();
|
||||
mob.EnsureComponent<MindContainerComponent>();
|
||||
|
||||
var ghostRoleSystem = EntitySystem.Get<GhostRoleSystem>();
|
||||
ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, Owner, mob, this);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Content.Server.Ghost.Roles.Components
|
||||
|
||||
Taken = true;
|
||||
|
||||
var mind = Owner.EnsureComponent<MindComponent>();
|
||||
var mind = Owner.EnsureComponent<MindContainerComponent>();
|
||||
|
||||
if (mind.HasMind)
|
||||
return false;
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.EUI;
|
||||
using Content.Server.Ghost.Components;
|
||||
using Content.Server.Ghost.Roles.Components;
|
||||
using Content.Server.Ghost.Roles.UI;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
@@ -30,6 +31,7 @@ namespace Content.Server.Ghost.Roles
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly FollowerSystem _followerSystem = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
|
||||
private uint _nextRoleIdentifier;
|
||||
private bool _needsUpdateGhostRoleCount = true;
|
||||
@@ -204,14 +206,12 @@ namespace Content.Server.Ghost.Roles
|
||||
|
||||
DebugTools.AssertNotNull(contentData);
|
||||
|
||||
var newMind = new Mind.Mind(player.UserId)
|
||||
{
|
||||
CharacterName = EntityManager.GetComponent<MetaDataComponent>(mob).EntityName
|
||||
};
|
||||
newMind.AddRole(new GhostRoleMarkerRole(newMind, role.RoleName));
|
||||
var newMind = _mindSystem.CreateMind(player.UserId,
|
||||
EntityManager.GetComponent<MetaDataComponent>(mob).EntityName);
|
||||
_mindSystem.AddRole(newMind, new GhostRoleMarkerRole(newMind, role.RoleName));
|
||||
|
||||
newMind.ChangeOwningPlayer(player.UserId);
|
||||
newMind.TransferTo(mob);
|
||||
_mindSystem.ChangeOwningPlayer(newMind, player.UserId);
|
||||
_mindSystem.TransferTo(newMind, mob);
|
||||
}
|
||||
|
||||
public GhostRoleInfo[] GetGhostRolesInfo()
|
||||
|
||||
@@ -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.");
|
||||
|
||||
Reference in New Issue
Block a user