Show health status on the HUD, shoddily.
This commit is contained in:
@@ -6,19 +6,20 @@ using Robust.Client.GameObjects;
|
|||||||
using Robust.Client.Interfaces.Graphics.Overlays;
|
using Robust.Client.Interfaces.Graphics.Overlays;
|
||||||
using Robust.Client.Interfaces.ResourceManagement;
|
using Robust.Client.Interfaces.ResourceManagement;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
using Robust.Client.ResourceManagement;
|
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Interfaces.Network;
|
using Robust.Shared.Interfaces.Network;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Log;
|
|
||||||
using Robust.Shared.Utility;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Content.Client.UserInterface;
|
||||||
using Content.Client.Utility;
|
using Content.Client.Utility;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Graphics.Overlays;
|
using Robust.Client.Graphics.Overlays;
|
||||||
|
using Robust.Client.Interfaces.UserInterface;
|
||||||
|
using Robust.Shared.GameObjects.Components.Renderable;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects
|
namespace Content.Client.GameObjects
|
||||||
{
|
{
|
||||||
@@ -27,6 +28,8 @@ namespace Content.Client.GameObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SpeciesUI : SharedSpeciesComponent, ICharacterUI
|
public class SpeciesUI : SharedSpeciesComponent, ICharacterUI
|
||||||
{
|
{
|
||||||
|
private StatusEffectsUI _ui;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds the godot control for the species window
|
/// Holds the godot control for the species window
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -37,10 +40,12 @@ namespace Content.Client.GameObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private ScreenEffects _currentEffect = ScreenEffects.None;
|
private ScreenEffects _currentEffect = ScreenEffects.None;
|
||||||
|
|
||||||
// Required dependencies
|
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
|
// Required dependencies
|
||||||
[Dependency] private readonly IOverlayManager _overlayManager;
|
[Dependency] private readonly IOverlayManager _overlayManager;
|
||||||
[Dependency] private readonly IPlayerManager _playerManager;
|
[Dependency] private readonly IPlayerManager _playerManager;
|
||||||
|
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
|
||||||
|
[Dependency] private readonly IResourceCache _resourceCache;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
//Relevant interface implementation for the character UI controller
|
//Relevant interface implementation for the character UI controller
|
||||||
@@ -69,6 +74,7 @@ namespace Content.Client.GameObjects
|
|||||||
base.OnAdd();
|
base.OnAdd();
|
||||||
|
|
||||||
_window = new SpeciesWindow();
|
_window = new SpeciesWindow();
|
||||||
|
_ui = new StatusEffectsUI();
|
||||||
|
|
||||||
EffectsDictionary = new Dictionary<ScreenEffects, Overlay>()
|
EffectsDictionary = new Dictionary<ScreenEffects, Overlay>()
|
||||||
{
|
{
|
||||||
@@ -89,19 +95,28 @@ namespace Content.Client.GameObjects
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PlayerAttachedMsg _:
|
case PlayerAttachedMsg _:
|
||||||
|
_ui.Parent?.RemoveChild(_ui);
|
||||||
|
|
||||||
|
_userInterfaceManager.StateRoot.AddChild(_ui);
|
||||||
ApplyOverlay();
|
ApplyOverlay();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PlayerDetachedMsg _:
|
case PlayerDetachedMsg _:
|
||||||
|
_ui.Parent?.RemoveChild(_ui);
|
||||||
RemoveOverlay();
|
RemoveOverlay();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeHudIcon(HudStateChange changemessage)
|
private void ChangeHudIcon(HudStateChange changeMessage)
|
||||||
{
|
{
|
||||||
_window.SetIcon(changemessage);
|
var path = SharedSpriteComponent.TextureRoot / changeMessage.StateSprite;
|
||||||
SetOverlay(changemessage);
|
var texture = _resourceCache.GetTexture(path);
|
||||||
|
|
||||||
|
_window.SetIcon(texture);
|
||||||
|
_ui.SetHealthIcon(texture);
|
||||||
|
|
||||||
|
SetOverlay(changeMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetOverlay(HudStateChange message)
|
private void SetOverlay(HudStateChange message)
|
||||||
@@ -117,8 +132,8 @@ namespace Content.Client.GameObjects
|
|||||||
{
|
{
|
||||||
if (_currentEffect != ScreenEffects.None)
|
if (_currentEffect != ScreenEffects.None)
|
||||||
{
|
{
|
||||||
var appliedeffect = EffectsDictionary[_currentEffect];
|
var appliedEffect = EffectsDictionary[_currentEffect];
|
||||||
_overlayManager.RemoveOverlay(appliedeffect.ID);
|
_overlayManager.RemoveOverlay(appliedEffect.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentEffect = ScreenEffects.None;
|
_currentEffect = ScreenEffects.None;
|
||||||
@@ -147,15 +162,9 @@ namespace Content.Client.GameObjects
|
|||||||
Texture = IoCManager.Resolve<IResourceCache>().GetTexture("/Textures/Mob/UI/Human/human0.png");
|
Texture = IoCManager.Resolve<IResourceCache>().GetTexture("/Textures/Mob/UI/Human/human0.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetIcon(HudStateChange changeMessage)
|
public void SetIcon(Texture texture)
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IResourceCache>().TryGetResource<TextureResource>(new ResourcePath("/Textures") / changeMessage.StateSprite, out var newtexture))
|
Texture = texture;
|
||||||
{
|
|
||||||
Logger.Info("The Species Health Sprite {0} Does Not Exist", new ResourcePath("/Textures") / changeMessage.StateSprite);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Texture = newtexture;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
38
Content.Client/UserInterface/StatusEffectsUI.cs
Normal file
38
Content.Client/UserInterface/StatusEffectsUI.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using Content.Client.Utility;
|
||||||
|
using Robust.Client.Graphics;
|
||||||
|
using Robust.Client.Interfaces.ResourceManagement;
|
||||||
|
using Robust.Client.UserInterface;
|
||||||
|
using Robust.Client.UserInterface.Controls;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
|
namespace Content.Client.UserInterface
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The status effects display on the right side of the screen.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class StatusEffectsUI : Control
|
||||||
|
{
|
||||||
|
private readonly VBoxContainer _vBox;
|
||||||
|
|
||||||
|
private TextureRect _healthStatusRect;
|
||||||
|
|
||||||
|
public StatusEffectsUI()
|
||||||
|
{
|
||||||
|
_vBox = new VBoxContainer {GrowHorizontal = GrowDirection.Begin};
|
||||||
|
AddChild(_vBox);
|
||||||
|
|
||||||
|
_vBox.AddChild(_healthStatusRect = new TextureRect
|
||||||
|
{
|
||||||
|
Texture = IoCManager.Resolve<IResourceCache>().GetTexture("/Textures/Mob/UI/Human/human0.png")
|
||||||
|
});
|
||||||
|
|
||||||
|
SetAnchorAndMarginPreset(LayoutPreset.TopRight);
|
||||||
|
MarginTop = 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetHealthIcon(Texture texture)
|
||||||
|
{
|
||||||
|
_healthStatusRect.Texture = texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user