LightFurniture - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Objects

LightFurniture Class

Light furniture is a furniture that additionally spawns and handles a set of Light instances.
To use this class effectively, set CreateLights to determine the lights that should be spawned from the furniture.

public class LightFurniture : TinyLife.Objects.Furniture,
TinyLife.Objects.IUpdatingObject

Inheritance System.Object 🡒 MLEM.Misc.GenericDataHolder 🡒 MapObject 🡒 Furniture 🡒 LightFurniture

Implements IUpdatingObject

Constructors

LightFurniture.LightFurniture(Guid, FurnitureType, int[], Map, Vector2) Constructor

Creates a new furniture instance.
By default, this is done using Construct(int[], Map, Vector2, Nullable<Guid>).

public LightFurniture(System.Guid id, TinyLife.Objects.FurnitureType type, int[] colors, TinyLife.World.Map map, Microsoft.Xna.Framework.Vector2 pos);

Parameters

id System.Guid
The id to apply to the created furniture instance

type FurnitureType
The type to create an instance of

colors System.Int32[]
The colors to apply to the furniture

map Map
The map to create the furniture on

pos Microsoft.Xna.Framework.Vector2
The position that the furniture should have

Fields

LightFurniture.IsDisabled Field

Whether this light is currently disabled.
Note that a light also gets disabled if AreUtilitiesDisabled, but this field will not be set to true in that case.

public bool IsDisabled;

Field Value

System.Boolean

Properties

LightFurniture.Lights Property

The lights that are currently in the world, based on this light furniture

public TinyLife.Objects.Light[] Lights { get; set; }

Property Value

Light[]

Methods

LightFurniture.OnAdded() Method

This method is called when this object is added to a Map.
By default, it does nothing.

public override void OnAdded();

LightFurniture.OnRemoved() Method

This method is called when this object is removed from a Map.
By default, it does nothing.

public override void OnRemoved();

LightFurniture.Update(GameTime, TimeSpan, GameSpeed) Method

The update method, which is called every update frame by the underlying Map

public void Update(Microsoft.Xna.Framework.GameTime time, System.TimeSpan passedInGame, TinyLife.GameSpeed speed);

Parameters

time Microsoft.Xna.Framework.GameTime
The game's time

passedInGame System.TimeSpan
The amount of time that has passed since the last call

speed GameSpeed
The game's speed

Implements Update(GameTime, TimeSpan, GameSpeed)

LightFurniture.Validate() Method

This method is called when this object is loaded from disk.
Returning false on this method causes the object to be removed from the map.
By default, this method invokes OnValidated and OnEventsAttachable.

public override bool Validate();

Returns

System.Boolean
false if the object is not valid, true otherwise