Action charges refactor (#33993)
* Action charges refactor - Fixes the slight godmoding of baseactioncomponent. - Gets back 1ms of server time. * chorg * Remove FrameUpdate * Fixes * More fixes * Combine * Fixes * Updates * weh * Last fixes * weh * Fix naughty * YAML fixes * This one too * Merge conflicts * This thing * Review * Fix this as well * Icon fix * weh * Review * Review * seamless * Review
This commit is contained in:
@@ -4,6 +4,8 @@ using Content.Client.Actions.UI;
|
||||
using Content.Client.Cooldown;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Charges.Components;
|
||||
using Content.Shared.Charges.Systems;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
@@ -22,10 +24,13 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
private IEntityManager _entities;
|
||||
private SpriteSystem? _spriteSys;
|
||||
private ActionUIController? _controller;
|
||||
private SharedChargesSystem _sharedChargesSys;
|
||||
private bool _beingHovered;
|
||||
private bool _depressed;
|
||||
private bool _toggled;
|
||||
|
||||
private int _lastCharges;
|
||||
|
||||
public BoundKeyFunction? KeyBind
|
||||
{
|
||||
set
|
||||
@@ -65,6 +70,7 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
|
||||
_entities = entities;
|
||||
_spriteSys = spriteSys;
|
||||
_sharedChargesSys = _entities.System<SharedChargesSystem>();
|
||||
_controller = controller;
|
||||
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
@@ -194,14 +200,22 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
|
||||
var name = FormattedMessage.FromMarkupPermissive(Loc.GetString(metadata.EntityName));
|
||||
var decr = FormattedMessage.FromMarkupPermissive(Loc.GetString(metadata.EntityDescription));
|
||||
FormattedMessage? chargesText = null;
|
||||
|
||||
if (_action is { Charges: not null })
|
||||
// TODO: Don't touch this use an event make callers able to add their own shit for actions or I kill you.
|
||||
if (_entities.TryGetComponent(ActionId, out LimitedChargesComponent? actionCharges))
|
||||
{
|
||||
var charges = FormattedMessage.FromMarkupPermissive(Loc.GetString($"Charges: {_action.Charges.Value.ToString()}/{_action.MaxCharges.ToString()}"));
|
||||
return new ActionAlertTooltip(name, decr, charges: charges);
|
||||
var charges = _sharedChargesSys.GetCurrentCharges((ActionId.Value, actionCharges, null));
|
||||
chargesText = FormattedMessage.FromMarkupPermissive(Loc.GetString($"Charges: {charges.ToString()}/{actionCharges.MaxCharges}"));
|
||||
|
||||
if (_entities.TryGetComponent(ActionId, out AutoRechargeComponent? autoRecharge))
|
||||
{
|
||||
var chargeTimeRemaining = _sharedChargesSys.GetNextRechargeTime((ActionId.Value, actionCharges, autoRecharge));
|
||||
chargesText.AddText(Loc.GetString($"{Environment.NewLine}Time Til Recharge: {chargeTimeRemaining}"));
|
||||
}
|
||||
}
|
||||
|
||||
return new ActionAlertTooltip(name, decr);
|
||||
return new ActionAlertTooltip(name, decr, charges: chargesText);
|
||||
}
|
||||
|
||||
protected override void ControlFocusExited()
|
||||
|
||||
Reference in New Issue
Block a user