Skip to main content

TimberPieceBase

An abstract class in Root.Township, Alta.Carpentry.

Base for one chiselable piece of a timber block in carpentry. Starts disabled; a TimberBlock stage enables, saves and syncs its pieces.

Constructors​

MemberWhat it is
protected TimberPieceBase()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
TimberPieceDelegate OnChangedDelegate called when the piece changes.
TimberPieceDelegate OnDoneDelegate called when the piece is finished.
2 private and internal fields
MemberWhat it is
private PooledObjectDefinition hittinEffectPooled effect spawned at the piece on clients when it takes damage.
private SoundEffectSet hittingSoundSound set played at the piece on clients when it takes damage.

Properties​

MemberWhat it is
int Index { get; set; }The piece's index within its stage.
bool IsDone { get; private set; }Set by MarkIsDone once the piece is finished.
bool IsModified { get; protected set; }Whether the piece has been carved or turned away from its starting state.
Player LastHittingPlayerController { get; protected set; }The player who last hit this piece.
abstract MeshFilter MeshFilter { get; }The mesh filter that shows the piece.
abstract float Progress { get; set; }How far the piece has been carved, as set by the subclass.
override bool TriggerHaptics { get; }Haptics only fire while the piece is enabled.

Methods​

MemberWhat it is
abstract void Load(PieceSaveData data)Restores the piece from its save data.
void MarkIsDone()Marks the piece finished and hides its game object.
override void ReceiveDamage(float damage, Vector3 position, Vector3 direction, ChiselingTool tool, Collider hitCollider)Applies a chisel hit, then plays the hit effect and sound (not on headless).
abstract void Rotate(bool isInversedUp)Turns the piece to match the block's orientation.
abstract PieceSaveData Save()Returns the piece's save data.
abstract void Serialize(Stream stream, bool isWritingFull)Writes or reads the piece's state on a network stream, fully or as a change.
protected virtual void Awake()Disables the piece until its stage turns it on.

Used in​

Members of other types that take, return or hold a TimberPieceBase: