* temp * #3898 some progress on DrinkCanVisualizer * Fixed implementation * Moved drink can sprite layer definition to abstract parent * Added open drink can sprites * #3898 - fixes for drink cans' sprite field after merge + moved UpdateAppeareance from DrinkComponent to DrinkSystem * Update Content.Server/Nutrition/EntitySystems/DrinkSystem.cs * #3898 removed obsolete comment Co-authored-by: Javier Guardia Fernández <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
40
Content.Client/Nutrition/Visualizers/DrinkCanVisualizer.cs
Normal file
40
Content.Client/Nutrition/Visualizers/DrinkCanVisualizer.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Nutrition.Visualizers
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class DrinkCanVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[DataField("stateClosed")]
|
||||
private string? _stateClosed;
|
||||
|
||||
[DataField("stateOpen")]
|
||||
private string? _stateOpen;
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent<ISpriteComponent>(out var sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.TryGetData<bool>(DrinkCanStateVisual.Opened, out var opened) && opened)
|
||||
{
|
||||
sprite.LayerSetState(DrinkCanVisualLayers.Icon, $"{_stateOpen}");
|
||||
return;
|
||||
}
|
||||
|
||||
sprite.LayerSetState(DrinkCanVisualLayers.Icon, $"{_stateClosed}");
|
||||
}
|
||||
}
|
||||
|
||||
public enum DrinkCanVisualLayers : byte
|
||||
{
|
||||
Icon = 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user