mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 21:48:58 +03:00
Removed all unused variables i could find, built and tested on a simple upstart and clicking trough most systems. Change Loc references to localization. <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p> "using Robust.Shared.Prototypes;" to "" "[dependency] private readonly ISpriteComponent" to "" </p> </details> --- No CL this isn't player facing. --------- Co-authored-by: ilmenwe <no@mail.com>
81 lines
2.6 KiB
C#
81 lines
2.6 KiB
C#
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!;
|
|
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);
|
|
}
|
|
}
|