|
|
@@ -26,7 +26,7 @@ |
|
|
|
If you don't have experience with programming C#, I'd suggest you learn the basics before tackling Gamecraft modding. |
|
|
|
I've tried to make the setup as easy as possible, so that you can get straight to the interesting part: modding. |
|
|
|
But before we get started, you've got some waiting around to do; time to install some software and download some stuff.</p> |
|
|
|
<p>To get the ball rolling, you'll need to download <a href="https://visualstudio.microsoft.com/vs/community/">Visual Studio Community Edition</a>, <a href="https://dotnet.microsoft.com/download/dotnet-framework/net48">the .NET 4.8 Developper pack</a> and <a href="https://git.exmods.org/modtainers/GCIPA/releases">GCIPA's latest release</a>for this guide (and for Gamecraft modding). |
|
|
|
<p>To get the ball rolling, you'll need to download <a href="https://visualstudio.microsoft.com/vs/community/">Visual Studio Community Edition</a>, the <a href="https://dotnet.microsoft.com/download/dotnet-framework/net48">.NET 4.8 Developper pack</a> and <a href="https://git.exmods.org/modtainers/GCIPA/releases"> GCIPA's latest release</a>for this guide (and for Gamecraft modding). |
|
|
|
I'm sorry in advance to the smart devs who don't use Windows; <a href="https://www.monodevelop.com/">monodevelop</a> may work, but I haven't had any success. |
|
|
|
You'll also need Gamecraft (and Steam) installed on your computer, unless you're magic or something. |
|
|
|
Since Visual Studio is a Microsoft product, it'll take a while to install, so while you're waiting for that to do it's thing, let's patch Gamecraft.</p> |
|
|
@@ -56,28 +56,29 @@ |
|
|
|
<h5>Blood in the cut</h5> |
|
|
|
<p>Your mod is installed, but it doesn't do anything yet. Let's fix that. |
|
|
|
In Visual Studio, open TestPlugin.cs and take a look at it. |
|
|
|
This is the main <a href="https://github.com/Eusth/IPA">Plugin</a> file, which is interface between Unity and IPA. |
|
|
|
This is the main <a href="https://github.com/Eusth/IPA">Plugin</a> file, which is the interface between Unity and IPA. |
|
|
|
It's very similar to a <a href="https://docs.unity3d.com/ScriptReference/MonoBehaviour.html">Unity MonoBehaviour</a>, but with some sprinkles. |
|
|
|
As the first modification, let's do something simple: In the OnUpdate() method, add (or uncomment) "Debug.Log("Print this to log every frame");" and then save and build the project. |
|
|
|
As the first modification, let's do something simple: In the OnUpdate() method, add (or uncomment) "Debug.Log("Print this to log every frame");" (without quotes) and then save and build the project. |
|
|
|
Once again, copy TestMod.dll into Gamecraft's Plugins folder. Now start Gamecraft. |
|
|
|
When you open Gamecraft's Player.log file (in something like %appdata%/../LocalLow/FreeJame/Gamecraft), you should see some wonderful spam of "Print this to log every frame". |
|
|
|
When you open Gamecraft's Player.log file (found in something like %appdata%/../LocalLow/FreeJame/Gamecraft), you should see some wonderful spam of "Print this to log every frame". |
|
|
|
You did that! You've modified your first mod! |
|
|
|
For more advanced stuff, I'd recommend using a C# decompiler like <a href="https://github.com/0xd4d/dnSpy/releases">dnSpy</a> to read Gamecraft code and figure out what you need to modify. |
|
|
|
Also read about <a href="https://github.com/pardeike/Harmony/wiki">Harmony</a> (included in the TestMod base configuration; see TestPatch.cs) for patching existing methods.</p> |
|
|
|
<h3>Gamecraft Architecture<h3> |
|
|
|
<h5>Do I wanna know</h5> |
|
|
|
<p>Gamecraft modding uses a few new ideas in game development which can be quite different from common software engineering practices. |
|
|
|
The most notable paradigm shifts are the <a href="https://en.wikipedia.org/wiki/Entity_component_system">Entity Component System (ECS)</a> and lack of documentation (and code comments aren't included in DLLs). |
|
|
|
The most notable paradigm shifts are the <a href="https://en.wikipedia.org/wiki/Entity_component_system">Entity Component System (ECS)</a> and lack of documentation. |
|
|
|
To add insult to injury, code comments aren't included in C# DLLs. |
|
|
|
Please note that I won't extensively cover Gamecraft's codebase because I don't understand all of it and I don't want to get sued for "exposing trade secrets" or copyright violations. |
|
|
|
You can learn all of this yourself by searching on the Internet and by using dnSpy, so nothing in Gamecraft is really secret.</p> |
|
|
|
<p>In traditional object-oriented programs, object relationships (eg One-to-many, One-to-one, Many-to-many) are stored in both objects which makes object traversal very easy. |
|
|
|
With ECS, an entity, which is similar to an object, simply describes what components it has relationships with; usually one-to-one. |
|
|
|
Those components are stored in an entity database, where they can be accessed and modified. |
|
|
|
Those components are created and then stored in an entity database, where they can be accessed and modified. |
|
|
|
The entity itself is never really created, so there is no easy entity traversal. |
|
|
|
ECS does offer other advantages, like performance-friendly operations on a set of components and much better dependency decoupling between objects.</p> |
|
|
|
<p>In Gamecraft, a custom-desgned ECS is used called <a href="https://github.com/sebas77/Svelto.ECS">Svelto.ECS</a> (made by FreeJam's superstar coder Seb). |
|
|
|
Gamecraft tends to use the most recent version of Svelto.ECS, or even a version newer than what is publicly available. |
|
|
|
Svelto.ECS does have some documentation (but nothing extensive) in the form of articles on Seb's website, but I find using dnSpy to read Svelto.ECS.dll to be much more helpful. |
|
|
|
Svelto.ECS does have some documentation (but nothing extensive) in the form of articles on <a href="http://www.sebaslab.com/">Seb's website</a>, but I find using dnSpy to read Svelto.ECS.dll to be much more helpful. |
|
|
|
Seb also has a Discord server if you have Svelto.ECS questions. |
|
|
|
Please don't bother him with non-ECS questions; Gamecraft doesn't officially support modding and we wouldn't want them to try to actively prevent it.</p> |
|
|
|
<p>In between third-party code, compiled-out code comments and the lack of official modding documentation, the hardest part of modding right now is figuring out how to do what you want to do. |
|
|
|