back

SimHub Plugins

SimHub is a .Net framework WPF C# application with XAML user interface.
Largely a collection of plugins (.dll files) to extract telemetry properties from games,
other plugins enabled in do things with those properties.
Many optional plugins are bundled with SimHub, but some are provided by others.


After Init() initialization, each plugin appears to run in its own thread.
A hang in one plugin minimally impacts function in others.  On launch,
plugin method public void DataUpdate(PluginManager pluginManager, ref GameData data)
should run in well under 1/60 second, updating any properties available to others
and preparing the plugin method for its next invocation.
SimHub appears robust against relaunching a still-busy plugin's DataUpdate() thread.
60Hz launch rate preempts plugins needing to implement dynamic invoking methods
and simplifies synchronization.

static
Class methods and data that are available without a class instance are static.
A static class cannot be instantiantiated (i.e., no new).
They are important e.g. for communication among threads.

Delegates can pass methods as arguments to other methods, AKA callback functions.
Event handlers are nothing more than methods invoked through delegates
that are either static or instance methods with matching return type,
but I have yet to recognize a delegate instance method... making statics crucial.
Unlike C++ function pointers, C# delegates encapsulate method and object instance.
Sadly, delegates are often coded in lambda expressions,
which syntax are IMO impossible to read.  Also IMO, many absurdly complex C# examples
can be blamed on programmers' being confounded by syntax,
resulting in more-or-less blind copy/pasting code from other working fragments.

SimHub C# Custom Expressions
SimHub property values can also be set using C# custom expressions.
Enable C# expressions via Additional plugins   More....
SimHub support for these C# expressions preceded NCalc, JavaScript, plugin SDK, etc
and is kept for backward compatibility.
SimHub stores them in PluginsData/*/DataCorePlugin/CustomExpressions
Those to be used in all games are stored in PluginsData/Common/DataCorePlugin/CustomExpressions
As of 7.04.8b4, these are evaluated when games are loaded,
before other plugins are loaded.

SimHub C# Custom Expressions special trick for a static:
init(value);    
return KKDash;
    
}  
static int KKDash = 0;

class KKDAsh{}
static void init(global::SimHub.Plugins.PluginManager pluginManager){
    
        pluginManager.AddAction("KartKraft_Dash_toggle", typeof(KKDAsh), (a, b) =>
        {
            KKDash = (KKDash + 1) % 3;
        });

Question:  are Custom Expressions evaluated at 60Hz or (more likely) only when referenced?
Properties set or referenced only in a plugin's Init{} section impose minimal overhead.
maintained by blekenbleu