From: TemporalOroboros Date: Mon, 15 May 2023 20:37:45 +0000 (-0700) Subject: Resolves BagOpenCloseVisualizer is Obsolete v2 Uncooked Edition (#16399) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=8094965285c94b7072fab07ad998baa2444a2ef0;p=space-station-14.git Resolves BagOpenCloseVisualizer is Obsolete v2 Uncooked Edition (#16399) --- diff --git a/Content.Client/Storage/Visualizers/BagOpenCloseVisualizer.cs b/Content.Client/Storage/Visualizers/BagOpenCloseVisualizer.cs deleted file mode 100644 index 0199e3994f..0000000000 --- a/Content.Client/Storage/Visualizers/BagOpenCloseVisualizer.cs +++ /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(); - - if (_openIcon != null && - entities.TryGetComponent(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(); - - if (_openIcon == null || - !entities.TryGetComponent(component.Owner, out SpriteComponent? spriteComponent)) - return; - - if (!component.TryGetData(SharedBagOpenVisuals.BagState, out var bagState)) - return; - - switch (bagState) - { - case SharedBagState.Open: - spriteComponent.LayerSetVisible(OpenIcon, true); - break; - default: - spriteComponent.LayerSetVisible(OpenIcon, false); - break; - } - } - } -} diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/box.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/box.yml index 46ac76b138..0601112ef7 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/box.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/box.yml @@ -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. @@ -15,6 +15,10 @@ 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! @@ -59,6 +61,10 @@ 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: @@ -211,7 +215,7 @@ # 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. @@ -220,6 +224,10 @@ 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 @@ -235,8 +243,6 @@ tags: [Nugget] - type: Appearance visuals: - - type: BagOpenCloseVisualizer - openIcon: box-open - type: StackVisualizer composite: true stackLayers: @@ -373,7 +379,7 @@ - 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. @@ -382,13 +388,13 @@ 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 diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/cartons.yml b/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/cartons.yml index 52fa3dd50b..2ae53cad2b 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/cartons.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/cartons.yml @@ -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 @@ -17,10 +19,6 @@ contents: - id: CigPackGreen amount: 6 - - type: Appearance - visuals: - - type: BagOpenCloseVisualizer - openIcon: open - type: Tag tags: - Trash diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/packs.yml b/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/packs.yml index 22946a9e04..49c25a54b5 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/packs.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigarettes/packs.yml @@ -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 @@ -45,10 +49,7 @@ 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 @@ -59,10 +60,7 @@ 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 @@ -73,10 +71,7 @@ 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 @@ -87,10 +82,7 @@ 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 @@ -100,14 +92,11 @@ 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 diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigars/case.yml b/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigars/case.yml index f975439b43..b3607ec794 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigars/case.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Smokeables/Cigars/case.yml @@ -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: diff --git a/Resources/Prototypes/Entities/Objects/Tools/matches.yml b/Resources/Prototypes/Entities/Objects/Tools/matches.yml index dfbe5474a5..0097cfa053 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/matches.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/matches.yml @@ -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 @@ -83,14 +85,12 @@ 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 diff --git a/Resources/Prototypes/Entities/Objects/base_item.yml b/Resources/Prototypes/Entities/Objects/base_item.yml index abb1876012..8cd3138d2f 100644 --- a/Resources/Prototypes/Entities/Objects/base_item.yml +++ b/Resources/Prototypes/Entities/Objects/base_item.yml @@ -62,6 +62,18 @@ 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 diff --git a/Resources/Prototypes/Entities/Structures/Storage/filing_cabinets.yml b/Resources/Prototypes/Entities/Structures/Storage/filing_cabinets.yml index 5b52f5c81a..5306ce02ae 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/filing_cabinets.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/filing_cabinets.yml @@ -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. @@ -17,10 +17,10 @@ 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 @@ -52,10 +52,11 @@ - 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 @@ -76,10 +77,11 @@ 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