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",
"SpentAmmoVisuals",
"MagazineVisuals",
"SolutionContainerVisuals",
"PowerCellVisuals",
"ToggleableLightVisuals",
"CableVisualizer",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -41,10 +41,9 @@
- type: Drink
isOpen: true
- type: Appearance
visuals:
- type: SolutionContainerVisualizer
maxFillLevels: 6
fillBaseName: beaker
- type: SolutionContainerVisuals
maxFillLevels: 6
fillBaseName: beaker
- type: Damageable
damageContainer: Inorganic
damageModifierSet: Glass
@@ -111,10 +110,9 @@
beaker:
maxVol: 100
- type: Appearance
visuals:
- type: SolutionContainerVisualizer
maxFillLevels: 6
fillBaseName: beakerlarge
- type: SolutionContainerVisuals
maxFillLevels: 6
fillBaseName: beakerlarge
- type: entity
name: cryostasis beaker
@@ -204,10 +202,9 @@
- type: Item
sprite: Objects/Specific/Chemistry/dropper.rsi
- type: Appearance
visuals:
- type: SolutionContainerVisualizer
maxFillLevels: 1
fillBaseName: dropper
- type: SolutionContainerVisuals
maxFillLevels: 1
fillBaseName: dropper
- type: entity
name: syringe
@@ -238,18 +235,9 @@
- type: TrashOnEmpty
solution: injector
- type: Appearance
visuals:
# this visualizer used for reagent inside
- type: SolutionContainerVisualizer
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: SolutionContainerVisuals
maxFillLevels: 4
fillBaseName: syringe
- type: entity
name: pill

View File

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

View File

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

View File

@@ -14,7 +14,13 @@
"name": "mopbucket"
},
{
"name": "mopbucket_water"
"name": "mopbucket_water-1"
},
{
"name": "mopbucket_water-2"
},
{
"name": "mopbucket_water-3"
},
{
"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
},
{
"name": "cart_water_1",
"name": "cart_water-1",
"directions": 4,
"delays": [
[
@@ -70,7 +70,7 @@
]
},
{
"name": "cart_water_2",
"name": "cart_water-2",
"directions": 4,
"delays": [
[
@@ -96,7 +96,7 @@
]
},
{
"name": "cart_water_3",
"name": "cart_water-3",
"directions": 4,
"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": "fill-1"
},
{
"name": "fill-2"
},
{
"name": "fill-3"
},
{
"name": "equipped-HELMET",
"directions": 4