Remove lights compref (#19531)

This commit is contained in:
metalgearsloth
2023-09-11 19:18:06 +10:00
committed by GitHub
parent d315ce3c8c
commit 99b77bc2d3
64 changed files with 222 additions and 132 deletions

View File

@@ -7,7 +7,6 @@ using Content.Shared.Light.Components;
using Content.Shared.Mind.Components;
using Content.Shared.Toggleable;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
@@ -16,11 +15,12 @@ namespace Content.Server.Light.EntitySystems
{
public sealed class UnpoweredFlashlightSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly SharedPointLightSystem _light = default!;
public override void Initialize()
{
@@ -71,13 +71,13 @@ namespace Content.Server.Light.EntitySystems
private void OnGotEmagged(EntityUid uid, UnpoweredFlashlightComponent component, ref GotEmaggedEvent args)
{
if (!TryComp<PointLightComponent>(uid, out var light))
if (!_light.TryGetLight(uid, out var light))
return;
if (_prototypeManager.TryIndex<ColorPalettePrototype>(component.EmaggedColorsPrototype, out var possibleColors))
{
var pick = _random.Pick(possibleColors.Colors.Values);
light.Color = pick;
_light.SetColor(uid, pick, light);
}
args.Repeatable = true;
@@ -86,11 +86,11 @@ namespace Content.Server.Light.EntitySystems
public void ToggleLight(EntityUid uid, UnpoweredFlashlightComponent flashlight)
{
if (!TryComp<PointLightComponent>(uid, out var light))
if (!_light.TryGetLight(uid, out var light))
return;
flashlight.LightOn = !flashlight.LightOn;
light.Enabled = flashlight.LightOn;
_light.SetEnabled(uid, flashlight.LightOn, light);
_appearance.SetData(uid, UnpoweredFlashlightVisuals.LightOn, flashlight.LightOn);