Mods Communicator
Outward Mods Communicator enables seamless communication between mods through shared events and configuration syncing. It also lets users override any changes made by other mods, giving them full control over their settings.
| Date uploaded | 9 months ago |
| Version | 1.0.1 |
| Download link | GymMed-Mods_Communicator-1.0.1.zip |
| Downloads | 281 |
| Dependency string | GymMed-Mods_Communicator-1.0.1 |
This mod requires the following mods to function
README
Outward Mods Communicator
Outward Mods Communicator enables seamless communication between mods through shared events and configuration syncing. It also lets users override any changes made by other mods, giving them full control over their settings. You can find library published on NuGet as Outward.ModsCommunicator.
Why should I use this?
Benefits of using this library:
Configuration Syncing
This library allows mod pack creators to synchronize configuration files without directly editing them.
Users don’t need to download configuration files from third-party sources.
Configurations can be edited through XML, and the control flow follows this order: User -> Mod -> Cfg Documents
Deeper explanation
Currently, Outward's BepInEx does not provide a built-in way for mods to modify.cfg configuration files inside the BepInEx/config directory.
Mods Communicator solves this by using two XML files. One XML file is placed in the
mod’s plugin directory (recommended), and Mods Communicator uses it to override
configuration settings right after the ResourcesPrefabManager class
finishes its Load method.
Afterwards, it reads the player’s PlayerModsOverrides.xml file, located
inside this mod’s folder, to apply personal overrides based on the player’s preferences.
FAQ
Why use XML instead of hardcoding values in the assembly/code/DLL?
XML is used so players can freely edit values without needing to modify any code. The XML structure is simple, human-readable, and gives full control to the user.Why are there two XML files?
Mods can be updated frequently, and each update may include new default XML values. By separating the player’s personal overrides into a second XML file, updates won’t overwrite their custom settings. Mods Communicator only provides aPlayerModsOverrides.example.xml file —
players must rename it to PlayerModsOverrides.xml.
This makes their configuration safe from updates and re-downloads.
Why are XML files read after the ResourcesPrefabManager.Load method?
Because all plugins and their configurations must be initialized first.
Once ResourcesPrefabManager.Load completes, all
.cfg files are loaded, and it becomes safe to apply overrides.
Does every mod that changes settings through configs need Mods Communicator as a dependency?
No. The Mods Communicator library is only required for mods that want to modify other mods’ default values to create new experiences. For example, theOutward Game Settings mod uses this dependency
solely for the EventBus feature to publish additional events.
Changing Configuration As User
This library includesPlayerModsOverrides.example.xml file. You will need
to change it's name to PlayerModsOverrides.xml when you can open it to add
or modify XML values.
Adding Configuration Path To Mod
You can add your configuration XML path inside your plugin’s Awake method like this:OutwardModsCommunicator.OMC.xmlFilePath = "FullPathTo/MyModsOverrides.xml";
Editing XML
This library will contain `PlayerModsOverrides.xml` document as an example. Each override is added inside a ConfigOverrides element:<ConfigOverrides>
<Mod GUID="gymmed.outward_game_settings">
<Section Name="Enchanting Modifications">
<Entry Key="EnchantingSuccessChance" Value="5" />
<Entry Key="RequireRecipeToAllowEnchant" Value="false" />
<Entry Key="UseRecipeOnEnchanting" Value="false" />
</Section>
</Mod>
<Mod GUID="gymmed.outward_mods_communicator">
<Section Name="Event Profiler">
<Entry Key="EnableEventsProfiler" Value="true" />
<Entry Key="InstantLogEventsProfileData" Value="true" />
</Section>
</Mod>
</ConfigOverrides>
Possible mod override information can be found in `BepInEx/config` directory inside `.cfg` documents
## Settings file was created by plugin Outward Game Settings v0.0.1
## Plugin GUID: gymmed.outward_game_settings
[Enchanting Modifications]
## Allow enchanting only if enchantment is on character?
# Setting type: Boolean
# Default value: true
RequireRecipeToAllowEnchant = false## Remove recipe after using it on enchanting?
# Setting type: Boolean
# Default value: true
UseRecipeOnEnchanting = false## What is success chance(%) of enchanting?
# Setting type: Int32
# Default value: 50
# Acceptable value range: From 0 to 100
EnchantingSuccessChance = 5
## Play additional audio on enchanting failed/success?
# Setting type: Boolean
# Default value: true
PlayAudioOnEnchantingDone = true
Mods Communication
Communication is handled through an Event Bus — a system that allows mods to fire (publish) and listen (subscribe) to shared events.
How to register event?
using OutwardModsCommunicator.EventBus;
...
void Awake()
{
...
// GUID is your plugin ID provided as a string
// "EnchantmentMenu@TryEnchant" is the event name
// ("menu", typeof(EnchantmentMenu)) defines your variable name and its type
EventBus.RegisterEvent(GUID, "EnchantmentMenu@TryEnchant", ("menu", typeof(EnchantmentMenu)));
// you can add multiple variables and
// add as many as you need like this:
//EventBus.RegisterEvent("MyPluginId", "MyClass@MyMethod", ("name", typeof(string)), ("health", typeof(int)));
...
}
How to publish event?
Use this in places where you want to allow other mods to extend your functionality:using OutwardModsCommunicator.EventBus;
...
void YourMethod()
{
...
// Add variable types and names
var payload = new EventPayload
{
["EnchantmentMenu"] = menu,
};
// Send event for subscribers to receive data
EventBus.Publish(OutwardGameSettings.GUID, "EnchantmentMenu@TryEnchant", payload);
}
How to subscribe to event?
Use this when you want to listen to an event and execute additional code:using OutwardModsCommunicator.EventBus;
...
void Awake()
{
...
// Provide other mod GUID
// Provide event name
// Provide method you want to execute
EventBus.Subscribe("gymmed.outward_game_settings", "EnchantmentMenu@TryEnchant", OnTryEnchant);
}
private static void OnTryEnchant(EventPayload payload)
{
if (payload == null) return;
// try to retrieve passed event data
EnchantmentMenu menu = payload.Get<EnchantmentMenu>("menu", null);
// if event data is null log and stop execution
if (menu == null)
{
Log.LogMessage("Mod gymmed.outward_game_settings event EnchantmentMenu@TryEnchant returned null for EnchantmentMenu");
return;
}
// Lets log success
Log.LogMessage($"{GUID} successfully communicated with gymmed.outward_game_settings mod and passed menu!");
}
How to get all registered events?
Use this when you want to log or inspect all registered events:using OutwardModsCommunicator.EventBus;
...
// We use harmony patch to execute code after each plugin is loaded
// and have already registered their events
[HarmonyPatch(typeof(ResourcesPrefabManager), nameof(ResourcesPrefabManager.Load))]
public class ResourcesPrefabManager_Load
{
static void Postfix(ResourcesPrefabManager __instance)
{
// Log all registered events
EventBusDataPresenter.LogRegisteredEvents();
}
}
The project also includes extra tools like EventProfiler and EventBusDataPresenter — feel free to explore them to learn more.
Can I find basic example how to use this?
You can view mod creation template here.
You can view outward game settings mod here.
How to set up
To manually set up, do the following
- Create the directory:
Outward\BepInEx\plugins\OutwardModsCommunicator\. - Extract the archive into any directory(recommend empty).
- Move the contents of the plugins\ directory from the archive into the
BepInEx\plugins\OutwardModsCommunicator\directory you created. - It should look like
Outward\BepInEx\plugins\OutwardModsCommunicator\OutwardModsCommunicator.dllLaunch the game.
If you liked the mod leave a star on GitHub it's free
CHANGELOG
Changelog
Release 1.2.0 Version
Added
- Added support for optional event description when registering events.
Example:
EventBus.RegisterEvent( GUID, "yourEvent", "your event description", ("yourVariableRetrievalKey", typeof(string), "Your variable description.") );
Fixed
- Fixed readme code blocks.
- Changed how
EventBusDataPresentershows logs. Now it is much clearer.
Release 1.1.0 Version
Added
- Added support for optional parameter descriptions when registering events.
Example:
EventBus.RegisterEvent( GUID, "EnchantmentMenu@TryEnchant", ("menu", typeof(EnchantmentMenu), "The enchantment menu instance that invoked the TryEnchant method.") ); - Added more text to readme description
Fixed
- Moved the
PlayerModsOverrides.example.xmlfile toBepInEx/config/gymmed.Mods_Communicator/to ensure configuration files remain untouched after updates — even after renaming.exampleto enable custom overrides.
Release 1.0.1 Version
Fixed
- Made sure to load
PlayerModsOverrides.xmleven ifxmlFilePathvariable is not provided from mods - Changed readme description
Release 1.0.0 Version
- Initial release.