GameMod Reference - FujiAPI/Fuji GitHub Wiki

In Fuji, the GameMod class is the entry point for a lot of actions within code mods. GameMod is an abstract class with a number of virtual functions that you can override to subscribe to various events in the game. This page will document the various events and functions the GameMod provides and how to use them.

How To Use

To subscribe to gamemod events, simply override the function in your custom gamemod class:

public override void OnActorCreated(Actor actor)
{
    // Your Code Here
}

Make sure you use the override keyword to properly override the virtual function.

You only need to override functions that you actually need to use. Anything else can just be ignored.

These events will not get called if the mod is disabled (Other than OnModUnloaded), so you don't need to worry about managing that

Event Types

Events

Mod

Event Description
OnModLoaded() Called when the Mod is loaded if it is enabled. Also called during reload after it gets enabled.
OnModUnloaded() Called after the mod gets disabled. Note: this does not get called immediately, but will get called when the game next reloads.
Update(float deltaTime) Called once every frame after the scene is updated. Note: This also gets called on the title screen and level select.

Player

Event Description
OnPlayerKilled(Player player) Called when a player is killed.
OnPlayerLanded(Player player) Called whenever a player lands on the ground after a jump or fall.
OnPlayerJumped(Player player, Player.JumpType jumpType) Called when a player jumps. jumpType gives you what type of jump (i.e. Normal Jump, Wall Jump, Skid Jump, Dash Jump)
OnPlayerStateChanged(Player player, Player.States? state) Called whenever a player's state changes. state gives you the new state it changes to.
OnPlayerSkinChange(Player player, SkinInfo skin) Called when a player's skin changes.
OnItemPickup(Player player, IPickup item) Called when a player picks up something that implements IPickup.

Actor

Event Description
OnActorCreated(Actor actor) Called when an actor is first created. Note: This is before it gets added to the World.
OnActorAdded(Actor actor) Called when an Actor gets first added to the world
OnActorDestroyed(Actor actor) Called when an Actor is destroyed.

Map

Event Description
OnPreMapLoaded(World world, Map map) Called right before the Map load starts. This is the ideal place to register custom mod actors
OnMapLoaded(Map map) Called after a map is finished loading.

Game

Event Description
OnGameLoaded(Game game) Called when the game is first loaded.
OnSceneEntered(Scene scene) Called after a scene transition either when a scene is first loaded, or reloaded.
OnWorldLoaded(World world) Called after the world finishes loading.
OnAssetsLoaded() Called after all assets have been loaded or reloaded.

Properties

The GameMod class also provides a number of additional properties to access various bits of data.

Reference Properties

These properties give you an easy reference to common objects used by the game

Property Description
Game? Game Convenience property to get a reference to the game. Equivalent to calling Game.Instance. Can be null.
World? World Convenience property to get a reference to the current World. Equivalent to calling Game.Instance?.World. Can be null.
Map? Map Convenience property to get a reference to the current Map. Equivalent to calling Game.Instance?.World?.Map. Can be null.
Player? Player Convenience property to get a reference to the Player. Equivalent to calling Game.Instance?.World?.Get<Player>(). Can be null.

Asset Dictionaries And Lists

These properties provide readonly access to assets associated with this specific mod. This is similar to how you'd access assets from the Assets class, but they'll pull directly from the assets associated with this mod. These can be used to bypass asset replacement and naming conflict checks which may be more efficient.

Property Description
IReadOnlyDictionary<string, Map> ModMaps Dictionary containing all maps loaded by this mod, indexed by the map filename.
IReadOnlyDictionary<string, SkinnedTemplate> ModModels Dictionary containing all models loaded by this mod, indexed by the model filename.
IReadOnlyDictionary<string, Texture> ModTextures Dictionary containing Textures loaded by this mod, indexed by the texture filename.
IReadOnlyDictionary<string, Subtexture> ModSubTextures Dictionary containing all subtextures(sprites) loaded by this mod, indexed by the image filename.
IReadOnlyDictionary<string, Shader> ModShaders Dictionary containing all shaders loaded by this mod, indexed by the shader filename.
IReadOnlyDictionary<string, Font> ModFonts Dictionary containing all fonts loaded by this mod, indexed by the font filename.
IReadOnlyDictionary<string, FMOD.Sound> ModSounds Dictionary containing all wav Sounds loaded by this mod, indexed by the sound filename. Note: This does not include Sounds loaded from FMOD banks.
IReadOnlyDictionary<string, FMOD.Sound> ModMusic Dictionary containing all wav Music Sounds loaded by this mod, indexed by the filename. Note: This does not include Sounds loaded from FMOD banks.
IReadOnlyDictionary<string, Dictionary<string, string>> ModStrings Dictionary containing all non-dialog strings loaded by this mod. The outer dictionary is indexed by the Language ID, and the inner dictionary is indexed by the string key. So to access the confirm key from the base game language for example, you'd write ModStrings["english"]["Confirm"]
IReadOnlyDictionary<string, Dictionary<string, List<Language.Line>>> ModDialogLines Dictionary containing all maps loaded by this mod. The outer dictionary is indexed by the Language ID, and the inner dictionary is indexed by the the dialog id. So to access the Granny1 key from the base game language for example, you'd write ModStrings["english"]["Granny1"], which would give you a list of all the dialog lines associated with that chunk of dialog.
IReadOnlyList<LevelInfo> ModLevels List containing all the LevelInfo objects that were loaded from the Levels.json file.
⚠️ **GitHub.com Fallback** ⚠️