Permanent Mod
The PermanentMod service is responsible for discovering, identifying, and sorting mods at application startup. it is the foundation of the Gnosis Modding System, handling global state patches and asset registration.
Code path: Runtime/GnosisEngine/Source/Services/Persistent/Services/Mod/GnosisPermanentModService.cs.
State
The service discovers mods in Application.persistentDataPath/Mods/ and loads their manifests.
| Key | Branch | Purpose |
|---|---|---|
discoveredMods | Internal | List of all found mod manifests. |
loadedMods | Internal | List of successfully loaded mods, sorted by priority. |
Manifest Structure (manifest.json)
manifest.json
{
"modId": "com.example.mod",
"name": "My Cool Mod",
"description": "Adds awesome things.",
"version": "1.0.0",
"author": "Gnosis Developer",
"minEngineVersion": "0.1.0",
"loadPriority": 10,
"dependencies": [],
"tags": ["VFX", "NewServices"]
}Lifecycle Actions
- Discovery: Scans the
Mods/folder for subdirectories containing amanifest.json. - Validation: Checks
minEngineVersioncompatibility. - Sorting: Orders mods based on
loadPriorityanddependencies. - Data Loading:
- Merges
Data/persistent.jsoninto the globalPersistentstate. - Processes
Data/Configuration/mappings. - Automatically registers
I18nfiles fromData/Configuration/I18n/.
- Merges
- Asset Registration: Automatically scans
Assets/for.png,.jpg(as Sprites) and.wav,.mp3,.ogg(as AudioClips). - Logic Initialization: Loads
Scripts/main.luaand creates an isolated Lua environment for each mod.
Events
The service publishes events related to mod loading (see GnosisModEvents in Runtime/GnosisEngine/Source/Services/Persistent/Services/Mod/GnosisModEvents.cs).
| Event id | Role |
|---|---|
FACT_MODS_DISCOVERED | Published after scanning the mods folder. |
FACT_MOD_LOADED | Published after an individual mod is successfully initialized. |
Functions
| Function | Parameters | Behavior |
|---|---|---|
GetLoadedMods | — | Returns a list of all active mod manifests. |
IsModLoaded | modId | Returns true if the specified mod is active. |
CallModFunction | modId, functionName, parameters | Invokes a function in the mod’s permanent Lua environment. |
Related
Last updated on