Skip to content

Generator (3.0)

ScalarVector edited this page Mar 11, 2025 · 1 revision

In this class you will find various utilities related to generating structures and getting important information from them such as their dimensions.

Methods

IsInBounds

public static bool IsInBounds(StructureData data, Point16 pos)

Summary

Helper to check bounds on a generation call. You can also use this to check the bounds of your own structure.

Parameters

  • data: The StructureData to check.
  • pos: The position to check from, this would be the top-left of the structure.

Returns

  • If the structure is in bounds or not.

IsInBounds

public static bool IsInBounds(string path, Mod mod, Point16 pos, bool fullPath = false)

Summary

Helper to check bounds on a generation call. You can also use this to check the bounds of your own structure.

Parameters

  • path: The path to search for the structure file.
  • mod: The mod to search for the structure file in.
  • pos: The position to check from, this would be the top-left of the structure.
  • fullPath: If the search path starts at the root of your file system(true) or the provided mod(false). This should usually be false.

Returns

  • If the structure is in bounds or not.

GetStructureDimensions

public static Point16 GetStructureDimensions(string path, Mod mod, bool fullPath = false)

Summary

Gets the dimensions (width and height) of a structure.

Parameters

  • path: The path to search for the structure file. If it is in a mod, it should not include the mod's name (for example, it should be "structures/coolHouse", not "CoolHouseMod/structures/coolHouse").
  • mod: The mod to search for the structure file in.
  • fullPath: If the search path starts at the root of your file system(true) or the provided mod(false). This should usually be false.

GetStructureData

public static StructureData GetStructureData(string path, Mod mod, bool fullPath = false)

Summary

Gets the StructureData for a given path in a given mod (or absolute path if fullPath is true). Will attempt to retrieve from the StructureData cache first if possible before doing I/O.

Parameters

  • path: The path to search for the structure file. If it is in a mod, it should not include the mod's name (for example, it should be "structures/coolHouse", not "CoolHouseMod/structures/coolHouse").
  • mod: The mod to search for the structure file in.
  • fullPath: If the search path starts at the root of your file system(true) or the provided mod(false). This should usually be false.

Returns

  • The StructureData associated with the desired file.

Exceptions

  • FileNotFoundException

GenerateStructure

public static void GenerateStructure(string path, Point16 pos, Mod mod, bool fullPath = false, bool ignoreNull = false, GenFlags flags = GenFlags.None)

Summary

This method generates a structure from a structure file.

Parameters

  • path: The path to search for the structure file. If it is in a mod, it should not include the mod's name (for example, it should be "structures/coolHouse", not "CoolHouseMod/structures/coolHouse").
  • pos: The position in the world to place the top-left of the structure, in tile coordinates.
  • mod: The mod to search for the structure file in.
  • fullPath: If the search path starts at the root of your file system(true) or the provided mod(false). This should usually be false.
  • ignoreNull: If the structure should respect the normal behavior of null tiles or not. This should never be true if you're using the mod as a dll reference.
  • flags: Allows you to pass flags for special generation behavior. See GenFlags.

GenerateFromData

public static void GenerateFromData(StructureData data, Point16 pos, bool ignoreNull = false, GenFlags flags = GenFlags.None)

Summary

Directly generates a given StructureData into the world. Use this directly if you have a StructureData object in memory you want to generate from.

Parameters

  • data: The StructureData to generate.
  • pos: The position in the world to place the top-left of the structure, in tile coordinates.
  • ignoreNull: If the structure should respect the normal behavior of null tiles or not. This should never be true if you're using the mod as a dll reference.
  • flags: Allows you to pass flags for special generation behavior. See GenFlags.
Clone this wiki locally