Skip to content

Light

namespace Griff.Scenes;
public sealed class Light : Component

Lights 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.

public Color Color { get; set; }

The light’s color: warm orange for a torch, pale blue for moonlight.

public float CurrentIntensity { get; }

The intensity right now, flicker included. The game updates it while it runs.

public float Flicker { get; set; }

How much it flickers, from 0 (steady) to 1 (a guttering candle). Flames look right at about 0.2.

public float Intensity { get; set; }

How bright it is: 1 lights its middle fully, more spreads full brightness further out, less is dim.

public Vector2 Offset { get; set; }

Where the light is, relative to the entity, e.g. (0, 0.5) for a lantern held up.

public float Radius { get; set; }

How far the light reaches, in world units.

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.

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).

public Vector2 WorldCenter { get; }

Where the light is in the world.

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.

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.