mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* PR 1
* fix an error with health bar overlay (#1292)
* Revert "Revert "Replace `ResourcePath` with `ResPath` (#15308)" (#155… (#15566)
* [1612] change ShowHealthBarsComponent's DamageContainer field to a list (#1662)
* fix build
* no crit entities from not updating
* cleanup
* namespace
* undu irrelevant changes
* undo icon change
* make health bar 1 px taller and icon 1 px shorter
* fix medibot
* fix comment
* don't show health bar ratio when in crit
* fix build
* put the crit bar back
* don't render healthbars for mobs that are in containers
* draw more boxes without the background sprite
* fine status icon for all bio mobs
* add wacky mandatory things
* attempt 2
* whoops wrong file
* cool, this works too
* move null check to top
* only 1 init
* security huds
* remove shader
* fix build after cleanup
* slight cleanup
* little more cleanup
* Remove clothing grant component system
* security HUD now shows a job icon on entities with a body
* remove sec stuff and do similar changes to split off PR + remove unused comp
* process comments
* don't return
* update to ComponentAddedOverlaySystemBase
* no cache
* colors and not rendering out of sight
* touch ups
* fix build & cleanup
* undo
* remove shader from icons
* process comments
* documentation
* fix licence
* validate prototype id
* just use args
* rename method and append in method
* type
* just fucken delete the command
* space
* undo
* remove
* don't use LocalPlayer
* re-add showhealthbars command, but working
* rename icon lists and conform health icon code to the others
* space
* undo
* update command
* oops
---------
Co-authored-by: Rane <60792108+Elijahrane@users.noreply.github.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
(cherry picked from commit eed663e8b4)
119 lines
3.3 KiB
C#
119 lines
3.3 KiB
C#
using Content.Shared.GameTicking;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.Inventory.Events;
|
|
using Robust.Client.Player;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Client.Overlays;
|
|
|
|
/// <summary>
|
|
/// This is a base system to make it easier to enable or disabling UI elements based on whether or not the player has
|
|
/// some component, either on their controlled entity on some worn piece of equipment.
|
|
/// </summary>
|
|
public abstract class EquipmentHudSystem<T> : EntitySystem where T : IComponent
|
|
{
|
|
[Dependency] private readonly IPlayerManager _player = default!;
|
|
|
|
protected bool IsActive;
|
|
protected virtual SlotFlags TargetSlots => ~SlotFlags.POCKET;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<T, ComponentStartup>(OnStartup);
|
|
SubscribeLocalEvent<T, ComponentRemove>(OnRemove);
|
|
|
|
SubscribeLocalEvent<LocalPlayerAttachedEvent>(OnPlayerAttached);
|
|
SubscribeLocalEvent<LocalPlayerDetachedEvent>(OnPlayerDetached);
|
|
|
|
SubscribeLocalEvent<T, GotEquippedEvent>(OnCompEquip);
|
|
SubscribeLocalEvent<T, GotUnequippedEvent>(OnCompUnequip);
|
|
|
|
SubscribeLocalEvent<T, RefreshEquipmentHudEvent<T>>(OnRefreshComponentHud);
|
|
SubscribeLocalEvent<T, InventoryRelayedEvent<RefreshEquipmentHudEvent<T>>>(OnRefreshEquipmentHud);
|
|
|
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
|
|
}
|
|
|
|
private void Update(RefreshEquipmentHudEvent<T> ev)
|
|
{
|
|
IsActive = true;
|
|
UpdateInternal(ev);
|
|
}
|
|
|
|
public void Deactivate()
|
|
{
|
|
if (!IsActive)
|
|
return;
|
|
|
|
IsActive = false;
|
|
DeactivateInternal();
|
|
}
|
|
|
|
protected virtual void UpdateInternal(RefreshEquipmentHudEvent<T> args) { }
|
|
|
|
protected virtual void DeactivateInternal() { }
|
|
|
|
private void OnStartup(EntityUid uid, T component, ComponentStartup args)
|
|
{
|
|
RefreshOverlay(uid);
|
|
}
|
|
|
|
private void OnRemove(EntityUid uid, T component, ComponentRemove args)
|
|
{
|
|
RefreshOverlay(uid);
|
|
}
|
|
|
|
private void OnPlayerAttached(LocalPlayerAttachedEvent args)
|
|
{
|
|
RefreshOverlay(args.Entity);
|
|
}
|
|
|
|
private void OnPlayerDetached(LocalPlayerDetachedEvent args)
|
|
{
|
|
if (_player.LocalSession?.AttachedEntity == null)
|
|
Deactivate();
|
|
}
|
|
|
|
private void OnCompEquip(EntityUid uid, T component, GotEquippedEvent args)
|
|
{
|
|
RefreshOverlay(args.Equipee);
|
|
}
|
|
|
|
private void OnCompUnequip(EntityUid uid, T component, GotUnequippedEvent args)
|
|
{
|
|
RefreshOverlay(args.Equipee);
|
|
}
|
|
|
|
private void OnRoundRestart(RoundRestartCleanupEvent args)
|
|
{
|
|
Deactivate();
|
|
}
|
|
|
|
protected virtual void OnRefreshEquipmentHud(EntityUid uid, T component, InventoryRelayedEvent<RefreshEquipmentHudEvent<T>> args)
|
|
{
|
|
OnRefreshComponentHud(uid, component, args.Args);
|
|
}
|
|
|
|
protected virtual void OnRefreshComponentHud(EntityUid uid, T component, RefreshEquipmentHudEvent<T> args)
|
|
{
|
|
args.Active = true;
|
|
args.Components.Add(component);
|
|
}
|
|
|
|
private void RefreshOverlay(EntityUid uid)
|
|
{
|
|
if (uid != _player.LocalSession?.AttachedEntity)
|
|
return;
|
|
|
|
var ev = new RefreshEquipmentHudEvent<T>(TargetSlots);
|
|
RaiseLocalEvent(uid, ev);
|
|
|
|
if (ev.Active)
|
|
Update(ev);
|
|
else
|
|
Deactivate();
|
|
}
|
|
}
|