Skip to content

Crumble

namespace Griff.Scenes;
public sealed class Crumble : Component, IDrawEffect

A platform that gives way, with no code: once something on its Layers stands on it, it shakes for Delay seconds and falls away, coming back Respawn seconds later. Needs a collider.

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

public bool Crumbled { get; set; }

True while it’s gone (its entity is hidden). Saved, so it stays gone when the game rewinds.

public float Delay { get; set; }

Seconds it shakes, once stood on, before it falls away.

public string? Effect { get; set; }

A prefab spawned where it was as it falls away, e.g. a burst of “Rubble”.

public bool IsShaking { get; }

True while it’s shaking, about to go.

public string? Layers { get; set; }

The collision layers that set it off by standing on it, e.g. “Player”. Empty is any body.

public float Respawn { get; set; }

Seconds until it comes back. 0 never comes back.

public Vector2 ShakeOffset { get; }

How far it’s shaken off its place right now; it’s drawn there, while its collider stays put.

public string? Sound { get; set; }

A sound played as it falls away, e.g. “Sounds/crumble.wav”.

public bool AcceptsLayer(string? layer)

True if something on collision layer layer sets it off.

public event Action<Crumble>? Fell

Raised when it falls away.

public event Action<Crumble>? Returned

Raised when it comes back.