Skip to content

API Interop

JonataOliveiraa edited this page Nov 14, 2026 · 1 revision
Reference

API reference · generated by tools/docs/ApiReference, do not edit by hand

How C# reaches the mobile game: handles to game objects, collections and hook helpers. All of it is only in Bunny Loader, because tModLoader runs on the game's own objects.

GameArray

struct BunnyLoader.Interop.GameArray : IGameObject · only in Bunny Loader

An array of the game, such as Main.npc. Index it as a C# array. foreach and LINQ work over a copy, so use for in code that runs every frame.

Member Kind tModLoader What it does
IntPtr Pointer field only here The array's address in the game.
new GameArray(IntPtr pointer) constructor only here Creates an instance.
GameArray<T> New(GameClass element, int length) static method only here Creates an array of the game with this element class.
GameArray<T> Resized(int length) method only here A new array of this length, with the same content.
bool IsNull property only here Whether there is no array.
int Length property only here How many it holds.
ref T this[int index] indexer only here A reference to one element. Throws when out of range.
Span<T> AsSpan() method only here The content as a Span, without copying.
Span<T>.Enumerator GetEnumerator() method only here Walks the items in foreach.

GameArray2D

struct BunnyLoader.Interop.GameArray2D : IGameObject · only in Bunny Loader

A two-dimensional array of the game.

Member Kind tModLoader What it does
IntPtr Pointer field only here The array's address in the game.
new GameArray2D(IntPtr pointer) constructor only here Creates an instance.
bool IsNull property only here Whether there is no array.
int GetLength(int dimension) method only here The length of one dimension.
ref T this[int i, int j] indexer only here Reads or writes one entry.

GameClass

class BunnyLoader.Interop.GameClass · only in Bunny Loader

A class of the game by namespace and name, to create arrays of it.

Member Kind tModLoader What it does
new GameClass(string ns, string name, string nested) constructor only here Creates an instance.
string FullName property only here The class's full name in the game.
IntPtr Handle property only here The class's address in the game.

GameConfiguration

struct Terraria.IO.GameConfiguration

What Bunny Loader adds to the game's settings file.

Member Kind tModLoader What it does
T Get<T>(string entry) method same Reads a value of the world generation's settings.

GameDictionary

struct BunnyLoader.Interop.GameDictionary · only in Bunny Loader

A Dictionary of the game. Wrap the field: new GameDictionary(field).

Member Kind tModLoader What it does
new GameDictionary(IntPtr dictionary) constructor only here Creates an instance.
new GameDictionary(GameObject dictionary) constructor only here Creates an instance.
bool IsNull property only here Whether there is no dictionary.
int Count property only here How many items it holds.
bool TryGetValue<TKey, TValue>(TKey key, out TValue value) method only here Reads an entry if there is one.
bool ContainsKey<TKey>(TKey key) method only here Whether there is an entry for this key.
void Set<TKey, TValue>(TKey key, TValue value) method only here Writes one entry.
KeyValuePair<int, int>[] IntEntries() method only here Copies an int to int dictionary.
bool Remove<TKey>(TKey key) method only here Removes an entry.

GameException

class BunnyLoader.Interop.GameException : Exception · only in Bunny Loader

An exception thrown by the game's code, carried into C#.

Member Kind tModLoader What it does
new GameException(string message) constructor only here Creates an instance.

GameHandle

class BunnyLoader.Interop.GameHandle : IDisposable · only in Bunny Loader

Holds a game object so the game's garbage collector keeps it. Needed for any object you keep past the current call.

Member Kind tModLoader What it does
new GameHandle(IntPtr obj) constructor only here Creates an instance.
IntPtr Target property only here The object, kept safe from the game's garbage collector while the handle lives.
void Dispose() method only here Lets the object go.

GameList

struct BunnyLoader.Interop.GameList · only in Bunny Loader

A List of the game. Wrap the field: new GameList(field).

