Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xilo templates!! #100

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions docs/dev/initial-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@ This guide is roughly based on some parts of the [BepInEx setup guide](https://d
### .Net SDK {#dotnet-sdk}
An SDK (=Software Development Kit) is a system that allows you to turn your code into something that your PC can run. It is used by other tools, and you'll generally not interact with it directly.

You'll want to download and install the latest .Net 7 SDK version from [this page](https://dotnet.microsoft.com/en-us/download/dotnet/7.0). It'll look something like this:
You'll want to download and install the latest .NET SDK version from [this page](https://dotnet.microsoft.com/en-us/download). It'll look something like this:

[![.Net SDK download](/images/initial-setup/net7sdkdownload.png)](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)

::: danger
The .Net 8 SDK can cause issues with the BepInEx 5 template. Until these issues are resolved, it is recommended to install .Net 7 instead of 8.
:::
[![.Net SDK download](/images/initial-setup/netsdkdownload.png)](https://dotnet.microsoft.com/en-us/download)

### IDE
By far the most important tool in a programmer's toolbox is an IDE (=Integrated Development Environment). For now, the definition of an "overengineered text editor" will suffice. Through an IDE, you can edit code far more efficiently, since it offers features such as:
Expand Down
58 changes: 42 additions & 16 deletions docs/dev/starting-a-mod.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This guide assumes you've completed all the required steps in **[initial setup](

This guide follows certain parts of the [official BepInEx guide](https://docs.bepinex.dev/articles/dev_guide/plugin_tutorial/2_plugin_start.html).

### Using the template repository {#using-template-repo}
### (Harmony Only) Using the template repository {#using-template-repo}
MaxWasUnavailable marked this conversation as resolved.
Show resolved Hide resolved
::: danger Outdated Template
The linked GitHub template repository may be **stale**. Refer to the Lethal Company Modding Discord server if you encounter issues using it.
:::
Expand All @@ -24,37 +24,63 @@ It does come with some minor drawbacks such as it using "LethalCompanyTemplate"

It is important that you remove all unused template code from the project before distributing your mod.

### Creating your project {#create-project}
### Using the dotnet template {#using-dotnet-template}
Xilophor marked this conversation as resolved.
Show resolved Hide resolved

First things first, you'll need to create your project. If you've not done so already, we recommend running the following command in a console to add some BepInEx templates for new projects:
First things first, you'll need to create your project. If you've not done so already, we recommend running the following command in a console to add some Lethal Company templates for new projects:

```cmd
dotnet new -i BepInEx.Templates --nuget-source https://nuget.bepinex.dev/v3/index.json
```shell
dotnet new -i Xilophor.LCModTemplates
```

Next, you'll want to create a new project (sometimes called "solution", in CSharp). There are two main ways to do this.

#### Using an IDE (more control) {#using-ide}
#### Using an IDE (easier) {#using-ide}

Depending on your IDE, this process will look slightly different. You'll want to give the solution the name of your soon-to-be mod. If given the option to use a template (you may want to google for *"how to use template in Visual Studio"* or *"how to use template in Rider"*), use the `BepInEx 5 Plugin Template`.
Depending on your IDE, this process will look slightly different. You'll want to give the solution the name of your soon-to-be mod. If given the option to use a template (you may want to google for *"how to use template in Visual Studio"* or *"how to use template in Rider"*), use the `Lethal Company Harmony Mod Template`.

#### Using the console (simpler) {#using-console}
::: warning
Note that Visual Studio has issues with both the `NuGetPackages` setting and the `UseNetcodePatcher` setting. Anything set in `NuGetPackages` will be ignored by Visual Studio; and if you set `UseNetcodePatcher` to true, you will have to manually run the `install-netcode-patcher.cmd` file.
Xilophor marked this conversation as resolved.
Show resolved Hide resolved

Rider also does not support custom arguments/settings in templates at the moment, so you will not be able to customize your mod other than the mod's name.
:::

#### Using the console (recommended for control) {#using-console}

Alternatively, you can open a console and run the following command, assuming you've set up the templates using the command above. Replace `MyFirstPlugin` with your mod's name:
Alternatively, you can open a console and run the following command, assuming you've set up the templates using the command above.
Replace `MyFirstMod` with your mod's name, and `MyName` with your username:

```cmd
dotnet new bepinex5plugin -n MyFirstPlugin -T "netstandard2.1" -U "2022.3.9"
```shell
dotnet new lchmod -n MyFirstMod -M MyName.MyFirstMod
Xilophor marked this conversation as resolved.
Show resolved Hide resolved
```

::: warning
Some people have been [reporting problems](https://github.com/BepInEx/BepInEx.Templates/issues/8) creating new BepInEx plugins from the template when using the .NET 8 SDK:
To see the other options provided in the mod template, you can use the following command:

```shell
dotnet new lchmod --help
```

#### Note for MonoMod users {#monomod-note}

`Failed to create template.
Details: Object reference not set to an instance of an object.`
If you want to use MonoMod, you can instead use the `Lethal Company MonoMod Mod Template` in your IDE or use `lcmmod` instead of `lchmod` in the console.
Xilophor marked this conversation as resolved.
Show resolved Hide resolved

If you get this error, try downgrading to the [.NET 7 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/7.0).
This template has an additional argument/setting for MonoMod specifically. In VS, it can be seen under MMHOOKLocation, and in the console, it's set with the `-MM` argument.
This argument/setting is to set the MMHOOK directory to use for hooking (i.e. the HookGen "plugin").

Without changing this setting, you will have to manually hook instead of using the `On.Class.Method += CustomMethod;` style provided by HookGen.

::: warning
Ensure that you include a trailing slash (`\` or`/`) in the path you give to your MMHOOK folder in your (test profile's) BepInEx/plugins folder.
Otherwise, your mod will fail to compile as the path is not complete.

If this happens, add a trailing slash (`\` or`/`) to the `MMHOOKLocation` property in the `.csproj.user` file.
:::

Example command line usage with a path of `C:\path\to\r2modman\LethalCompany\profiles\test\BepInEx\plugins\MMHOOK\`:

```shell
dotnet new lcmmod -n MyFirstMod -M MyName.MyFirstMod -MM "C:\path\to\r2modman\LethalCompany\profiles\test\BepInEx\plugins\MMHOOK\"
```

### Organising your modding projects {#organize-project}

We recommend creating a folder somewhere easily accessible that will store all of your future modding projects. Something like "LethalCompanyMods". Move the newly created folder for your mod into this folder, to keep things well-organised.
Expand Down
Binary file removed docs/public/images/initial-setup/net7sdkdownload.png
Binary file not shown.
Binary file modified docs/public/images/initial-setup/netsdkdownload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.