Design and logic for user-facing site https://exmods.org
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

115 linhas
12KB

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta name="theme-color" content="#20c420" />
  5. <meta name="author" content="Exmods community" />
  6. <meta name="keywords" content="exmods,gamecraft,modding,mod" />
  7. <meta name="og:type" content="website" />
  8. <meta name="og:title" content="Exmods" />
  9. <meta name="og:description" content="Gamecraft modding website" />
  10. <meta name="description" content="Gamecraft modding website" />
  11. <meta name="og:image" content="../static/favicon.png" />
  12. <meta name="og:url" content="https://www.exmods.org" />
  13. <meta charset="UTF-8" />
  14. <link rel="icon" href="../static/favicon.png" type="image/x-icon"/>
  15. <link rel="shortcut icon" href="../static/favicon.png" type="image/x-icon"/>
  16. <link rel="stylesheet" href="../static/style.css" type="text/css" />
  17. <title>Exmods Getting Started</title>
  18. </head>
  19. <body>
  20. <h1>Getting Started with Modding</h1>
  21. <h5>by NGniusness</h5>
  22. <div>
  23. <iframe width="850" height="480" sandbox="allow-same-origin allow-scripts" src="https://peertube.co.uk/videos/embed/b41abd31-fa16-42c8-be37-df10072c1c29?title=0&warningTitle=0" frameborder="0" allowfullscreen class="iframe-player"></iframe>
  24. </div>
  25. <div class="text-content">
  26. <h3>The First Step</h3>
  27. <h5>The first cut is the deepest</h5>
  28. <p>Modding Techblox is quite easy, once you get past the initial setup and learning.
  29. This guide was made to cover all of that in enough detail for anyone with coding experience.
  30. If you don't have experience with programming C#, I'd suggest you learn the basics before tackling Techblox modding.
  31. I've tried to make the setup as easy as possible, so that you can get straight to the interesting part: modding.
  32. But before we get started, you've got some waiting around to do; time to install some software and download some stuff.</p>
  33. <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 Techblox modding).
  34. To any smart devs who don't use Windows; <a href="https://www.monodevelop.com/">monodevelop</a> does work, but you'll need to use .NET 4.7.* when building.
  35. The process is quite similar for every IDE, but I'll focus on VS because it's popular.
  36. You'll also need Techblox installed on your computer, unless you're magic or something.
  37. 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 Techblox.</p>
  38. <p>The latest release of GCIPA that you just downloaded is for patching Techblox.
  39. GCIPA stands for Gamecraft Illusion Plugin Architecture, which is based on Eusth's <a href="https://github.com/Eusth/IPA">IPA</a> for patching games built on the Unity game engine (eg Techblox, Kerbal Space Program, Robocraft <- EAC will stop you with that one).
  40. To get started with patching Techblox, unzip GCIPA's latest release <b>directly</b> into Techblox's install folder.
  41. You'll know it worked because you'll see some new files and folders, including an executable called IPA.
  42. Now for the real hackerman move: drag Techblox onto IPA.
  43. You'll know this worked because a folder called "Plugins" will be created (we'll need this later).
  44. Congratulations! Here's your certificate: <a href="http://pre06.deviantart.net/23ca/th/pre/f/2016/306/0/9/hackerman_by_shiiftyshift-dan31sc.png">(Certification of hacking that I stole off the internet)</a>.
  45. (NOTE: you'll need to re-patch the game everytime Techblox is updated)</p>
  46. <p>I'm willing to bet Visual Studio is still downloading (thanks MS), so wait until that's done and then continue.
  47. Using Visual Studio, clone the <a href="https://git.exmods.org/modtainers/HelloModdingWorld">HelloModdingWorld git repository</a> into a folder.
  48. If you'll need the <a href="https://git.exmods.org/modtainers/GamecraftModdingAPI">TechbloxModdingAPI</a> installed as well, which you can do by following <a href="https://git.exmods.org/modtainers/GamecraftModdingAPI/src/branch/master/README.md#installation">these instructions</a>.
  49. The base branch of HelloModdingWorld provides a starter project for creating your own GCIPA-based mod (called a "plugin").
  50. Before you make any changes, though, you'll want to create your own git repository to store your mod (unless you're that one guy in my office who dislikes open-source).
  51. Feel free to use <a href="https://git.exmods.org/">Exmods' Git server</a> (hosted by me!) to make your mod accessible to other modders and Techblox players.
  52. For the purpose of this guide the git repository name I'm using is "MyFirstMod".
  53. Clone your new git repository using Visual Studio, then copy the files (except the .git folder, if you can see it) from HelloModdingWorld into MyFirstMod's folder.
  54. Now you've got your first mod ready to go.
  55. It won't build though, since the project has no idea where Techblox is.</p>
  56. <p>To point the Visual Studio project to the right Techblox dependencies, you've got two options:
  57. copy the contents of your Techblox install location into a new folder called "ref" in MyFirstMod, or <a href="https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/">create a symlink to Techblox's main folder</a>.
  58. The disadvantage to the former option is that you'll have to re-copy the files everytime there's a Techblox update.
  59. This step is explained in HelloModdingWorld's <a href="https://git.exmods.org/modtainers/HelloModdingWorld/src/branch/no-api/README.md">README</a> as well.
  60. No matter which you choose, if you've done everything correctly the project should now build successfully (CTRL+SHIFT+B or [top menu]Build > Build Solution).
  61. In MyFirstMod's HelloModdingWorld/bin/net48 folder copy HelloModdingWorld (HelloModdingWorld.dll) into Techblox's new Plugins folder and your first mod is installed.</p>
  62. <h3>Modifying Your Mod</h3>
  63. <h5>Blood in the cut</h5>
  64. <p>Your mod is installed, but it doesn't do anything yet. Let's fix that.
  65. In Visual Studio, open MyPlugin.cs and take a look at it.
  66. This is the main <a href="https://git.exmods.org/modtainers/GCIPA">Plugin</a> file, which is the interface between Unity and IPA.
  67. It's very similar to a <a href="https://docs.unity3d.com/ScriptReference/MonoBehaviour.html">Unity MonoBehaviour</a>, but with some sprinkles.
  68. As the first modification, let's do something simple: In the OnUpdate() method, add "Debug.Log("Print this to log every frame");" (without quotes) and then save and build the project.
  69. Once again, copy HelloModdingWorld (HelloModdingWorld.dll) into Techblox's Plugins folder. Now start Techblox.
  70. If you open Techblox's Player.log file (found in something like %appdata%/../LocalLow/FreeJam/Techblox), you should see some wonderful spam of "Print this to log every frame".
  71. You did that! You've modified your first mod!</p>
  72. <p>For more advanced stuff, I'd recommend using a C# decompiler like <a href="https://github.com/0xd4d/dnSpy/releases">dnSpy</a> to read Techblox code and figure out what you need to modify.
  73. Also read about <a href="https://github.com/pardeike/Harmony/wiki">Harmony</a> (included in the HelloModdingWorld base configuration; see HelloModdingWorld.csproj) for patching existing methods.</p>
  74. <h3>Gamecraft Architecture<h3>
  75. <h5>Do I wanna know</h5>
  76. <p>Techblox is Gamecraft. It's also RobocraftX. This is quite obvious when you start decompiling things and you look at all of the names in the codebase.
  77. To make things easier, let's call the game Gamecraft in this section.
  78. Gamecraft modding uses a few new ideas in game development which can be quite different from common software engineering practices.
  79. 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.
  80. To add insult to injury, code comments aren't included in C# DLLs.
  81. 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.
  82. You can learn all of this yourself by searching on the Internet and by using dnSpy, so nothing in Gamecraft is really secret.</p>
  83. <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.
  84. With ECS, an entity, which is similar to an object, simply describes what components it has relationships with; usually one-to-one.
  85. Those components are created and then stored in an entity database, where they can be accessed and modified.
  86. The entity itself is never really created, so there is no easy entity traversal.
  87. ECS does offer other advantages though, like performance-friendly operations on a set of components and much better dependency decoupling between objects.</p>
  88. <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).
  89. Gamecraft tends to use the most recent version of Svelto.ECS, or even a version newer than what is publicly available.
  90. 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.
  91. Seb also has a Discord server if you have Svelto.ECS questions.
  92. 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>
  93. <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.
  94. Using a combination of dnSpy and some of the resources mentioned in Further Reading, I hope it isn't too hard for you.
  95. Either way, rest assured that modding does get easier with a bit of practice; the start of the learning curve is the steepest.</p>
  96. <h3>Further Reading</h3>
  97. <h5></h5>
  98. <p>Some of these resources have already been mentioned, but I'll mention them again to have a complete list of resources for quick reference.</p>
  99. <p>- <a href="http://www.sebaslab.com/">Seba's Lab</a>, for articles and examples about Svelto.ECS, Techblox's entity handler.</p>
  100. <p>- <a href="https://git.exmods.org/modtainers/GamecraftModdingAPI">TechbloxModdingAPI</a>, for an easier way to modify the behaviour of some parts of Techblox.</p>
  101. <p>- <a href="https://docs.unity3d.com/ScriptReference/">Unity Scripting API</a>, for interfacing with Techblox's game engine.</p>
  102. <p>- <a href="https://github.com/pardeike/Harmony/wiki">Harmony</a>, for patching existing methods in Techblox's code.</p>
  103. <p>- <a href="https://github.com/Eusth/IPA">Eusth's Illusion Plugin Architecture (Reloaded)</a>, for injecting plugins into Unity games.</p>
  104. <p>- <a href="https://discord.gg/2CtWzZT">Exmods Discord</a>, for modding help and discussions.</p>
  105. <p>- <a href="https://git.exmods.org">Exmods Git server</a>, for other mods and custom tools.</p>
  106. <p>- <a href="https://github.com/hecomi/uREPL">uREPL</a>, the command-line interface in Techblox.</p>
  107. <p>- <a href="https://assetstore.unity.com/packages/tools/utilities/rewired-21676">Rewired</a>, the input handling library in Techblox.</p>
  108. </div>
  109. <footer>
  110. exmods.org|<a href="https://git.exmods.org/ExMods/html-site">Site Repository</a>|<a href="https://exmods.org">Home</a>|<a href="https://discord.gg/2CtWzZT">Discord</a>|<a href="https://twitter.com/GamecraftMods">Twitter</a>
  111. </footer>
  112. </body>
  113. </html>