Lathe Refactor and ECS (#11201)
* lathe and material storage refactor * materialStorage ECS it kinda sus tho * beginning the lathe shitcode dive * couple lathe visuals and lathe system * lathe changes and such * dynamic lathe databases * rewrote internal logic on to ui * da newI * material display clientside * misc ui changes * component state handling and various other things * moar * Update Content.Shared/Lathe/LatheComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * first volley of sloth review * more fixes * losin' my mind * all da changes * test fix and other review Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -2,45 +2,62 @@ using Robust.Client.GameObjects;
|
||||
using Content.Shared.Lathe;
|
||||
using Content.Shared.Power;
|
||||
using Content.Client.Power;
|
||||
using Content.Shared.Research.Prototypes;
|
||||
|
||||
namespace Content.Client.Lathe
|
||||
namespace Content.Client.Lathe;
|
||||
|
||||
public sealed class LatheSystem : SharedLatheSystem
|
||||
{
|
||||
public sealed class LatheSystem : VisualizerSystem<LatheVisualsComponent>
|
||||
public override void Initialize()
|
||||
{
|
||||
protected override void OnAppearanceChange(EntityUid uid, LatheVisualsComponent component, ref AppearanceChangeEvent args)
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<LatheComponent, AppearanceChangeEvent>(OnAppearanceChange);
|
||||
}
|
||||
|
||||
private void OnAppearanceChange(EntityUid uid, LatheComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
|
||||
if (args.Component.TryGetData(PowerDeviceVisuals.Powered, out bool powered) &&
|
||||
args.Sprite.LayerMapTryGet(PowerDeviceVisualLayers.Powered, out _))
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
args.Sprite.LayerSetVisible(PowerDeviceVisualLayers.Powered, powered);
|
||||
}
|
||||
|
||||
if (args.Component.TryGetData(PowerDeviceVisuals.Powered, out bool powered) &&
|
||||
args.Sprite.LayerMapTryGet(PowerDeviceVisualLayers.Powered, out _))
|
||||
// Lathe specific stuff
|
||||
if (args.Component.TryGetData(LatheVisuals.IsRunning, out bool isRunning))
|
||||
{
|
||||
var state = isRunning ? component.RunningState : component.IdleState;
|
||||
args.Sprite.LayerSetAnimationTime(LatheVisualLayers.IsRunning, 0f);
|
||||
args.Sprite.LayerSetState(LatheVisualLayers.IsRunning, state);
|
||||
}
|
||||
|
||||
if (args.Component.TryGetData(LatheVisuals.IsInserting, out bool isInserting)
|
||||
&& args.Sprite.LayerMapTryGet(LatheVisualLayers.IsInserting, out var isInsertingLayer))
|
||||
{
|
||||
if (args.Component.TryGetData(LatheVisuals.InsertingColor, out Color color)
|
||||
&& !component.IgnoreColor)
|
||||
{
|
||||
args.Sprite.LayerSetVisible(PowerDeviceVisualLayers.Powered, powered);
|
||||
args.Sprite.LayerSetColor(isInsertingLayer, color);
|
||||
}
|
||||
|
||||
// Lathe specific stuff
|
||||
if (args.Component.TryGetData(LatheVisuals.IsRunning, out bool isRunning))
|
||||
{
|
||||
var state = isRunning ? component.RunningState : component.IdleState;
|
||||
args.Sprite.LayerSetAnimationTime(LatheVisualLayers.IsRunning, 0f);
|
||||
args.Sprite.LayerSetState(LatheVisualLayers.IsRunning, state);
|
||||
}
|
||||
|
||||
if (args.Component.TryGetData(LatheVisuals.IsInserting, out bool isInserting)
|
||||
&& args.Sprite.LayerMapTryGet(LatheVisualLayers.IsInserting, out var isInsertingLayer))
|
||||
{
|
||||
if (args.Component.TryGetData(LatheVisuals.InsertingColor, out Color color)
|
||||
&& !component.IgnoreColor)
|
||||
{
|
||||
args.Sprite.LayerSetColor(isInsertingLayer, color);
|
||||
}
|
||||
|
||||
args.Sprite.LayerSetAnimationTime(isInsertingLayer, 0f);
|
||||
args.Sprite.LayerSetVisible(isInsertingLayer, isInserting);
|
||||
}
|
||||
args.Sprite.LayerSetAnimationTime(isInsertingLayer, 0f);
|
||||
args.Sprite.LayerSetVisible(isInsertingLayer, isInserting);
|
||||
}
|
||||
}
|
||||
|
||||
///<remarks>
|
||||
/// Whether or not a recipe is available is not really visible to the client,
|
||||
/// so it just defaults to true.
|
||||
///</remarks>
|
||||
protected override bool HasRecipe(EntityUid uid, LatheRecipePrototype recipe, LatheComponent component)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public enum LatheVisualLayers : byte
|
||||
{
|
||||
IsRunning,
|
||||
|
||||
Reference in New Issue
Block a user