Remove lights compref (#19531)
This commit is contained in:
@@ -9,7 +9,6 @@ using Content.Shared.Examine;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Light.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Color = Robust.Shared.Maths.Color;
|
||||
|
||||
namespace Content.Server.Light.EntitySystems;
|
||||
@@ -103,7 +102,7 @@ public sealed class EmergencyLightSystem : SharedEmergencyLightSystem
|
||||
if (CompOrNull<StationMemberComponent>(xform.GridUid)?.Station != ev.Station)
|
||||
continue;
|
||||
|
||||
pointLight.Color = details.EmergencyLightColor;
|
||||
_pointLight.SetColor(uid, details.EmergencyLightColor, pointLight);
|
||||
_appearance.SetData(uid, EmergencyLightVisuals.Color, details.EmergencyLightColor, appearance);
|
||||
|
||||
if (details.ForceEnableEmergencyLights && !light.ForciblyEnabled)
|
||||
|
||||
@@ -13,18 +13,20 @@ using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Light.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class HandheldLightSystem : SharedHandheldLightSystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly ActionsSystem _actions = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly PowerCellSystem _powerCell = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedPointLightSystem _lights = default!;
|
||||
|
||||
// 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.
|
||||
@@ -196,12 +198,12 @@ namespace Content.Server.Light.EntitySystems
|
||||
|
||||
public bool TurnOff(EntityUid uid, HandheldLightComponent component, bool makeNoise = true)
|
||||
{
|
||||
if (!component.Activated || !TryComp<PointLightComponent>(uid, out var pointLightComponent))
|
||||
if (!component.Activated || !_lights.TryGetLight(uid, out var pointLightComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pointLightComponent.Enabled = false;
|
||||
_lights.SetEnabled(uid, false, pointLightComponent);
|
||||
SetActivated(uid, false, component, makeNoise);
|
||||
component.Level = null;
|
||||
_activeLights.Remove(component);
|
||||
@@ -210,7 +212,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
|
||||
public bool TurnOn(EntityUid user, EntityUid uid, HandheldLightComponent component)
|
||||
{
|
||||
if (component.Activated || !TryComp<PointLightComponent>(uid, out var pointLightComponent))
|
||||
if (component.Activated || !_lights.TryGetLight(uid, out var pointLightComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -233,7 +235,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
return false;
|
||||
}
|
||||
|
||||
pointLightComponent.Enabled = true;
|
||||
_lights.SetEnabled(uid, true, pointLightComponent);
|
||||
SetActivated(uid, true, component, true);
|
||||
_activeLights.Add(component);
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using Content.Server.Light.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.Light.EntitySystems
|
||||
{
|
||||
public sealed class LitOnPoweredSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedPointLightSystem _lights = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -16,17 +17,17 @@ namespace Content.Server.Light.EntitySystems
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, LitOnPoweredComponent component, ref PowerChangedEvent args)
|
||||
{
|
||||
if (EntityManager.TryGetComponent<PointLightComponent>(uid, out var light))
|
||||
if (_lights.TryGetLight(uid, out var light))
|
||||
{
|
||||
light.Enabled = args.Powered;
|
||||
_lights.SetEnabled(uid, args.Powered, light);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPowerSupply(EntityUid uid, LitOnPoweredComponent component, ref PowerNetBatterySupplyEvent args)
|
||||
{
|
||||
if (EntityManager.TryGetComponent<PointLightComponent>(uid, out var light))
|
||||
if (_lights.TryGetLight(uid, out var light))
|
||||
{
|
||||
light.Enabled = args.Supply;
|
||||
_lights.SetEnabled(uid, args.Supply, light);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,10 @@ namespace Content.Server.Light.EntitySystems
|
||||
public sealed class MatchstickSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly SharedItemSystem _item = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly SharedItemSystem _item = default!;
|
||||
[Dependency] private readonly SharedPointLightSystem _lights = default!;
|
||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||
|
||||
private HashSet<MatchstickComponent> _litMatches = new();
|
||||
|
||||
@@ -92,25 +93,25 @@ namespace Content.Server.Light.EntitySystems
|
||||
{
|
||||
component.CurrentState = value;
|
||||
|
||||
if (TryComp<PointLightComponent>(component.Owner, out var pointLightComponent))
|
||||
if (_lights.TryGetLight(uid, out var pointLightComponent))
|
||||
{
|
||||
pointLightComponent.Enabled = component.CurrentState == SmokableState.Lit;
|
||||
_lights.SetEnabled(uid, component.CurrentState == SmokableState.Lit, pointLightComponent);
|
||||
}
|
||||
|
||||
if (EntityManager.TryGetComponent(component.Owner, out ItemComponent? item))
|
||||
if (EntityManager.TryGetComponent(uid, out ItemComponent? item))
|
||||
{
|
||||
switch (component.CurrentState)
|
||||
{
|
||||
case SmokableState.Lit:
|
||||
_item.SetHeldPrefix(component.Owner, "lit", item);
|
||||
_item.SetHeldPrefix(uid, "lit", item);
|
||||
break;
|
||||
default:
|
||||
_item.SetHeldPrefix(component.Owner, "unlit", item);
|
||||
_item.SetHeldPrefix(uid, "unlit", item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearance))
|
||||
if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
|
||||
{
|
||||
_appearance.SetData(uid, SmokingVisuals.Smoking, component.CurrentState, appearance);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly PointLightSystem _pointLight = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
|
||||
private static readonly TimeSpan ThunkDelay = TimeSpan.FromSeconds(2);
|
||||
@@ -74,9 +75,10 @@ namespace Content.Server.Light.EntitySystems
|
||||
|
||||
private void OnMapInit(EntityUid uid, PoweredLightComponent light, MapInitEvent args)
|
||||
{
|
||||
// TODO: Use ContainerFill dog
|
||||
if (light.HasLampOnSpawn != null)
|
||||
{
|
||||
var entity = EntityManager.SpawnEntity(light.HasLampOnSpawn, EntityManager.GetComponent<TransformComponent>(light.Owner).Coordinates);
|
||||
var entity = EntityManager.SpawnEntity(light.HasLampOnSpawn, EntityManager.GetComponent<TransformComponent>(uid).Coordinates);
|
||||
light.LightBulbContainer.Insert(entity);
|
||||
}
|
||||
// need this to update visualizers
|
||||
@@ -386,16 +388,16 @@ namespace Content.Server.Light.EntitySystems
|
||||
|
||||
if (EntityManager.TryGetComponent(uid, out PointLightComponent? pointLight))
|
||||
{
|
||||
pointLight.Enabled = value;
|
||||
_pointLight.SetEnabled(uid, value, pointLight);
|
||||
|
||||
if (color != null)
|
||||
pointLight.Color = color.Value;
|
||||
_pointLight.SetColor(uid, color.Value, pointLight);
|
||||
if (radius != null)
|
||||
pointLight.Radius = (float) radius;
|
||||
_pointLight.SetRadius(uid, (float) radius, pointLight);
|
||||
if (energy != null)
|
||||
pointLight.Energy = (float) energy;
|
||||
_pointLight.SetEnergy(uid, (float) energy, pointLight);
|
||||
if (softness != null)
|
||||
pointLight.Softness = (float) softness;
|
||||
_pointLight.SetSoftness(uid, (float) softness, pointLight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user