Modding:Worlds: Difference between revisions

Jump to navigation Jump to search
1,532 bytes added ,  21:56, 9 August 2020
Add info about C# interfaces
m (Add some more detail)
(Add info about C# interfaces)
Line 1: Line 1:
{{Modding Info}}
{{Modding Info}}
<code>Worlds.xml</code> defines many of the important zones on the world map. The game currently only uses one "world", called JoppaWorld, but it is theoretically set up to support more worlds than that.


== Structure ==
<code>Worlds.xml</code> defines many of the important zones on the world map. The game's primary "world", called JoppaWorld, contains most of the game content, but it is theoretically possible to add additional worlds.
 
In addition to the XML, the game code includes a few hooks that a programmer can use to modify the world state during the world generation process.
 
== XML Structure ==


<code>Worlds.xml</code> has the following general structure:
<code>Worlds.xml</code> has the following general structure:
Line 44: Line 47:
|-
|-
|}
|}
== World Generation Code ==
The game exposes two interfaces that a modder may hook into to apply custom logic before or after the world generation process.
=== JoppaWorldBuilderExtension ===
This interface is called before and after JoppaWorld generation.
<syntaxhighlight lang="csharp">
using XRL.World.WorldBuilders;
namespace YourMod.YourNamespace
{
    //The game code instantiates an instance of this class during the JoppaWorld generation process
    [JoppaWorldBuilderExtension]
    public class YourJoppaWorldBuilderExtension : IJoppaWorldBuilderExtension
    {
        public override void OnBeforeBuild(JoppaWorldBuilder builder)
        {
            //The game calls this method before JoppaWorld genration takes place (i.e. creation of lairs, historic ruins, villages, and more)
        }
        public override void OnAfterBuild(JoppaWorldBuilder builder)
        {
            //The game calls this method after JoppaWorld genration takes place
        }
    }
}
</syntaxhighlight>
=== WorldBuilderExtension ===
This interface is called before and after the '''overall''' world generation process runs (it is not specific to JoppaWorld).
The format is pretty much identical to JoppaWorldBuilderExtension above, except that the attribute is <code>[WorldBuilderExtension]</code> and the interface is <code>IWorldBuilderExtension</code>.


{{Modding Navbox}}
{{Modding Navbox}}


[[Category: Modding]]
[[Category: Modding]]

Navigation menu