Spawner
namespace Griff.Scenes;
public sealed class Spawner : ComponentSpawns copies of a prefab every Interval seconds at its position, with no code: enemy waves, falling rocks, collectibles that come back. Limit it with Count and MaxAlive. With Beats set, it spawns on the beat of a BeatClock instead.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”public IReadOnlyList<Entity> Alive { get; }Its spawns still in the scene.
BeatOffset
Section titled “BeatOffset”public int BeatOffset { get; set; }Steps this many beats later: with two spawners on every 2 beats, one 1 beat later, they take turns.
public int Beats { get; set; }Steps to the music of a BeatClock: spawns on every this many beats instead of every Interval seconds, once Delay has passed. A spawn that has no room waits for the next. 0 goes by seconds.
public string? Clock { get; set; }The entity whose BeatClock it steps to. Empty follows the first in the scene.
public int Count { get; set; }How many to spawn in all; 0 keeps going forever.
public float Delay { get; set; }Seconds before the first spawn.
Interval
Section titled “Interval”public float Interval { get; set; }Seconds between spawns (unless it steps to the Beats).
IsFinished
Section titled “IsFinished”public bool IsFinished { get; }True once it has spawned Count.
MaxAlive
Section titled “MaxAlive”public int MaxAlive { get; set; }How many of its spawns may be around at once; 0 is no limit. When one is destroyed it makes room, and the next spawns as soon as it’s due.
NeedsFlag
Section titled “NeedsFlag”public string? NeedsFlag { get; set; }A flag that has to be set before it starts spawning, e.g. “AlarmRaised” (set by a trigger’s Set Flag, a dialogue’s “[set AlarmRaised]” or a script’s Game.SetFlag), or “not AlarmRaised” to spawn only while it isn’t. Its count down waits until then; its Spawn action still spawns one.
Prefab
Section titled “Prefab”public string? Prefab { get; set; }The prefab to spawn, e.g. “Enemy” (Assets/Prefabs/Enemy.prefab).
Radius
Section titled “Radius”public float Radius { get; set; }Spawns land at a random spot up to this far from the spawner.
Running
Section titled “Running”public bool Running { get; set; }Untick it to stop spawning for now. Switches tick and untick it.
Spawned
Section titled “Spawned”public int Spawned { get; }How many it has spawned.
Events
Section titled “Events”EntitySpawned
Section titled “EntitySpawned”public event Action<Entity>? EntitySpawnedRaised with each new spawn, e.g. to give it a speed or a target.