

To put it in another way, OnWorldLoadFinishedEventHandler listens for the OnWorldLoadFinished event which is fired when a world have been loaded. This will be a good time to get our code executed.ĭon't feel bad if you're confused, as it can be difficult to grasp at first. That would be after you've created a new kingdom or after loading an existing kingdom. Like its name implies, this delegate handler call all its delegates once a world have been loaded. Now, a delegate is a reference type variable that references a method, instead of referencing an object. Inside the SimIFace library, you'll find a delegate handler called OnWorldLoadFinishedEventHandler within ScriptCore.World. Otherwise it won't be able to do anything and would probably lead to a game crash.



Well we can't just go right ahead and do all sorts of awesome stuff, as we need to ensure that our code gets executed at the right time. Then we have our static constructor, which in itself is technically mandatory for the type to be functional, but what's going on inside it? First of all we have our entry point kInstantiator, which is explained in the next section. Private static void OnWorldLoadFinishedHandler(object sender, EventArgs e)Īs of now, we have a little bit of code already, but it is in fact the most important part of the whole mod. World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinishedHandler) / Unless it's absolutely neccessary not to, leave it unchanged. Protected static bool kInstantiator = false Open up Instantiator.cs in Visual Studio, and it should look like this: NET assembly browser/decompiler your best friend when developing mods for TSM. While it's not required to complete or follow this tutorial, you should make a. If you fail to accomplish that, don't even bother reading the rest of the tutorial.
