Skip to content

Prepare for future development#1

Open
binyamin555 wants to merge 8 commits into
EE-modders:mainfrom
binyamin555:main
Open

Prepare for future development#1
binyamin555 wants to merge 8 commits into
EE-modders:mainfrom
binyamin555:main

Conversation

@binyamin555
Copy link
Copy Markdown

@binyamin555 binyamin555 commented Oct 6, 2025

This PR contains some updates, including:

  • Some types from LLE
  • Access to game options (only PlayerName for now)
  • New event system (IMO it looks better)
  • New modding system

The new modding system tracks the currently executing mod by updating the current mod before and after every call to any function provided by the mod.

For example, before running CreateMod, mod->OnStart and mod->OnUpdate, we set the currently executing mod to that mod. This allows up to track which mod subscribes to which events, and so allow us to automatically unsubscribe from events.

The new modding system is declared inside the ee::modding::core namespace and introduces:

  • ModManager - Manages existing and loads new mods.
  • ModInstance - An internal structure that holds information about the mod, such as resources and the lifetime object.
  • Mod - This class represents the lifetime of the mod and should be subclasses by each mod.
  • Loader - Represents an abstract loader. A loader is an object that loads all mods given a path to a directory.

The core of the system is defined in include/modding/core.h and src/modding/core.cpp. These 2 files contain the functions:

  • GetCurrentlyRunningMod - Get the mod which is currently running in the current thread.
  • SetCurrentlyRunningMod - Set the currently running mod to the given mod. This function only changes a context state. It does NOT cause any function inside the mod itself to be called. This function is internal to EELibrary and should not be exposed/called outside of it.

Things that still need to be done:

  • Add service scope provider so mods can expose public APIs safely.
  • Add support for event options (protected events, priority).
  • Add event context passed as first argument to all events (used to retrieve the invoking & owning mod, cancel propagaion).

Now that I think about it, I should've probably made a different project for testing.. Because now the mod template is not really a template anymore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant