Skip to main content

InstructionSet

A class in Root.Township, Alta.Static.

A cacheable list of world-generation instructions for one chunk. Forest generation fills it, it saves to the cache, and later replays the instructions a few per frame.

Constructors​

MemberWhat it is
InstructionSet()Creates an InstructionSet with default values.

Fields​

6 private and internal fields
MemberWhat it is
private ConcurrentQueue<Instruction> addingThread-safe queue of instructions added (possibly from generation threads) that are not yet in instructions.
private List<Instruction> instructionsInstructions held in memory.
private static Logger loggerNLog logger for this class.
private StreamReader readerCache stream the set was loaded from. Instructions are read from it lazily on execute or GetInstructions.
private uint readerOffsetBit position in reader where this set's data starts.
private List<IInstructionResult> resultsBacking field for Results: what each executed instruction made, so Undo can remove it.

Properties​

MemberWhat it is
IEnumerable<IInstructionResult> Results { get; }Results of the instructions run so far, kept so they can be undone.
uint Version { get; }Cache format version, always 1.

Methods​

MemberWhat it is
void Add(Instruction instruction)Queues an instruction. Safe to call from other threads.
Task Execute(object context, int instructionsPerFrame = 10)Runs all instructions over several frames (10 per frame by default), also running ones still being added until the given task finishes.
Task Execute(object context, Task addingFinished, int instructionsPerFrame = 10)Runs all instructions over several frames (10 per frame by default), also running ones still being added until the given task finishes.
IEnumerable<Instruction> GetInstructions()Returns all instructions, decoding any still only in the loaded cache stream.
Task SerializeAsync(uint version, Stream stream)Writes the instructions, or on read just remembers the stream so they're decoded when needed.
void Undo()Undoes every result and clears the list.
1 private and internal method
MemberWhat it is
private IEnumerator ExecuteInternal(object context, Task addingFinished, int instructionsPerFrame) (iterator)Coroutine that runs the stored instructions in batches per frame, then any added later, then any still in a loaded stream.

Used in​

Members of other types that take, return or hold a InstructionSet: