Refactor ExtinguisherCabinet->ItemCabinet and actually maps them in, adds EntityWhitelist (#4154)
* i probably shouldnt have done this in one commit * map nonsense * fix example code * unnecessary * test * reviews * little fix for open datafield * add soul
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.GameObjects.Components
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ItemCabinetVisualizer : AppearanceVisualizer
|
||||
{
|
||||
// TODO proper layering
|
||||
[DataField("fullState", required: true)]
|
||||
private string _fullState = default!;
|
||||
|
||||
[DataField("emptyState", required: true)]
|
||||
private string _emptyState = default!;
|
||||
|
||||
[DataField("closedState", required: true)]
|
||||
private string _closedState = default!;
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (component.Owner.TryGetComponent<SpriteComponent>(out var sprite)
|
||||
&& component.TryGetData(ItemCabinetVisuals.IsOpen, out bool isOpen))
|
||||
{
|
||||
if (isOpen)
|
||||
{
|
||||
if (component.TryGetData(ItemCabinetVisuals.ContainsItem, out bool contains))
|
||||
{
|
||||
if (contains)
|
||||
{
|
||||
sprite.LayerSetState(0, _fullState);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite.LayerSetState(0, _emptyState);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite.LayerSetState(0, _closedState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user