From: TemporalOroboros Date: Sun, 5 Feb 2023 18:34:54 +0000 (-0800) Subject: Resolves PDAVisualizer is Obsolete (#13896) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=b95f4f474bb067fa24c933d78e0497ebf423f8c3;p=space-station-14.git Resolves PDAVisualizer is Obsolete (#13896) --- diff --git a/Content.Client/PDA/PDASystem.cs b/Content.Client/PDA/PDASystem.cs index cec18d90b3..276f65a349 100644 --- a/Content.Client/PDA/PDASystem.cs +++ b/Content.Client/PDA/PDASystem.cs @@ -1,10 +1,34 @@ 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(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(uid, UnpoweredFlashlightVisuals.LightOn, out var isFlashlightOn, args.Component)) + args.Sprite.LayerSetVisible(PDAVisualLayers.Flashlight, isFlashlightOn); + + if (_appearance.TryGetData(uid, PDAVisuals.IDCardInserted, out var isCardInserted, args.Component)) + args.Sprite.LayerSetVisible(PDAVisualLayers.IDLight, isCardInserted); + } +} + +enum PDAVisualLayers : byte +{ + Base, + Flashlight, + IDLight } diff --git a/Content.Client/PDA/PDAVisualizer.cs b/Content.Client/PDA/PDAVisualizer.cs deleted file mode 100644 index 84a0f994f5..0000000000 --- a/Content.Client/PDA/PDAVisualizer.cs +++ /dev/null @@ -1,65 +0,0 @@ -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 - { - /// - /// The base PDA sprite state, eg. "pda", "pda-clown" - /// - [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(); - var sprite = entityManager.GetComponent(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(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().GetComponent(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); - } - } - } -} diff --git a/Content.Shared/PDA/PDAComponent.cs b/Content.Shared/PDA/PDAComponent.cs index 551d4846b0..4acbcf3582 100644 --- a/Content.Shared/PDA/PDAComponent.cs +++ b/Content.Shared/PDA/PDAComponent.cs @@ -11,6 +11,12 @@ namespace Content.Shared.PDA public const string PDAIdSlotId = "PDA-id"; public const string PDAPenSlotId = "PDA-pen"; + /// + /// The base PDA sprite state, eg. "pda", "pda-clown" + /// + [DataField("state")] + public string? State; + [DataField("idSlot")] public ItemSlot IdSlot = new(); diff --git a/Content.Shared/PDA/SharedPDASystem.cs b/Content.Shared/PDA/SharedPDASystem.cs index 611e188581..c0d4249ca4 100644 --- a/Content.Shared/PDA/SharedPDASystem.cs +++ b/Content.Shared/PDA/SharedPDASystem.cs @@ -7,7 +7,7 @@ namespace Content.Shared.PDA 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() { diff --git a/Resources/Prototypes/Entities/Objects/Devices/pda.yml b/Resources/Prototypes/Entities/Objects/Devices/pda.yml index 46d8068223..e2881ef35d 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/pda.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/pda.yml @@ -6,15 +6,35 @@ 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 @@ -76,20 +96,6 @@ 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 @@ -106,6 +112,7 @@ components: - type: PDA id: PassengerIDCard + state: pda - type: PDABorderColor borderColor: "#717059" @@ -117,10 +124,7 @@ components: - type: PDA id: TechnicalAssistantIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-interntech + state: pda-interntech - type: Icon state: pda-interntech @@ -132,10 +136,7 @@ components: - type: PDA id: MedicalInternIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-internmed + state: pda-internmed - type: Icon state: pda-internmed - type: HealthAnalyzer @@ -151,10 +152,7 @@ components: - type: PDA id: SecurityCadetIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-interncadet + state: pda-interncadet - type: Icon state: pda-interncadet @@ -166,10 +164,7 @@ components: - type: PDA id: ResearchAssistantIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-internsci + state: pda-internsci - type: Icon state: pda-internsci @@ -181,10 +176,7 @@ components: - type: PDA id: ServiceWorkerIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-internservice + state: pda-internservice - type: Icon state: pda-internservice @@ -196,10 +188,7 @@ components: - type: PDA id: ChefIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-cook + state: pda-cook - type: PDABorderColor borderColor: "#d7d7d0" - type: Icon @@ -213,10 +202,7 @@ components: - type: PDA id: BotanistIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-hydro + state: pda-hydro - type: Icon state: pda-hydro @@ -228,6 +214,7 @@ components: - type: PDA id: ClownIDCard + state: pda-clown penSlot: startingItem: CrayonOrange # no pink crayon?!? # ^ Still unacceptable. @@ -236,10 +223,6 @@ whitelist: tags: - Write - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-clown - type: PDABorderColor borderColor: "#C18199" - type: Icon @@ -276,15 +259,12 @@ 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 @@ -296,10 +276,7 @@ components: - type: PDA id: ChaplainIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-chaplain + state: pda-chaplain - type: PDABorderColor borderColor: "#333333" - type: Icon @@ -313,10 +290,7 @@ components: - type: PDA id: QuartermasterIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-qm + state: pda-qm - type: Icon state: pda-qm @@ -328,10 +302,7 @@ components: - type: PDA id: CargoIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-cargo + state: pda-cargo - type: Icon state: pda-cargo @@ -343,10 +314,7 @@ components: - type: PDA id: SalvageIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-miner + state: pda-miner - type: Icon state: pda-miner @@ -358,10 +326,7 @@ components: - type: PDA id: BartenderIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-bartender + state: pda-bartender - type: Icon state: pda-bartender @@ -373,10 +338,7 @@ components: - type: PDA id: LibrarianIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-library + state: pda-library - type: Icon state: pda-library @@ -388,10 +350,7 @@ components: - type: PDA id: LawyerIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-lawyer + state: pda-lawyer - type: Icon state: pda-lawyer @@ -403,10 +362,7 @@ components: - type: PDA id: JanitorIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-janitor + state: pda-janitor - type: PDABorderColor borderColor: "#5D2D56" - type: Icon @@ -420,16 +376,13 @@ 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 @@ -443,16 +396,13 @@ 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 @@ -464,13 +414,11 @@ 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 @@ -482,10 +430,7 @@ components: - type: PDA id: EngineeringIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-engineer + state: pda-engineer - type: Icon state: pda-engineer @@ -497,10 +442,7 @@ components: - type: PDA id: CMOIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-cmo + state: pda-cmo - type: PDABorderColor borderColor: "#d7d7d0" accentHColor: "#447987" @@ -520,10 +462,7 @@ components: - type: PDA id: MedicalIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-medical + state: pda-medical - type: PDABorderColor borderColor: "#d7d7d0" accentVColor: "#447987" @@ -542,10 +481,7 @@ components: - type: PDA id: ChemistIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-chemistry + state: pda-chemistry - type: PDABorderColor borderColor: "#d7d7d0" accentVColor: "#B34200" @@ -560,10 +496,7 @@ components: - type: PDA id: RDIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-rd + state: pda-rd - type: Icon state: pda-rd @@ -575,10 +508,7 @@ components: - type: PDA id: ResearchIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-science + state: pda-science - type: Icon state: pda-science @@ -590,10 +520,7 @@ components: - type: PDA id: HoSIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-hos + state: pda-hos - type: PDABorderColor borderColor: "#A32D26" accentHColor: "#447987" @@ -608,10 +535,7 @@ components: - type: PDA id: WardenIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-warden + state: pda-warden - type: Icon state: pda-warden @@ -623,10 +547,7 @@ components: - type: PDA id: SecurityIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-security + state: pda-security - type: Icon state: pda-security @@ -638,6 +559,7 @@ components: - type: PDA id: CentcomIDCardSyndie + state: pda - type: entity parent: BasePDA @@ -647,10 +569,7 @@ components: - type: PDA id: MusicianIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-musician + state: pda-musician - type: Instrument allowPercussion: false handheld: true @@ -665,10 +584,7 @@ components: - type: PDA id: AtmosIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-atmos + state: pda-atmos - type: Icon state: pda-atmos @@ -680,10 +596,7 @@ components: - type: PDA id: PassengerIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-clear + state: pda-clear - type: Icon state: pda-clear @@ -695,10 +608,7 @@ components: - type: PDA id: SyndicateIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-syndi + state: pda-syndi - type: Icon state: pda-syndi @@ -710,13 +620,11 @@ 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 @@ -728,6 +636,7 @@ components: - type: PDA id: CBURNIDcard + state: pda-ert - type: PDABorderColor borderColor: "#A32D26" accentHColor: "#447987" @@ -740,10 +649,7 @@ components: - type: PDA id: PsychologistIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-medical + state: pda-medical - type: PDABorderColor borderColor: "#d7d7d0" accentVColor: "#447987" @@ -758,10 +664,7 @@ components: - type: PDA id: ReporterIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-reporter + state: pda-reporter - type: Icon state: pda-reporter @@ -773,10 +676,7 @@ components: - type: PDA id: ZookeeperIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-zookeeper + state: pda-zookeeper - type: Icon state: pda-zookeeper @@ -788,10 +688,7 @@ components: - type: PDA id: BoxerIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-boxer + state: pda-boxer - type: PDABorderColor borderColor: "#333333" borderVColor: "#390504" @@ -806,10 +703,7 @@ components: - type: PDA id: DetectiveIDCard - - type: Appearance - visuals: - - type: PDAVisualizer - state: pda-detective + state: pda-detective - type: PDABorderColor borderColor: "#774705" - type: Icon