# Conflicts: # Content.Server/PDA/PdaSystem.cs # Resources/Prototypes/Roles/Jobs/Cargo/salvage_specialist.yml # Resources/Prototypes/Roles/Jobs/Civilian/bartender.yml # Resources/Prototypes/Roles/Jobs/Civilian/chef.yml # Resources/Prototypes/Roles/Jobs/Engineering/atmospheric_technician.yml # Resources/Prototypes/Roles/Jobs/Engineering/station_engineer.yml # Resources/Prototypes/Roles/Jobs/Engineering/technical_assistant.yml # Resources/Prototypes/Roles/Jobs/Medical/chemist.yml # Resources/Prototypes/Roles/Jobs/Medical/medical_doctor.yml # Resources/Prototypes/Roles/Jobs/Medical/medical_intern.yml # Resources/Prototypes/Roles/Jobs/Medical/paramedic.yml # Resources/Prototypes/Roles/Jobs/Science/borg.yml # Resources/Prototypes/Roles/Jobs/Science/research_assistant.yml # Resources/Prototypes/Roles/Jobs/Science/scientist.yml # Resources/Prototypes/Roles/Jobs/Security/security_cadet.yml # Resources/Prototypes/Roles/Jobs/Security/security_officer.yml # Resources/Prototypes/Roles/Jobs/Security/warden.yml # Resources/Prototypes/borg_types.yml # Resources/Textures/Structures/Walls/shuttleinterior.rsi/full.png # Resources/Textures/Structures/Walls/shuttleinterior.rsi/meta.json # Resources/Textures/Structures/Walls/shuttleinterior.rsi/state0.png # Resources/Textures/Structures/Walls/shuttleinterior.rsi/state1.png # Resources/Textures/Structures/Walls/shuttleinterior.rsi/state2.png # Resources/Textures/Structures/Walls/shuttleinterior.rsi/state3.png # Resources/Textures/Structures/Walls/shuttleinterior.rsi/state4.png # Resources/Textures/Structures/Walls/shuttleinterior.rsi/state5.png # Resources/Textures/Structures/Walls/shuttleinterior.rsi/state6.png # Resources/Textures/Structures/Walls/shuttleinterior.rsi/state7.png
78 lines
2.9 KiB
C#
78 lines
2.9 KiB
C#
using Content.Shared.Access.Components;
|
|
using Content.Shared.Containers.ItemSlots;
|
|
using Robust.Shared.Containers;
|
|
|
|
namespace Content.Shared.PDA
|
|
{
|
|
public abstract class SharedPdaSystem : EntitySystem
|
|
{
|
|
[Dependency] protected readonly ItemSlotsSystem ItemSlotsSystem = default!;
|
|
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<PdaComponent, ComponentInit>(OnComponentInit);
|
|
SubscribeLocalEvent<PdaComponent, ComponentRemove>(OnComponentRemove);
|
|
|
|
SubscribeLocalEvent<PdaComponent, EntInsertedIntoContainerMessage>(OnItemInserted);
|
|
SubscribeLocalEvent<PdaComponent, EntRemovedFromContainerMessage>(OnItemRemoved);
|
|
|
|
SubscribeLocalEvent<PdaComponent, GetAdditionalAccessEvent>(OnGetAdditionalAccess);
|
|
}
|
|
protected virtual void OnComponentInit(EntityUid uid, PdaComponent pda, ComponentInit args)
|
|
{
|
|
if (pda.IdCard != null)
|
|
pda.IdSlot.StartingItem = pda.IdCard;
|
|
if (pda.Pen != null)
|
|
pda.PenSlot.StartingItem = pda.Pen;
|
|
|
|
ItemSlotsSystem.AddItemSlot(uid, PdaComponent.PdaIdSlotId, pda.IdSlot);
|
|
ItemSlotsSystem.AddItemSlot(uid, PdaComponent.PdaPenSlotId, pda.PenSlot);
|
|
ItemSlotsSystem.AddItemSlot(uid, PdaComponent.PdaPaiSlotId, pda.PaiSlot);
|
|
|
|
UpdatePdaAppearance(uid, pda);
|
|
}
|
|
|
|
private void OnComponentRemove(EntityUid uid, PdaComponent pda, ComponentRemove args)
|
|
{
|
|
ItemSlotsSystem.RemoveItemSlot(uid, pda.IdSlot);
|
|
ItemSlotsSystem.RemoveItemSlot(uid, pda.PenSlot);
|
|
ItemSlotsSystem.RemoveItemSlot(uid, pda.PaiSlot);
|
|
}
|
|
|
|
protected virtual void OnItemInserted(EntityUid uid, PdaComponent pda, EntInsertedIntoContainerMessage args)
|
|
{
|
|
if (args.Container.ID == PdaComponent.PdaIdSlotId)
|
|
pda.ContainedId = args.Entity;
|
|
|
|
UpdatePdaAppearance(uid, pda);
|
|
}
|
|
|
|
protected virtual void OnItemRemoved(EntityUid uid, PdaComponent pda, EntRemovedFromContainerMessage args)
|
|
{
|
|
if (args.Container.ID == pda.IdSlot.ID)
|
|
pda.ContainedId = null;
|
|
|
|
UpdatePdaAppearance(uid, pda);
|
|
}
|
|
|
|
private void OnGetAdditionalAccess(EntityUid uid, PdaComponent component, ref GetAdditionalAccessEvent args)
|
|
{
|
|
if (component.ContainedId is { } id)
|
|
args.Entities.Add(id);
|
|
}
|
|
|
|
private void UpdatePdaAppearance(EntityUid uid, PdaComponent pda)
|
|
{
|
|
Appearance.SetData(uid, PdaVisuals.IdCardInserted, pda.ContainedId != null);
|
|
}
|
|
|
|
public virtual void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null)
|
|
{
|
|
// This does nothing yet while I finish up PDA prediction
|
|
// Overriden by the server
|
|
}
|
|
}
|
|
}
|