Resolves BagOpenCloseVisualizer is Obsolete v2 Uncooked Edition (#16399)

This commit is contained in:
TemporalOroboros
2023-05-15 13:37:45 -07:00
committed by GitHub
parent e03c627709
commit 8094965285
8 changed files with 72 additions and 134 deletions

View File

@@ -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;
}
}
}
}

View File

@@ -6,7 +6,7 @@
# an alpha color which -Y- said he would implement. # an alpha color which -Y- said he would implement.
- type: entity - type: entity
parent: BoxCardboard parent: [ BoxCardboard, BaseBagOpenClose ]
id: FoodBoxDonut id: FoodBoxDonut
name: donut box name: donut box
description: Mmm, Donuts. description: Mmm, Donuts.
@@ -15,6 +15,10 @@
netsync: false netsync: false
sprite: Objects/Consumable/Food/Baked/donut.rsi sprite: Objects/Consumable/Food/Baked/donut.rsi
state: box state: box
layers:
- state: box
- state: box-open
map: ["openLayer"]
- type: Storage - type: Storage
capacity: 6 capacity: 6
whitelist: whitelist:
@@ -35,8 +39,6 @@
tags: [Donut] tags: [Donut]
- type: Appearance - type: Appearance
visuals: visuals:
- type: BagOpenCloseVisualizer
openIcon: box-open
- type: StackVisualizer - type: StackVisualizer
composite: true composite: true
stackLayers: stackLayers:
@@ -50,7 +52,7 @@
# Egg # Egg
- type: entity - type: entity
parent: BoxCardboard parent: [ BoxCardboard, BaseBagOpenClose ]
id: FoodContainerEgg id: FoodContainerEgg
name: egg carton name: egg carton
description: Don't drop 'em! description: Don't drop 'em!
@@ -59,6 +61,10 @@
netsync: false netsync: false
sprite: Objects/Consumable/Food/egg.rsi sprite: Objects/Consumable/Food/egg.rsi
state: box-closed state: box-closed
layers:
- state: box-closed
- state: box-open
map: ["openLayer"]
- type: Storage - type: Storage
capacity: 12 capacity: 12
whitelist: whitelist:
@@ -76,8 +82,6 @@
tags: [Egg] tags: [Egg]
- type: Appearance - type: Appearance
visuals: visuals:
- type: BagOpenCloseVisualizer
openIcon: box-open
- type: StackVisualizer - type: StackVisualizer
composite: true composite: true
stackLayers: stackLayers:
@@ -211,7 +215,7 @@
# Nugget # Nugget
- type: entity - type: entity
parent: BoxCardboard parent: [ BoxCardboard, BaseBagOpenClose ]
id: FoodBoxNugget id: FoodBoxNugget
name: chicken nuggets name: chicken nuggets
description: You suddenly have an urge to trade on the intergalactic stock market. description: You suddenly have an urge to trade on the intergalactic stock market.
@@ -220,6 +224,10 @@
netsync: false netsync: false
sprite: Objects/Consumable/Food/Baked/nuggets.rsi sprite: Objects/Consumable/Food/Baked/nuggets.rsi
state: box state: box
layers:
- state: box
- state: box-open
map: ["openLayer"]
- type: Storage - type: Storage
capacity: 6 capacity: 6
- type: Item - type: Item
@@ -235,8 +243,6 @@
tags: [Nugget] tags: [Nugget]
- type: Appearance - type: Appearance
visuals: visuals:
- type: BagOpenCloseVisualizer
openIcon: box-open
- type: StackVisualizer - type: StackVisualizer
composite: true composite: true
stackLayers: stackLayers:
@@ -373,7 +379,7 @@
- type: entity - type: entity
id: HappyHonk id: HappyHonk
parent: BoxCardboard parent: [ BoxCardboard, BaseBagOpenClose ]
name: happy honk meal name: happy honk meal
suffix: Toy Safe suffix: Toy Safe
description: The toy is more edible than the food. description: The toy is more edible than the food.
@@ -382,13 +388,13 @@
netsync: false netsync: false
sprite: Objects/Storage/Happyhonk/clown.rsi sprite: Objects/Storage/Happyhonk/clown.rsi
state: box state: box
layers:
- state: box
- state: box-open
map: ["openLayer"]
- type: Item - type: Item
sprite: Objects/Storage/Happyhonk/clown.rsi sprite: Objects/Storage/Happyhonk/clown.rsi
heldPrefix: box heldPrefix: box
- type: Appearance
visuals:
- type: BagOpenCloseVisualizer
openIcon: box-open
- type: Storage - type: Storage
capacity: 30 capacity: 30
- type: Tag - type: Tag

