FSLoader - robot9706/FSSE GitHub Wiki

FSLoader

FSLoader (or FalloutShelter mod loader) is a library which loads mods and handles hooks patched into the game. The hooks can be used by mods to change the behaviour of the game or even add new content.

Mod dlls are loaded from ".../FalloutShelter_Data/Mods".

ModInfo attribute

This attribute is used by FSLoader to find mods in an assembly. It contains a unique ID of the mod, a display name, an author, a version and an optional description (most of this data is not used yet...).

An example:

...
[ModInfo("unique_id", "My mod", "Me", 1, 0)]
public class MyModClass : Mod
{
...

Hook attribute:

This attribute is used on methods to tell FSLoader which game method is overwritten by a mod method. Multiple mods can hook to the same method, each hooked method is called after each other. The first parameter of a hook method has to be a "CallContext".

Hook signatures can be determined using FSModTool ("Signatures" tab).

An example:

//This is in the game
...
public class TargetClass
{
    public bool TestMethod(int someInt)
    {
        return (someInt == 5);
    }
}
...
//This is a mod
...
[Hook("TargetClass::TestMethod(System.Int32)")]
public void Hook_TestMethod(CallContext context, int someInt)
{
    context.IsHandled = true;
    context.ReturnValue = (someInt == 20);
}
...

CallContext

This object contains info of the source of the hook also controls the hooked method.

Field Description
This This is the object which has the hooked method. If the hooked method is static, this field is null.
IsHandled This field is used to tell if the hooked method is handled by a mod. If it's true that means the method is handled and the hooked method will return. If it's false the hooked method won't return and the original game code will be executed.
ReturnValue If "IsHandled" is true the value of this field will be returned in the hooked method.