Resolves PDAVisualizer is Obsolete (#13896)
This commit is contained in:
@@ -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
|
||||
{
|
||||
// Nothing here. Have a lovely day.
|
||||
public override void Initialize()
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,12 @@ namespace Content.Shared.PDA
|
||||
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();
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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,9 +124,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: TechnicalAssistantIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-interntech
|
||||
- type: Icon
|
||||
state: pda-interntech
|
||||
@@ -132,9 +136,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: MedicalInternIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-internmed
|
||||
- type: Icon
|
||||
state: pda-internmed
|
||||
@@ -151,9 +152,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: SecurityCadetIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-interncadet
|
||||
- type: Icon
|
||||
state: pda-interncadet
|
||||
@@ -166,9 +164,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: ResearchAssistantIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-internsci
|
||||
- type: Icon
|
||||
state: pda-internsci
|
||||
@@ -181,9 +176,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: ServiceWorkerIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-internservice
|
||||
- type: Icon
|
||||
state: pda-internservice
|
||||
@@ -196,9 +188,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: ChefIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-cook
|
||||
- type: PDABorderColor
|
||||
borderColor: "#d7d7d0"
|
||||
@@ -213,9 +202,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: BotanistIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
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,9 +276,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: ChaplainIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-chaplain
|
||||
- type: PDABorderColor
|
||||
borderColor: "#333333"
|
||||
@@ -313,9 +290,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: QuartermasterIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-qm
|
||||
- type: Icon
|
||||
state: pda-qm
|
||||
@@ -328,9 +302,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: CargoIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-cargo
|
||||
- type: Icon
|
||||
state: pda-cargo
|
||||
@@ -343,9 +314,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: SalvageIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-miner
|
||||
- type: Icon
|
||||
state: pda-miner
|
||||
@@ -358,9 +326,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: BartenderIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-bartender
|
||||
- type: Icon
|
||||
state: pda-bartender
|
||||
@@ -373,9 +338,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: LibrarianIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-library
|
||||
- type: Icon
|
||||
state: pda-library
|
||||
@@ -388,9 +350,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: LawyerIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-lawyer
|
||||
- type: Icon
|
||||
state: pda-lawyer
|
||||
@@ -403,9 +362,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: JanitorIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-janitor
|
||||
- type: PDABorderColor
|
||||
borderColor: "#5D2D56"
|
||||
@@ -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"
|
||||
accentHColor: "#447987"
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-ce
|
||||
accentHColor: "#447987"
|
||||
- type: Icon
|
||||
state: pda-ce
|
||||
|
||||
@@ -482,9 +430,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: EngineeringIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-engineer
|
||||
- type: Icon
|
||||
state: pda-engineer
|
||||
@@ -497,9 +442,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: CMOIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-cmo
|
||||
- type: PDABorderColor
|
||||
borderColor: "#d7d7d0"
|
||||
@@ -520,9 +462,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: MedicalIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-medical
|
||||
- type: PDABorderColor
|
||||
borderColor: "#d7d7d0"
|
||||
@@ -542,9 +481,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: ChemistIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-chemistry
|
||||
- type: PDABorderColor
|
||||
borderColor: "#d7d7d0"
|
||||
@@ -560,9 +496,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: RDIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-rd
|
||||
- type: Icon
|
||||
state: pda-rd
|
||||
@@ -575,9 +508,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: ResearchIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-science
|
||||
- type: Icon
|
||||
state: pda-science
|
||||
@@ -590,9 +520,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: HoSIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-hos
|
||||
- type: PDABorderColor
|
||||
borderColor: "#A32D26"
|
||||
@@ -608,9 +535,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: WardenIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-warden
|
||||
- type: Icon
|
||||
state: pda-warden
|
||||
@@ -623,9 +547,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: SecurityIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-security
|
||||
- type: Icon
|
||||
state: pda-security
|
||||
@@ -638,6 +559,7 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: CentcomIDCardSyndie
|
||||
state: pda
|
||||
|
||||
- type: entity
|
||||
parent: BasePDA
|
||||
@@ -647,9 +569,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: MusicianIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-musician
|
||||
- type: Instrument
|
||||
allowPercussion: false
|
||||
@@ -665,9 +584,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: AtmosIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-atmos
|
||||
- type: Icon
|
||||
state: pda-atmos
|
||||
@@ -680,9 +596,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: PassengerIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-clear
|
||||
- type: Icon
|
||||
state: pda-clear
|
||||
@@ -695,9 +608,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: SyndicateIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-syndi
|
||||
- type: Icon
|
||||
state: pda-syndi
|
||||
@@ -710,13 +620,11 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: ERTLeaderIDCard
|
||||
state: pda-ert
|
||||
- type: PDABorderColor
|
||||
borderColor: "#A32D26"
|
||||
accentHColor: "#447987"
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-ert
|
||||
accentHColor: "#447987"
|
||||
- type: Icon
|
||||
state: pda-ert
|
||||
|
||||
@@ -728,6 +636,7 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: CBURNIDcard
|
||||
state: pda-ert
|
||||
- type: PDABorderColor
|
||||
borderColor: "#A32D26"
|
||||
accentHColor: "#447987"
|
||||
@@ -740,9 +649,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: PsychologistIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-medical
|
||||
- type: PDABorderColor
|
||||
borderColor: "#d7d7d0"
|
||||
@@ -758,9 +664,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: ReporterIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-reporter
|
||||
- type: Icon
|
||||
state: pda-reporter
|
||||
@@ -773,9 +676,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: ZookeeperIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-zookeeper
|
||||
- type: Icon
|
||||
state: pda-zookeeper
|
||||
@@ -788,9 +688,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: BoxerIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-boxer
|
||||
- type: PDABorderColor
|
||||
borderColor: "#333333"
|
||||
@@ -806,9 +703,6 @@
|
||||
components:
|
||||
- type: PDA
|
||||
id: DetectiveIDCard
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PDAVisualizer
|
||||
state: pda-detective
|
||||
- type: PDABorderColor
|
||||
borderColor: "#774705"
|
||||
|
||||
Reference in New Issue
Block a user