Bucket solution fills + ECS SolutionContainerVisualizer (#10289)

This commit is contained in:
Kara
2022-08-07 01:50:52 -07:00
committed by GitHub
parent ee8d5d7828
commit b947151d9a
28 changed files with 200 additions and 185 deletions

View File

@@ -1,61 +0,0 @@
using System;
using Content.Shared.Chemistry;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Client.Chemistry.Visualizers
{
[UsedImplicitly]
public sealed class SolutionContainerVisualizer : AppearanceVisualizer
{
[DataField("maxFillLevels")] private int _maxFillLevels = 0;
[DataField("fillBaseName")] private string? _fillBaseName = null;
[DataField("layer")] private SolutionContainerLayers _layer = SolutionContainerLayers.Fill;
[DataField("changeColor")] private bool _changeColor = true;
[DataField("emptySpriteName")] private string? _emptySpriteName = null;
[DataField("emptySpriteColor")] private Color _emptySpriteColor = Color.White;
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (!component.TryGetData(SolutionContainerVisuals.VisualState,
out SolutionContainerVisualState state)) return;
var entities = IoCManager.Resolve<IEntityManager>();
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite)) return;
if (!sprite.LayerMapTryGet(_layer, out var fillLayer)) return;
var fillPercent = state.FilledVolumePercent;
var closestFillSprite = (int) Math.Round(fillPercent * _maxFillLevels);
if (closestFillSprite > 0)
{
if (_fillBaseName == null) return;
sprite.LayerSetVisible(fillLayer, true);
var stateName = _fillBaseName + closestFillSprite;
sprite.LayerSetState(fillLayer, stateName);
if (_changeColor)
sprite.LayerSetColor(fillLayer, state.Color);
}
else
{
if (_emptySpriteName == null)
sprite.LayerSetVisible(fillLayer, false);
else
{
sprite.LayerSetState(fillLayer, _emptySpriteName);
if (_changeColor)
sprite.LayerSetColor(fillLayer, _emptySpriteColor);
}
}
}
}
}

View File

@@ -0,0 +1,28 @@
using System;
using Content.Shared.Chemistry;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Client.Chemistry.Visualizers
{
[RegisterComponent]
public sealed class SolutionContainerVisualsComponent : Component
{
[DataField("maxFillLevels")]
public int MaxFillLevels = 0;
[DataField("fillBaseName")]
public string? FillBaseName = null;
[DataField("layer")]
public SolutionContainerLayers Layer = SolutionContainerLayers.Fill;
[DataField("changeColor")]
public bool ChangeColor = true;
[DataField("emptySpriteName")]
public string? EmptySpriteName = null;
[DataField("emptySpriteColor")]
public Color EmptySpriteColor = Color.White;
}
}

View File

@@ -0,0 +1,47 @@
using Content.Shared.Chemistry;
using Robust.Client.GameObjects;
namespace Content.Client.Chemistry.Visualizers;
public sealed class SolutionContainerVisualsSystem : VisualizerSystem<SolutionContainerVisualsComponent>
{
protected override void OnAppearanceChange(EntityUid uid, SolutionContainerVisualsComponent component, ref AppearanceChangeEvent args)
{
if (!args.Component.TryGetData(SolutionContainerVisuals.VisualState, out SolutionContainerVisualState state))
return;
if (args.Sprite == null)
return;
if (!args.Sprite.LayerMapTryGet(component.Layer, out var fillLayer))
return;
var fillPercent = state.FilledVolumePercent;
var closestFillSprite = (int) Math.Round(fillPercent * component.MaxFillLevels);
if (closestFillSprite > 0)
{
if (component.FillBaseName == null)
return;
args.Sprite.LayerSetVisible(fillLayer, true);
var stateName = component.FillBaseName + closestFillSprite;
args.Sprite.LayerSetState(fillLayer, stateName);
if (component.ChangeColor)
args.Sprite.LayerSetColor(fillLayer, state.Color);
}
else
{
if (component.EmptySpriteName == null)
args.Sprite.LayerSetVisible(fillLayer, false);
else
{
args.Sprite.LayerSetState(fillLayer, component.EmptySpriteName);
if (component.ChangeColor)
args.Sprite.LayerSetColor(fillLayer, component.EmptySpriteColor);
}
}
}
}

View File

@@ -26,6 +26,7 @@ namespace Content.Server.Entry
"HandheldGPS", "HandheldGPS",
"SpentAmmoVisuals", "SpentAmmoVisuals",
"MagazineVisuals", "MagazineVisuals",
"SolutionContainerVisuals",
"PowerCellVisuals", "PowerCellVisuals",
"ToggleableLightVisuals", "ToggleableLightVisuals",
"CableVisualizer", "CableVisualizer",

