mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 16:17:27 +00:00
* Fix various light sources counting as Light, Give Skia spacewalk * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Replace the Ignore Gravity with Jetpack * Clean up event code + Avoid touching upstream code where possible * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Double cone, strategic untouches * Additional strategic untouch --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
38 lines
1.5 KiB
C#
38 lines
1.5 KiB
C#
using Content.Server.Light.Components;
|
|
using Content.Shared._DV.Light;
|
|
using Content.Shared.Light.Components;
|
|
|
|
namespace Content.Server._DV.Light.EntitySystems;
|
|
|
|
public sealed partial class ExpendableLightEnergySystem : EntitySystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ExpendableLightComponent, OnGetLightEnergyEvent>(GetLightEnergy);
|
|
}
|
|
|
|
private void GetLightEnergy(Entity<ExpendableLightComponent> ent, ref OnGetLightEnergyEvent args)
|
|
{
|
|
// This isn't a perfect clone of the Clientside code, as it relies on animation behaviours
|
|
// and thus is by nature different per-client (Especially those with random flickers)
|
|
// This same code is not used clientside, because the client doesn't actually have access to the start time(??)
|
|
float lightFactor;
|
|
switch (ent.Comp.CurrentState)
|
|
{
|
|
case ExpendableLightState.Lit:
|
|
float timeElapsed = ent.Comp.GlowDuration.Seconds - ent.Comp.StateExpiryTime;
|
|
lightFactor = MathF.Min(1.0f, 1.0f - timeElapsed / ent.Comp.FadeInDuration);
|
|
break;
|
|
case ExpendableLightState.Fading:
|
|
lightFactor = MathF.Min(1.0f, ent.Comp.StateExpiryTime / ent.Comp.FadeOutDuration.Seconds);
|
|
break;
|
|
default: // Other states aren't lit.
|
|
return;
|
|
}
|
|
args.LightEnergy = ent.Comp.LitEnergy * lightFactor;
|
|
args.LightRadius = ent.Comp.LitRadius * lightFactor;
|
|
}
|
|
}
|