Skip to content

Commit

Permalink
fix: add some instructions for advanced users
Browse files Browse the repository at this point in the history
  • Loading branch information
sirskunkalot committed Apr 22, 2021
1 parent 391d6a3 commit 7e5da56
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
9 changes: 6 additions & 3 deletions JotunnLib/Documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ Jötunn (/ˈjɔːtʊn/, "giant"), the Valheim Library was created with the inten
We have lots of features planned for the future, and did hold back on what we wanted to release with so that we could focus on house keeping post-merger, however I hope the features we have implemented thus far prove to be a useful base and provide an idea of the consistency we aim to deliver moving forwards.

## Source code
The source code for Jötunn (and the accompanying test/demo mod) is available on GitHub, [here](https://github.com/Valheim-Modding)
The source code for Jötunn (and the accompanying test/demo mod) is available on [GitHub](https://github.com/Valheim-Modding).

## Getting started
A quick overview of the prerequisites to start using Jötunn for beginners and advanced users can be found [here](tutorials/getting-started.md).

## Tutorials
This section contains tutorials on how to get started with using JötunnLib, and how to create a basic mod. View it [here](tutorials/intro.md)
This section contains tutorials on how to get started with Valheim modding using Jötunn. View it [here](tutorials/intro.md)

_note: the tutorial uses the [Mod Stub](https://github.com/Valheim-Modding/JotunnModStub) to work towards creating the final [Example mod](https://github.com/Valheim-Modding/JotunnModExample)._
_note: the tutorial uses the [Mod Stub](https://github.com/Valheim-Modding/JotunnModStub) to work towards creating the final [Example mod](https://github.com/Valheim-Modding/JotunnModExample) from scratch. If you just want to look up some of the concepts of Jötunn skip the intro part and browse to the specific topic you are interested in._

## Conceptual
This section contains information about how Valheim itself works, as well as how JötunnLib interfaces with the game. There likely will not be many code examples here, but rather high level overviews of how various systems work. View it [here](conceptual/intro.md)
Expand Down
38 changes: 22 additions & 16 deletions JotunnLib/Documentation/tutorials/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Getting started
# Getting started

If you already have a mod for Valheim and want to switch to Jötunn or did use legacy JötunnLib or ValheimLib before all you need to do is to install the latest release of Jötunn from [nuget.org](https://www.nuget.org/packages/JotunnLib) into your project and start using it. Jötunn uses [MMHooks](https://github.com/MonoMod/MonoMod), so make sure you have build the detour dlls and reference them in your project.

Jötunn offers some PreBuild tasks to automate certain housekeeping duties for you. Skip the first part if you already have an environment setup but still want to learn about the automations.

If you want step-by-step instructions to start a Valheim mod from scratch using Jötunn continue reading as we guide you through the process of setting up everything you need to get going.

## Development Environment

Expand All @@ -14,9 +19,12 @@
* In visual studio, in the right hand toobar, select `Git Changes`, and then `Clone Repository`, and paste the URL provided by the previous step. Name your project and place it accordingly.<br />
![VS Clone forked stub](../images/getting-started/vs-CloneForkedStub.png)

* Browse to your solution directory. Create a new file called `Environment.props` and place the following contents inside, modifying your `<VALHEIM_INSTALL>` to point to your game directory. Right click on your project in the solution explorer, and select reload project:
## Setting up Jötunn PreBuild automations

### Add project references

Jötunn can automatically set references to all important libraries needed to mod the game on your project. To use this feature browse to your solution directory. Create a new file called `Environment.props` and place the following contents inside, modifying your `<VALHEIM_INSTALL>` to point to your game directory. This sets up references in your project to BepInEx, the publicized dlls, the unstripped corlibs from Unity and MMHook dlls.

Example:
```xml
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Expand All @@ -27,10 +35,11 @@ Example:
</Project>
```

**WARNING:** *This prebuild task will add references to your current project. If you already have setup that references it most certainly will duplicate them.*

If you want the publicised and MMHOOK dlls automatically created, then set `ExecutePrebuild` in [DoPrebuild.props](https://github.com/Valheim-Modding/JotunnModStub/blob/master/DoPrebuild.props) to true. If you opt not to utilise this automation, it is suggested that you generate your method detours and publicised assemblies, and add them to your projects references manually.
### Publicize and MMHook Valheim assemblies

**WARNING:** *This prebuild task will automate the generation of monomod method detours and publicising of game assemblies. By enabling this, you understand that you will be generating new publicised assemblies and method detours upon PreBuild **IF** the binaries have been updated since the last time the PreBuild has run.*
If you want the publicised and MMHOOK dlls automatically created, then set `ExecutePrebuild` in [DoPrebuild.props](https://github.com/Valheim-Modding/JotunnModStub/blob/master/DoPrebuild.props) to true. Create that file if you are not using the ModStub but still want Jötunn to create the Hooks for you. If you opt not to utilise this automation, it is suggested that you generate your method detours and publicised assemblies, and add them to your projects references manually.

```xml
<?xml version="1.0" encoding="utf-8"?>
Expand All @@ -41,20 +50,17 @@ If you want the publicised and MMHOOK dlls automatically created, then set `Exec
</Project>
```

**WARNING:** *This prebuild task will automate the generation of monomod method detours and publicising of game assemblies. By enabling this, you understand that you will be generating new publicised assemblies and method detours upon PreBuild **IF** the binaries have been updated since the last time the PreBuild has run.*

### Manual setup

**NOTE**: If for whatever reason you disable the prebuild, you will need to:
If for whatever reason you disable the prebuild, you will need to:
- acquire and install [HookGen](https://valheim.thunderstore.io/package/ValheimModding/HookGenPatcher/)
- launch the game to generate event wrappers
- add the `/BepInEx/plugins/MMHook/assembly_*` files to your project references.
- grab the [Assembly Publiciser](https://github.com/CabbageCrow/AssemblyPublicizer) *(drag drop your `/BepInEx/plugins/MMHook/assembly_*` files ontop of the publiciser)*
- and add the resulting assemblies to your stub project.
- Build the stub, make sure it compiles and automates the postbuild tasks, producing compiled binaries in your plugin directory
- Create a new project template of this project. You will then be able to duplicate this project to create a multi-plugin solution, convenient for maintaining multiple mods.

* Build your solution. Check your `BepInEx/plugins/yourtestmod/` folder for the `yourtestmod.dll.mdb` monodebug symbols file.

* You may now proceed to one of the [Tutorials](intro.md)
- grab the [Assembly Publicizer](https://github.com/CabbageCrow/AssemblyPublicizer) *(drag drop your `/BepInEx/plugins/MMHook/assembly_*` files ontop of the publiciser)* and add the resulting assemblies to your stub project.
- Build the stub, make sure it compiles and automates the postbuild tasks, producing compiled binaries in your plugin directory `BepInEx/plugins/yourtestmod/` folder and also generated a `yourtestmod.dll.mdb` monodebug symbols file.
- You may now proceed to one of the [Tutorials](intro.md)

## Customising your project

Expand All @@ -73,9 +79,9 @@ If you want the publicised and MMHOOK dlls automatically created, then set `Exec
* Your project base is now ready for use! You can proceed to []() or select a specific section to learn about from our [Tutorials]()


# Build automations
# Post Build automations

Included in this repo are a PowerShell script `publish.ps1`. The script is referenced in the project file as a build event. Depending on the chosen configuration in Visual Studio the script executes the following actions.
Included in the ModStub and ModExample repos is a PowerShell script `publish.ps1`. The script is referenced in the project file as a post build event. Depending on the chosen configuration in Visual Studio the script executes the following actions.

## Building Debug

Expand Down

0 comments on commit 7e5da56

Please sign in to comment.