Table of Contents

Interface IBreakableObject

Namespace
TinyLife.Objects
Assembly
Tiny Life.dll

An interface that can be applied to a MapObject if it should be breakable and repairable. A default implementation of a Furniture object with this interface is BreakableFurniture.

public interface IBreakableObject
Extension Methods

Properties

BreakSettings

The IBreakableObject.Settings that apply to this breakable object.

IBreakableObject.Settings BreakSettings { get; }

Property Value

IBreakableObject.Settings

Broken

A field that stores whether this furniture is currently broken

bool Broken { get; set; }

Property Value

bool

RepairProgress

The progress that has been made on repairing this object, between 0 and 1.

float RepairProgress { get; set; }

Property Value

float

Methods

Update<T>(T, RectangleF, Direction2, TimeSpan, Random, ref TimeSpan, ref SoundEffectInstance)

Causes a IBreakableObject instance to be updated, namely displaying its broken visuals and playing or stopping any broken sounds.

protected static void Update<T>(T obj, RectangleF area, Direction2 visualRotation, TimeSpan passedInGame, Random random, ref TimeSpan puddleTimer, ref SoundEffectInstance playingBrokenSound) where T : MapObject, IBreakableObject

Parameters

obj T

The breakable object to be worn down.

area RectangleF

The area covered by the breakable object, for spawning puddles and displaying particles.

visualRotation Direction2

The object's rotation, in camera space.

passedInGame TimeSpan

The amount of in-game time that this furniture should be worn down by

random Random

A Random instance to use for breaking down.

puddleTimer TimeSpan

A timer that is used to store the amount of time that has passed for the purpose of spawning a puddle in the world. The puddle timer is added onto in this method, and higher values increase the likelihood of a call to this method causing the object to spawn a puddle. Generally, the puddle timer is short-lived and does not need to be stored to disk by implementers.

playingBrokenSound SoundEffectInstance

A sound effect instance to store any playing broken sounds in.

Type Parameters

T

WearDown<T>(T, TimeSpan, Random, ref TimeSpan)

Causes an IBreakableObject instance to wear down, increasing the likelihood of it becoming Broken and randomly breaking it

protected static void WearDown<T>(T obj, TimeSpan passedInGame, Random random, ref TimeSpan breakTimer) where T : MapObject, IBreakableObject

Parameters

obj T

The breakable object to be worn down.

passedInGame TimeSpan

The amount of in-game time that this furniture should be worn down by

random Random

A Random instance to use for breaking down.

breakTimer TimeSpan

A timer that is used to store the amount of time that the object has been worn down for. The break timer is added onto in this method, and higher values increase the likelihood of a call to this method causing the object to break. Implementers should store their break timer to disk using DataMemberAttribute.

Type Parameters

T

Events

OnBreak

An event that is invoked when this breakable furniture breaks.

public static event Action<IBreakableObject> OnBreak

Event Type

Action<IBreakableObject>

OnWearDown

An event that is invoked when this breakable furniture is worn down in WearDown<T>(T, TimeSpan, Random, ref TimeSpan).

public static event IBreakableObject.WearDownDelegate OnWearDown

Event Type

IBreakableObject.WearDownDelegate