Files
tbd-station-14/Content.Client/GameObjects/Components/Conveyor/ConveyorVisualizer.cs
Paul Ritter 501156f84c makes conveyors to use machine linking & refactors machine linking a bit (#2464)
* makes conveyors to use machine linking & refactors machine linking a bit

* nullable errors

* temp commit, starting work on construction

* working recipies & graphs

* fixes crash

* makes items gravitate towards the center when on a conveyor

* makes conveyors take bool signal too

* ignores components clientside

* default arm
entitymanager
maxtransmitters
unsubscribe methods

* twowayLEVER

* _

* componentreference
struct

* yaml run
leverDefinitelyNotCopiedFromGirderNoNoNo dies today :(

* nullable

* no divide by 0

* making sloth happy

* space gone - happy?

* final fix

* yes

* adds item to lathe

* conveyor item -> conveyor assembly

* technology

* reviews ADRESSED

* Update Content.Shared/GameObjects/Verbs/VerbUtility.cs

Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2020-11-19 00:53:46 +11:00

64 lines
1.9 KiB
C#

using System;
using Content.Shared.GameObjects.Components.Conveyor;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Conveyor
{
[UsedImplicitly]
public class ConveyorVisualizer : AppearanceVisualizer
{
private string _stateRunning;
private string _stateStopped;
private string _stateReversed;
private void ChangeState(AppearanceComponent appearance)
{
if (!appearance.Owner.TryGetComponent(out ISpriteComponent sprite))
{
return;
}
appearance.TryGetData(ConveyorVisuals.State, out ConveyorState state);
var texture = state switch
{
ConveyorState.Off => _stateStopped,
ConveyorState.Forward => _stateRunning,
ConveyorState.Reversed => _stateReversed,
_ => throw new ArgumentOutOfRangeException()
};
sprite.LayerSetState(0, texture);
}
public override void LoadData(YamlMappingNode node)
{
base.LoadData(node);
_stateRunning = node.GetNode("state_running").AsString();
_stateStopped = node.GetNode("state_stopped").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);
}
}
}