* Engine namespace changes.
* Automated remove redundant using statements.
* Simplified Graphics namespace.
* Apparently the container system stores full type names in the map file.😞 This updates those names.
* API Changes to LocalizationManager.LoadCulture.
* Update submodule to v0.3.2
61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using Content.Shared.GameObjects.Components.MachineLinking;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Utility;
|
|
using YamlDotNet.RepresentationModel;
|
|
|
|
namespace Content.Client.GameObjects.Components.Conveyor
|
|
{
|
|
[UsedImplicitly]
|
|
public class TwoWayLeverVisualizer : AppearanceVisualizer
|
|
{
|
|
private string _stateForward;
|
|
private string _stateOff;
|
|
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 LoadData(YamlMappingNode node)
|
|
{
|
|
base.LoadData(node);
|
|
|
|
_stateForward = node.GetNode("state_forward").AsString();
|
|
_stateOff = node.GetNode("state_off").AsString();
|
|
_stateReversed = node.GetNode("state_reversed").AsString();
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|