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.
- 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

View 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
@@ -17,10 +19,6 @@
contents:
- id: CigPackGreen
amount: 6
- type: Appearance
visuals:
- type: BagOpenCloseVisualizer
openIcon: open
- type: Tag
tags:
- Trash

View 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
@@ -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: Sprite
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/syndicate.rsi
- type: Item
sprite: Objects/Consumable/Smokeables/Cigarettes/Packs/syndicate.rsi
- 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

View 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:

View 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
@@ -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

View File

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

View 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.
@@ -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