Add envelopes (#30298)

* Add envelopes

* oops

* Remove unused loc string

* comments and fixes
This commit is contained in:
themias
2024-07-29 21:49:05 -04:00
committed by GitHub
parent b16de9bb35
commit 85e36266fa
12 changed files with 316 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using Content.Shared.Paper;
using Robust.Client.GameObjects;
namespace Content.Client.Paper;
public sealed class EnvelopeSystem : VisualizerSystem<EnvelopeComponent>
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<EnvelopeComponent, AfterAutoHandleStateEvent>(OnAfterAutoHandleState);
}
private void OnAfterAutoHandleState(Entity<EnvelopeComponent> ent, ref AfterAutoHandleStateEvent args)
{
UpdateAppearance(ent);
}
private void UpdateAppearance(Entity<EnvelopeComponent> ent, SpriteComponent? sprite = null)
{
if (!Resolve(ent.Owner, ref sprite))
return;
sprite.LayerSetVisible(EnvelopeVisualLayers.Open, ent.Comp.State == EnvelopeComponent.EnvelopeState.Open);
sprite.LayerSetVisible(EnvelopeVisualLayers.Sealed, ent.Comp.State == EnvelopeComponent.EnvelopeState.Sealed);
sprite.LayerSetVisible(EnvelopeVisualLayers.Torn, ent.Comp.State == EnvelopeComponent.EnvelopeState.Torn);
}
public enum EnvelopeVisualLayers : byte
{
Open,
Sealed,
Torn
}
}