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:
mirrorcult
2021-06-08 19:10:29 -07:00
committed by GitHub
parent 07494e4059
commit 1c7285825c
18 changed files with 795 additions and 191 deletions

View File

@@ -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);
}
}
}
}
}