View File

@@ -25,10 +25,9 @@
# REMEMBER IF YOU'RE SPAWNING WITH LIQUID ALREADY IN IT YOU WANT THIS TRUE # REMEMBER IF YOU'RE SPAWNING WITH LIQUID ALREADY IN IT YOU WANT THIS TRUE
visible: true visible: true
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 6
maxFillLevels: 6 fillBaseName: fill-
fillBaseName: fill-
# Without (For food, non cut-out stuff) # Without (For food, non cut-out stuff)
@@ -53,9 +52,8 @@
map: ["enum.SolutionContainerLayers.Fill"] map: ["enum.SolutionContainerLayers.Fill"]
visible: true visible: true
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 6
maxFillLevels: 6 fillBaseName: icon-
fillBaseName: icon- changeColor: false
changeColor: false emptySpriteName: icon
emptySpriteName: icon

View File

@@ -58,10 +58,9 @@
- type: Icon - type: Icon
state: packet-astrotame state: packet-astrotame
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 2
maxFillLevels: 2 fillBaseName: packet-trans-
fillBaseName: packet-trans-
- type: entity - type: entity
parent: FoodCondimentPacket parent: FoodCondimentPacket
@@ -85,10 +84,9 @@
- type: Icon - type: Icon
state: packet-bbq state: packet-bbq
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 2
maxFillLevels: 2 fillBaseName: packet-trans-
fillBaseName: packet-trans-
- type: entity - type: entity
parent: FoodCondimentPacket parent: FoodCondimentPacket
@@ -112,10 +110,9 @@
- type: Icon - type: Icon
state: packet-cornoil state: packet-cornoil
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 2
maxFillLevels: 2 fillBaseName: packet-trans-
fillBaseName: packet-trans-
- type: entity - type: entity
parent: FoodCondimentPacket parent: FoodCondimentPacket
@@ -139,10 +136,9 @@
- type: Icon - type: Icon
state: packet-frostoil state: packet-frostoil
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 2
maxFillLevels: 2 fillBaseName: packet-trans-
fillBaseName: packet-trans-
- type: entity - type: entity
parent: FoodCondimentPacket parent: FoodCondimentPacket
@@ -166,10 +162,9 @@
- type: Icon - type: Icon
state: packet-greygoo state: packet-greygoo
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 2
maxFillLevels: 2 fillBaseName: packet-solid-
fillBaseName: packet-solid-
- type: entity - type: entity
parent: FoodCondimentPacket parent: FoodCondimentPacket
@@ -193,10 +188,9 @@
- type: Icon - type: Icon
state: packet-hotsauce state: packet-hotsauce
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 2
maxFillLevels: 2 fillBaseName: packet-trans-
fillBaseName: packet-trans-
- type: entity - type: entity
parent: FoodCondimentPacket parent: FoodCondimentPacket
@@ -219,10 +213,9 @@
- type: Icon - type: Icon
state: packet-ketchup state: packet-ketchup
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 2
maxFillLevels: 2 fillBaseName: packet-solid-
fillBaseName: packet-solid-
- type: entity - type: entity
parent: FoodCondimentPacket parent: FoodCondimentPacket
@@ -245,10 +238,9 @@
- type: Icon - type: Icon
state: packet-pepper state: packet-pepper
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 2
maxFillLevels: 2 fillBaseName: packet-solid-
fillBaseName: packet-solid-
- type: entity - type: entity
parent: FoodCondimentPacket parent: FoodCondimentPacket
@@ -273,10 +265,9 @@
- type: Icon - type: Icon
state: packet-salt state: packet-salt
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 2
maxFillLevels: 2 fillBaseName: packet-solid-
fillBaseName: packet-solid-
- type: entity - type: entity
parent: FoodCondimentPacket parent: FoodCondimentPacket
@@ -299,10 +290,9 @@
- type: Icon - type: Icon
state: packet-soysauce state: packet-soysauce
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 2
maxFillLevels: 2 fillBaseName: packet-solid-
fillBaseName: packet-solid-
- type: entity - type: entity
parent: FoodCondimentPacket parent: FoodCondimentPacket
@@ -325,10 +315,9 @@
- type: Icon - type: Icon
state: packet-sugar state: packet-sugar
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 2
maxFillLevels: 2 fillBaseName: packet-solid-
fillBaseName: packet-solid-
# Bottles # Bottles
@@ -355,10 +344,9 @@
sprite: Objects/Consumable/Food/condiments.rsi sprite: Objects/Consumable/Food/condiments.rsi
state: bottle-empty state: bottle-empty
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 6
maxFillLevels: 6 fillBaseName: bottle-alpha-
fillBaseName: bottle-alpha-
- type: TrashOnEmpty - type: TrashOnEmpty
solution: food solution: food
@@ -501,10 +489,9 @@
sprite: Objects/Consumable/Food/condiments.rsi sprite: Objects/Consumable/Food/condiments.rsi
state: bottle-s-empty state: bottle-s-empty
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 3
maxFillLevels: 3 fillBaseName: bottle-s-alpha-
fillBaseName: bottle-s-alpha-
- type: TrashOnEmpty - type: TrashOnEmpty
solution: food solution: food

