From: TemporalOroboros Date: Mon, 15 May 2023 18:55:36 +0000 (-0700) Subject: Resolves GenericEnumVisualizer is Obsolete (#13914) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=a71d9c8eff80921086743a1778ab799f0c2adcac;p=space-station-14.git Resolves GenericEnumVisualizer is Obsolete (#13914) --- diff --git a/Content.Client/Visualizer/GenericEnumVisualizer.cs b/Content.Client/Visualizer/GenericEnumVisualizer.cs deleted file mode 100644 index df2bcf86dd..0000000000 --- a/Content.Client/Visualizer/GenericEnumVisualizer.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using JetBrains.Annotations; -using Robust.Client.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Log; -using Robust.Shared.Reflection; -using Robust.Shared.Serialization; -using Robust.Shared.Serialization.Manager.Attributes; - -namespace Content.Client.Visualizer -{ - [UsedImplicitly] - public sealed class GenericEnumVisualizer : AppearanceVisualizer, ISerializationHooks - { - public Enum Key { get; set; } = default!; - - public Dictionary States { get; set; } = default!; - - [DataField("layer")] - public int Layer { get; set; } = 0; - - [DataField("key", readOnly: true, required: true)] - private string _keyRaw = default!; - - [DataField("states", readOnly: true, required: true)] - private Dictionary _statesRaw { get; set; } = default!; - - void ISerializationHooks.AfterDeserialization() - { - var reflectionManager = IoCManager.Resolve(); - - object ResolveRef(string raw) - { - if (reflectionManager.TryParseEnumReference(raw, out var @enum)) - { - return @enum; - } - else - { - Logger.WarningS("c.c.v.genum", $"Unable to convert enum reference: {raw}"); - } - - return raw; - } - - // It's important that this conversion be done here so that it may "fail-fast". - Key = (Enum) ResolveRef(_keyRaw); - States = _statesRaw.ToDictionary(kvp => ResolveRef(kvp.Key), kvp => kvp.Value); - } - - [Obsolete("Subscribe to AppearanceChangeEvent instead.")] - public override void OnChangeData(AppearanceComponent component) - { - base.OnChangeData(component); - - var entities = IoCManager.Resolve(); - if (!entities.TryGetComponent(component.Owner, out SpriteComponent? sprite)) return; - if (!component.TryGetData(Key, out object status)) return; - if (!States.TryGetValue(status, out var val)) return; - sprite.LayerSetState(Layer, val); - } - } -} diff --git a/Resources/Prototypes/Entities/Mobs/Player/silicon.yml b/Resources/Prototypes/Entities/Mobs/Player/silicon.yml index 4b28e6e821..71b3677350 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/silicon.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/silicon.yml @@ -130,6 +130,7 @@ layers: - state: shell sprite: Mobs/Silicon/drone.rsi + map: ["base"] - type: MovementIgnoreGravity - type: Fixtures fixtures: @@ -143,13 +144,12 @@ layer: - SmallMobLayer - type: Appearance + - type: GenericVisualizer visuals: - - type: GenericEnumVisualizer - key: enum.DroneVisuals.Status - layer: 0 - states: - enum.DroneStatus.Off: shell - enum.DroneStatus.On: drone + enum.DroneVisuals.Status: + base: + Off: { state: shell } + On: { state: drone } - type: ReplacementAccent accent: silicon - type: Repairable diff --git a/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml b/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml index 74f8462802..b09460ce97 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml @@ -10,6 +10,7 @@ drawdepth: SmallMobs # if mice can hide under tables, so can mousetraps layers: - state: mousetrap + map: ["base"] - type: StepTrigger intersectRatio: 0.2 requiredTriggeredSpeed: 0 @@ -27,13 +28,12 @@ - type: Item sprite: Objects/Devices/mousetrap.rsi - type: Appearance + - type: GenericVisualizer visuals: - - type: GenericEnumVisualizer - key: enum.MousetrapVisuals.Visual - layer: 0 - states: - enum.MousetrapVisuals.Armed: mousetraparmed - enum.MousetrapVisuals.Unarmed: mousetrap + enum.MousetrapVisuals.Visual: + base: + Armed: { state: mousetraparmed } + Unarmed: { state: mousetrap } - type: Physics bodyType: Dynamic - type: CollisionWake diff --git a/Resources/Prototypes/Entities/Objects/Devices/payload.yml b/Resources/Prototypes/Entities/Objects/Devices/payload.yml index beab635e9e..4752ac1ba2 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/payload.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/payload.yml @@ -60,6 +60,9 @@ - type: Sprite sprite: Objects/Devices/payload.rsi state: payload-empty + layers: + - state: payload-empty + map: ["base"] - type: ChemicalPayload beakerSlotA: &slotDef whitelist: @@ -68,14 +71,14 @@ swap: false beakerSlotB: *slotDef - type: Appearance + - type: GenericVisualizer visuals: - - type: GenericEnumVisualizer - key: enum.ChemicalPayloadVisuals.Slots - states: - enum.ChemicalPayloadFilledSlots.None: payload-empty - enum.ChemicalPayloadFilledSlots.Left: payload-chemical-left - enum.ChemicalPayloadFilledSlots.Right: payload-chemical-right - enum.ChemicalPayloadFilledSlots.Both: payload-chemical-armed + enum.ChemicalPayloadVisuals.Slots: + base: + None: { state: payload-empty } + Left: { state: payload-chemical-left } + Right: { state: payload-chemical-right } + Both: { state: payload-chemical-armed } - type: ItemSlots - type: ContainerContainer containers: diff --git a/Resources/Prototypes/Entities/Objects/Fun/pai.yml b/Resources/Prototypes/Entities/Objects/Fun/pai.yml index c5c4035cfb..6f34e113fa 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/pai.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/pai.yml @@ -22,6 +22,7 @@ - state: pai-base - state: pai-off-overlay shader: unshaded + map: ["screen"] - type: Input context: "human" - type: PAI @@ -50,12 +51,10 @@ allowedStates: - Alive - type: Appearance + - type: GenericVisualizer visuals: - - type: GenericEnumVisualizer - key: enum.PAIVisuals.Status - layer: 1 - states: - enum.PAIStatus.Off: pai-off-overlay - enum.PAIStatus.Searching: pai-searching-overlay - enum.PAIStatus.On: pai-on-overlay - + enum.PAIVisuals.Status: + screen: + Off: { state: pai-off-overlay } + Searching: { state: pai-searching-overlay } + On: { state: pai-on-overlay } diff --git a/Resources/Prototypes/Entities/Objects/Tools/t-ray.yml b/Resources/Prototypes/Entities/Objects/Tools/t-ray.yml index 24a6a238e2..189f653033 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/t-ray.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/t-ray.yml @@ -8,17 +8,17 @@ netsync: false layers: - state: tray-off + map: ["base"] - type: TrayScanner - type: Item sprite: Objects/Tools/t-ray.rsi - type: Appearance + - type: GenericVisualizer visuals: - - type: GenericEnumVisualizer - key: enum.TrayScannerVisual.Visual - layer: 0 - states: - enum.TrayScannerVisual.On: tray-on - enum.TrayScannerVisual.Off: tray-off + enum.TrayScannerVisual.Visual: + base: + On: { state: tray-on } + Off: { state: tray-off } - type: Tag tags: - DroneUsable diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Bombs/funny.yml b/Resources/Prototypes/Entities/Objects/Weapons/Bombs/funny.yml index a0f646d1e1..27cea3bdb7 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Bombs/funny.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Bombs/funny.yml @@ -8,6 +8,9 @@ sprite: Objects/Weapons/Bombs/hot_potato.rsi state: icon netsync: false + layers: + - state: icon + map: ["base"] - type: Item sprite: Objects/Weapons/Bombs/hot_potato.rsi size: 5 @@ -40,12 +43,12 @@ types: Heat: 1 - type: Appearance + - type: GenericVisualizer visuals: - - type: GenericEnumVisualizer - key: enum.Trigger.TriggerVisuals.VisualState - states: - enum.Trigger.TriggerVisualState.Primed: activated - enum.Trigger.TriggerVisualState.Unprimed: complete + enum.Trigger.TriggerVisuals.VisualState: + base: + Primed: { state: activated } + Unprimed: { state: complete } - type: entity id: HotPotatoEffect diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Bombs/plastic.yml b/Resources/Prototypes/Entities/Objects/Weapons/Bombs/plastic.yml index 13ab7309d5..4d9fed1f91 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Bombs/plastic.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Bombs/plastic.yml @@ -4,56 +4,59 @@ parent: BaseItem id: C4 components: - - type: Sprite - sprite: Objects/Weapons/Bombs/c4.rsi - state: icon - - type: Item - sprite: Objects/Weapons/Bombs/c4.rsi - size: 10 - - type: OnUseTimerTrigger - delay: 10 - delayOptions: [10, 30, 60, 120, 300] - initialBeepDelay: 0 - beepSound: /Audio/Machines/Nuke/general_beep.ogg - startOnStick: true - canToggleStartOnStick: true - - type: TriggerOnSignal - - type: DeviceLinkSink - ports: - - Trigger - - type: Sticky - stickDelay: 5 - unstickDelay: 5 - stickPopupStart: comp-sticky-start-stick-bomb - stickPopupSuccess: comp-sticky-success-stick-bomb - unstickPopupStart: comp-sticky-start-unstick-bomb - unstickPopupSuccess: comp-sticky-success-unstick-bomb - blacklist: # can't stick it to other items - components: - - Item - - type: Explosive # Powerful explosion in a very small radius. Doesn't break underplating. - explosionType: DemolitionCharge - totalIntensity: 60 - intensitySlope: 5 - maxIntensity: 30 - canCreateVacuum: false - - type: ExplodeOnTrigger - - type: Damageable - damageContainer: Inorganic - - type: Destructible - thresholds: - - trigger: - !type:DamageTrigger - damage: 50 - behaviors: - - !type:DoActsBehavior - acts: ["Destruction"] - - !type:ExplodeBehavior - - type: StickyVisualizer - - type: Appearance - visuals: - - type: GenericEnumVisualizer - key: enum.Trigger.TriggerVisuals.VisualState - states: - enum.Trigger.TriggerVisualState.Primed: primed - enum.Trigger.TriggerVisualState.Unprimed: complete + - type: Sprite + sprite: Objects/Weapons/Bombs/c4.rsi + state: icon + layers: + - state: icon + map: ["base"] + - type: Item + sprite: Objects/Weapons/Bombs/c4.rsi + size: 10 + - type: OnUseTimerTrigger + delay: 10 + delayOptions: [10, 30, 60, 120, 300] + initialBeepDelay: 0 + beepSound: /Audio/Machines/Nuke/general_beep.ogg + startOnStick: true + canToggleStartOnStick: true + - type: TriggerOnSignal + - type: DeviceLinkSink + ports: + - Trigger + - type: Sticky + stickDelay: 5 + unstickDelay: 5 + stickPopupStart: comp-sticky-start-stick-bomb + stickPopupSuccess: comp-sticky-success-stick-bomb + unstickPopupStart: comp-sticky-start-unstick-bomb + unstickPopupSuccess: comp-sticky-success-unstick-bomb + blacklist: # can't stick it to other items + components: + - Item + - type: Explosive # Powerful explosion in a very small radius. Doesn't break underplating. + explosionType: DemolitionCharge + totalIntensity: 60 + intensitySlope: 5 + maxIntensity: 30 + canCreateVacuum: false + - type: ExplodeOnTrigger + - type: Damageable + damageContainer: Inorganic + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 50 + behaviors: + - !type:DoActsBehavior + acts: ["Destruction"] + - !type:ExplodeBehavior + - type: StickyVisualizer + - type: Appearance + - type: GenericVisualizer + visuals: + enum.Trigger.TriggerVisuals.VisualState: + base: + Primed: { state: primed } + Unprimed: { state: complete } diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml b/Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml index b1bf565bb2..77f61f8943 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml @@ -168,12 +168,6 @@ - !type:DoActsBehavior acts: [ "Destruction" ] - type: Appearance - visuals: - - type: GenericEnumVisualizer - key: enum.Trigger.TriggerVisuals.VisualState - states: - enum.Trigger.TriggerVisualState.Primed: primed - enum.Trigger.TriggerVisualState.Unprimed: complete - type: GenericVisualizer visuals: enum.ConstructionVisuals.Key: @@ -182,6 +176,10 @@ wiredCase: { state: wired } caseWithTrigger: { state: no-payload } grenade: { state: complete } + enum.Trigger.TriggerVisuals.VisualState: + enum.ConstructionVisuals.Layer: + Primed: { state: primed } + Unprimed: { state: complete } - type: StaticPrice price: 25 diff --git a/Resources/Prototypes/Entities/Structures/Machines/cloning_machine.yml b/Resources/Prototypes/Entities/Structures/Machines/cloning_machine.yml index b58b49fb98..9db97829dc 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/cloning_machine.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/cloning_machine.yml @@ -18,6 +18,7 @@ snapCardinals: true layers: - state: pod_0 + map: ["base"] - type: Physics bodyType: Static - type: Fixtures @@ -65,15 +66,14 @@ - type: ApcPowerReceiver powerLoad: 200 #Receives most of its power from the console - type: Appearance + - type: GenericVisualizer visuals: - - type: GenericEnumVisualizer - key: enum.CloningPodVisuals.Status - layer: 0 - states: - enum.CloningPodStatus.Cloning: pod_1 - enum.CloningPodStatus.NoMind: pod_e - enum.CloningPodStatus.Gore: pod_g - enum.CloningPodStatus.Idle: pod_0 + enum.CloningPodVisuals.Status: + base: + Cloning: { state: pod_1 } + NoMind: { state: pod_e } + Gore: { state: pod_g } + Idle: { state: pod_0 } - type: Climbable - type: StaticPrice price: 1000 diff --git a/Resources/Prototypes/Entities/Structures/meat_spike.yml b/Resources/Prototypes/Entities/Structures/meat_spike.yml index 03b22865e9..92922f09d4 100644 --- a/Resources/Prototypes/Entities/Structures/meat_spike.yml +++ b/Resources/Prototypes/Entities/Structures/meat_spike.yml @@ -10,6 +10,9 @@ # temp to make clickmask work sprite: Structures/meat_spike.rsi state: spike + layers: + - state: spike + map: ["base"] - type: Damageable damageContainer: Inorganic damageModifierSet: Metallic @@ -41,13 +44,12 @@ - type: Anchorable - type: Pullable - type: Appearance + - type: GenericVisualizer visuals: - - type: GenericEnumVisualizer - key: enum.KitchenSpikeVisuals.Status - layer: 0 - states: - enum.KitchenSpikeStatus.Empty: spike - enum.KitchenSpikeStatus.Bloody: spikebloody + enum.KitchenSpikeVisuals.Status: + base: + Empty: { state: spike } + Bloody: { state: spikebloody } - type: Construction graph: MeatSpike node: MeatSpike