Table of Contents

Class Light

Namespace
TinyLife.Objects
Assembly
Tiny Life.dll

A light is a semi-object that can be added to a Map using AddLight(Light). A light draws a light texture onto a lightmap and, as such, adds lighting to the rendered world.

public class Light
Inheritance
Light
Inherited Members
Extension Methods

Constructors

Light(Map, Vector2, float, TextureRegion, Vector2, Color)

Creates a new light with the given settings

public Light(Map map, Vector2 position, float floor, TextureRegion texture, Vector2 size, Color color)

Parameters

map Map

The map to add the light to

position Vector2

The light's position, in world space

floor float

The floor this light is on.

texture TextureRegion

The light's texture

size Vector2

The size of the light, centered on its position

color Color

The color to render the light with

Fields

CircleTexture

A texture that can be used as the Texture of a light that is circular

public static readonly TextureRegion CircleTexture

Field Value

TextureRegion

Color

The color that this light renders with. Note that, when drawing, this color is passed through MLEM.Extensions.ColorExtensions.Invert(Microsoft.Xna.Framework.Color) due to the way the lightmap is drawn.

public Color Color

Field Value

Color

Floor

The floor this light is on.

public float Floor

Field Value

float

IsDisabled

Whether this light is currently disabled. If a light is disabled, it will not be rendered.

public bool IsDisabled

Field Value

bool

Map

The map that this light is on

public readonly Map Map

Field Value

Map

PositionOffset

An offset from this light's Position, in world space, that is applied before the ToScreenPos(Vector2, float, bool, bool, bool) call. This can be used if the light should be drawn in a different location than its Position, which also determines the room and section that it is in.

public Vector2 PositionOffset

Field Value

Vector2

Rotation

The rotation that this light displays with, in radians. Rotation is applied around the center of the light's Texture.

public float Rotation

Field Value

float

Scale

The scale that this light is drawn with.

public float Scale

Field Value

float

ScreenPosOffset

An offset from this light's screen-space draw position, also in screen space. This is added to the final draw position in Draw(GameTime, SpriteBatch), after ToScreenPos(Vector2, float, bool, bool, bool) has already been called.

public Vector2 ScreenPosOffset

Field Value

Vector2

Size

The size, in world space, of this light, centered on its Position. This value is multiplied with TileWidth and TileHeight.

public Vector2 Size

Field Value

Vector2

Texture

The texture that this light currently has. A custom texture can be used, or any of the static texture regions in this class, including CircleTexture.

public readonly TextureRegion Texture

Field Value

TextureRegion

VisualWorldOffset

An offset from this light's world-space draw position, also in world space. This is translated to screen space using ToScreenPos(Vector2, float, bool, bool, bool) and added to the final draw position in Draw(GameTime, SpriteBatch).

public Vector2 VisualWorldOffset

Field Value

Vector2

Properties

Position

The position of this light, in world space. Note that, if this position is changed, this light's current MapSection is changed automatically if needed.

public Vector2 Position { get; set; }

Property Value

Vector2

Methods

Draw(GameTime, SpriteBatch)

Draws the light in the world with the given sprite batch, at its current Position and with its current Color

public virtual void Draw(GameTime time, SpriteBatch batch)

Parameters

time GameTime

The game's current time, which can be used for animations

batch SpriteBatch

The sprite batch to draw the light with