View File

@@ -32,7 +32,9 @@
sprite: Objects/Specific/Janitorial/janitorial.rsi sprite: Objects/Specific/Janitorial/janitorial.rsi
layers: layers:
- state: mopbucket - state: mopbucket
- state: mopbucket_water - state: mopbucket_water-1
map: ["enum.SolutionContainerLayers.Fill"]
visible: false
drawdepth: Objects drawdepth: Objects
- type: InteractionOutline - type: InteractionOutline
- type: SolutionContainerManager - type: SolutionContainerManager
@@ -47,6 +49,8 @@
solution: bucket solution: bucket
- type: RefillableSolution - type: RefillableSolution
solution: bucket solution: bucket
- type: ExaminableSolution
solution: bucket
- type: Tag - type: Tag
tags: tags:
- Wringer - Wringer
@@ -67,6 +71,10 @@
- type: Pullable - type: Pullable
- type: Drink - type: Drink
isOpen: true isOpen: true
- type: Appearance
- type: SolutionContainerVisuals
maxFillLevels: 3
fillBaseName: mopbucket_water-
- type: entity - type: entity
name: wet floor sign name: wet floor sign
@@ -96,8 +104,9 @@
sprite: Objects/Specific/Janitorial/janitorial_cart.rsi sprite: Objects/Specific/Janitorial/janitorial_cart.rsi
layers: layers:
- state: cart - state: cart
- state: cart_water_1 - state: cart_water-1
map: ["enum.SolutionContainerLayers.Fill"] map: ["enum.SolutionContainerLayers.Fill"]
visible: false
- type: Rotatable - type: Rotatable
- type: InteractionOutline - type: InteractionOutline
- type: Storage - type: Storage
@@ -202,10 +211,9 @@
visuals: visuals:
- type: MappedItemVisualizer - type: MappedItemVisualizer
sprite: Objects/Specific/Janitorial/janitorial_cart.rsi sprite: Objects/Specific/Janitorial/janitorial_cart.rsi
- type: SolutionContainerVisualizer - type: SolutionContainerVisuals
maxFillLevels: 3 maxFillLevels: 3
fillBaseName: cart_water_ fillBaseName: cart_water-
changeColor: false
- type: UserInterface - type: UserInterface
interfaces: interfaces:
- key: enum.StorageUiKey.Key - key: enum.StorageUiKey.Key

View File

@@ -67,11 +67,10 @@
solutionName: pen solutionName: pen
transferAmount: 15 transferAmount: 15
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 1
maxFillLevels: 1 changeColor: false
changeColor: false emptySpriteName: medipen_empty
emptySpriteName: medipen_empty
- type: Tag - type: Tag
tags: tags:
- Trash - Trash
@@ -126,11 +125,10 @@
- state: hypovolemic - state: hypovolemic
map: [ "enum.SolutionContainerLayers.Fill" ] map: [ "enum.SolutionContainerLayers.Fill" ]
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 1
maxFillLevels: 1 changeColor: false
changeColor: false emptySpriteName: hypovolemic_empty
emptySpriteName: hypovolemic_empty
- type: Hypospray - type: Hypospray
solutionName: pen solutionName: pen
transferAmount: 30 transferAmount: 30

View File

@@ -56,10 +56,9 @@
map: ["enum.SolutionContainerLayers.Fill"] map: ["enum.SolutionContainerLayers.Fill"]
visible: false visible: false
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 6
maxFillLevels: 6 fillBaseName: bottle-1-
fillBaseName: bottle-1-
- type: entity - type: entity
name: bottle name: bottle
@@ -74,10 +73,9 @@
map: ["enum.SolutionContainerLayers.Fill"] map: ["enum.SolutionContainerLayers.Fill"]
visible: false visible: false
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 6
maxFillLevels: 6 fillBaseName: bottle-2-
fillBaseName: bottle-2-
- type: entity - type: entity
name: bottle name: bottle
@@ -92,10 +90,9 @@
map: ["enum.SolutionContainerLayers.Fill"] map: ["enum.SolutionContainerLayers.Fill"]
visible: false visible: false
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 6
maxFillLevels: 6 fillBaseName: bottle-3-
fillBaseName: bottle-3-
- type: entity - type: entity
name: bottle name: bottle
@@ -110,10 +107,9 @@
map: ["enum.SolutionContainerLayers.Fill"] map: ["enum.SolutionContainerLayers.Fill"]
visible: false visible: false
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 6
maxFillLevels: 6 fillBaseName: bottle-4-
fillBaseName: bottle-4-
- type: entity - type: entity
id: EpinephrineChemistryBottle id: EpinephrineChemistryBottle