Member Kind tModLoader What it does
new GameList(IntPtr list) constructor only here Creates an instance.
new GameList(GameObject list) constructor only here Creates an instance.
bool IsNull property only here Whether there is no list.
int Count property only here How many items it holds.
IntPtr this[int index] indexer only here Reads or writes one entry.
T Get<T>(int index) method only here Reads one element as T.
bool Contains<T>(T value) method only here Whether it holds this value.
void Add(IntPtr item) method only here Adds at the end.
void Add<T>(T item) method only here Adds at the end.
void Insert(int index, IntPtr item) method only here Adds at a position.
int IndexOf(IntPtr item) method only here The position of an object, or -1.
void RemoveAt(int index) method only here Removes one by position.

GameListExtensions

static class Terraria.GameListExtensions · only in Bunny Loader

Helper for List<int> fields of the game, through GameObject.

Member Kind tModLoader What it does
void Add(this GameObject list, int value) static method only here Adds an int to a game list.

GameNullable

struct BunnyLoader.Interop.GameNullable · only in Bunny Loader

int? and friends of the game. HasValue and Value work as in C#.

Member Kind tModLoader What it does
new GameNullable(T value) constructor only here Creates an instance.
bool HasValue property only here Whether it has a value.
T Value property only here The value. Throws when it has none.
T GetValueOrDefault(T fallback) method only here The value, or this fallback.
string ToString() override only here The text form of this value.

GameObject

struct BunnyLoader.Interop.GameObject : IGameObject · only in Bunny Loader

Any object of the game, as a pointer. IsNull says if it is empty.

Member Kind tModLoader What it does
IntPtr Pointer field only here The object's address in the game.
new GameObject(IntPtr pointer) constructor only here Creates an instance.
bool IsNull property only here Whether there is no object.
string ClassName property only here The object's class name.
bool Equals(GameObject other) method only here Whether both hold the same value.
bool Equals(object obj) override only here Whether both hold the same value.
int GetHashCode() override only here The hash of this value.
string ToString() override only here The text form of this value.

GameString

struct BunnyLoader.Interop.GameString : IGameObject · only in Bunny Loader

A string of the game. It converts to and from a C# string by itself.

Member Kind tModLoader What it does
IntPtr Pointer field only here The string's address in the game.
new GameString(IntPtr pointer) constructor only here Creates an instance.
bool IsNull property only here Whether there is no string.
int Length property only here How many characters it has.
string ToString() override only here The text form of this value.
string Read(IntPtr str) static method only here A C# string from a string of the game.
IntPtr New(string value) static method only here A string of the game from a C# string, as an address.
GameString From(string value) static method only here A GameString from a C# string.

GameTipData

class Terraria.ModLoader.GameTipData

Wrapper class for a LocalizedText and visibility field that has intended use with modification of Game Tips.

Member Kind tModLoader What it does
LocalizedText TipText property same The text of the tip.
Mod Mod property same The mod instance this tip belongs to. This value is null for vanilla tips.
string Name property same Retrieves the "name" of this GameTip, which is the Key excluding the beginning Mods.ModName.GameTips portion. For example, if the key was "Mods.ExampleMod.GameTips.ExampleTip", this would return "ExampleTip".
string FullName property same Retrieves the FULL "name" of this GameTip, which includes the Mod and this tip's Name. For example, if this tip was from ExampleMod and was named "ExampleTip", this would return "ExampleMod/ExampleTip"
new GameTipData(LocalizedText text, Mod mod) constructor same Creates an instance.
void Hide() method same Until reload, prevents this tip from ever appearing during loading screens.

GameTipID

static class Terraria.ModLoader.GameTipID

Numbers of the game's tips. Only two have a name here. tModLoader names all of them.

Member Kind tModLoader What it does
int BloodMoonZombieDoorOpening static field same "During a Blood Moon, Zombies can open doors."
int SolarEclipseCreepyMonsters static field same "During a Solar Eclipse, be on the lookout for tons of strange and creepy monsters."

IGameObject

interface BunnyLoader.Interop.IGameObject · only in Bunny Loader

Every type that wraps a game object, with its Pointer.

Member Kind tModLoader What it does
IntPtr Pointer hook only here The object's address in the game.

← Interface, input and config  ·  Everything else →

Clone this wiki locally