
You are viewing a potentially older version of this package. View Latest Version

Model Swap Lib is an abstraction 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.
To use this as a developer, add ModelSwapLib.dll as a project reference:
[assembly: MelonAdditionalDependencies("ModelSwapLib")]
namespace YourMod
{
public class Core : MelonMod
{
public override void OnInitializeMelon()
{
Swapper swapper = new Swapper
{
ModName = "YourModName",
SwapperName = "Any Name You Want",
ObjectNames = new List<string>([
"ObjectName1",
"ObjectName2"
]),
BundleName = "YourBundle.bundle",
Modules = new List<IModule>
{
new MeshModule("Path/To/Your/Model.fbx"),
new Texture2DModule("Path/To/Your/Texture.png")
},
Deactivations = new List<string>([
"SomeObjectNameYouWantDeactivated"
])
};
Guid guid = ObjectActionManager.GetInstance().RegisterSwapper(swapper);
if(guid == Guid.Empty) // If you receive a Guid.Empty then the Swapper.Validate() failed
{
Melon<Core>.Logger.Warning($"Failed to register swapper: {swapper.SwapperName}");
} else
{
Melon<Core>.Logger.Msg($"Successfully registered swapper: {swapper.SwapperName} with guid: {swapper.SwapperGuid}");
ObjectActionManager.GetInstance().ClearSkipCache(swapper); // Call this after registering each swapper/batch of swappers as it
// ensures the SkipCache doesnt contain objects you want swapped
}
Melon<Core>.Logger.Msg($"YourMod Initialized");
}
}
}
If any of the above properties are null or empty, Validate() will return false and the swapper will not be registered.
Many thanks to GraciousCub5622 @graciouscub5622 on discord for his Asset Swap Template, upon which this entire project is based.
Many thanks to ScribbleTAS for MeshUtils and also for his help in debugging and brainstorming.