| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- // SPDX-FileCopyrightText: 2024 Piras314 <p1r4s@proton.me>
- // SPDX-FileCopyrightText: 2024 gluesniffler <159397573+gluesniffler@users.noreply.github.com>
- // SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
- //
- // SPDX-License-Identifier: AGPL-3.0-or-later
- using Content.Client.Gameplay;
- using Content.Client._Shitmed.UserInterface.Systems.PartStatus.Widgets;
- using Content.Shared._Shitmed.Targeting;
- using Content.Client._Shitmed.Targeting;
- using Robust.Client.GameObjects;
- using Robust.Client.UserInterface.Controllers;
- using Robust.Shared.Utility;
- using Robust.Client.Graphics;
- namespace Content.Client._Shitmed.UserInterface.Systems.PartStatus;
- public sealed class PartStatusUIController : UIController, IOnStateEntered<GameplayState>, IOnSystemChanged<TargetingSystem>
- {
- [Dependency] private readonly IEntityManager _entManager = default!;
- [Dependency] private readonly IEntityNetworkManager _net = default!;
- private SpriteSystem _spriteSystem = default!;
- private TargetingComponent? _targetingComponent;
- private PartStatusControl? PartStatusControl => UIManager.GetActiveUIWidgetOrNull<PartStatusControl>();
- public void OnSystemLoaded(TargetingSystem system)
- {
- system.PartStatusStartup += AddPartStatusControl;
- system.PartStatusShutdown += RemovePartStatusControl;
- system.PartStatusUpdate += UpdatePartStatusControl;
- }
- public void OnSystemUnloaded(TargetingSystem system)
- {
- system.PartStatusStartup -= AddPartStatusControl;
- system.PartStatusShutdown -= RemovePartStatusControl;
- system.PartStatusUpdate -= UpdatePartStatusControl;
- }
- public void OnStateEntered(GameplayState state)
- {
- if (PartStatusControl != null)
- {
- PartStatusControl.SetVisible(_targetingComponent != null);
- if (_targetingComponent != null)
- PartStatusControl.SetTextures(_targetingComponent.BodyStatus);
- }
- }
- public void AddPartStatusControl(TargetingComponent component)
- {
- _targetingComponent = component;
- if (PartStatusControl != null)
- {
- PartStatusControl.SetVisible(_targetingComponent != null);
- if (_targetingComponent != null)
- PartStatusControl.SetTextures(_targetingComponent.BodyStatus);
- }
- }
- public void RemovePartStatusControl()
- {
- if (PartStatusControl != null)
- PartStatusControl.SetVisible(false);
- _targetingComponent = null;
- }
- public void UpdatePartStatusControl(TargetingComponent component)
- {
- if (PartStatusControl != null && _targetingComponent != null)
- PartStatusControl.SetTextures(_targetingComponent.BodyStatus);
- }
- public Texture GetTexture(SpriteSpecifier specifier)
- {
- if (_spriteSystem == null)
- _spriteSystem = _entManager.System<SpriteSystem>();
- return _spriteSystem.Frame0(specifier);
- }
- }
|