Many lighting tweaks (#4709)
This commit is contained in:
18
Content.Server/Light/Components/LitOnPoweredComponent.cs
Normal file
18
Content.Server/Light/Components/LitOnPoweredComponent.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Content.Server.Light.EntitySystems;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Light.Components
|
||||
{
|
||||
// TODO PoweredLight also snowflakes this behavior. Ideally, powered light is renamed to 'wall light' and the
|
||||
// actual 'light on power' stuff is just handled by this component.
|
||||
/// <summary>
|
||||
/// Enables or disables a pointlight depending on the powered
|
||||
/// state of an entity.
|
||||
/// </summary>
|
||||
[RegisterComponent, Friend(typeof(PoweredLightSystem))]
|
||||
public class LitOnPoweredComponent : Component
|
||||
{
|
||||
public override string Name => "LitOnPowered";
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ using System;
|
||||
using Content.Server.Ghost;
|
||||
using Content.Server.Light.Components;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -24,6 +26,9 @@ namespace Content.Server.Light.EntitySystems
|
||||
SubscribeLocalEvent<PoweredLightComponent, GhostBooEvent>(OnGhostBoo);
|
||||
SubscribeLocalEvent<PoweredLightComponent, SignalReceivedEvent>(OnSignalReceived);
|
||||
SubscribeLocalEvent<PoweredLightComponent, DamageChangedEvent>(HandleLightDamaged);
|
||||
|
||||
SubscribeLocalEvent<LitOnPoweredComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
SubscribeLocalEvent<LitOnPoweredComponent, PowerNetBatterySupplyEvent>(OnPowerSupply);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,5 +89,21 @@ namespace Content.Server.Light.EntitySystems
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, LitOnPoweredComponent component, PowerChangedEvent args)
|
||||
{
|
||||
if (EntityManager.TryGetComponent<PointLightComponent>(uid, out var light))
|
||||
{
|
||||
light.Enabled = args.Powered;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPowerSupply(EntityUid uid, LitOnPoweredComponent component, PowerNetBatterySupplyEvent args)
|
||||
{
|
||||
if (EntityManager.TryGetComponent<PointLightComponent>(uid, out var light))
|
||||
{
|
||||
light.Enabled = args.Supply;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user