#2
25th Oct 2020 at 7:41 PM
Last edited by Battery : 25th Oct 2020 at
8:01 PM.
Posts: 433
Thanks: 792 in 6 Posts
10 Achievements
tere are multiple ways to achive this
1. Simple Solution: Make a common Base mod that supplies these classes and reference them in the other mods (this would be a strict requirement)
2. More Complex Solution you can use Reflection to check if a mod is installed and then call the methods you need through reflection aswell ( you can look at the Battery.RemoteUtil class from my C# Utility mod to check that functionality out) this has the advantage that each mod is independent of each other but has the disadvantage that calls to these methods will be much slower
E: and yes the version needs to be the same, so do you want a hard requirement or and optional implementation ?
E2:
heres how you would use it
The mod that supplies the Method
Code:
public static class MyStaticClass
{
public static void CallMe(int a, string b)
{
Battery.UI.MessageUtil.WriteNotification(a + " " + b);
}
}
The mod that uses the method
Code:
if(Battery.RemoteUtil.IsScriptModInstalled("Modname"))
{
Battery.RemoteUtil.InvokerUtil.InvokeStatic("...MyStaticClass","CallMe",100,"Test");
}
replace the ... with a qualified name