diff --git a/Content.Client/Construction/FlatpackSystem.cs b/Content.Client/Construction/FlatpackSystem.cs new file mode 100644 index 0000000000..911ff1279c --- /dev/null +++ b/Content.Client/Construction/FlatpackSystem.cs @@ -0,0 +1,48 @@ +using Content.Shared.Construction; +using Content.Shared.Construction.Components; +using Robust.Client.GameObjects; +using Robust.Shared.Prototypes; + +namespace Content.Client.Construction; + +/// +public sealed class FlatpackSystem : SharedFlatpackSystem +{ + [Dependency] private readonly AppearanceSystem _appearance = default!; + + /// + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnAppearanceChange); + } + + private void OnAppearanceChange(Entity ent, ref AppearanceChangeEvent args) + { + var (_, comp) = ent; + if (!_appearance.TryGetData(ent, FlatpackVisuals.Machine, out var machineBoardId) || args.Sprite == null) + return; + + if (!PrototypeManager.TryIndex(machineBoardId, out var machineBoardPrototype)) + return; + + if (!machineBoardPrototype.TryGetComponent(out var sprite)) + return; + + Color? color = null; + foreach (var layer in sprite.AllLayers) + { + if (layer.RsiState.Name is not { } spriteState) + continue; + + if (!comp.BoardColors.TryGetValue(spriteState, out var c)) + continue; + color = c; + break; + } + + if (color != null) + args.Sprite.LayerSetColor(FlatpackVisualLayers.Overlay, color.Value); + } +} diff --git a/Content.Client/Construction/UI/FlatpackCreatorBoundUserInterface.cs b/Content.Client/Construction/UI/FlatpackCreatorBoundUserInterface.cs new file mode 100644 index 0000000000..86f1b8b83c --- /dev/null +++ b/Content.Client/Construction/UI/FlatpackCreatorBoundUserInterface.cs @@ -0,0 +1,40 @@ +using Content.Shared.Construction.Components; +using JetBrains.Annotations; + +namespace Content.Client.Construction.UI +{ + [UsedImplicitly] + public sealed class FlatpackCreatorBoundUserInterface : BoundUserInterface + { + [ViewVariables] + private FlatpackCreatorMenu? _menu; + + public FlatpackCreatorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + } + + protected override void Open() + { + base.Open(); + + _menu = new FlatpackCreatorMenu(Owner); + _menu.OnClose += Close; + + _menu.PackButtonPressed += () => + { + SendMessage(new FlatpackCreatorStartPackBuiMessage()); + }; + + _menu.OpenCentered(); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (!disposing) + return; + + _menu?.Dispose(); + } + } +} diff --git a/Content.Client/Construction/UI/FlatpackCreatorMenu.xaml b/Content.Client/Construction/UI/FlatpackCreatorMenu.xaml new file mode 100644 index 0000000000..5dffc5aa7f --- /dev/null +++ b/Content.Client/Construction/UI/FlatpackCreatorMenu.xaml @@ -0,0 +1,43 @@ + + + + + + + + +