using Content.Shared.PDA;
-using Robust.Shared.GameObjects;
+using Content.Shared.Light;
+using Robust.Client.GameObjects;
-namespace Content.Client.PDA
+namespace Content.Client.PDA;
+
+public sealed class PDASystem : SharedPDASystem
{
- public sealed class PDASystem : SharedPDASystem
+ public override void Initialize()
{
- // Nothing here. Have a lovely day.
+ base.Initialize();
+ SubscribeLocalEvent<PDAComponent, AppearanceChangeEvent>(OnAppearanceChange);
}
+
+ private void OnAppearanceChange(EntityUid uid, PDAComponent component, ref AppearanceChangeEvent args)
+ {
+ if (args.Sprite == null)
+ return;
+
+ args.Sprite.LayerSetState(PDAVisualLayers.Base, component.State);
+ if (_appearance.TryGetData<bool>(uid, UnpoweredFlashlightVisuals.LightOn, out var isFlashlightOn, args.Component))
+ args.Sprite.LayerSetVisible(PDAVisualLayers.Flashlight, isFlashlightOn);
+
+ if (_appearance.TryGetData<bool>(uid, PDAVisuals.IDCardInserted, out var isCardInserted, args.Component))
+ args.Sprite.LayerSetVisible(PDAVisualLayers.IDLight, isCardInserted);
+ }
+}
+
+enum PDAVisualLayers : byte
+{
+ Base,
+ Flashlight,
+ IDLight
}
+++ /dev/null
-using Content.Shared.Light;
-using Content.Shared.PDA;
-using JetBrains.Annotations;
-using Robust.Client.GameObjects;
-using Robust.Shared.GameObjects;
-using Robust.Shared.IoC;
-using Robust.Shared.Serialization.Manager.Attributes;
-
-namespace Content.Client.PDA
-{
- [UsedImplicitly]
- // ReSharper disable once InconsistentNaming
- public sealed class PDAVisualizer : AppearanceVisualizer
- {
- /// <summary>
- /// The base PDA sprite state, eg. "pda", "pda-clown"
- /// </summary>
- [DataField("state")]
- private string? _state;
-
- private enum PDAVisualLayers : byte
- {
- Base,
- Flashlight,
- IDLight
- }
-
- [Obsolete("Subscribe to your component being initialised instead.")]
- public override void InitializeEntity(EntityUid entity)
- {
- base.InitializeEntity(entity);
- var entityManager = IoCManager.Resolve<IEntityManager>();
- var sprite = entityManager.GetComponent<SpriteComponent>(entity);
-
- if (_state != null)
- {
- sprite.LayerMapSet(PDAVisualLayers.Base, sprite.AddLayerState(_state));
- }
-
- sprite.LayerMapSet(PDAVisualLayers.Flashlight, sprite.AddLayerState("light_overlay"));
- sprite.LayerSetShader(PDAVisualLayers.Flashlight, "unshaded");
- sprite.LayerMapSet(PDAVisualLayers.IDLight, sprite.AddLayerState("id_overlay"));
- sprite.LayerSetShader(PDAVisualLayers.IDLight, "unshaded");
-
- var appearance = entityManager.GetComponent<PDAComponent>(entity);
- sprite.LayerSetVisible(PDAVisualLayers.IDLight, appearance.IdSlot.StartingItem != null);
- }
-
- [Obsolete("Subscribe to AppearanceChangeEvent instead.")]
- public override void OnChangeData(AppearanceComponent component)
- {
- base.OnChangeData(component);
- var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(component.Owner);
- sprite.LayerSetVisible(PDAVisualLayers.Flashlight, false);
- if (component.TryGetData(UnpoweredFlashlightVisuals.LightOn, out bool isFlashlightOn))
- {
- sprite.LayerSetVisible(PDAVisualLayers.Flashlight, isFlashlightOn);
- }
- if (component.TryGetData(PDAVisuals.IDCardInserted, out bool isCardInserted))
- {
- sprite.LayerSetVisible(PDAVisualLayers.IDLight, isCardInserted);
- }
- }
- }
-}
public const string PDAIdSlotId = "PDA-id";
public const string PDAPenSlotId = "PDA-pen";
+ /// <summary>
+ /// The base PDA sprite state, eg. "pda", "pda-clown"
+ /// </summary>
+ [DataField("state")]
+ public string? State;
+
[DataField("idSlot")]
public ItemSlot IdSlot = new();
public abstract class SharedPDASystem : EntitySystem
{
[Dependency] protected readonly ItemSlotsSystem ItemSlotsSystem = default!;
- [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
+ [Dependency] protected readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
description: Personal Data Assistant.
components:
- type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda
- type: Sprite
sprite: Objects/Devices/pda.rsi
- netsync: false
+ layers:
+ - map: [ "enum.PDAVisualLayers.Base" ]
+ - map: [ "enum.PDAVisualLayers.Flashlight" ]
+ shader: "unshaded"
+ visible: false
+ - state: "id_overlay"
+ map: [ "enum.PDAVisualLayers.IDLight" ]
+ shader: "unshaded"
+ visible: false
- type: Icon
sprite: Objects/Devices/pda.rsi
state: pda
+ - type: PDA
+ state: pda
+ penSlot:
+ startingItem: Pen
+ priority: -1
+ whitelist:
+ tags:
+ - Write
+ idSlot:
+ name: ID Card
+ ejectSound: /Audio/Machines/id_swipe.ogg
+ insertSound: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
+ whitelist:
+ components:
+ - IdCard
- type: Item
size: 10
- type: ContainerContainer
type: InstrumentBoundUserInterface
- key: enum.HealthAnalyzerUiKey.Key
type: HealthAnalyzerBoundUserInterface
- - type: PDA
- penSlot:
- startingItem: Pen
- priority: -1
- whitelist:
- tags:
- - Write
- idSlot:
- name: ID Card
- ejectSound: /Audio/Machines/id_swipe.ogg
- insertSound: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
- whitelist:
- components:
- - IdCard
- type: CrewManifestViewer
unsecure: true
- type: Tag
components:
- type: PDA
id: PassengerIDCard
+ state: pda
- type: PDABorderColor
borderColor: "#717059"
components:
- type: PDA
id: TechnicalAssistantIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-interntech
+ state: pda-interntech
- type: Icon
state: pda-interntech
components:
- type: PDA
id: MedicalInternIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-internmed
+ state: pda-internmed
- type: Icon
state: pda-internmed
- type: HealthAnalyzer
components:
- type: PDA
id: SecurityCadetIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-interncadet
+ state: pda-interncadet
- type: Icon
state: pda-interncadet
components:
- type: PDA
id: ResearchAssistantIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-internsci
+ state: pda-internsci
- type: Icon
state: pda-internsci
components:
- type: PDA
id: ServiceWorkerIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-internservice
+ state: pda-internservice
- type: Icon
state: pda-internservice
components:
- type: PDA
id: ChefIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-cook
+ state: pda-cook
- type: PDABorderColor
borderColor: "#d7d7d0"
- type: Icon
components:
- type: PDA
id: BotanistIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-hydro
+ state: pda-hydro
- type: Icon
state: pda-hydro
components:
- type: PDA
id: ClownIDCard
+ state: pda-clown
penSlot:
startingItem: CrayonOrange # no pink crayon?!?
# ^ Still unacceptable.
whitelist:
tags:
- Write
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-clown
- type: PDABorderColor
borderColor: "#C18199"
- type: Icon
components:
- type: PDA
id: MimeIDCard
+ state: pda-mime
idSlot:
name: ID Card
whitelist:
components:
- IdCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-mime
- type: Icon
state: pda-mime
components:
- type: PDA
id: ChaplainIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-chaplain
+ state: pda-chaplain
- type: PDABorderColor
borderColor: "#333333"
- type: Icon
components:
- type: PDA
id: QuartermasterIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-qm
+ state: pda-qm
- type: Icon
state: pda-qm
components:
- type: PDA
id: CargoIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-cargo
+ state: pda-cargo
- type: Icon
state: pda-cargo
components:
- type: PDA
id: SalvageIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-miner
+ state: pda-miner
- type: Icon
state: pda-miner
components:
- type: PDA
id: BartenderIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-bartender
+ state: pda-bartender
- type: Icon
state: pda-bartender
components:
- type: PDA
id: LibrarianIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-library
+ state: pda-library
- type: Icon
state: pda-library
components:
- type: PDA
id: LawyerIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-lawyer
+ state: pda-lawyer
- type: Icon
state: pda-lawyer
components:
- type: PDA
id: JanitorIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-janitor
+ state: pda-janitor
- type: PDABorderColor
borderColor: "#5D2D56"
- type: Icon
components:
- type: PDA
id: CaptainIDCard
+ state: pda-captain
penSlot:
startingItem: PenCap
priority: -1
whitelist:
tags:
- Write
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-captain
- type: PDABorderColor
borderColor: "#7C5D00"
- type: Icon
components:
- type: PDA
id: HoPIDCard
+ state: pda-hop
penSlot:
startingItem: PenHop
priority: -1
whitelist:
tags:
- Write
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-hop
- type: Icon
state: pda-hop
components:
- type: PDA
id: CEIDCard
+ state: pda-ce
- type: PDABorderColor
borderColor: "#949137"
+ state: pda-ce
accentHColor: "#447987"
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-ce
- type: Icon
state: pda-ce
components:
- type: PDA
id: EngineeringIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-engineer
+ state: pda-engineer
- type: Icon
state: pda-engineer
components:
- type: PDA
id: CMOIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-cmo
+ state: pda-cmo
- type: PDABorderColor
borderColor: "#d7d7d0"
accentHColor: "#447987"
components:
- type: PDA
id: MedicalIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-medical
+ state: pda-medical
- type: PDABorderColor
borderColor: "#d7d7d0"
accentVColor: "#447987"
components:
- type: PDA
id: ChemistIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-chemistry
+ state: pda-chemistry
- type: PDABorderColor
borderColor: "#d7d7d0"
accentVColor: "#B34200"
components:
- type: PDA
id: RDIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-rd
+ state: pda-rd
- type: Icon
state: pda-rd
components:
- type: PDA
id: ResearchIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-science
+ state: pda-science
- type: Icon
state: pda-science
components:
- type: PDA
id: HoSIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-hos
+ state: pda-hos
- type: PDABorderColor
borderColor: "#A32D26"
accentHColor: "#447987"
components:
- type: PDA
id: WardenIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-warden
+ state: pda-warden
- type: Icon
state: pda-warden
components:
- type: PDA
id: SecurityIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-security
+ state: pda-security
- type: Icon
state: pda-security
components:
- type: PDA
id: CentcomIDCardSyndie
+ state: pda
- type: entity
parent: BasePDA
components:
- type: PDA
id: MusicianIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-musician
+ state: pda-musician
- type: Instrument
allowPercussion: false
handheld: true
components:
- type: PDA
id: AtmosIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-atmos
+ state: pda-atmos
- type: Icon
state: pda-atmos
components:
- type: PDA
id: PassengerIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-clear
+ state: pda-clear
- type: Icon
state: pda-clear
components:
- type: PDA
id: SyndicateIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-syndi
+ state: pda-syndi
- type: Icon
state: pda-syndi
components:
- type: PDA
id: ERTLeaderIDCard
+ state: pda-ert
- type: PDABorderColor
borderColor: "#A32D26"
+ state: pda-ert
accentHColor: "#447987"
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-ert
- type: Icon
state: pda-ert
components:
- type: PDA
id: CBURNIDcard
+ state: pda-ert
- type: PDABorderColor
borderColor: "#A32D26"
accentHColor: "#447987"
components:
- type: PDA
id: PsychologistIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-medical
+ state: pda-medical
- type: PDABorderColor
borderColor: "#d7d7d0"
accentVColor: "#447987"
components:
- type: PDA
id: ReporterIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-reporter
+ state: pda-reporter
- type: Icon
state: pda-reporter
components:
- type: PDA
id: ZookeeperIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-zookeeper
+ state: pda-zookeeper
- type: Icon
state: pda-zookeeper
components:
- type: PDA
id: BoxerIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-boxer
+ state: pda-boxer
- type: PDABorderColor
borderColor: "#333333"
borderVColor: "#390504"
components:
- type: PDA
id: DetectiveIDCard
- - type: Appearance
- visuals:
- - type: PDAVisualizer
- state: pda-detective
+ state: pda-detective
- type: PDABorderColor
borderColor: "#774705"
- type: Icon