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,8 +25,7 @@
# 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-
@@ -53,8 +52,7 @@
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

View File

@@ -58,8 +58,7 @@
- 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-
@@ -85,8 +84,7 @@
- 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-
@@ -112,8 +110,7 @@
- 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-
@@ -139,8 +136,7 @@
- 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-
@@ -166,8 +162,7 @@
- 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-
@@ -193,8 +188,7 @@
- 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-
@@ -219,8 +213,7 @@
- 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-
@@ -245,8 +238,7 @@
- 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-
@@ -273,8 +265,7 @@
- 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-
@@ -299,8 +290,7 @@
- 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-
@@ -325,8 +315,7 @@
- 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-
@@ -355,8 +344,7 @@
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
@@ -501,8 +489,7 @@
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

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,8 +67,7 @@
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
@@ -126,8 +125,7 @@
- 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

View File

@@ -56,8 +56,7 @@
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-
@@ -74,8 +73,7 @@
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-
@@ -92,8 +90,7 @@
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-
@@ -110,8 +107,7 @@
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-

View File

@@ -41,8 +41,7 @@
- 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
@@ -111,8 +110,7 @@
beaker: beaker:
maxVol: 100 maxVol: 100
- type: Appearance - type: Appearance
visuals: - type: SolutionContainerVisuals
- type: SolutionContainerVisualizer
maxFillLevels: 6 maxFillLevels: 6
fillBaseName: beakerlarge fillBaseName: beakerlarge
@@ -204,8 +202,7 @@
- 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
@@ -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
- type: SolutionContainerVisualizer
maxFillLevels: 4 maxFillLevels: 4
fillBaseName: syringe 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