From: Kara Date: Tue, 11 Apr 2023 06:28:10 +0000 (-0700) Subject: Delete more body code (#15259) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=3bb2b2716976cf0ae594cd7cf8d86d89b5b7fa77;p=space-station-14.git Delete more body code (#15259) --- diff --git a/Content.Client/Body/UI/BodyScannerBoundUserInterface.cs b/Content.Client/Body/UI/BodyScannerBoundUserInterface.cs deleted file mode 100644 index e5aacdb31c..0000000000 --- a/Content.Client/Body/UI/BodyScannerBoundUserInterface.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using Content.Shared.Body.Components; -using JetBrains.Annotations; -using Robust.Client.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.ViewVariables; - -namespace Content.Client.Body.UI -{ - [UsedImplicitly] - public sealed class BodyScannerBoundUserInterface : BoundUserInterface - { - [ViewVariables] - private BodyScannerDisplay? _display; - - public BodyScannerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) { } - - protected override void Open() - { - base.Open(); - _display = new BodyScannerDisplay(this); - _display.OnClose += Close; - _display.OpenCentered(); - } - - protected override void UpdateState(BoundUserInterfaceState state) - { - base.UpdateState(state); - - if (state is not BodyScannerUIState scannerState) - { - return; - } - - var entMan = IoCManager.Resolve(); - - if (!entMan.EntityExists(scannerState.Uid)) - { - throw new ArgumentException($"Received an invalid entity with id {scannerState.Uid} for body scanner with id {Owner.Owner} at {entMan.GetComponent(Owner.Owner).MapPosition}"); - } - - _display?.UpdateDisplay(scannerState.Uid); - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - if (disposing) - { - _display?.Dispose(); - } - } - } -} diff --git a/Content.Client/Body/UI/BodyScannerDisplay.cs b/Content.Client/Body/UI/BodyScannerDisplay.cs deleted file mode 100644 index 75c7a67b6d..0000000000 --- a/Content.Client/Body/UI/BodyScannerDisplay.cs +++ /dev/null @@ -1,186 +0,0 @@ -using System.Linq; -using Content.Shared.Body.Components; -using Content.Shared.Body.Part; -using Content.Shared.Body.Systems; -using Content.Shared.Damage; -using Robust.Client.UserInterface.Controls; -using Robust.Client.UserInterface.CustomControls; -using static Robust.Client.UserInterface.Controls.BoxContainer; -using static Robust.Client.UserInterface.Controls.ItemList; - -namespace Content.Client.Body.UI -{ - public sealed class BodyScannerDisplay : DefaultWindow - { - private EntityUid? _currentEntity; - private BodyPartComponent? _currentBodyPart; - private readonly Dictionary _bodyPartsList = new(); - - public BodyScannerDisplay(BodyScannerBoundUserInterface owner) - { - IoCManager.InjectDependencies(this); - Owner = owner; - Title = Loc.GetString("body-scanner-display-title"); - - var hSplit = new BoxContainer - { - Orientation = LayoutOrientation.Horizontal, - Children = - { - // Left half - new ScrollContainer - { - HorizontalExpand = true, - Children = - { - (BodyPartList = new ItemList()) - } - }, - // Right half - new BoxContainer - { - Orientation = LayoutOrientation.Vertical, - HorizontalExpand = true, - Children = - { - // Top half of the right half - new BoxContainer - { - Orientation = LayoutOrientation.Vertical, - VerticalExpand = true, - Children = - { - (BodyPartLabel = new Label()), - new BoxContainer - { - Orientation = LayoutOrientation.Horizontal, - Children = - { - new Label - { - Text = $"{Loc.GetString("body-scanner-display-health-label")} " - }, - (BodyPartHealth = new Label()) - } - }, - new ScrollContainer - { - VerticalExpand = true, - Children = - { - (MechanismList = new ItemList()) - } - } - } - }, - // Bottom half of the right half - (MechanismInfoLabel = new RichTextLabel - { - VerticalExpand = true - }) - } - } - } - }; - - Contents.AddChild(hSplit); - - BodyPartList.OnItemSelected += BodyPartOnItemSelected; - MechanismList.OnItemSelected += MechanismOnItemSelected; - MinSize = SetSize = (800, 600); - } - - public BodyScannerBoundUserInterface Owner { get; } - - private ItemList BodyPartList { get; } - - private Label BodyPartLabel { get; } - - private Label BodyPartHealth { get; } - - private ItemList MechanismList { get; } - - private RichTextLabel MechanismInfoLabel { get; } - - public void UpdateDisplay(EntityUid entity) - { - _currentEntity = entity; - BodyPartList.Clear(); - _bodyPartsList.Clear(); - - var bodySystem = IoCManager.Resolve().GetEntitySystem(); - var factory = IoCManager.Resolve(); - var i = 0; - foreach (var part in bodySystem.GetBodyChildren(_currentEntity)) - { - _bodyPartsList[i++] = part.Component.ParentSlot!; - BodyPartList.AddItem(Loc.GetString(factory.GetComponentName(part.Component.GetType()))); - } - } - - public void BodyPartOnItemSelected(ItemListSelectedEventArgs args) - { - var entMan = IoCManager.Resolve(); - - _currentBodyPart = entMan.GetComponentOrNull(_bodyPartsList[args.ItemIndex].Child); - - if (_currentBodyPart is {ParentSlot.Id: var slotId} part) - { - UpdateBodyPartBox(part, slotId); - } - } - - private void UpdateBodyPartBox(BodyPartComponent part, string slotName) - { - var entMan = IoCManager.Resolve(); - BodyPartLabel.Text = - $"{Loc.GetString(slotName)}: {Loc.GetString(entMan.GetComponent(part.Owner).EntityName)}"; - - // TODO BODY Part damage - if (entMan.TryGetComponent(part.Owner, out DamageableComponent? damageable)) - { - BodyPartHealth.Text = Loc.GetString("body-scanner-display-body-part-damage-text", - ("damage", damageable.TotalDamage)); - } - - MechanismList.Clear(); - - var bodySystem = entMan.System(); - foreach (var organ in bodySystem.GetPartOrgans(part.Owner, part)) - { - var organName = entMan.GetComponent(organ.Id).EntityName; - MechanismList.AddItem(organName); - } - } - - // TODO BODY Guaranteed this is going to crash when a part's mechanisms change. This part is left as an exercise for the reader. - public void MechanismOnItemSelected(ItemListSelectedEventArgs args) - { - if (_currentBodyPart == null) - { - UpdateMechanismBox(null); - return; - } - - var bodySystem = IoCManager.Resolve().System(); - var organ = bodySystem.GetPartOrgans(_currentBodyPart.Owner, _currentBodyPart).ElementAt(args.ItemIndex); - UpdateMechanismBox(organ.Id); - } - - private void UpdateMechanismBox(EntityUid? organ) - { - // TODO BODY Improve UI - if (organ == null) - { - MechanismInfoLabel.SetMessage(""); - return; - } - - // TODO BODY Mechanism description - var entMan = IoCManager.Resolve(); - var organName = entMan.GetComponent(organ.Value).EntityName; - var message = Loc.GetString($"{organName}"); - MechanismInfoLabel.SetMessage(message); - } - } -} diff --git a/Content.Server/Body/Components/BodyScannerComponent.cs b/Content.Server/Body/Components/BodyScannerComponent.cs deleted file mode 100644 index 2ec8e7aeb2..0000000000 --- a/Content.Server/Body/Components/BodyScannerComponent.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Content.Server.UserInterface; -using Content.Shared.Body.Components; -using Robust.Server.GameObjects; - -namespace Content.Server.Body.Components -{ - [RegisterComponent] - [ComponentReference(typeof(SharedBodyScannerComponent))] - public sealed class BodyScannerComponent : SharedBodyScannerComponent - { - [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(BodyScannerUiKey.Key); - protected override void Initialize() - { - base.Initialize(); - - Owner.EnsureComponentWarn(); - - if (UserInterface != null) - { - UserInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage; - } - } - - private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage serverMsg) { } - - /// - /// Copy BodyTemplate and BodyPart data into a common data class that the client can read. - /// - private BodyScannerUIState InterfaceState(BodyComponent body) - { - return new(body.Owner); - } - } -} diff --git a/Content.Shared/Body/Components/SharedBodyScannerComponent.cs b/Content.Shared/Body/Components/SharedBodyScannerComponent.cs deleted file mode 100644 index 0549e7a9c1..0000000000 --- a/Content.Shared/Body/Components/SharedBodyScannerComponent.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Robust.Shared.Serialization; - -namespace Content.Shared.Body.Components -{ - public abstract class SharedBodyScannerComponent : Component - { - } - - [Serializable, NetSerializable] - public enum BodyScannerUiKey - { - Key - } - - [Serializable, NetSerializable] - public sealed class BodyScannerUIState : BoundUserInterfaceState - { - public readonly EntityUid Uid; - - public BodyScannerUIState(EntityUid uid) - { - Uid = uid; - } - } -} diff --git a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml index 2d8481b75a..8bbf94c430 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml @@ -469,13 +469,6 @@ name: body scanner computer description: A body scanner. components: - - type: BodyScanner - - type: ActivatableUI - key: enum.BodyScannerUiKey.Key - - type: UserInterface - interfaces: - - key: enum.BodyScannerUiKey.Key - type: BodyScannerBoundUserInterface - type: ApcPowerReceiver powerLoad: 500 - type: Computer