Interface IBreakableObject
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
Broken
A field that stores whether this furniture is currently broken
bool Broken { get; set; }
Property Value
RepairProgress
The progress that has been made on repairing this object, between 0 and 1.
float RepairProgress { get; set; }
Property Value
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
TThe breakable object to be worn down.
area
RectangleFThe area covered by the breakable object, for spawning puddles and displaying particles.
visualRotation
Direction2The object's rotation, in camera space.
passedInGame
TimeSpanThe amount of in-game time that this furniture should be worn down by
random
RandomA Random instance to use for breaking down.
puddleTimer
TimeSpanA 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
SoundEffectInstanceA 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
TThe breakable object to be worn down.
passedInGame
TimeSpanThe amount of in-game time that this furniture should be worn down by
random
RandomA Random instance to use for breaking down.
breakTimer
TimeSpanA 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
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