Skip to main content

Plugin

A class in Root.Township, Alta.Caves.

A cave generation step asset (blob, tunnels, crystals, structures and so on), made of MapGeneratorParts that write values into a per-chunk layer. Run through a PluginInstance for each cave layer.

Constructors​

MemberWhat it is
Plugin()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

9 private and internal fields
MemberWhat it is
private Element elementBacking field for Element. The base Render spawns this element's prefab.
private GenerationStage generationStageBacking field for Stage, the generation stage the plugin runs in.
private bool isDynamicBacking field for IsDynamic (formerly isServerOnly). Dynamic plugins only run when the generator generates dynamic content.
private bool isEnabledBacking field for IsEnabled. Disabled plugins make instances that skip modify and render.
private bool isNonZeroListCreatedBacking field for IsNonZeroListCreated. If set, each layer builds a list of its non-zero cells after generation.
private int layerHeightBacking field for LayerHeight, the Y size of this plugin's chunk layer.
private int layerOverflowXZBacking field for LayerOverflowXZ: extra cells the layer reaches past each chunk edge. 1 by default.
private List<MapGeneratorPart> partsBacking field for Parts, the generator parts that modify each chunk in order.
private int pluginIdentifierBacking field for PluginIdentifier. Seeds the per-plugin random hash and is cached in generated loot saves.

Properties​

MemberWhat it is
Element Element { get; }Optional element whose prefab the default Render spawns.
bool IsDynamic { get; }Marks plugins that place saved things (crystals, structures, totems). They only run when a layer is first generated on the server.
bool IsEnabled { get; }Turns the plugin off entirely when false.
bool IsNonZeroListCreated { get; }When true, the chunk layer builds a list of its non-zero values for later passes such as spawners.
int LayerHeight { get; }Height in cells of this plugin's value layer in each map chunk.
int LayerOverflowXZ { get; }Extra cells kept around each chunk edge in this plugin's layer, so parts can read past the border.
List<MapGeneratorPart> Parts { get; }The generator parts run in order by Modify.
int PluginIdentifier { get; }Stable id that seeds the plugin's randomness. Set from the instance id if it is 0 or less.
GenerationStage Stage { get; }Which generation stage the plugin belongs to.

Methods​

MemberWhat it is
virtual PluginInstance GetInstance(IGenerator generator)Makes a PluginInstance of this plugin for a generator.
virtual void Modify(MapChunk chunk, IPartInstance[] parts)Runs each part on the map chunk. Subclasses can change this.
void RegenerateIdentifier()Editor: sets PluginIdentifier from the asset's instance id.
virtual IEnumerator Render(MapChunk chunk, PluginInstance pluginInstance) (iterator)Coroutine that spawns Element's prefab for the chunk, if there is one.
1 private and internal method
MemberWhat it is
private void OnValidate()Editor: gives the plugin a new identifier if it has none.

Used in​

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