@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.GameObjects.Components.Animations;
|
||||
using Robust.Shared.Animations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.GameObjects.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class EmergencyLightComponent : Component
|
||||
{
|
||||
public override string Name => "EmergencyLight";
|
||||
|
||||
protected override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
var animation = new Animation
|
||||
{
|
||||
Length = TimeSpan.FromSeconds(4),
|
||||
AnimationTracks =
|
||||
{
|
||||
new AnimationTrackComponentProperty
|
||||
{
|
||||
ComponentType = typeof(PointLightComponent),
|
||||
InterpolationMode = AnimationInterpolationMode.Linear,
|
||||
Property = nameof(PointLightComponent.Rotation),
|
||||
KeyFrames =
|
||||
{
|
||||
new AnimationTrackProperty.KeyFrame(Angle.Zero, 0),
|
||||
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(1080), 4)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var playerComponent = Owner.EnsureComponent<AnimationPlayerComponent>();
|
||||
playerComponent.Play(animation, "emergency");
|
||||
|
||||
playerComponent.AnimationCompleted += s => playerComponent.Play(animation, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Shared.GameObjects.Components.Storage;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
@@ -8,6 +9,7 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
{
|
||||
public sealed class StorageVisualizer2D : AppearanceVisualizer
|
||||
{
|
||||
private string _stateBase;
|
||||
private string _stateOpen;
|
||||
private string _stateClosed;
|
||||
|
||||
@@ -15,7 +17,12 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
{
|
||||
base.LoadData(node);
|
||||
|
||||
if (node.TryGetNode("state_open", out var child))
|
||||
if (node.TryGetNode("state", out var child))
|
||||
{
|
||||
_stateBase = child.AsString();
|
||||
}
|
||||
|
||||
if (node.TryGetNode("state_open", out child))
|
||||
{
|
||||
_stateOpen = child.AsString();
|
||||
}
|
||||
@@ -26,6 +33,19 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
}
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
{
|
||||
if (!entity.TryGetComponent(out ISpriteComponent sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_stateBase != null)
|
||||
{
|
||||
sprite.LayerSetState(0, _stateBase);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
@@ -36,7 +56,9 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
}
|
||||
|
||||
component.TryGetData(StorageVisuals.Open, out bool open);
|
||||
sprite.LayerSetState(StorageVisualLayers.Door, open ? _stateOpen : _stateClosed);
|
||||
sprite.LayerSetState(StorageVisualLayers.Door, open
|
||||
? _stateOpen ?? $"{_stateBase}_open"
|
||||
: _stateClosed ?? $"{_stateBase}_door");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user