This is the main repository of the Hi3Helper.Plugin.Core library (aka Collapse Launcher Standard Core Plugin Library), broadly used as a fundamental to develop Game Plugin Support system on Collapse Launcher, implements standard of API contracts and core functionality which is used by both the plugin and the launcher, including: Platform Invocation, COM Interop and Marshalling.
As per current state of the Plugin System on Collapse Launcher, you can contribute to this library by providing a proposal of the new API contract or by improving the existing API contract implementation. You might expect some changes in the near future as the existing APIs are still under development.
Keep in mind that the code included in this repository are mainly unsafe due to marshalling nature from Managed .NET code to Unmanaged code platform invocation.
Make sure that your code is reflection-free as possible as the code are entirely purposed to work with NativeAOT Compilation. A minimal reflection features (GetType and such) are still supported, but ensure that you set the IlcDisableReflection on your .csproj project file (or .pubxml publish profile) to false. If you need to perform JSON Serialization/Deserialization, please ensure that your code uses source-generated JsonSerializerContext or use Lightweight/No-Reflection (manually deserialize the JSON with some interface implementation (See below)) via JsonDocument, Utf8JsonReader and Utf8JsonWriter.
This Core Library includes few core implementation to support the plugin development faster without need to implement the entire functions from scratch. These are including:
-
Base/Abstract API Classes
InitializableTask(Implement:IInitializableTask)PluginBase(Implement:IPlugin)PluginPresetConfigBase(Inherit:InitializableTask, Implement:IPluginPresetConfig)PluginSelfUpdateBase(Implement:IPluginSelfUpdate)GameInstallerBase(Inherit:LauncherApiBase, Implement:IGameInstaller)GameManagerBase(Inherit:LauncherApiBase, Implement:IGameManager)LauncherApiBase(Inherit:InitializableTask, Implement:ILauncherApi)LauncherApiMediaBase(Inherit:LauncherApiBase, Implement:ILauncherApiMedia)LauncherApiNewsBase(Inherit:LauncherApiBase, Implement:ILauncherApiNews)
-
COM-API Interfaces/Contracts
IFreeIPlugin(Inherit:IFree)IInitializableTask(Inherit:IFree)IPluginPresetConfig(Inherit:IInitializableTask)IPluginSelfUpdate(Inherit:IFree)IGameManager(Inherit:IInitializableTask)IGameUninstaller(Inherit:IInitializableTask)IGameInstaller(Inherit:IGameUninstaller)ILauncherApi(Inherit:IInitializableTask)ILauncherApiMedia(Inherit:ILauncherApi)ILauncherApiNews(Inherit:ILauncherApi)
-
COM Interop, Marshallers and Extensions
- Asynchronous Task Marshaller with
Exceptionthrow andCancellationTokensupport (via:ComAsyncResultandComAsyncExtension) - COM-Interop ABI For Manual Marshalling to Support
No-Reflectionmode ifMANUALCOM"constant define" included inside the.csprojfile (via:ABI\ABI_I***Wrappers)Source-generated COM ABI and Wrapper is used by default if
MANUALCOMisn't defined. - Disposable Plugin Memory for managing data in unmanaged memory between the plugin and the main application (via:
PluginDisposableMemory) - Memory and String Tools (via:
MemandMem.String) - Lightweight/No-Reflection Supported JSON Serializer/Deserializer Contracts (using:
JsonDocument,Utf8JsonWriterandUtf8JsonReader) via:
- Asynchronous Task Marshaller with
To see the example of how the plugin implemented using this Core Library, check the link below:
- Hi3Helper.Plugin.HBR (A basic plugin implementation for Game: Heaven Burns Red by Key)
- Hi3Helper.Plugin.Template (A template for Plugin Development example, also a plugin implementation for Wuthering Waves by Kuro Games)