Skip to main content

ChisellingDeck

A class in Root.Township, Alta.Carpentry.

The carpentry bench: holds a timber block whose size grows as wood is docked into it, spawns the matching block prefab and syncs which block is current. Server drives it; saves the block's carving.

Constructors​

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

Fields​

MemberWhat it is
TimberBlockEvent blockModifiedEvent raised when the current block is carved.
TimberBlockEvent changedBlockEvent raised when the current block is replaced or removed.
9 private and internal fields
MemberWhat it is
private NetworkPrefab[] blockMapBlock prefab for each size, built from levels.
private TimberBlockSpawner blockPositionerBacking field for BlockPositioner.
private ColliderGroup colliderGroupThe deck's colliders, set to ignore the block on it.
private int currentSizeBacking field for CurrentSize.
private BuilderDock dockerBuilder dock that takes timber in and spawns refuse.
private ChisellingDeck.BuilderLevel[] levelsSize to block prefab pairs.
private ChiselBlockSize maxSizeLargest block size the deck can hold.
private MethodSync updateBlockMethod sync for the block message.
private int wedgesPerBlockBacking field for WedgesPerBlock.

Properties​

MemberWhat it is
TimberBlockSpawner BlockPositioner { get; }Spawner that gives the spot each block size sits at.
TimberBlock CurrentBlock { get; private set; }The timber block on the bench, or null when empty.
int CurrentRequiredSize { get; }Current size plus one if the dock is currently holding wood, capped at the max.
int CurrentSize { get; set; }Block size as a number (0 means empty). Setting it on the server despawns the old block and spawns one of the new size.
ChiselDefinition Guide { get; private set; }The chisel guide (recipe) currently set on the bench. Private setter.
bool HasSpace { get; }True while the block is below its maximum size.
bool IsBlockNotModified { get; }True if there's no block or it hasn't been carved yet.
int MaxSize { get; }Largest block size allowed, as a number.
int WedgesPerBlock { get; }How many wedges one size step of block is worth, used when shrinking a block into refuse.

Methods​

MemberWhat it is
override void Initialize()Creates the sync for the current block.
override void InitializeAsServer(SpawnData spawnData)Server: makes sure the block spawner has room straight away.
override void OnConnected(Player player)Sends the current block to a joining player.
void Resize(ChiselBlockSize toSize)Server: shrinks the block down to a size, dropping wedges as refuse. A carved block is cleared entirely and refunds part of its wood.
bool SetupBlockMap()Editor: fills the size-to-prefab map from the levels list if it's empty. True if it changed.
7 private and internal methods
MemberWhat it is
private void BlockDone(TimberBlock block)When the block is finished, empties the deck and repositions the dock.
private void BlockModified(TimberBlock block)Passes a block's Modified event on to blockModified.
private void Alta.Chunks.ISavableFull.LoadSetup()After loading, lets the current block finish its own setup.
private void NetworkUpdateBlock(IPlayer player, Stream stream)Block message: the server sends the current block's ID; clients wait for it to spawn and set it up.
private void SetCollisionIgnore(List<Collider> colliders, bool isIgnoring)Makes the deck's colliders ignore (or stop ignoring) the given colliders.
private void SetupBlock()Parents the block to the spawn point for its size, hooks its Modified event and ignores collisions with it.
private void UpdateBlock()Server: destroys the current block and spawns a new one for currentSize, then tells clients.

Used in​

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