Skip to main content

Instruction

An abstract class in Root.Township, Alta.Static.

One cached world-generation step (spawn, spline, forest core or river core) that can be saved to a stream and replayed later. Subclasses are SpawnInstruction, SplineInstruction, ForestGCoreInstruction and RiverGCoreInstruction.

Constructors​

MemberWhat it is
protected Instruction(Instruction.Type type)Creates an Instruction from type.

Fields​

MemberWhat it is
protected static Logger loggerNLog logger shared by instructions.
3 private and internal fields
MemberWhat it is
private static Dictionary<Instruction.Type, Func<Instruction>> createFactory per instruction type, used by Reconstruct to make an empty instruction before reading it.
private static Dictionary<Instruction.Type, Func<StreamReader, object, IInstructionResult>> executeRead-and-run function per instruction type, used by the static Execute.
private Instruction.Type typeThis instruction's type, written as the first 8 bits by Save.

Methods​

MemberWhat it is
static IInstructionResult Execute(StreamReader stream, object context)Runs the instruction. The static overload reads type and data from a stream and runs it without keeping the object.
abstract IInstructionResult Execute(object context)Runs the instruction. The static overload reads type and data from a stream and runs it without keeping the object.
static Instruction Reconstruct(Stream stream)Reads a type id from a stream and builds that instruction from the data that follows.
void Save(Stream stream)Writes the instruction's type id, then its own data.
IInstructionResult SerializeAndExecute(Stream stream, object context)Reads the instruction's fields from a stream and runs it straight away.
protected abstract void SerializeInternal(Stream stream)Reads or writes the instruction's own fields.

Used in​

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