-
Notifications
You must be signed in to change notification settings - Fork 9
Generator Class (LEGACY 2.0)
Update: As of 3.0 this API can be accessed through StructureHelper.API.LegacyGenerator instead.
The Generator class allows you to programmatically generate your saved structures in the game, whenever you want! While normally this would occur during world generation, you're free to use it at any point. A good example of this might be an event similar to meteors, where updates to the world would occur mid-game.
public static bool GenerateStructure(string path, Point16 pos, Mod mod, bool fullPath = false, bool ignoreNull = false)
The GenerateStructure method allows you to place a structure from a file into the world. Note that it is your responsibility to ensure that your structures dont try to generate outside of the bounds of the world! You can use GetDimensions or GetMultistructureDimensions to check for this.
string path The path to your structure file within your mod - this should not include your mod's folder, only the path beyond it.
Point16 pos The position in the world in which you want your structure to generate, in tile coordinates.
Mod mod An instance of your mod class.
bool fullPath = false Indicates if you want to use a fully qualified path to get the structure file instead of one from your mod - generally should only be used for debugging.
bool ignoreNull = false 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.
Returns if the structure was able to be generated or not.
public static bool GenerateMultistructureRandom(string path, Point16 pos, Mod mod, bool fullPath = false, bool ignoreNull = false)
The GenerateMultistructureRandom will pick a random structure from a multistructure file and place it in the world.
string path The path to your multistructure file within your mod - this should not include your mod's folder, only the path beyond it.
Point16 pos The position in the world in which you want your structure to generate, in tile coordinates.
Mod mod An instance of your mod class.
bool fullPath = false Indicates if you want to use a fully qualified path to get the structure file instead of one from your mod - generally should only be used for debugging.
bool ignoreNull = false 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.
Returns if the structure was able to be generated or not.
public static bool GenerateMultistructureSpecific(string path, Point16 pos, Mod mod, int index, bool fullPath = false, bool ignoreNull = false)
The GenerateMultistructureSpecific method allows you to select a specific structure from a multistructure file and place it in the world.
string path The path to your multistructure file within your mod - this should not include your mod's folder, only the path beyond it.
Point16 pos The position in the world in which you want your structure to generate, in tile coordinates.
Mod mod An instance of your mod class.
int index The index of the structure you want to generate out of the multistructure file, structure indicies are 0-based and match the order they were saved in.
bool fullPath = false Indicates if you want to use a fully qualified path to get the structure file instead of one from your mod - generally should only be used for debugging.
bool ignoreNull = false 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.
Returns if the structure was able to be generated or not.
public static bool GetDimensions(string path, Mod mod, ref Point16 dims, bool fullPath = false)
The GetDimensions method allows you to check the dimensions of a structure from a file.
string path The path to your structure file within your mod - this should not include your mod's folder, only the path beyond it.
Mod mod An instance of your mod class.
ref Point16 dims The Point16 variable which you want to be set to the dimensions of the structure.
bool fullPath = false Indicates if you want to use a fully qualified path to get the structure file instead of one from your mod - generally should only be used for debugging.
Returns if the dimensions were able to be grabbed or not.
public static bool GetMultistructureDimensions(string path, Mod mod, int index, ref Point16 dims, bool fullPath = false)
The GetMultistructureDimensions method allows you to check the dimensions of a specific structure from a multistructure file.
string path The path to your structure file within your mod - this should not include your mod's folder, only the path beyond it.
Mod mod An instance of your mod class.
int index The index of the structure you want to get the dimensions of out of the multistructure file, structure indicies are 0-based and match the order they were saved in.
ref Point16 dims The Point16 variable which you want to be set to the dimensions of the structure.
bool fullPath = false Indicates if you want to use a fully qualified path to get the structure file instead of one from your mod - generally should only be used for debugging.
Returns if the dimensions were able to be grabbed or not.
public static bool? IsMultistructure(string path, Mod mod)
the IsMultistructure method allows you to programmatically check if a file is a structure, multistructure, or invalid file.
string path The path of the file to check within your mod - this should not include your mod's folder, only the path beyond it.
Mod mod An instance of your mod class.
Returns true if a file is a multistructure, false if it is a regular structure, and null if it is invalid
