* Laws * positronic brain and PAI rewrite * MMI * MMI pt. 2 * borg brain transfer * Roleban support, Borg job (WIP), the end of mind shenaniganry * battery drain, item slot cleanup, alerts * visuals * fix this pt1 * fix this pt2 * Modules, Lingering Stacks, Better borg flashlight * Start on UI, fix battery alerts, expand activation/deactivation, low movement speed on no power. * sprotes * no zombie borgs * oh fuck yeah i love a good relay * charger * fix the tiniest of sprite issues * adjustable names * a functional UI???? * foobar * more modules * this shit for some reason * upstream * genericize selectable borg modules * upstream again * holy fucking shit * i love christ * proper construction * da job * AA borgs * and boom more shit * admin logs * laws redux * ok just do this rq * oh boy that looks like modules * oh shit research * testos passo * so much shit holy fuck * fuckit we SHIP * last minute snags * should've gotten me on a better day
67 lines
2.8 KiB
C#
67 lines
2.8 KiB
C#
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;
|
|
using Content.Shared.Body.Organ;
|
|
using Content.Shared.Body.Part;
|
|
using Content.Shared.Movement.Components;
|
|
using Content.Shared.Movement.Systems;
|
|
|
|
namespace Content.Server.Body.Systems
|
|
{
|
|
public sealed class BrainSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
|
|
[Dependency] private readonly MindSystem _mindSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<BrainComponent, AddedToBodyEvent>((uid, _, args) => HandleMind(args.Body, uid));
|
|
SubscribeLocalEvent<BrainComponent, AddedToPartEvent>((uid, _, args) => HandleMind(args.Part, uid));
|
|
SubscribeLocalEvent<BrainComponent, AddedToPartInBodyEvent>((uid, _, args) => HandleMind(args.Body, uid));
|
|
SubscribeLocalEvent<BrainComponent, RemovedFromBodyEvent>(OnRemovedFromBody);
|
|
SubscribeLocalEvent<BrainComponent, RemovedFromPartEvent>((uid, _, args) => HandleMind(uid, args.Old));
|
|
SubscribeLocalEvent<BrainComponent, RemovedFromPartInBodyEvent>((uid, _, args) => HandleMind(args.OldBody, uid));
|
|
}
|
|
|
|
private void OnRemovedFromBody(EntityUid uid, BrainComponent component, RemovedFromBodyEvent args)
|
|
{
|
|
// This one needs to be special, okay?
|
|
if (!EntityManager.TryGetComponent(uid, out OrganComponent? organ) ||
|
|
organ.ParentSlot is not {Parent: var parent})
|
|
return;
|
|
|
|
HandleMind(parent, args.Old);
|
|
}
|
|
|
|
private void HandleMind(EntityUid newEntity, EntityUid oldEntity)
|
|
{
|
|
EnsureComp<MindContainerComponent>(newEntity);
|
|
var oldMind = EnsureComp<MindContainerComponent>(oldEntity);
|
|
|
|
var ghostOnMove = EnsureComp<GhostOnMoveComponent>(newEntity);
|
|
if (HasComp<BodyComponent>(newEntity))
|
|
ghostOnMove.MustBeDead = true;
|
|
|
|
// TODO: This is an awful solution.
|
|
// Our greatest minds still can't figure out how to allow brains/heads to ghost without giving them the
|
|
// ability to move first. I hate this with a passion.
|
|
if (!HasComp<InputMoverComponent>(newEntity))
|
|
{
|
|
AddComp<InputMoverComponent>(newEntity);
|
|
var move = EnsureComp<MovementSpeedModifierComponent>(newEntity);
|
|
_movementSpeed.ChangeBaseSpeed(newEntity, 0, 0 , 0, move);
|
|
}
|
|
|
|
if (!_mindSystem.TryGetMind(oldEntity, out var mind, oldMind))
|
|
return;
|
|
|
|
_mindSystem.TransferTo(mind, newEntity);
|
|
}
|
|
}
|
|
}
|