View File

@@ -1,6 +1,6 @@
- type: entity - type: entity
id: CigCartonGreen id: CigCartonGreen
parent: BoxCardboard parent: [ BoxCardboard, BaseBagOpenClose ]
name: Spessman's Smokes carton name: Spessman's Smokes carton
description: "A carton containing 6 packets of Spessman's Smokes." description: "A carton containing 6 packets of Spessman's Smokes."
components: components:
@@ -8,6 +8,8 @@
sprite: Objects/Consumable/Smokeables/Cigarettes/Cartons/green.rsi sprite: Objects/Consumable/Smokeables/Cigarettes/Cartons/green.rsi
layers: layers:
- state: closed - state: closed
- state: open
map: ["openLayer"]
- type: Storage - type: Storage
capacity: 36 capacity: 36
- type: Item - type: Item
@@ -17,10 +19,6 @@
contents: contents:
- id: CigPackGreen - id: CigPackGreen
amount: 6 amount: 6
- type: Appearance
visuals:
- type: BagOpenCloseVisualizer
openIcon: open
- type: Tag - type: Tag
tags: tags:
- Trash - Trash

View File

@@ -1,9 +1,15 @@
- type: entity - type: entity
id: CigPackBase id: CigPackBase
parent: BaseStorageItem parent: [ BaseStorageItem, BaseBagOpenClose ]
name: cigarette pack name: cigarette pack
abstract: true abstract: true
components: components:
- type: Sprite
netsync: false
layers:
- state: closed
- state: open
map: ["openLayer"]
- type: Tag - type: Tag
tags: tags:
- CigPack - CigPack
@@ -25,8 +31,6 @@
tags: [Cigarette] tags: [Cigarette]
- type: Appearance - type: Appearance
visuals: visuals:
- type: BagOpenCloseVisualizer
openIcon: open
- type: StackVisualizer - type: StackVisualizer
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/visualizer.rsi sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/visualizer.rsi
composite: true composite: true
@@ -45,10 +49,7 @@
description: A label on the packaging reads, Wouldn't a slow death make a change? description: A label on the packaging reads, Wouldn't a slow death make a change?
components: components:
- type: Sprite - type: Sprite
netsync: false
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/green.rsi sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/green.rsi
layers:
- state: closed
- type: Item - type: Item
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/green.rsi 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. description: The most popular brand of Space Cigarettes, sponsors of the Space Olympics.
components: components:
- type: Sprite - type: Sprite
netsync: false
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/red.rsi sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/red.rsi
layers:
- state: closed
- type: Item - type: Item
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/red.rsi 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. description: For those who somehow want to obtain the record for the most amount of cancerous tumors.
components: components:
- type: Sprite - type: Sprite
netsync: false
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/blue.rsi sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/blue.rsi
layers:
- state: closed
- type: Item - type: Item
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/blue.rsi 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. description: Nomads's extra strong, for when your life is more extra hard.
components: components:
- type: Sprite - type: Sprite
netsync: false
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/black.rsi sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/black.rsi
layers:
- state: closed
- type: Item - type: Item
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/black.rsi sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/black.rsi
@@ -100,14 +92,11 @@
name: Syndicate Smokes packet name: Syndicate Smokes packet
description: Elite cigarettes for elite agents. Infused with medicine for when you need to do more than calm your nerves. description: Elite cigarettes for elite agents. Infused with medicine for when you need to do more than calm your nerves.
components: components:
- type: Sprite
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/syndicate.rsi
- type: Item
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/syndicate.rsi
- type: StorageFill - type: StorageFill
contents: contents:
- id: CigaretteSyndicate - id: CigaretteSyndicate
amount: 5 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

View File

