Skip to main content

StructurePart

A class in Root.Township, the global namespace.

A piece that MiningBaseGenerator can place in a generated mine: its size in tiles, the sides that are gates, solid or air, and limits on how low it can be placed.

Constructors​

MemberWhat it is
StructurePart()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
int xPublic grid coordinate field; not used in this class.
int yPublic grid coordinate field; not used in this class.
int zPublic grid coordinate field; not used in this class.
17 private and internal fields
MemberWhat it is
private StructureSide[,,] airPer-cell air side flags. Backing field for Air.
private StructureSide[,,] connectToAirPer-cell connect-to-air side flags. Backing field for ConnectToAir.
private StructureSide[,,] connectToSolidPer-cell connect-to-solid side flags. Backing field for ConnectToSolid.
private int depthSize of the part in tiles along z. Default 1.
private StructureSide[,,] gatesPer-cell gate side flags. Backing field for Gates.
private int heightSize of the part in tiles along y. Default 1.
private bool isRequiringGateWhen true, MiningBaseGenerator only places the part where a path reaches one of its gates.
private int maximumDropLargest vertical drop MiningBaseGenerator tries when placing the part. No limit by default.
private int maximumYHighest tile y the part may be placed at. -1 means no limit.
private int minimumDropSmallest vertical drop MiningBaseGenerator tries when placing the part.
private int minimumYLowest tile y the part may be placed at. Default -1.
private StructurePart.Cube[] obsoleteOld cube list (formerly cubes), converted to StructureCube children in OnValidate and then cleared.
private StructureSide[,,] solidPer-cell solid side flags. Backing field for Solid.
private StructureCube[] structureCubesCached StructureCube children. Backing field for StructureCubes.
private Transform structureCubesParentTransform whose children are the part's StructureCube components.
private StructureType structureTypeThe StructureType this part belongs to, which sets the tile size.
private int widthSize of the part in tiles along x. Default 1.

Properties​

MemberWhat it is
StructureSide[,,] Air { get; }Per-tile flags of sides that are open air.
StructureSide[,,] ConnectToAir { get; }Per-tile flags of sides that must touch air.
StructureSide[,,] ConnectToSolid { get; }Per-tile flags of sides that must touch solid ground.
int Depth { get; }Size in tiles along z.
StructureSide[,,] Gates { get; }Per-tile flags of sides that are openings, built from the cubes.
int Height { get; }Size in tiles along y.
bool IsRequiringGate { get; }If true, the generator only places this part where a path connects to one of its gates.
int MaximumDrop { get; }Highest drop the generator will try. No limit when left at int.MaxValue.
int MaximumY { get; }Highest tile row the part may be placed at, or -1 for no limit.
int MinimumDrop { get; }Lowest drop (in tiles) below the connecting point the generator will try.
int MinimumY { get; }Lowest tile row the part may be placed at.
StructureSide[,,] Solid { get; }Per-tile flags of sides that are solid.
StructureCube[] StructureCubes { get; }The StructureCube children that describe each tile's sides. Found once and cached.
StructureType StructureType { get; }The structure type this part belongs to, which sets tile size.
int Width { get; }Size in tiles along x.

Methods​

3 private and internal methods
MemberWhat it is
private void InitializeSides()Builds the per-cell side arrays (gates, solid, air and connect masks) from the child StructureCube components.
private void OnDrawGizmosSelected()Editor: draws the part's footprint as a blue box scaled by the structure type's tile size.
private void OnValidate()Editor: makes the Structure Cubes parent if missing and turns old serialized Cube entries into StructureCube objects.

Used in​

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