Improves bartending with some tweaks. (#14169)

* Improves bartending with some tweaks.
- Glasses got resprited and now support fill levels.
-

* New glass type and improve shotglass visuals.

* oobsy

* fixes

* get flasked

* flask

* flask

---------

Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
This commit is contained in:
Moony
2023-02-18 19:00:31 -06:00
committed by GitHub
parent e29a3874b8
commit cc0c516e02
61 changed files with 799 additions and 533 deletions

View File

@@ -1,10 +1,27 @@
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Reagent;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Client.Chemistry.Visualizers;
public sealed class SolutionContainerVisualsSystem : VisualizerSystem<SolutionContainerVisualsComponent>
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SolutionContainerVisualsComponent, MapInitEvent>(OnMapInit);
}
private void OnMapInit(EntityUid uid, SolutionContainerVisualsComponent component, MapInitEvent args)
{
var meta = MetaData(uid);
component.InitialName = meta.EntityName;
component.InitialDescription = meta.EntityDescription;
}
protected override void OnAppearanceChange(EntityUid uid, SolutionContainerVisualsComponent component, ref AppearanceChangeEvent args)
{
if (!AppearanceSystem.TryGetData<float>(uid, SolutionContainerVisuals.FillFraction, out var fraction, args.Component))
@@ -13,7 +30,7 @@ public sealed class SolutionContainerVisualsSystem : VisualizerSystem<SolutionCo
if (args.Sprite == null)
return;
if (!args.Sprite.LayerMapTryGet(component.Layer, out var fillLayer))
if (!args.Sprite.LayerMapTryGet(component.FillLayer, out var fillLayer))
return;
// Currently some solution methods such as overflowing will try to update appearance with a
@@ -25,6 +42,43 @@ public sealed class SolutionContainerVisualsSystem : VisualizerSystem<SolutionCo
fraction = 1f;
}
if (component.Metamorphic)
{
if (args.Sprite.LayerMapTryGet(component.BaseLayer, out var baseLayer))
{
var hasOverlay = args.Sprite.LayerMapTryGet(component.OverlayLayer, out var overlayLayer);
if (AppearanceSystem.TryGetData<string>(uid, SolutionContainerVisuals.BaseOverride,
out var baseOverride,
args.Component))
{
_prototype.TryIndex<ReagentPrototype>(baseOverride, out var reagentProto);
var metadata = MetaData(uid);
if (reagentProto?.MetamorphicSprite is { } sprite)
{
args.Sprite.LayerSetSprite(baseLayer, sprite);
args.Sprite.LayerSetVisible(fillLayer, false);
if (hasOverlay)
args.Sprite.LayerSetVisible(overlayLayer, false);
metadata.EntityName = Loc.GetString(component.MetamorphicNameFull,
("name", reagentProto.LocalizedName));
metadata.EntityDescription = reagentProto.LocalizedDescription;
return;
}
else
{
if (hasOverlay)
args.Sprite.LayerSetVisible(overlayLayer, true);
args.Sprite.LayerSetSprite(baseLayer, component.MetamorphicDefaultSprite);
metadata.EntityName = component.InitialName;
metadata.EntityDescription = component.InitialDescription;
}
}
}
}
var closestFillSprite = (int) Math.Round(fraction * component.MaxFillLevels);
if (closestFillSprite > 0)
@@ -51,5 +105,7 @@ public sealed class SolutionContainerVisualsSystem : VisualizerSystem<SolutionCo
args.Sprite.LayerSetColor(fillLayer, component.EmptySpriteColor);
}
}
}
}