- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 10
Writing a plugin
ViLA is built on plugins, and without great plugins ViLA wouldn't really be a thing. Ultimately you'll have to decide what your plugin will do, but once you do this page should help you out.
No exceptions here. If you're not sure how to do this:
Make sure you install the .NET 6 SDK if you haven't already.
The manifest.json
file should be packaged at the root of your plugin and should resemble the following. Currently only github api links are supported for providing releases. The only required field is entrypoint
; all other fields are optional.
{
"entrypoint": "MyPlugin.dll", // The dll containing your plugin
"version": "1.0.0", // the version of your plugin
"releases": "https://api.github.com/repos/charliefoxtwo/ViLA-Sample-Plugin/releases" // github api link to the plugin's releases
}
ViLA.PluginBase
is a NuGet package which contains the base class that all plugins must inherit.
If you like, your plugin class may have a parameterless constructor. However, it's important to understand that SendData
and LoggerFactory
will both be null at the time the constructor is called.
The Start
method should start a thread that runs your plugin in the background, and then return whether or not that start was successful.
Don't do this:
public override async Task<bool> Start()
{
// BAD! DO NOT DO THIS
while (true) { ... }
}
Instead, consider:
public override async Task<bool> Start()
{
ThreadPool.QueueUserWorkItem(...);
return true;
}
There are multiple methods that can be used to send data back to ViLA. These are:
-
Send
: sends any data -
SendAction
: sends simply the id
Calling any one of these for your data will send the data back to ViLA for processing. Generally you should only be calling one.
Because ViLA has its own dependencies, it's important not to publish your plugin with any clashing dependencies. The easiest way to do this is to specify a manifest file when running dotnet publish. You can use plugin_manifest.xml in the root of this repository for exactly this purpose.
Check out the publish command used in DCS-BIOS reader to see an example of this.
For an example of a plugin, check out the Sample Plugin. For something more practical, check out DCS-BIOS Reader.