* Non-accessed local variable * Merge cast and type checks. * StringComparison.Ordinal added for better culture support * Supposed code improvement in launcher. Remove unused code. * Update ExplosionHelper.cs Unintentional change. * Optimized Import * Add Robust.Shared.Utility import where it was deleted * Other random suggestion * Improve my comment
43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using Content.Shared.GameObjects.Components.Nutrition;
|
|
using Content.Shared.Utility;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.Interfaces.GameObjects.Components;
|
|
using Robust.Shared.Utility;
|
|
using YamlDotNet.RepresentationModel;
|
|
|
|
namespace Content.Client.GameObjects.Components.Nutrition
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed class DrinkFoodVisualizer2D : AppearanceVisualizer
|
|
{
|
|
private int _steps;
|
|
|
|
public override void LoadData(YamlMappingNode node)
|
|
{
|
|
base.LoadData(node);
|
|
|
|
_steps = node.GetNode("steps").AsInt();
|
|
}
|
|
|
|
public override void OnChangeData(AppearanceComponent component)
|
|
{
|
|
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
|
if (!component.TryGetData<int>(SharedFoodComponent.FoodVisuals.MaxUses, out var maxUses))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (component.TryGetData<int>(SharedFoodComponent.FoodVisuals.Visual, out var usesLeft))
|
|
{
|
|
var step = ContentHelpers.RoundToLevels(usesLeft, maxUses, _steps);
|
|
sprite.LayerSetState(0, $"icon-{step}");
|
|
}
|
|
else
|
|
{
|
|
sprite.LayerSetState(0, "icon-0");
|
|
}
|
|
}
|
|
}
|
|
}
|