View File

@@ -41,10 +41,9 @@
- type: Drink - type: Drink
isOpen: true isOpen: true
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 6
maxFillLevels: 6 fillBaseName: beaker
fillBaseName: beaker
- type: Damageable - type: Damageable
damageContainer: Inorganic damageContainer: Inorganic
damageModifierSet: Glass damageModifierSet: Glass
@@ -111,10 +110,9 @@
beaker: beaker:
maxVol: 100 maxVol: 100
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 6
maxFillLevels: 6 fillBaseName: beakerlarge
fillBaseName: beakerlarge
- type: entity - type: entity
name: cryostasis beaker name: cryostasis beaker
@@ -204,10 +202,9 @@
- type: Item - type: Item
sprite: Objects/Specific/Chemistry/dropper.rsi sprite: Objects/Specific/Chemistry/dropper.rsi
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer maxFillLevels: 1
maxFillLevels: 1 fillBaseName: dropper
fillBaseName: dropper
- type: entity - type: entity
name: syringe name: syringe
@@ -238,18 +235,9 @@
- type: TrashOnEmpty - type: TrashOnEmpty
solution: injector solution: injector
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
# this visualizer used for reagent inside maxFillLevels: 4
- type: SolutionContainerVisualizer fillBaseName: syringe
maxFillLevels: 4
fillBaseName: syringe
# this one for syrigine itself (plunger)
- type: SolutionContainerVisualizer
maxFillLevels: 4
fillBaseName: syringe_base
emptySpriteName: syringe_base0
layer: Base
changeColor: false
- type: entity - type: entity
name: pill name: pill

View File

@@ -10,7 +10,11 @@
- type: Sprite - type: Sprite
netsync: false netsync: false
sprite: Objects/Tools/bucket.rsi sprite: Objects/Tools/bucket.rsi
state: icon layers:
- state: icon
- map: ["enum.SolutionContainerLayers.Fill"]
state: fill-1
visible: false
- type: Item - type: Item
size: 100 size: 100
- type: Clothing - type: Clothing
@@ -38,3 +42,9 @@
solution: bucket solution: bucket
- type: DrainableSolution - type: DrainableSolution
solution: bucket solution: bucket
- type: Appearance
- type: SolutionContainerVisuals
maxFillLevels: 3
fillBaseName: fill-
- type: ExaminableSolution
solution: bucket

View File

@@ -240,7 +240,7 @@
parent: BaseDrink parent: BaseDrink
desc: reagent-desc-water desc: reagent-desc-water
physicalDesc: reagent-physical-desc-translucent physicalDesc: reagent-physical-desc-translucent
color: "#c0e0ff20" color: "#75b1f0"
boilingPoint: 100.0 boilingPoint: 100.0
meltingPoint: 0.0 meltingPoint: 0.0
metabolisms: metabolisms:

View File

@@ -14,7 +14,13 @@
"name": "mopbucket" "name": "mopbucket"
}, },
{ {
"name": "mopbucket_water" "name": "mopbucket_water-1"
},
{
"name": "mopbucket_water-2"
},
{
"name": "mopbucket_water-3"
}, },
{ {
"name": "inhand-left", "name": "inhand-left",

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 803 B

View File

@@ -44,7 +44,7 @@
"directions": 4 "directions": 4
}, },
{ {
"name": "cart_water_1", "name": "cart_water-1",
"directions": 4, "directions": 4,
"delays": [ "delays": [
[ [
@@ -70,7 +70,7 @@
] ]
}, },
{ {
"name": "cart_water_2", "name": "cart_water-2",
"directions": 4, "directions": 4,
"delays": [ "delays": [
[ [
@@ -96,7 +96,7 @@
] ]
}, },
{ {
"name": "cart_water_3", "name": "cart_water-3",
"directions": 4, "directions": 4,
"delays": [ "delays": [
[ [

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

View File

@@ -10,6 +10,15 @@
{ {
"name": "icon" "name": "icon"
}, },
{
"name": "fill-1"
},
{
"name": "fill-2"
},
{
"name": "fill-3"
},
{ {
"name": "equipped-HELMET", "name": "equipped-HELMET",
"directions": 4 "directions": 4