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.
- Listed in World, chunks and saving
- Inherits or implements
ICacheable - Documented in Static objects
Constructors
| Member | What it is |
|---|---|
InstructionSet() | Creates an InstructionSet with default values. |
Fields
6 private and internal fields
| Member | What it is |
|---|---|
private ConcurrentQueue<Instruction> adding | Thread-safe queue of instructions added (possibly from generation threads) that are not yet in instructions. |
private List<Instruction> instructions | Instructions held in memory. |
private static Logger logger | NLog logger for this class. |
private StreamReader reader | Cache stream the set was loaded from. Instructions are read from it lazily on execute or GetInstructions. |
private uint readerOffset | Bit position in reader where this set's data starts. |
private List<IInstructionResult> results | Backing field for Results: what each executed instruction made, so Undo can remove it. |
Properties
| Member | What 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
| Member | What 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
Used in
Members of other types that take, return or hold a InstructionSet:
CliffFill.GenerateInternal, CutoutPathEdgeFill.GenerateInternal, ForestBridges.GenerateStatic, ForestEncounters.GenerateStatic, ForestFill.GenerateInternal, ForestFillCore.AddInstructions, ForestFillCore.GenerateInternal, ForestFillCore.GenerateStatic, ForestGenerator.GetChunkInstructionsAsync, ForestGenerator.instructions, IForestGeneration.GenerateStatic, RiverCenterFill.GenerateInternal, RiverCollision.GenerateStatic, RiverEdgeFill.GenerateInternal, RiverEncounters.GenerateStatic.