mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
63 lines
1.7 KiB
C#
63 lines
1.7 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.GameStates;
|
|
|
|
namespace Robust.Server.GameObjects;
|
|
|
|
public sealed class PointLightSystem : SharedPointLightSystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<PointLightComponent, ComponentGetState>(OnLightGetState);
|
|
}
|
|
|
|
private void OnLightGetState(EntityUid uid, PointLightComponent component, ref ComponentGetState args)
|
|
{
|
|
args.State = new PointLightComponentState()
|
|
{
|
|
Color = component.Color,
|
|
Enabled = component.Enabled,
|
|
Energy = component.Energy,
|
|
Offset = component.Offset,
|
|
Radius = component.Radius,
|
|
Softness = component.Softness,
|
|
CastShadows = component.CastShadows,
|
|
};
|
|
}
|
|
|
|
public override SharedPointLightComponent EnsureLight(EntityUid uid)
|
|
{
|
|
return EnsureComp<PointLightComponent>(uid);
|
|
}
|
|
|
|
public override bool ResolveLight(EntityUid uid, [NotNullWhen(true)] ref SharedPointLightComponent? component)
|
|
{
|
|
if (TryComp<PointLightComponent>(uid, out var comp))
|
|
{
|
|
component = comp;
|
|
return true;
|
|
}
|
|
|
|
component = null;
|
|
return false;
|
|
}
|
|
|
|
public override bool TryGetLight(EntityUid uid, [NotNullWhen(true)] out SharedPointLightComponent? component)
|
|
{
|
|
if (TryComp<PointLightComponent>(uid, out var comp))
|
|
{
|
|
component = comp;
|
|
return true;
|
|
}
|
|
|
|
component = null;
|
|
return false;
|
|
}
|
|
|
|
public override bool RemoveLightDeferred(EntityUid uid)
|
|
{
|
|
return RemCompDeferred<PointLightComponent>(uid);
|
|
}
|
|
}
|