General modding

From Edge Of Eternity - Eternal Forge Modkit Wiki
Revision as of 22:43, 20 December 2018 by Virror (talk | contribs) (Making an additive scene)
Jump to: navigation, search

Scripting basics

Basics

Before you start your Journey on making script mods for Edge of Eternity, you have to understand the limitations that come with the mod kit framework you are working with. First of all, you should always start from a template project, which is automatically setup for modding and provide simple examples. These template projects are available from GitHub, the link is in the Official EOE Modding Guide.

Second, only one script can inherit from the IModInterface abstract class. This is because this script acts as an entrance point to all scripting logic in your mod, similar to how the Program class is usually the entrance point in C# projects. The IModInterface has several overridable methods, such as the "OnIngameUpdate" method (similar to Update), which allows you to hook logic to in game events. You can, however, have as many classes in your project as you like. And your entrance point IModInterface script can reference any of these classes.

Another limitation, one that I had trouble with initially, is that scripts attached to GameObjects in Additive scenes will NOT BE CALLED. This limitation is due to the way your mod assembly gets loaded into the game at runtime. But you can always attach a MonoBehaviour derived script to a GameObject. You can also create a Prefab, and load it Dynamically into the game.

I haven't tried attaching a MonoBehaviour to a prefab, and then loading it Dynamically through script. This may be another limitation.

A temporary limitation, one that the developers hope to fix in the future, is that you can't use DLLs (Dynamically Linked Library) from the Asset Store or from other projects in your mod. All of the code in your mod must be C# Files. Be wary of this when you import Assets from the Unity Asset Store.

And lastly, you cannot create additional resources inside the "Resources" folder. This is because of the way Unity builds packages into asset bundles. It'll only understand Resources that were created from the actual game project, but not through mods that are dynamically loaded into a game. So don't try using "Resources.Load" on resources you created in your mod project. Only use this method on resources from the actual Edge of Eternity game project.

Editor Scripts

Just like any Unity Game, you cannot build Editor Scripts. Usually developers will put the Editor scripts in special "Editor" folders. When it's time to build a game, the compiler will ignore any scripts inside of these special folders.

The current EOE modding tools do not automatically do this for the user. So if you include any editor scripts from any assets you download from the Unity Asset Store (you'll see Editor folders in the import preview), you need to manually tell the compiler to not build these scripts.

To do this, all you need to do is open up every Editor script in a text editor, and wrap the whole script in a UnityEditor preprocessor.

//Insert this at the top of the script, above any namespaces
#if UnityEditor
//A simple Editor Script
class SampleEditorClass : UnityEditor.Editor {
   //Editor Code
}
//Don't forget to add endif at the end
#endif

Adding References

This is a simple fix if you are have issues with default Unity References not being included in your project, such as the TextMeshPro references (TMPro). You most likely will run into these issues if you opened up a template sample project from Kaldorei's EOE modkit github page. If this is the case, you should have a ModScripts.asmdef file at the root of your assets folder. All you need to do is click on it, look at the details in the inspector, and look for References near the top.

Press on the add button, you'll see a new item appear, a missing reference. The right section of this reference is a small circle. Select it, and find the appropriate reference you need (make sure to select the editor references too). For TextMeshPro, you'll need to select two references, "Unity.TextMeshPro" and "Unity.TextMeshPro.Editor". At the bottom of the inspector, press the apply button. The references should now be included in your project, so you shouldn't have issues referencing them now in your scripts.

Making an additive scene

This section assumes that you successfully imported the databank and know how to view levels using the Game Scenes Viewer.

If you know how to create a model swap mod, then adding an additive level should be very straight forward. Just like with a model swap, you'll need to head over to the mod settings menu (EOE Mods Toolkit -> Mod Settings), and enter in all the appropriate information. Make sure to remember what your Mod ID is, as you'll need it for your level mod. I'd highly recommend going into the mod override manager and making sure you aren't overriding any assets you don't wish to for this level mod.

Now head on over to EOE Mods Toolkit -> Mod Scene Manager. In the Scene Handling Mode: Make sure Additive is selected (I don't think replace works properly at the moment). Then Press the Plus Button To Add a New Scene.

Source Asset Paths: Path: You can choose whatever levels appear from the databank or the default levels database. But for most of the game, the player will be exploring the AstryanContinent. So it would be wise to create a an additive level for this scene. Press the Builtin button, and navigate to Assets -> EOE -> GameMaps -> Chapters -> Chapter I -> AstryanContinent -> AstryanContinent.unity. Or you can simple copy this file url below: "Assets/EOE/GameMaps/Chapters/Chapter I/AstryanContinent/AstryanContinent.unity" Load Method: Choose Resources DLC or ModID: Leave this blank Replacement Asset Paths: Path: Copy the Scene Name You Wish To Add To the Source Scene Additively. This Scene can be anywhere in your project, but make sure it is spelt correctly. Do not use any file suffexes such as ".unity". Load Method: Choose Asset Bundles Mod Kit DLC or ModID: Copy your ModID you inserted in the mod settings, and paste them into the text field.

After you are all done, make sure to press the save button and exit.