diff --git a/Content.Server/_White/Lighting/PointLightBatteryComponent.cs b/Content.Server/_White/Lighting/PointLightBatteryComponent.cs new file mode 100644 index 0000000000..7ad8c5c84c --- /dev/null +++ b/Content.Server/_White/Lighting/PointLightBatteryComponent.cs @@ -0,0 +1,8 @@ +namespace Content.Server._White.Lighting; + +[RegisterComponent] +public sealed partial class PointLightBatteryComponent : Component +{ + [DataField, ViewVariables(VVAccess.ReadWrite)] + public bool RequireBattery = true; +} diff --git a/Content.Server/_White/Lighting/PointLightBatterySystem.cs b/Content.Server/_White/Lighting/PointLightBatterySystem.cs new file mode 100644 index 0000000000..95a41c28c6 --- /dev/null +++ b/Content.Server/_White/Lighting/PointLightBatterySystem.cs @@ -0,0 +1,30 @@ +using Content.Shared.Lightning; +using Content.Shared.PowerCell; +using Content.Shared.PowerCell.Components; + +namespace Content.Server._White.Lighting; + +public sealed class PointLightBatterySystem : SharedLightningSystem +{ + [Dependency] private readonly SharedPointLightSystem _pointLightSystem = default!; + [Dependency] private readonly SharedPowerCellSystem _cell = default!; + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnBatteryLoose); + } + + private void OnBatteryLoose(EntityUid uid, PointLightBatteryComponent component, PowerCellChangedEvent args) + { + if (!component.RequireBattery) + return; + + if (!_pointLightSystem.TryGetLight(uid, out var pointLightComponent)) + return; + + var isBatteryCharged = _cell.HasDrawCharge(uid); + _pointLightSystem.SetEnabled(uid, isBatteryCharged && !args.Ejected, pointLightComponent); + + RaiseLocalEvent(uid, new PointLightToggleEvent(isBatteryCharged && !args.Ejected), true); + } +} diff --git a/Content.Shared/PowerCell/SharedPowerCellSystem.cs b/Content.Shared/PowerCell/SharedPowerCellSystem.cs index 508bfc85f0..dbf5baf42a 100644 --- a/Content.Shared/PowerCell/SharedPowerCellSystem.cs +++ b/Content.Shared/PowerCell/SharedPowerCellSystem.cs @@ -19,6 +19,7 @@ public abstract class SharedPowerCellSystem : EntitySystem SubscribeLocalEvent(OnCellInserted); SubscribeLocalEvent(OnCellRemoved); SubscribeLocalEvent(OnCellInsertAttempt); + SubscribeLocalEvent(OnPowerChanged); } private void OnRejuvenate(EntityUid uid, PowerCellSlotComponent component, RejuvenateEvent args) @@ -30,6 +31,16 @@ public abstract class SharedPowerCellSystem : EntitySystem RaiseLocalEvent(itemSlot.Item.Value, args); } + private void OnPowerChanged(EntityUid uid, PowerCellSlotComponent component, PowerCellChangedEvent _) + { + if (!component.Initialized) + return; + + var charged = HasDrawCharge(uid); + + _appearance.SetData(uid, PowerCellSlotVisuals.Enabled, charged); + } + private void OnCellInsertAttempt(EntityUid uid, PowerCellSlotComponent component, ContainerIsInsertingAttemptEvent args) { if (!component.Initialized) @@ -51,14 +62,18 @@ public abstract class SharedPowerCellSystem : EntitySystem if (args.Container.ID != component.CellSlotId) return; - _appearance.SetData(uid, PowerCellSlotVisuals.Enabled, true); - RaiseLocalEvent(uid, new PowerCellChangedEvent(false), false); + + var charged = HasDrawCharge(uid); + + _appearance.SetData(uid, PowerCellSlotVisuals.Enabled, charged); + RaiseLocalEvent(uid, new PowerCellChangedEvent(false)); } protected virtual void OnCellRemoved(EntityUid uid, PowerCellSlotComponent component, EntRemovedFromContainerMessage args) { if (args.Container.ID != component.CellSlotId) return; + _appearance.SetData(uid, PowerCellSlotVisuals.Enabled, false); RaiseLocalEvent(uid, new PowerCellChangedEvent(true), false); } diff --git a/Resources/Prototypes/Entities/Objects/Specific/Medical/healthanalyzer.yml b/Resources/Prototypes/Entities/Objects/Specific/Medical/healthanalyzer.yml index 64bd04569b..288099f9f1 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Medical/healthanalyzer.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Medical/healthanalyzer.yml @@ -8,11 +8,12 @@ sprite: Objects/Specific/Medical/healthanalyzer.rsi state: icon layers: - - state: icon - - state: analyzer - shader: unshaded + - map: [ "analyzerLayerBody" ] + state: icon visible: true - map: [ "enum.PowerDeviceVisualLayers.Powered" ] + - map: [ "analyzerLayerScreen" ] + state: powered + visible: false - type: Item storedRotation: -90 - type: ActivatableUI @@ -33,8 +34,8 @@ visuals: enum.PowerCellSlotVisuals.Enabled: enum.PowerDeviceVisualLayers.Powered: - True: { visible: true } - False: { visible: false } + True: { state: powered, visible: true, shader: unshaded } + False: { state: powered, visible: false } - type: GuideHelp guides: - Medical Doctor @@ -46,7 +47,14 @@ components: - type: PowerCellDraw drawRate: 1.2 #Calculated for 5 minutes on a small cell + - type: PowerCellSlot + cellSlotId: cell_slot - type: ActivatableUIRequiresPowerCell + - type: PointLightBattery + - type: PointLight + radius: 1.2 + energy: 0.5 + color: "#7FB6C0" - type: entity id: HandheldHealthAnalyzerEmpty diff --git a/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/analyzer.png b/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/analyzer.png deleted file mode 100644 index 3fbab3f112..0000000000 Binary files a/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/analyzer.png and /dev/null differ diff --git a/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/meta.json b/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/meta.json index af66c180db..fbc9eac793 100644 --- a/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/meta.json +++ b/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/meta.json @@ -8,7 +8,7 @@ "copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/f07f847706d85b7cfa4b398e5175732212b69a63", "states": [ { - "name": "analyzer", + "name": "powered", "delays": [ [ 0.1, diff --git a/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/powered.png b/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/powered.png new file mode 100644 index 0000000000..19bb0da12d Binary files /dev/null and b/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/powered.png differ