Re-organize all projects (#4166)
This commit is contained in:
55
Content.Client/Conveyor/Visualizers/TwoWayLeverVisualizer.cs
Normal file
55
Content.Client/Conveyor/Visualizers/TwoWayLeverVisualizer.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Content.Shared.MachineLinking;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Conveyor.Visualizers
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class TwoWayLeverVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[DataField("state_forward")]
|
||||
private string? _stateForward;
|
||||
|
||||
[DataField("state_off")]
|
||||
private string? _stateOff;
|
||||
|
||||
[DataField("state_reversed")]
|
||||
private string? _stateReversed;
|
||||
|
||||
private void ChangeState(AppearanceComponent appearance)
|
||||
{
|
||||
if (!appearance.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
appearance.TryGetData(TwoWayLeverVisuals.State, out TwoWayLeverSignal state);
|
||||
|
||||
var texture = state switch
|
||||
{
|
||||
TwoWayLeverSignal.Middle => _stateOff,
|
||||
TwoWayLeverSignal.Right => _stateForward,
|
||||
TwoWayLeverSignal.Left => _stateReversed,
|
||||
_ => _stateOff
|
||||
};
|
||||
|
||||
sprite.LayerSetState(0, texture);
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
var appearance = entity.EnsureComponent<AppearanceComponent>();
|
||||
ChangeState(appearance);
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
ChangeState(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user