Mod Construction and Importing
Construction
Known Game
If you know the game you will be working with at compile time, this is the typical way to create a new mod:
var newMod = new SkyrimMod(ModKey.FromFileName("MyMod.esp"), SkyrimRelease.SkyrimSE);
Unknown Game
In more complex setups, often the game type is not known at compile time
var newMod = ModInstantiator.Activator(ModKey.FromFileName("MyMod.esp"), release);
var newMod = ModInstantiator<TMod>.Activator(ModKey.FromFileName("MyMod.esp"), release);
Importing
It is usually preferable to import as readonly initially. As such, importing a mod as readonly is usually preferable.
Known Game
If you know the game you will be working with at compile time, this is the typical way to import a mod:
using var readOnlyInputMod = SkyrimMod.CreateFromBinaryOverlay(inputPath, SkyrimRelease.SkyrimSE);
Dispose Appropriately
Binary overlays are disposable, as they can keep streams open as they are accessed. Make sure to utilize using
statements to dispose of them appropriately.
var mutableInputMod = SkyrimMod.CreateFromBinary(inputPath, SkyrimRelease.SkyrimSE);
Unknown Game
In more complex setups, often the game type is not known at compile time.
using var readOnlyInputMod = ModInstantiator.ImportGetter(pathToMod, release);
var mutableMod = ModInstantiator.ImportSetter(pathToMod, release);
var mod = ModInstantiator<TMod>.Importer(ModKey.FromFileName("MyMod.esp"), release);
Dispose Appropriately
Binary overlays are disposable, as they can keep streams open as they are accessed. Make sure to utilize using
statements to dispose of them appropriately.