@@ -1,6 +1,6 @@
- type: entity - type: entity
id: CigarCase id: CigarCase
parent: BaseStorageItem parent: [ BaseStorageItem, BaseBagOpenClose ]
name: cigar case name: cigar case
description: A case for holding your cigars when you are not smoking them. description: A case for holding your cigars when you are not smoking them.
components: components:
@@ -9,6 +9,8 @@
sprite: Objects/Consumable/Smokeables/Cigars/case.rsi sprite: Objects/Consumable/Smokeables/Cigars/case.rsi
layers: layers:
- state: closed - state: closed
- state: open
map: ["openLayer"]
- type: Storage - type: Storage
capacity: 8 capacity: 8
- type: Item - type: Item
@@ -23,8 +25,6 @@
tags: [Cigar] tags: [Cigar]
- type: Appearance - type: Appearance
visuals: visuals:
- type: BagOpenCloseVisualizer
openIcon: open
- type: StackVisualizer - type: StackVisualizer
composite: true composite: true
stackLayers: stackLayers:

View File

@@ -55,7 +55,7 @@
- type: entity - type: entity
name: match box name: match box
parent: SmallboxItem parent: [ SmallboxItem, BaseBagOpenClose ]
id: Matchbox id: Matchbox
description: A small box of Almost But Not Quite Plasma Premium Matches. description: A small box of Almost But Not Quite Plasma Premium Matches.
components: components:
@@ -67,7 +67,9 @@
netsync: false netsync: false
sprite: Objects/Tools/matches.rsi sprite: Objects/Tools/matches.rsi
layers: layers:
- state: matchbox - state: matchbox
- state: matchbox-open
map: ["openLayer"]
- type: Item - type: Item
sprite: Objects/Tools/matches.rsi sprite: Objects/Tools/matches.rsi
heldPrefix: matchbox heldPrefix: matchbox
@@ -83,14 +85,12 @@
tags: [Matchstick] tags: [Matchstick]
- type: Appearance - type: Appearance
visuals: visuals:
- type: BagOpenCloseVisualizer - type: StackVisualizer
openIcon: matchbox-open composite: true
- type: StackVisualizer stackLayers:
composite: true - matchbox1
stackLayers: - matchbox2
- matchbox1 - matchbox3
- matchbox2
- matchbox3
- type: Tag - type: Tag
tags: tags:
- Trash - Trash

View File

@@ -62,6 +62,18 @@
storagebase: !type:Container storagebase: !type:Container
ents: [] 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 # PowerCellSlot parents
- type: entity - type: entity

View File

@@ -1,6 +1,6 @@
- type: entity - type: entity
name: filing cabinet name: filing cabinet
parent: BaseStructureDynamic parent: [ BaseStructureDynamic, BaseBagOpenClose ]
id: filingCabinet id: filingCabinet
suffix: Empty suffix: Empty
description: A cabinet for all your filing needs. description: A cabinet for all your filing needs.
@@ -17,10 +17,10 @@
sprite: Structures/Storage/cabinets.rsi sprite: Structures/Storage/cabinets.rsi
state: filingcabinet state: filingcabinet
noRot: true noRot: true
- type: Appearance layers:
visuals: - state: filingcabinet
- type: BagOpenCloseVisualizer - state: filingcabinet-open
openIcon: filingcabinet-open map: ["openLayer"]
- type: UserInterface - type: UserInterface
interfaces: interfaces:
- key: enum.StorageUiKey.Key - key: enum.StorageUiKey.Key
@@ -52,10 +52,11 @@
- type: Sprite - type: Sprite
sprite: Structures/Storage/cabinets.rsi sprite: Structures/Storage/cabinets.rsi
state: tallcabinet state: tallcabinet
layers:
- state: tallcabinet
- state: tallcabinet-open
map: ["openLayer"]
- type: Appearance - type: Appearance
visuals:
- type: BagOpenCloseVisualizer
openIcon: tallcabinet-open
- type: entity - type: entity
name: chest drawer name: chest drawer
@@ -76,10 +77,11 @@
sprite: Structures/Storage/cabinets.rsi sprite: Structures/Storage/cabinets.rsi
state: chestdrawer state: chestdrawer
noRot: true noRot: true
layers:
- state: chestdrawer
- state: chestdrawer-open
map: ["openLayer"]
- type: Appearance - type: Appearance
visuals:
- type: BagOpenCloseVisualizer
openIcon: chestdrawer-open
- type: UserInterface - type: UserInterface
interfaces: interfaces:
- key: enum.StorageUiKey.Key - key: enum.StorageUiKey.Key