]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Resolves BagOpenCloseVisualizer is Obsolete v2 Uncooked Edition (#16399)
authorTemporalOroboros <TemporalOroboros@gmail.com>
Mon, 15 May 2023 20:37:45 +0000 (13:37 -0700)
committerGitHub <noreply@github.com>
Mon, 15 May 2023 20:37:45 +0000 (16:37 -0400)
Content.Client/Storage/Visualizers/BagOpenCloseVisualizer.cs [deleted file]
Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/box.yml
Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/cartons.yml
Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/packs.yml
Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigars/case.yml
Resources/Prototypes/Entities/Objects/Tools/matches.yml
Resources/Prototypes/Entities/Objects/base_item.yml
Resources/Prototypes/Entities/Structures/Storage/filing_cabinets.yml

diff --git a/Content.Client/Storage/Visualizers/BagOpenCloseVisualizer.cs b/Content.Client/Storage/Visualizers/BagOpenCloseVisualizer.cs
deleted file mode 100644 (file)
index 0199e39..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-using Content.Shared.Storage.Components;
-using JetBrains.Annotations;
-using Robust.Client.GameObjects;
-using Robust.Shared.GameObjects;
-using Robust.Shared.IoC;
-using Robust.Shared.Log;
-using Robust.Shared.Serialization;
-using Robust.Shared.Serialization.Manager.Attributes;
-using static Robust.Shared.Utility.SpriteSpecifier;
-
-namespace Content.Client.Storage.Visualizers
-{
-    [UsedImplicitly]
-    public sealed class BagOpenCloseVisualizer : AppearanceVisualizer, ISerializationHooks
-    {
-        private const string OpenIcon = "openIcon";
-        [DataField(OpenIcon)]
-        private string? _openIcon;
-
-        void ISerializationHooks.AfterDeserialization()
-        {
-            if(_openIcon == null){
-                Logger.Warning("BagOpenCloseVisualizer is useless with no `openIcon`");
-            }
-        }
-
-        [Obsolete("Subscribe to your component being initialised instead.")]
-        public override void InitializeEntity(EntityUid entity)
-        {
-            base.InitializeEntity(entity);
-
-            var entities = IoCManager.Resolve<IEntityManager>();
-
-            if (_openIcon != null &&
-                entities.TryGetComponent<SpriteComponent?>(entity, out var spriteComponent) &&
-                spriteComponent.BaseRSI?.Path is { } path)
-            {
-                spriteComponent.LayerMapReserveBlank(OpenIcon);
-                spriteComponent.LayerSetSprite(OpenIcon, new Rsi(path, _openIcon));
-                spriteComponent.LayerSetVisible(OpenIcon, false);
-            }
-        }
-
-        [Obsolete("Subscribe to AppearanceChangeEvent instead.")]
-        public override void OnChangeData(AppearanceComponent component)
-        {
-            base.OnChangeData(component);
-
-            var entities = IoCManager.Resolve<IEntityManager>();
-
-            if (_openIcon == null ||
-                !entities.TryGetComponent(component.Owner, out SpriteComponent? spriteComponent))
-                return;
-
-            if (!component.TryGetData<SharedBagState>(SharedBagOpenVisuals.BagState, out var bagState))
-                return;
-
-            switch (bagState)
-            {
-                case SharedBagState.Open:
-                    spriteComponent.LayerSetVisible(OpenIcon, true);
-                    break;
-                default:
-                    spriteComponent.LayerSetVisible(OpenIcon, false);
-                    break;
-            }
-        }
-    }
-}
index 46ac76b13861dc50ad9c71d8162b06a1bec434a2..0601112ef7d4a71c045b7b7377dc783453278eb6 100644 (file)
@@ -6,7 +6,7 @@
 # an alpha color which -Y- said he would implement.
 
 - type: entity
-  parent: BoxCardboard
+  parent: [ BoxCardboard, BaseBagOpenClose ]
   id: FoodBoxDonut
   name: donut box
   description: Mmm, Donuts.
     netsync: false
     sprite: Objects/Consumable/Food/Baked/donut.rsi
     state: box
+    layers:
+    - state: box
+    - state: box-open
+      map: ["openLayer"]
   - type: Storage
     capacity: 6
     whitelist:
@@ -35,8 +39,6 @@
       tags: [Donut]
   - type: Appearance
     visuals:
-    - type: BagOpenCloseVisualizer
-      openIcon: box-open
     - type: StackVisualizer
       composite: true
       stackLayers:
@@ -50,7 +52,7 @@
 # Egg
 
 - type: entity
-  parent: BoxCardboard
+  parent: [ BoxCardboard, BaseBagOpenClose ]
   id: FoodContainerEgg
   name: egg carton
   description: Don't drop 'em!
     netsync: false
     sprite: Objects/Consumable/Food/egg.rsi
     state: box-closed
+    layers:
+    - state: box-closed
+    - state: box-open
+      map: ["openLayer"]
   - type: Storage
     capacity: 12
     whitelist:
@@ -76,8 +82,6 @@
       tags: [Egg]
   - type: Appearance
     visuals:
-    - type: BagOpenCloseVisualizer
-      openIcon: box-open
     - type: StackVisualizer
       composite: true
       stackLayers:
 # Nugget
 
 - type: entity
-  parent: BoxCardboard
+  parent: [ BoxCardboard, BaseBagOpenClose ]
   id: FoodBoxNugget
   name: chicken nuggets
   description: You suddenly have an urge to trade on the intergalactic stock market.
     netsync: false
     sprite: Objects/Consumable/Food/Baked/nuggets.rsi
     state: box
+    layers:
+    - state: box
+    - state: box-open
+      map: ["openLayer"]
   - type: Storage
     capacity: 6
   - type: Item
       tags: [Nugget]
   - type: Appearance
     visuals:
-    - type: BagOpenCloseVisualizer
-      openIcon: box-open
     - type: StackVisualizer
       composite: true
       stackLayers:
 
 - type: entity
   id: HappyHonk
-  parent: BoxCardboard
+  parent: [ BoxCardboard, BaseBagOpenClose ]
   name: happy honk meal
   suffix: Toy Safe
   description: The toy is more edible than the food.
     netsync: false
     sprite: Objects/Storage/Happyhonk/clown.rsi
     state: box
+    layers:
+    - state: box
+    - state: box-open
+      map: ["openLayer"]
   - type: Item
     sprite: Objects/Storage/Happyhonk/clown.rsi
     heldPrefix: box
-  - type: Appearance
-    visuals:
-    - type: BagOpenCloseVisualizer
-      openIcon: box-open
   - type: Storage
     capacity: 30
   - type: Tag
index 52fa3dd50b872b98c4791c0f109cf9be2d050785..2ae53cad2b3d54ff5df826b16c03297a09310691 100644 (file)
@@ -1,6 +1,6 @@
 - type: entity
   id: CigCartonGreen
-  parent: BoxCardboard
+  parent: [ BoxCardboard, BaseBagOpenClose ]
   name: Spessman's Smokes carton
   description: "A carton containing 6 packets of Spessman's Smokes."
   components:
@@ -8,6 +8,8 @@
     sprite: Objects/Consumable/Smokeables/Cigarettes/Cartons/green.rsi
     layers:
       - state: closed
+      - state: open
+        map: ["openLayer"]
   - type: Storage
     capacity: 36
   - type: Item
     contents:
       - id: CigPackGreen
         amount: 6
-  - type: Appearance
-    visuals:
-      - type: BagOpenCloseVisualizer
-        openIcon: open
   - type: Tag
     tags:
     - Trash
index 22946a9e048f231ee76a2c689de4f5618f3514df..49c25a54b5e44972d1926c52e0b5f3db876390f8 100644 (file)
@@ -1,9 +1,15 @@
 - type: entity
   id: CigPackBase
-  parent: BaseStorageItem
+  parent: [ BaseStorageItem, BaseBagOpenClose ]
   name: cigarette pack
   abstract: true
   components:
+  - type: Sprite
+    netsync: false
+    layers:
+    - state: closed
+    - state: open
+      map: ["openLayer"]
   - type: Tag
     tags:
     - CigPack
@@ -25,8 +31,6 @@
       tags: [Cigarette]
   - type: Appearance
     visuals:
-    - type: BagOpenCloseVisualizer
-      openIcon: open
     - type: StackVisualizer
       sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/visualizer.rsi
       composite: true
   description: A label on the packaging reads, Wouldn't a slow death make a change?
   components:
   - type: Sprite
-    netsync: false
     sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/green.rsi
-    layers:
-    - state: closed
   - type: Item
     sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/green.rsi
 
   description: The most popular brand of Space Cigarettes, sponsors of the Space Olympics.
   components:
   - type: Sprite
-    netsync: false
     sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/red.rsi
-    layers:
-    - state: closed
   - type: Item
     sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/red.rsi
 
   description: For those who somehow want to obtain the record for the most amount of cancerous tumors.
   components:
   - type: Sprite
-    netsync: false
     sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/blue.rsi
-    layers:
-    - state: closed
   - type: Item
     sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/blue.rsi
 
   description: Nomads's extra strong, for when your life is more extra hard.
   components:
   - type: Sprite
-    netsync: false
     sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/black.rsi
-    layers:
-    - state: closed
   - type: Item
     sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/black.rsi
 
   name: Syndicate Smokes packet
   description: Elite cigarettes for elite agents. Infused with medicine for when you need to do more than calm your nerves.
   components:
-  - type: StorageFill
-    contents:
-    - id: CigaretteSyndicate
-      amount: 5
   - type: Sprite
-    netsync: false
     sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/syndicate.rsi
-    layers:
-    - state: closed
   - type: Item
     sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/syndicate.rsi
+  - type: StorageFill
+    contents:
+    - id: CigaretteSyndicate
+      amount: 5
index f975439b431ec5c999916b95417675703864f116..b3607ec794c9c354f6fc19888b4b6eef2c591432 100644 (file)
@@ -1,6 +1,6 @@
 - type: entity
   id: CigarCase
-  parent: BaseStorageItem
+  parent: [ BaseStorageItem, BaseBagOpenClose ]
   name: cigar case
   description: A case for holding your cigars when you are not smoking them.
   components:
@@ -9,6 +9,8 @@
     sprite: Objects/Consumable/Smokeables/Cigars/case.rsi
     layers:
     - state: closed
+    - state: open
+      map: ["openLayer"]
   - type: Storage
     capacity: 8
   - type: Item
@@ -23,8 +25,6 @@
       tags: [Cigar]
   - type: Appearance
     visuals:
-    - type: BagOpenCloseVisualizer
-      openIcon: open
     - type: StackVisualizer
       composite: true
       stackLayers:
index dfbe5474a51eb247a9f2f5b7afc703e2c5ebb297..0097cfa053575cfc89c244f36c5c9b5306fc32f9 100644 (file)
@@ -55,7 +55,7 @@
 
 - type: entity
   name: match box
-  parent: SmallboxItem
+  parent: [ SmallboxItem, BaseBagOpenClose ]
   id: Matchbox
   description: A small box of Almost But Not Quite Plasma Premium Matches.
   components:
@@ -67,7 +67,9 @@
     netsync: false
     sprite: Objects/Tools/matches.rsi
     layers:
-      - state: matchbox
+    - state: matchbox
+    - state: matchbox-open
+      map: ["openLayer"]
   - type: Item
     sprite: Objects/Tools/matches.rsi
     heldPrefix: matchbox
       tags: [Matchstick]
   - type: Appearance
     visuals:
-      - type: BagOpenCloseVisualizer
-        openIcon: matchbox-open
-      - type: StackVisualizer
-        composite: true
-        stackLayers:
-          - matchbox1
-          - matchbox2
-          - matchbox3
+    - type: StackVisualizer
+      composite: true
+      stackLayers:
+        - matchbox1
+        - matchbox2
+        - matchbox3
   - type: Tag
     tags:
     - Trash
index abb187601267f04210466804611f4277eb9da47c..8cd3138d2fdfdcfed899d7920eddd37567909b20 100644 (file)
       storagebase: !type:Container
         ents: []
 
+- type: entity
+  id: BaseBagOpenClose
+  abstract: true
+  components:
+  - type: Appearance
+  - type: GenericVisualizer
+    visuals:
+      enum.SharedBagOpenVisuals.BagState:
+        openLayer:
+          True: { visible: true }
+          False: { visible: false }
+
 
 # PowerCellSlot parents
 - type: entity
index 5b52f5c81a8349aaa665ba43e77b8d5e70329d18..5306ce02aedcfe29b6db7372161f789d78660c81 100644 (file)
@@ -1,6 +1,6 @@
 - type: entity
   name: filing cabinet
-  parent: BaseStructureDynamic
+  parent: [ BaseStructureDynamic, BaseBagOpenClose ]
   id: filingCabinet
   suffix: Empty
   description: A cabinet for all your filing needs.
     sprite: Structures/Storage/cabinets.rsi
     state: filingcabinet
     noRot: true
-  - type: Appearance
-    visuals:
-    - type: BagOpenCloseVisualizer
-      openIcon: filingcabinet-open
+    layers:
+    - state: filingcabinet
+    - state: filingcabinet-open
+      map: ["openLayer"]
   - type: UserInterface
     interfaces:
     - key: enum.StorageUiKey.Key
   - type: Sprite
     sprite: Structures/Storage/cabinets.rsi
     state: tallcabinet
+    layers:
+    - state: tallcabinet
+    - state: tallcabinet-open
+      map: ["openLayer"]
   - type: Appearance
-    visuals:
-    - type: BagOpenCloseVisualizer
-      openIcon: tallcabinet-open
 
 - type: entity
   name: chest drawer
     sprite: Structures/Storage/cabinets.rsi
     state: chestdrawer
     noRot: true
+    layers:
+    - state: chestdrawer
+    - state: chestdrawer-open
+      map: ["openLayer"]
   - type: Appearance
-    visuals:
-    - type: BagOpenCloseVisualizer
-      openIcon: chestdrawer-open
   - type: UserInterface
     interfaces:
     - key: enum.StorageUiKey.Key