mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
Uses the following Cherry-Picks: https://github.com/space-wizards/space-station-14/pull/26994 https://github.com/space-wizards/space-station-14/pull/26518 https://github.com/space-wizards/space-station-14/pull/26279 https://github.com/space-wizards/space-station-14/pull/24946 https://github.com/space-wizards/space-station-14/pull/27188 Requires: https://github.com/Simple-Station/Einstein-Engines/pull/535 https://github.com/Simple-Station/Einstein-Engines/pull/534 --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Co-authored-by: Jake Huxell <JakeHuxell@pm.me> Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: 0x6273 <0x40@keemail.me> Co-authored-by: DEATHB4DEFEAT <zachcaffee@outlook.com>
48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using Content.Server.Body.Components;
|
|
using Content.Server.Ghost.Components;
|
|
using Content.Shared.Body.Components;
|
|
using Content.Shared.Body.Events;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Mind.Components;
|
|
using Content.Shared.Pointing;
|
|
|
|
namespace Content.Server.Body.Systems
|
|
{
|
|
public sealed class BrainSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<BrainComponent, OrganAddedToBodyEvent>((uid, _, args) => HandleMind(args.Body, uid));
|
|
SubscribeLocalEvent<BrainComponent, OrganRemovedFromBodyEvent>((uid, _, args) => HandleMind(uid, args.OldBody));
|
|
SubscribeLocalEvent<BrainComponent, PointAttemptEvent>(OnPointAttempt);
|
|
}
|
|
|
|
private void HandleMind(EntityUid newEntity, EntityUid oldEntity)
|
|
{
|
|
if (TerminatingOrDeleted(newEntity) || TerminatingOrDeleted(oldEntity))
|
|
return;
|
|
|
|
EnsureComp<MindContainerComponent>(newEntity);
|
|
EnsureComp<MindContainerComponent>(oldEntity);
|
|
|
|
var ghostOnMove = EnsureComp<GhostOnMoveComponent>(newEntity);
|
|
if (HasComp<BodyComponent>(newEntity))
|
|
ghostOnMove.MustBeDead = true;
|
|
|
|
if (!_mindSystem.TryGetMind(oldEntity, out var mindId, out var mind))
|
|
return;
|
|
|
|
_mindSystem.TransferTo(mindId, newEntity, mind: mind);
|
|
}
|
|
|
|
private void OnPointAttempt(Entity<BrainComponent> ent, ref PointAttemptEvent args)
|
|
{
|
|
args.Cancel();
|
|
}
|
|
}
|
|
}
|