Blocks
namespace Griff.Modules.BlockWorlds;
public sealed class Blocks : Component, ILightSourceMakes 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.
Properties
Section titled “Properties”BreakEffect
Section titled “BreakEffect”public string? BreakEffect { get; set; }A prefab spawned where a block breaks, e.g. a puff of dust.
BreakSound
Section titled “BreakSound”public string? BreakSound { get; set; }A sound played when a block breaks.
DarkDepth
Section titled “DarkDepth”public float DarkDepth { get; set; }How far below the surface it takes to get fully dark, in world units.
DigSound
Section titled “DigSound”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.
FallingTiles
Section titled “FallingTiles”public string? FallingTiles { get; set; }Tiles that fall when there’s nothing under them, like sand and gravel: tile numbers and ranges.
GlowColor
Section titled “GlowColor”public Color GlowColor { get; set; }The color of the light glowing tiles give off.
GlowRadius
Section titled “GlowRadius”public float GlowRadius { get; set; }How far the light of a glowing tile reaches, in world units.
GlowingTiles
Section titled “GlowingTiles”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.
Hardness
Section titled “Hardness”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.
MineTime
Section titled “MineTime”public float MineTime { get; set; }Seconds it takes to break a block, unless Hardness says otherwise.
PlaceSound
Section titled “PlaceSound”public string? PlaceSound { get; set; }A sound played when a block is put down.
SaveAs
Section titled “SaveAs”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.
Unbreakable
Section titled “Unbreakable”public string? Unbreakable { get; set; }Tiles that can’t be broken, like the bottom of the world: tile numbers and ranges, e.g. “9”.
Underground
Section titled “Underground”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.
Methods
Section titled “Methods”DropOf
Section titled “DropOf”public string? DropOf(int tile)The item mining tile gives, or null for nothing.
public bool Falls(int tile)public bool Glows(int tile)IsUnbreakable
Section titled “IsUnbreakable”public bool IsUnbreakable(int tile)NameOf
Section titled “NameOf”public string? NameOf(int tile)The name of the item that puts down tile, or null.
TileOf
Section titled “TileOf”public int TileOf(string? item)The tile item puts down, or -1 if it isn’t a block.
TimeToBreak
Section titled “TimeToBreak”public float TimeToBreak(int tile)Seconds it takes to break tile: its Hardness, or MineTime.