diff --git a/Content.Client/GameObjects/Components/HandheldLightComponent.cs b/Content.Client/GameObjects/Components/HandheldLightComponent.cs index 2b2d43b1a7..fb5be31391 100644 --- a/Content.Client/GameObjects/Components/HandheldLightComponent.cs +++ b/Content.Client/GameObjects/Components/HandheldLightComponent.cs @@ -13,7 +13,10 @@ namespace Content.Client.GameObjects.Components [RegisterComponent] public sealed class HandheldLightComponent : SharedHandheldLightComponent, IItemStatus { + private bool _hasCell; + [ViewVariables] public float? Charge { get; private set; } + [ViewVariables] protected override bool HasCell => _hasCell; public Control MakeControl() { @@ -26,6 +29,7 @@ namespace Content.Client.GameObjects.Components return; Charge = cast.Charge; + _hasCell = cast.HasCell; } private sealed class StatusControl : Control diff --git a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs index aa9e44ee83..b6de8165ab 100644 --- a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs @@ -53,6 +53,8 @@ namespace Content.Server.GameObjects.Components.Interactable [ViewVariables] public bool Activated { get; private set; } + [ViewVariables] protected override bool HasCell => Cell != null; + async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { if (!eventArgs.Using.HasComponent()) return false; @@ -211,6 +213,8 @@ namespace Content.Server.GameObjects.Components.Interactable return; } + Dirty(); + if (!user.TryGetComponent(out HandsComponent? hands)) { return; @@ -229,17 +233,17 @@ namespace Content.Server.GameObjects.Components.Interactable { if (Cell == null) { - return new HandheldLightComponentState(null); + return new HandheldLightComponentState(null, false); } if (Wattage > Cell.CurrentCharge) { // Practically zero. // This is so the item status works correctly. - return new HandheldLightComponentState(0); + return new HandheldLightComponentState(0, HasCell); } - return new HandheldLightComponentState(Cell.CurrentCharge / Cell.MaxCharge); + return new HandheldLightComponentState(Cell.CurrentCharge / Cell.MaxCharge, HasCell); } [Verb] diff --git a/Content.Shared/GameObjects/Components/SharedHandheldLightComponent.cs b/Content.Shared/GameObjects/Components/SharedHandheldLightComponent.cs index ecc9229693..760bd134cf 100644 --- a/Content.Shared/GameObjects/Components/SharedHandheldLightComponent.cs +++ b/Content.Shared/GameObjects/Components/SharedHandheldLightComponent.cs @@ -9,15 +9,20 @@ namespace Content.Shared.GameObjects.Components public sealed override string Name => "HandheldLight"; public sealed override uint? NetID => ContentNetIDs.HANDHELD_LIGHT; + protected abstract bool HasCell { get; } + [Serializable, NetSerializable] protected sealed class HandheldLightComponentState : ComponentState { - public HandheldLightComponentState(float? charge) : base(ContentNetIDs.HANDHELD_LIGHT) + public HandheldLightComponentState(float? charge, bool hasCell) : base(ContentNetIDs.HANDHELD_LIGHT) { Charge = charge; + HasCell = hasCell; } public float? Charge { get; } + + public bool HasCell { get; } } } }