ModelSwapLib
A modding library intending to make asset swap mod development slightly easier.
About this mod Author’s original text
Model Swap Lib
Model Swap Lib is an abstraction originally based on this Asset Swap Template for the game Jump Space.
This library is intended for use by mod developers and will have no effect if installed alone.
Usage Steps:
- Add ModelSwapLib.dll as a project reference
- Include [assembly: MelonAdditionalDependencies("ModelSwapLib")] in your core file
- Instantiate a swapper using one of the options below
- Register your swapper with ObjectActionManager.GetInstance().RegisterSwapper(swapper); - This will return a populated Guid if this succeeded, or a Guid.Empty if ModelSwapLib was unable to validate the Swapper structure
There are 2 ways to create a swapper:
Option 1 - Builder Pattern:
Swapper swapper = new SwapperBuilder("Optional ModName").SetModName("YourModName").SetSwapperName("Any Name You Want").SetBundleName("YourBundle.bundle").AddObjectName("ObjectName").AddAssetModule(new MeshModule("Path/To/Your/Model.fbx")).AddAssetModule(new Texture2DModule("Path/To/Your/Texture.png")).AddTransformModule(new MoveMeshModule(0f, 0f, 0f)).AddTransformModule(new RotateMeshModule(0f, 0f, 0f)).AddTransformModule(new ScaleMeshModule(0f, 0f, 0f)).AddDeactivation("ObjectYouWantDeactivated").Build();
new Swapper() - The string parameter for ModName is optional here but is required at some point
SetModName(string) - ModName is a required parameter for a Swapper
SetSwapperName(string) - SwapperName is not required and will default to "Unnamed Swapper", this is mainly for logging
SetBundleName(string) - BundleName is only required if you use an IAssetModule
AddObjectName(string) - Swapper must contain at least 1 object name, otherwise it will not apply to anything and will be rejected
AddAssetModule(IAssetModule) - List of modules that use an asset from a provided AssetBundle
AddTransformModule(ITransformModule) - List of modules that manipulate the transform of a mesh
AddDeactivation(string) - List of object names to be deactivated
Additional methods include:
- AddObjectNames(List<string>)
- AddAssetModules(List<IAssetModule>)
- AddTransformModules(List<ITransformModule>)
- AddDeactivations(List<string>)
Build() - Returns the swapper object, or null if the configuration is not valid
Option 2 - Manual creation:
Swapper swapper = new Swapper
{
ModName = "YourModName",
SwapperName = "Any Name You Want",
ObjectNames = new List([
"ObjectName1",
"ObjectName2"
]),
BundleName = "YourBundle.bundle",
AssetModules = new List
{
new MeshModule("Path/To/Your/Model.fbx"),
new Texture2DModule("Path/To/Your/Texture.png")
},
TransformModules = new List
{
new MoveMeshModule(0f, 0f, 0f),
new RotateMeshModule(0f, 0f, 0f),
new ScaleMeshModule(0f, 0f, 0f)
},
Deactivations = new List
{
"ObjectYouWantDeactivated"
}
};
Full Implementation Template
[assembly: MelonAdditionalDependencies("ModelSwapLib")]
namespace YourMod
{
public class Core: MelonMod
{
public override void OnInitializeMelon()
{
Swapper swapper = new SwapperBuilder().SetModName("YourModName").SetSwapperName("Any Name You Want").AddObjectNames(["ObjectName1", "ObjectName2"]).SetBundleName("YourBundle.bundle").AddAssetModule(new MeshModule("Path/To/Your/Model.fbx")).AddAssetModule(new Texture2DModule("Path/To/Your/Texture.png")).AddTransformModule(new MoveMeshModule(0f, 0f, 0f)).AddTransformModule(new RotateMeshModule(0f, 0f, 0f)).AddTransformModule(new ScaleMeshModule(0f, 0f, 0f)).AddDeactivation("ObjectYouWantDeactivated").Build();
if(swapper == null)
{
Melon.Logger.Warning($"Invalid swapper");
}else{
Guid guid = ObjectActionManager.GetInstance().RegisterSwapper(swapper);
if(guid == Guid.Empty) // If you receive a Guid.Empty then the Swapper.Validate() failed
{
Melon.Logger.Warning($"Failed to register swapper: {swapper.SwapperName}");
} else
{
Melon.Logger.Msg($"Successfully registered swapper: {swapper.SwapperName} with guid: {swapper.SwapperGuid}");
}
}
Melon.Logg
Install & use Install: follow the bundled instructions
- Unzip the archive from playbuff and read the bundled readme / instructions first.
- Most mods rely on the game's mod loader — the usual route is a community mod manager (such as r2modman): pick this game, install, and it handles the loader and dependencies.
- For a manual install, put the mod files into the matching Mod / plugins folder inside the game directory.
- Launch the game to confirm it loaded; mods with listed dependencies need those installed as well.
Install locations vary a lot between mods — the bundled readme is the most reliable guide.
Install these first, or the mod will not work: