From: Tayrtahn Date: Mon, 19 Feb 2024 21:29:42 +0000 (-0500) Subject: Add support for metamorphic fill levels (#25022) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=e74f3019f7dc36a9e8ba19ae253692ed4af864c7;p=space-station-14.git Add support for metamorphic fill levels (#25022) * Added support for fill levels to metamorphic glasses * Fix warnings and cleanup * Don't break non-metamorphic fills! --- diff --git a/Content.Client/Chemistry/Visualizers/SolutionContainerVisualsSystem.cs b/Content.Client/Chemistry/Visualizers/SolutionContainerVisualsSystem.cs index b4486b8c0e..f1e8e8d7aa 100644 --- a/Content.Client/Chemistry/Visualizers/SolutionContainerVisualsSystem.cs +++ b/Content.Client/Chemistry/Visualizers/SolutionContainerVisualsSystem.cs @@ -49,12 +49,17 @@ public sealed class SolutionContainerVisualsSystem : VisualizerSystem 1f) { - Logger.Error("Attempted to set solution container visuals volume ratio on " + ToPrettyString(uid) + " to a value greater than 1. Volume should never be greater than max volume!"); + Log.Error("Attempted to set solution container visuals volume ratio on " + ToPrettyString(uid) + " to a value greater than 1. Volume should never be greater than max volume!"); fraction = 1f; } if (component.Metamorphic) @@ -72,13 +77,23 @@ public sealed class SolutionContainerVisualsSystem : VisualizerSystem 0) + { + args.Sprite.LayerSetVisible(fillLayer, true); + maxFillLevels = reagentProto.MetamorphicMaxFillLevels; + fillBaseName = reagentProto.MetamorphicFillBaseName; + changeColor = reagentProto.MetamorphicChangeColor; + fillSprite = sprite; + } + else + args.Sprite.LayerSetVisible(fillLayer, false); + if (hasOverlay) args.Sprite.LayerSetVisible(overlayLayer, false); - return; } else { + args.Sprite.LayerSetVisible(fillLayer, true); if (hasOverlay) args.Sprite.LayerSetVisible(overlayLayer, true); if (component.MetamorphicDefaultSprite != null) @@ -87,21 +102,27 @@ public sealed class SolutionContainerVisualsSystem : VisualizerSystem 0) { - if (component.FillBaseName == null) + if (fillBaseName == null) return; - args.Sprite.LayerSetVisible(fillLayer, true); - - var stateName = component.FillBaseName + closestFillSprite; + var stateName = fillBaseName + closestFillSprite; + if (fillSprite != null) + args.Sprite.LayerSetSprite(fillLayer, fillSprite); args.Sprite.LayerSetState(fillLayer, stateName); - if (component.ChangeColor && AppearanceSystem.TryGetData(uid, SolutionContainerVisuals.Color, out var color, args.Component)) + if (changeColor && AppearanceSystem.TryGetData(uid, SolutionContainerVisuals.Color, out var color, args.Component)) args.Sprite.LayerSetColor(fillLayer, color); + else + args.Sprite.LayerSetColor(fillLayer, Color.White); } else { @@ -110,8 +131,10 @@ public sealed class SolutionContainerVisualsSystem : VisualizerSystem(uid, SolutionContainerVisuals.FillFraction, out var fraction, appearance)) return; - int closestFillSprite = ContentHelpers.RoundToLevels(fraction, 1, component.InHandsMaxFillLevels + 1); + var closestFillSprite = ContentHelpers.RoundToLevels(fraction, 1, component.InHandsMaxFillLevels + 1); if (closestFillSprite > 0) { diff --git a/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs b/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs index f71afa7f47..5d6d9d2120 100644 --- a/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs +++ b/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs @@ -89,6 +89,15 @@ namespace Content.Shared.Chemistry.Reagent [DataField] public SpriteSpecifier? MetamorphicSprite { get; private set; } = null; + [DataField] + public int MetamorphicMaxFillLevels { get; private set; } = 0; + + [DataField] + public string? MetamorphicFillBaseName { get; private set; } = null; + + [DataField] + public bool MetamorphicChangeColor { get; private set; } = true; + /// /// If this reagent is part of a puddle is it slippery. /// @@ -102,7 +111,7 @@ namespace Content.Shared.Chemistry.Reagent [DataField] public float Viscosity; - /// + /// /// Should this reagent work on the dead? /// [DataField] @@ -163,7 +172,7 @@ namespace Content.Shared.Chemistry.Reagent if (plantMetabolizable.ShouldLog) { var entity = args.SolutionEntity; - EntitySystem.Get().Add(LogType.ReagentEffect, plantMetabolizable.LogImpact, + entMan.System().Add(LogType.ReagentEffect, plantMetabolizable.LogImpact, $"Plant metabolism effect {plantMetabolizable.GetType().Name:effect} of reagent {ID:reagent} applied on entity {entMan.ToPrettyString(entity):entity} at {entMan.GetComponent(entity).Coordinates:coordinates}"); }