handheldlightsystem cleanup (#13402)
This commit is contained in:
@@ -10,6 +10,8 @@ namespace Content.Client.Light;
|
|||||||
|
|
||||||
public sealed class HandheldLightSystem : SharedHandheldLightSystem
|
public sealed class HandheldLightSystem : SharedHandheldLightSystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -30,13 +32,12 @@ public sealed class HandheldLightSystem : SharedHandheldLightSystem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.Component.TryGetData(ToggleableLightVisuals.Enabled, out bool enabled))
|
if (!_appearance.TryGetData(uid, ToggleableLightVisuals.Enabled, out bool enabled, args.Component))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.Component.TryGetData(HandheldLightVisuals.Power,
|
if (!_appearance.TryGetData(uid, HandheldLightVisuals.Power, out HandheldLightPowerStates state, args.Component))
|
||||||
out HandheldLightPowerStates state))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
[Dependency] private readonly PopupSystem _popup = default!;
|
[Dependency] private readonly PopupSystem _popup = default!;
|
||||||
[Dependency] private readonly PowerCellSystem _powerCell = default!;
|
[Dependency] private readonly PowerCellSystem _powerCell = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||||
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||||
|
|
||||||
// TODO: Ideally you'd be able to subscribe to power stuff to get events at certain percentages.. or something?
|
// TODO: Ideally you'd be able to subscribe to power stuff to get events at certain percentages.. or something?
|
||||||
// But for now this will be better anyway.
|
// But for now this will be better anyway.
|
||||||
@@ -209,7 +211,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
if (!_powerCell.TryGetBatteryFromSlot(component.Owner, out var battery) &&
|
if (!_powerCell.TryGetBatteryFromSlot(component.Owner, out var battery) &&
|
||||||
!TryComp(component.Owner, out battery))
|
!TryComp(component.Owner, out battery))
|
||||||
{
|
{
|
||||||
SoundSystem.Play(component.TurnOnFailSound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner);
|
_audio.PlayPvs(_audio.GetSound(component.TurnOnFailSound), component.Owner);
|
||||||
_popup.PopupEntity(Loc.GetString("handheld-light-component-cell-missing-message"), component.Owner, user);
|
_popup.PopupEntity(Loc.GetString("handheld-light-component-cell-missing-message"), component.Owner, user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -219,7 +221,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
// Simple enough.
|
// Simple enough.
|
||||||
if (component.Wattage > battery.CurrentCharge)
|
if (component.Wattage > battery.CurrentCharge)
|
||||||
{
|
{
|
||||||
SoundSystem.Play(component.TurnOnFailSound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner);
|
_audio.PlayPvs(_audio.GetSound(component.TurnOnFailSound), component.Owner);
|
||||||
_popup.PopupEntity(Loc.GetString("handheld-light-component-cell-dead-message"), component.Owner, user);
|
_popup.PopupEntity(Loc.GetString("handheld-light-component-cell-dead-message"), component.Owner, user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -245,15 +247,15 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
var fraction = battery.CurrentCharge / battery.MaxCharge;
|
var fraction = battery.CurrentCharge / battery.MaxCharge;
|
||||||
if (fraction >= 0.30)
|
if (fraction >= 0.30)
|
||||||
{
|
{
|
||||||
appearanceComponent.SetData(HandheldLightVisuals.Power, HandheldLightPowerStates.FullPower);
|
_appearance.SetData(component.Owner, HandheldLightVisuals.Power, HandheldLightPowerStates.FullPower, appearanceComponent);
|
||||||
}
|
}
|
||||||
else if (fraction >= 0.10)
|
else if (fraction >= 0.10)
|
||||||
{
|
{
|
||||||
appearanceComponent.SetData(HandheldLightVisuals.Power, HandheldLightPowerStates.LowPower);
|
_appearance.SetData(component.Owner, HandheldLightVisuals.Power, HandheldLightPowerStates.LowPower, appearanceComponent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appearanceComponent.SetData(HandheldLightVisuals.Power, HandheldLightPowerStates.Dying);
|
_appearance.SetData(component.Owner, HandheldLightVisuals.Power, HandheldLightPowerStates.Dying, appearanceComponent); ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component.Activated && !battery.TryUseCharge(component.Wattage * frameTime))
|
if (component.Activated && !battery.TryUseCharge(component.Wattage * frameTime))
|
||||||
|
|||||||
Reference in New Issue
Block a user