Skip to content

BlockBuilder

namespace Griff.Modules.BlockWorlds;
public sealed class BlockBuilder : Component

Digs up and puts down the blocks of a Blocks world with the mouse: hold the left button on a block to mine it (it goes in the Inventory), and click the right button to put down the Item (the one picked on the Hotbar). In first person it works on the block straight ahead.

Blocks go down next to another block, never in mid-air or on top of someone.

This is a component: its saved properties are on its component page.

public bool CanBuild { get; set; }

Whether it can put blocks down.

public bool CanMine { get; set; }

Whether it can dig blocks out (with Attack).

public bool Controllable { get; set; }

Untick it to have it ignore the mouse (no digging or building, and its hotbar and crafting ignore their keys): another part of the scene has the player’s input. Its Focus action ticks it and unticks it on everything else the player plays, and another’s Focus takes it back.

public Color Highlight { get; set; }

The color of the outline around the block it’s pointing at. Transparent hides it.

public string? Item { get; set; }

The item it puts down. The Hotbar sets it to whatever’s picked there.

public float MineSpeed { get; set; }

How fast it digs: 2 breaks blocks in half the time.

public ValueTuple<int, int>? PlaceAt { get; }

The empty cell it would put a block in, if any.

public float Progress { get; }

How far through breaking Target it is, from 0 to 1.

public float Reach { get; set; }

How far away it can reach a block, in world units from the middle of the entity.

public ValueTuple<int, int>? Target { get; }

The block it’s pointing at, if any, as a cell of the world’s map.

public string? World { get; set; }

The name of the world’s entity. Empty uses the first Blocks map in the scene.