Light
namespace Griff.Scenes;
public sealed class Light : ComponentLights up the dark around its entity: a torch, a lamp, a glowing mushroom, the player’s lantern. Lights only show where the Camera’s Ambient is darker than white; there, everything within Radius is lit by its Color, brightest in the middle. Where lights overlap they add up.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”public Color Color { get; set; }The light’s color: warm orange for a torch, pale blue for moonlight.
CurrentIntensity
Section titled “CurrentIntensity”public float CurrentIntensity { get; }The intensity right now, flicker included. The game updates it while it runs.
Flicker
Section titled “Flicker”public float Flicker { get; set; }How much it flickers, from 0 (steady) to 1 (a guttering candle). Flames look right at about 0.2.
Intensity
Section titled “Intensity”public float Intensity { get; set; }How bright it is: 1 lights its middle fully, more spreads full brightness further out, less is dim.
Offset
Section titled “Offset”public Vector2 Offset { get; set; }Where the light is, relative to the entity, e.g. (0, 0.5) for a lantern held up.
Radius
Section titled “Radius”public float Radius { get; set; }How far the light reaches, in world units.
Shadows
Section titled “Shadows”public bool Shadows { get; set; }Walls, solid tiles and solid colliders block the light and cast shadows behind them. What carries the light (a lantern’s holder) and anything the light is inside (a torch set into a wall) cast none; triggers, one-way platforms and background tiles let it through.
Softness
Section titled “Softness”public float Softness { get; set; }How gradually it fades out towards its edge: 1 fades all the way from the middle, 0 is a hard-edged circle (a spotlight, a window’s square of light seen from above).
WorldCenter
Section titled “WorldCenter”public Vector2 WorldCenter { get; }Where the light is in the world.
Methods
Section titled “Methods”public ValueTuple<Vector2, float, Color, float, float> Drawn(StepBlend blend)Where it is, how far it reaches, its color, its intensity (flicker included, as CurrentIntensity) and how soft its edge is, in a frame drawn as blend says.
Falloff
Section titled “Falloff”public static float Falloff(float distance, float radius, float softness)How much of a light’s brightness reaches distance from its middle (0 to 1), for one of radius and softness: the same falloff the game is drawn with.