diff --git a/Content.Client/Backmen/Disease/DiseaseMachineSystem.cs b/Content.Client/Backmen/Disease/DiseaseMachineSystem.cs new file mode 100644 index 00000000000..f42c587dd50 --- /dev/null +++ b/Content.Client/Backmen/Disease/DiseaseMachineSystem.cs @@ -0,0 +1,26 @@ +using Content.Client.Medical; +using Content.Shared.Backmen.Disease; +using Robust.Client.GameObjects; + +namespace Content.Client.Backmen.Disease; + +/// +/// Controls client-side visuals for the +/// disease machines. +/// +public sealed class DiseaseMachineSystem : VisualizerSystem +{ + protected override void OnAppearanceChange(EntityUid uid, DiseaseMachineVisualsComponent component, ref AppearanceChangeEvent args) + { + if (args.Sprite == null) + return; + + if (AppearanceSystem.TryGetData(uid, DiseaseMachineVisuals.IsOn, out var isOn, args.Component) + && AppearanceSystem.TryGetData(uid, DiseaseMachineVisuals.IsRunning, out var isRunning, args.Component)) + { + var state = isRunning ? component.RunningState : component.IdleState; + args.Sprite.LayerSetVisible(DiseaseMachineVisualLayers.IsOn, isOn); + args.Sprite.LayerSetState(DiseaseMachineVisualLayers.IsRunning, state); + } + } +} diff --git a/Content.Client/Backmen/Disease/DiseaseMachineVisualsComponent.cs b/Content.Client/Backmen/Disease/DiseaseMachineVisualsComponent.cs new file mode 100644 index 00000000000..a7624d202e0 --- /dev/null +++ b/Content.Client/Backmen/Disease/DiseaseMachineVisualsComponent.cs @@ -0,0 +1,15 @@ +namespace Content.Client.Backmen.Disease; + +/// +/// Holds the idle and running state for machines to control +/// playing animtions on the client. +/// +[RegisterComponent] +public sealed partial class DiseaseMachineVisualsComponent : Component +{ + [DataField("idleState", required: true)] + public string IdleState = default!; + + [DataField("runningState", required: true)] + public string RunningState = default!; +} diff --git a/Content.Client/Backmen/Disease/UI/VaccineMachineBoundUserInterface.cs b/Content.Client/Backmen/Disease/UI/VaccineMachineBoundUserInterface.cs new file mode 100644 index 00000000000..9cc96a24a3f --- /dev/null +++ b/Content.Client/Backmen/Disease/UI/VaccineMachineBoundUserInterface.cs @@ -0,0 +1,67 @@ +using Content.Shared.Backmen.Disease; +using JetBrains.Annotations; + +namespace Content.Client.Backmen.Disease.UI; + +[UsedImplicitly] +public sealed class VaccineMachineBoundUserInterface : BoundUserInterface +{ + private VaccineMachineMenu? _machineMenu; + + public VaccineMachineBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + } + + protected override void Open() + { + base.Open(); + + _machineMenu = new VaccineMachineMenu(this); + + _machineMenu.OnClose += Close; + + _machineMenu.OnServerSelectionButtonPressed += _ => + { + SendMessage(new VaccinatorServerSelectionMessage()); + }; + + _machineMenu.OpenCentered(); + _machineMenu?.PopulateBiomass(Owner); + } + + public void CreateVaccineMessage(string disease, int amount) + { + SendMessage(new CreateVaccineMessage(disease, amount)); + } + + public void RequestSync() + { + SendMessage(new VaccinatorSyncRequestMessage()); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + switch (state) + { + case VaccineMachineUpdateState msg: + _machineMenu?.UpdateLocked(msg.Locked); + _machineMenu?.PopulateDiseases(msg.Diseases); + _machineMenu?.PopulateBiomass(Owner); + _machineMenu?.UpdateCost(msg.BiomassCost); + _machineMenu?.UpdateServerConnection(msg.HasServer); + break; + } + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + if (!disposing) + return; + + _machineMenu?.Dispose(); + } +} diff --git a/Content.Client/Backmen/Disease/UI/VaccineMachineMenu.xaml b/Content.Client/Backmen/Disease/UI/VaccineMachineMenu.xaml new file mode 100644 index 00000000000..6d0653912a0 --- /dev/null +++ b/Content.Client/Backmen/Disease/UI/VaccineMachineMenu.xaml @@ -0,0 +1,50 @@ + + + + + + +