Skip to content

Blocks

namespace Griff.Modules.BlockWorlds;
public sealed class Blocks : Component, ILightSource

Makes a Tilemap a world of blocks to dig up and build with: what each tile gives when it’s mined, what each item puts down, how long blocks take to break, blocks that can’t be broken, sand that falls, and torches that glow. A BlockBuilder on the player does the digging and building.

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

public string? BreakEffect { get; set; }

A prefab spawned where a block breaks, e.g. a puff of dust.

public string? BreakSound { get; set; }

A sound played when a block breaks.

public float DarkDepth { get; set; }

How far below the surface it takes to get fully dark, in world units.

public string? DigSound { get; set; }

A sound played while digging, each time a block cracks a little more.

public string? Drops { get; set; }

Tiles that give something else when mined: a tile and an item, separated by commas, e.g. “0 Dirt, 6 Sapling”. “6 nothing” gives nothing.

public string? FallingTiles { get; set; }

Tiles that fall when there’s nothing under them, like sand and gravel: tile numbers and ranges.

public Color GlowColor { get; set; }

The color of the light glowing tiles give off.

public float GlowRadius { get; set; }

How far the light of a glowing tile reaches, in world units.

public string? GlowingTiles { get; set; }

Tiles that give off light, like torches and lava: tile numbers and ranges. They light up a dark scene (a camera with an Ambient light) like a Light would.

public string? Hardness { get; set; }

Blocks that take longer (or less long) to break: tiles and seconds, separated by commas, e.g. “2 0.8, 3-4 1.2”.

public IReadOnlyList<string> Items { get; set; }

The blocks the player can carry and put down, one per row: the item’s name and its tile, e.g. “Dirt 1”. Mining a tile gives the item named for it here, unless Drops says otherwise.

public float MineTime { get; set; }

Seconds it takes to break a block, unless Hardness says otherwise.

public string? PlaceSound { get; set; }

A sound played when a block is put down.

public string? SaveAs { get; set; }

A name to keep the world under in the game’s save data, e.g. “World”: what was dug and built comes back next time the game runs, instead of a new world. Empty starts over each time.

public string? Unbreakable { get; set; }

Tiles that can’t be broken, like the bottom of the world: tile numbers and ranges, e.g. “9”.

public Color Underground { get; set; }

How dark it gets underground: as the camera goes below the ground (where it was when the game started), its light fades to this color, and torches and other glowing blocks light the way. Transparent keeps it bright everywhere.

public string? DropOf(int tile)

The item mining tile gives, or null for nothing.

public bool Falls(int tile)
public bool Glows(int tile)
public bool IsUnbreakable(int tile)
public string? NameOf(int tile)

The name of the item that puts down tile, or null.

public int TileOf(string? item)

The tile item puts down, or -1 if it isn’t a block.

public float TimeToBreak(int tile)

Seconds it takes to break tile: its Hardness, or MineTime.