public struct ModAPI
No description provided
Fields
public const float PixelSize
Constant float value that is the size of a pixel in a vanilla texture
Constant value: 1 / 35f
Properties
public static ModMetaData Metadata { get; internal set; }
Read-only property that returns the mod's metadata. You can access any field of the mod.json here.
public static ModDebugDrawer Draw { get; internal set; }
Read-only property that gives access to debug drawing functionality.
Methods
public static SpawnableAsset FindSpawnable(string name)
Function that returns the first item in the catalog that matches the given name.
public static Category FindCategory(string name)
Function that returns the first category that matches the given name.
public static Sprite LoadSprite(string path, float scale = 1, bool pixelated = true)
Loads and generates a Sprite from the given path (relative to the metadata file). It also accepts an optional scale parameter.This decides how large the texture should appear in game.E.g., when your texture has double the resolution of a regular in-game sprite, you should set the scale to 2.It also accepts a pixelisation parameter that determines the texture filter mode.
public static Texture2D LoadTexture(string path, bool pixelated = true)
Loads a texture from the given path (relative to the metadata file).It accepts a pixelisation parameter that determines the texture filter mode.
public static AudioClip LoadSound(string path)
Loads and generates an AudioClip from the given path (relative to the metadata file). This method only accepts 16 bit .wav files, similar to the custom Jukebox folder.
public static Cartridge FindCartridge(string name)
Function that returns the first gun cartridge in the game that exactly matches the input name.
public static PhysicalProperties FindPhysicalProperties(string name)
Function that returns the first PhysicalProperties in the game that exactly matches the input name. PhysicalProperties is a class that describes an object's physical properties.
public static Material FindMaterial(string name)
Function that returns the first material in the game that exactly matches the input name.
public static GameObject CreateParticleEffect(string name, Vector2 position)
Creates the specified particle effect at the given position.
public static void Register(Modification modification)
This function registers an item modification to the catalog. The catalog will read this modification and add it to the item list (toybox).
public static void Register()
This function registers a behaviour that should be handled globally in the background. Treat your behaviour as if it was created at level load.
public static void RegisterTool(string name, string description, Sprite icon, string parent = null)
This function registers a type (inherting from ToolBehaviour) as a new tool.
public static void RegisterPower(string name, string description, Sprite icon, string parent = null)
This function registers a type (inherting from ToolBehaviour) as a new power.
public static void RegisterInput(string name, string uniqueId, KeyCode defaultKey)
This function regsiters a new input control to the game. It should be called in the OnLoad function.It will appear in the key rebinding menu. Use InputSystem.Down(string)
to check if the input is pressed.
public static void RegisterCategory(string name, string description, Sprite icon)
This function registers a new category to the catalog. The catalog will add the new category to the dropdown list.
public static void Notify(object message)
Shows a temporary notification in the bottom-right of the screen.
public static GameObject CreatePhysicalObject(string name, Sprite sprite)
Creates a GameObject with the given sprite and initialises all the necessary components for you. Creates a BoxCollider2D by default but this can be destroyed.
public static LightSprite CreateLight(Transform parent, Color color, float radius = 5, float brightness = 1.5f)
Creates a light glow sprite. Returns a LightSprite component that has Color, Brightness, Radius properties.
public static void KeepExtraObjects()
Calling this in your AfterSpawn function will prevent the automatic removal of some original object children. For firearms with animations, this includes the animated parts.
public static void RegisterLiquid(string id, Liquid liquidInstance)
Lets the game know that a new liquid exists.A liquid cannot be used if it is not registered.
The given identity must be globally unique.
Note that this method can only be called after or during map load.
public static void DeleteJSON(in string path)
Delete the JSON file at the given path.The output path. Has to end with .json and has to stay inside the game mod directory.
public static void SerialiseJSON(in object obj, in string path)
Serialise the fields of an object to disk in JSON format. The given path is relative to the mods directory.The object. Not that this cannot be an engine type.The output path. Has to end with .json and has to stay inside the game mod directory.
public static T DeserialiseJSON(in string path)
Deserialise the JSON data at the given path. The given path is relative to the mods directory.The input path. Has to end with .json and has to stay inside the game directory.