Mind ecs (#14412)
This commit is contained in:
@@ -4,6 +4,7 @@ using Content.Server.Body.Components;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Humanoid;
|
||||
using Content.Server.Kitchen.Components;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
@@ -28,6 +29,7 @@ public sealed class BodySystem : SharedBodySystem
|
||||
[Dependency] private readonly HumanoidAppearanceSystem _humanoidSystem = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -40,16 +42,14 @@ public sealed class BodySystem : SharedBodySystem
|
||||
|
||||
private void OnRelayMoveInput(EntityUid uid, BodyComponent component, ref MoveInputEvent args)
|
||||
{
|
||||
if (_mobState.IsDead(uid) &&
|
||||
EntityManager.TryGetComponent<MindComponent>(uid, out var mind) &&
|
||||
mind.HasMind)
|
||||
if (_mobState.IsDead(uid) && _mindSystem.TryGetMind(uid, out var mind))
|
||||
{
|
||||
if (!mind.Mind!.TimeOfDeath.HasValue)
|
||||
if (!mind.TimeOfDeath.HasValue)
|
||||
{
|
||||
mind.Mind.TimeOfDeath = _gameTiming.RealTime;
|
||||
mind.TimeOfDeath = _gameTiming.RealTime;
|
||||
}
|
||||
|
||||
_ticker.OnGhostAttempt(mind.Mind!, true);
|
||||
_ticker.OnGhostAttempt(mind, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Ghost.Components;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Events;
|
||||
@@ -10,6 +11,8 @@ namespace Content.Server.Body.Systems
|
||||
{
|
||||
public sealed class BrainSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -34,8 +37,8 @@ namespace Content.Server.Body.Systems
|
||||
|
||||
private void HandleMind(EntityUid newEntity, EntityUid oldEntity)
|
||||
{
|
||||
EntityManager.EnsureComponent<MindComponent>(newEntity);
|
||||
var oldMind = EntityManager.EnsureComponent<MindComponent>(oldEntity);
|
||||
EntityManager.EnsureComponent<MindContainerComponent>(newEntity);
|
||||
var oldMind = EntityManager.EnsureComponent<MindContainerComponent>(oldEntity);
|
||||
|
||||
EnsureComp<GhostOnMoveComponent>(newEntity);
|
||||
if (HasComp<BodyComponent>(newEntity))
|
||||
@@ -44,7 +47,10 @@ namespace Content.Server.Body.Systems
|
||||
// TODO: This is an awful solution.
|
||||
EnsureComp<InputMoverComponent>(newEntity);
|
||||
|
||||
oldMind.Mind?.TransferTo(newEntity);
|
||||
if (!_mindSystem.TryGetMind(oldEntity, out var mind, oldMind))
|
||||
return;
|
||||
|
||||
_mindSystem.TransferTo(mind, newEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user