Files
tbd-station-14/Content.Client/GameObjects/Components/Fluids/SprayVisualizer.cs
DrSmugleaf 902aa128c2 Enable nullability in Content.Client (#3257)
* Enable nullability in Content.Client

* Remove #nullable enable

* Merge fixes

* Remove Debug.Assert

* Merge fixes

* Fix build

* Fix build
2021-03-10 14:48:29 +01:00

39 lines
1.1 KiB
C#

using Content.Shared.GameObjects.Components.Fluids;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Client.GameObjects.Components.Fluids
{
[UsedImplicitly]
public class SprayVisualizer : AppearanceVisualizer
{
[DataField("safety_on_state")]
private string? _safetyOnState;
[DataField("safety_off_state")]
private string? _safetyOffState;
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (component.TryGetData<bool>(SprayVisuals.Safety, out var safety))
{
SetSafety(component, safety);
}
}
private void SetSafety(AppearanceComponent component, bool safety)
{
var sprite = component.Owner.GetComponent<ISpriteComponent>();
sprite.LayerSetState(SprayVisualLayers.Base, safety ? _safetyOnState : _safetyOffState);
}
}
public enum SprayVisualLayers : byte
{
Base
}
}