* 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
71 lines
2.6 KiB
C#
71 lines
2.6 KiB
C#
using Content.Server.Instruments;
|
|
using Content.Server.Mind.Components;
|
|
using Content.Shared.Interaction.Events;
|
|
using Content.Shared.PAI;
|
|
using Robust.Server.GameObjects;
|
|
|
|
namespace Content.Server.PAI
|
|
{
|
|
public sealed class PAISystem : SharedPAISystem
|
|
{
|
|
[Dependency] private readonly InstrumentSystem _instrumentSystem = default!;
|
|
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<PAIComponent, UseInHandEvent>(OnUseInHand);
|
|
SubscribeLocalEvent<PAIComponent, MindAddedMessage>(OnMindAdded);
|
|
SubscribeLocalEvent<PAIComponent, MindRemovedMessage>(OnMindRemoved);
|
|
}
|
|
|
|
private void OnUseInHand(EntityUid uid, PAIComponent component, UseInHandEvent args)
|
|
{
|
|
if (!TryComp<MindContainerComponent>(uid, out var mind) || !mind.HasMind)
|
|
component.LastUser = args.User;
|
|
}
|
|
|
|
private void OnMindAdded(EntityUid uid, PAIComponent component, MindAddedMessage args)
|
|
{
|
|
if (component.LastUser == null)
|
|
return;
|
|
|
|
// Ownership tag
|
|
var val = Loc.GetString("pai-system-pai-name", ("owner", component.LastUser));
|
|
|
|
// TODO Identity? People shouldn't dox-themselves by carrying around a PAI.
|
|
// But having the pda's name permanently be "old lady's PAI" is weird.
|
|
// Changing the PAI's identity in a way that ties it to the owner's identity also seems weird.
|
|
// Cause then you could remotely figure out information about the owner's equipped items.
|
|
|
|
_metaData.SetEntityName(uid, val);
|
|
}
|
|
|
|
private void OnMindRemoved(EntityUid uid, PAIComponent component, MindRemovedMessage args)
|
|
{
|
|
// Mind was removed, shutdown the PAI.
|
|
PAITurningOff(uid);
|
|
}
|
|
|
|
public void PAITurningOff(EntityUid uid)
|
|
{
|
|
// Close the instrument interface if it was open
|
|
// before closing
|
|
if (HasComp<ActiveInstrumentComponent>(uid) && TryComp<ActorComponent>(uid, out var actor))
|
|
{
|
|
_instrumentSystem.ToggleInstrumentUi(uid, actor.PlayerSession);
|
|
}
|
|
|
|
// Stop instrument
|
|
if (TryComp<InstrumentComponent>(uid, out var instrument)) _instrumentSystem.Clean(uid, instrument);
|
|
if (TryComp<MetaDataComponent>(uid, out var metadata))
|
|
{
|
|
var proto = metadata.EntityPrototype;
|
|
if (proto != null)
|
|
_metaData.SetEntityName(uid, proto.Name);
|
|
}
|
|
}
|
|
}
|
|
}
|