Health analyzer displays turns off when the battery dies (#16125)
This commit is contained in:
@@ -11,6 +11,7 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class BatterySystem : EntitySystem
|
public sealed class BatterySystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly SharedAppearanceSystem _sharedAppearanceSystem = default!;
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|||||||
@@ -166,7 +166,6 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
|
|||||||
|
|
||||||
return HasCharge(uid, battery.UseRate, cell, user);
|
return HasCharge(uid, battery.UseRate, cell, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to use the <see cref="PowerCellDrawComponent.UseRate"/> for this entity.
|
/// Tries to use the <see cref="PowerCellDrawComponent.UseRate"/> for this entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -179,6 +178,7 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
|
|||||||
|
|
||||||
if (TryUseCharge(uid, battery.UseRate, cell, user))
|
if (TryUseCharge(uid, battery.UseRate, cell, user))
|
||||||
{
|
{
|
||||||
|
_sharedAppearanceSystem.SetData(uid, PowerCellSlotVisuals.Enabled, HasActivatableCharge(uid, battery, cell, user));
|
||||||
_activatable.CheckUsage(uid);
|
_activatable.CheckUsage(uid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -243,6 +243,7 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_sharedAppearanceSystem.SetData(uid, PowerCellSlotVisuals.Enabled, battery.Charge > 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,3 +24,8 @@ public enum PowerCellVisuals : byte
|
|||||||
{
|
{
|
||||||
ChargeLevel
|
ChargeLevel
|
||||||
}
|
}
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum PowerCellSlotVisuals : byte
|
||||||
|
{
|
||||||
|
Enabled
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace Content.Shared.PowerCell;
|
|||||||
public abstract class SharedPowerCellSystem : EntitySystem
|
public abstract class SharedPowerCellSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
|
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
|
||||||
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -48,7 +49,7 @@ public abstract class SharedPowerCellSystem : EntitySystem
|
|||||||
|
|
||||||
if (args.Container.ID != component.CellSlotId)
|
if (args.Container.ID != component.CellSlotId)
|
||||||
return;
|
return;
|
||||||
|
_appearance.SetData(uid, PowerCellSlotVisuals.Enabled, true);
|
||||||
RaiseLocalEvent(uid, new PowerCellChangedEvent(false), false);
|
RaiseLocalEvent(uid, new PowerCellChangedEvent(false), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ public abstract class SharedPowerCellSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
if (args.Container.ID != component.CellSlotId)
|
if (args.Container.ID != component.CellSlotId)
|
||||||
return;
|
return;
|
||||||
|
_appearance.SetData(uid, PowerCellSlotVisuals.Enabled, false);
|
||||||
RaiseLocalEvent(uid, new PowerCellChangedEvent(true), false);
|
RaiseLocalEvent(uid, new PowerCellChangedEvent(true), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,13 @@
|
|||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Specific/Medical/healthanalyzer.rsi
|
sprite: Objects/Specific/Medical/healthanalyzer.rsi
|
||||||
netsync: false
|
netsync: false
|
||||||
state: analyzer
|
state: icon
|
||||||
|
layers:
|
||||||
|
- state: icon
|
||||||
|
- state: analyzer
|
||||||
|
shader: unshaded
|
||||||
|
visible: true
|
||||||
|
map: [ "enum.PowerDeviceVisualLayers.Powered" ]
|
||||||
- type: PowerCellDraw
|
- type: PowerCellDraw
|
||||||
drawRate: 0
|
drawRate: 0
|
||||||
useRate: 20
|
useRate: 20
|
||||||
@@ -27,6 +33,13 @@
|
|||||||
- type: Tag
|
- type: Tag
|
||||||
tags:
|
tags:
|
||||||
- DiscreteHealthAnalyzer
|
- DiscreteHealthAnalyzer
|
||||||
|
- type: Appearance
|
||||||
|
- type: GenericVisualizer
|
||||||
|
visuals:
|
||||||
|
enum.PowerCellSlotVisuals.Enabled:
|
||||||
|
enum.PowerDeviceVisualLayers.Powered:
|
||||||
|
True: { visible: true }
|
||||||
|
False: { visible: false }
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: HandheldHealthAnalyzerEmpty
|
id: HandheldHealthAnalyzerEmpty
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 622 B |
Binary file not shown.
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 1.9 KiB |
Reference in New Issue
Block a user