Getting Started - norech/scaphandre-engine GitHub Wiki

Install Scaphandre Engine

Download installer archive from releases, extract it into a new folder and then run ScaphandreInstaller.exe, locate your Subnautica installation using Browse folder and then click Install.

How to install a Scaphandre-compatible mod?

You may find a Mods folder inside of Subnautica installation folder. Put mods .dll files inside of it.

DISCLAIMER: We are not responsible of any damage made by mods you installed. Scaphandre Engine does not provide any kind of sandboxing for mods.

Create your first mod

You may now want to create a mod. To do it, you will need Visual Studio 2017 or another IDE supporting the creation of projects using .NET Framework.

You will need to create a shared library project targeting .NET Framework 3.5.

After that, you will need to have the modding API. You can get it using the ScaphandreInstaller.exe, by checking "Create Scaphandre Modding API archive" before clicking Install or Reinstall. After that, an archive named ScaphandreModdingAPI.zip will be created. Extract all the files from the archive into a new subfolder of your solution named ScaphandreModdingAPI. After that, in your new project, you will need to add references to those .dll files.

DISTRIBUTION CONCERNS: The modding API contains parts of Subnautica source code. You SHOULD NOT distribute it in any way. If you share source code, please remove the ScaphandreModdingAPI folder from your project before publishing it and indicate to the contributors the Scaphandre Modding API version you used in your project. When building project, you should only share <Your Project>.dll.

Now you will need to create a main class for your mod. It will be loaded by ScaphandreEngine and be the entry point of your mod. You should be sure that it extends Mod and have a ModInfo annotation like below.

using ScaphandreEngine;

namespace MyMod
{
    [ModInfo(
        name="MyMod",
        version="1.0.0"
    )]
    public class Main : Mod
    {
        public override void Initialize()
        {
            // This code will be run when the plugin is initialized
        }
    }
}

Create a command

To create a command, you will need to create a class extending CommandHandler. Your class should be like this:

using ScaphandreEngine;
using ScaphandreEngine.CommandHandler;

namespace MyMod
{
    public class CustomCommand : CommandBase
    {
        Main mod = Mod.GetMod<Main>();

        public override string GetName()
        {
            return "custom";  // The command name
        }

        public override void Execute(string[] args)
        {
            // The code here will be called when the command is executed
            mod.Logger.Log("Hello World!");
        }
    }
}

After you've created this class, you will need to register it into the registry of your mod using the RegisterCommand method of an GameRegistry instance. You can get one using GameRegistry.ForMod(this).

using ScaphandreEngine;

namespace MyMod
{
    [ModInfo(
        name="MyMod",
        version="1.0.0"
    )]
    public class Main : Mod
    {
        public override void Initialize()
        {
            var registry = GameRegistry.ForMod(this);

            //...

            registry.RegisterCommand(new CustomCommand());
            
            //...
        }
    }
}

Listen to an event

Scaphandre provides a way to listen for events when you need it and execute code. Events listeners are functions that you can place in any registered class instance but it requires you to add an [ListenEvent] tag and to have only one argument: the event you want to listen. Events need to extend Event (ScaphandreEngine.Events.Event).

using ScaphandreEngine;
using ScaphandreEngine.EventHandler;
using ScaphandreEngine.Events;

namespace MyMod
{
    public class CustomEventListener
    {
        Main mod = Mod.GetMod<Main>();

        [ListenEvent]
        public void OnLanguageChange(LanguageChangeEvent @event)
        {
            // The code here will be called when the event is triggered
            mod.Logger.Log("You were in " + @event.PreviousLanguage + " and you are now in " + @event.Language + "!");
        }
    }
}

Event listeners are not loaded fully automatically. You will need to register them into the registry of your mod using the RegisterEvents method of an GameRegistry instance. You can get one using GameRegistry.ForMod(this).

using ScaphandreEngine;

namespace MyMod
{
    [ModInfo(
        name="MyMod",
        version="1.0.0"
    )]
    public class Main : Mod
    {
        public override void Initialize()
        {
            var registry = GameRegistry.ForMod(this);

            //...

            registry.RegisterEvents(new CustomEventListener());
            
            //...
        }
    }
}
⚠️ **GitHub.com Fallback** ⚠️