Skip to content

Commit

Permalink
Merge pull request #4 from LethalCompany/feat_copy-over-old-wiki
Browse files Browse the repository at this point in the history
Copy over content from old wiki
  • Loading branch information
legoandmars authored Nov 28, 2023
2 parents d80d346 + 1f156ba commit a7a45c4
Show file tree
Hide file tree
Showing 6 changed files with 331 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/extras/about.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# About This Guide
---
This guide is mainly written by [Bobbie](https://twitter.com/VRBobbie), with assistance and advice from various other writers and wikis. The guide was inspired by [bsmg.wiki](https://bsmg.wiki).
This guide is mainly written by [Max](https://github.com/MaxWasUnavailable) & [Bobbie](https://twitter.com/VRBobbie), with assistance and advice from various other writers and wikis. The guide was inspired by [bsmg.wiki](https://bsmg.wiki).

> ## Credits
>
> ### Writers
> **Bobbie, Jdewi, Burrito, Steven, Lauriethefish, Nintendo Homebrew Discord Staff (original guide creators)**
> **Bobbie, Max, Jdewi, Burrito, Steven, Lauriethefish, Nintendo Homebrew Discord Staff (original guide creators)**
>
> ---
> Thank you to [everyone else](https://github.com/legoandmars/LethalCompanyModdingWiki/graphs/contributors) that contributed to the guide on GitHub.
> Thank you to [everyone else](https://github.com/LethalCompany/ModdingWiki/graphs/contributors) that contributed to the guide on GitHub.
>
> ## Developer / Tool Credits
Expand Down
47 changes: 47 additions & 0 deletions docs/user-guide/ethics/open-source-and-ethics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Open-source and ethics

## What is open-source?

Open-source means that code is publicly available, to be used, edited, and distributed by anyone. It fosters a
collaborative and public approach to software development. There are a number of important things to take into account
when developing open-source software, however.

### Licenses

A GitHub repository *without* a License is **not** open-source:

> without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one
> may reproduce, distribute, or create derivative works from your work.
>
> *source: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository#choosing-the-right-license*
This means, if you actually want to properly open-source your mods, that you'll have to pick an open-source license.
This might sound scary, but it really doesn't have to be. GitHub created a very simple and nice website to find a
license that fits your project: https://choosealicense.com/

!> **Obligatory "we are not lawyers". Our interpretation of these licenses is primarily based off of the `choosealicense`
website, as well as personal experience.**

We recommend going with one of the following two licenses for mods:

- [GNU General Public License v3.0](https://choosealicense.com/licenses/gpl-3.0/) -- the main benefit of this license is
that anyone using your mod's code (be it as a spin-off version, updated version, or in other games) will *have* to use
this license as well. This means your work, and any derivative work, will remain open-source. It means people can't
grab your work and create a version which has no public code, and it means the community will forever be able to build
upon your work and keep your mod alive, even if you lose interest in it.
- [MIT License](https://choosealicense.com/licenses/mit/) -- this is a more permissive version of the GNU General Public
License. It *also* allows users to create *closed-source* versions of your mod. This means a user is not required to
share their updated code publicly. They must, however, still retain the original license's copyright notice readily
available.

### Healthy collaboration

A modding community thrives when users help each other out. Keeping your mods open-source means current (and future)
modders can learn from your current work, and perhaps even keep your mods updated if you ever leave the community.

It is, however, important to be ethical about this. We understand a modding community can get competitive. Please,
refrain from taking code and claiming it as your own - always properly give credit where credit is due.

Likewise, when other users help you by fixing bugs, and want to submit a pull request, please accept that, rather
than taking the fix and implementing it yourself - this gives them some credit for the fix, and fosters a community
where people aren't afraid to help out.
106 changes: 106 additions & 0 deletions docs/user-guide/modding/initial-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Initial Setup

## Setting up your development environment

Before you can start modding, you'll need some tools to actually create mods. Luckily, all of these are **available for free**.

>! This guide is roughly based on some parts of the [BepInEx setup guide](https://docs.bepinex.dev/articles/dev_guide/plugin_tutorial/1_setup.html), which is another great resource for learning how to mod
### .Net 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 recommended version from [this page](https://dotnet.microsoft.com/en-us/download). It'll look something like this:

[![image](https://github.com/LethalCompany/LethalCompanyModdingWiki/assets/89798523/6cbfe6ac-bc13-4566-a458-f432061f9393)](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:
- Syntax highlighting
- Compiling
- Code completion
- Integrated tools (version control, linting, etc...)
- Debugging

You might wonder why some of these are important (or what some of these even are), but that falls outside of the scope of this wiki. Rest assured however that they're essential and will save you a lot of headaches. Do *not* try and create mods in a simple text editor such as notepad. Technically, you can do this, but there's no reason for it beyond masochism.

For IDE's, we recommend one of the following free options:
- [Visual Studio](https://visualstudio.microsoft.com/) -- **Recommended** -- An all-in-one package. Has a built-in decompiler, which can save some time.
- [Visual Studio Code](https://code.visualstudio.com/) -- A more lightweight package.

If you have access to a Jetbrains License, we recommend the following paid option:
- [Rider](https://www.jetbrains.com/rider/) -- **Recommended** (The author of this article uses it himself) -- An all-in-one package. Comparable to Visual Studio. Has a built-in decompiler, which can save some time.

### BepInEx
To actually load mods into the game, we need a mod loader. This is where BepInEx comes in! **Be**pis **In**jector **Ex**tensible is a patcher/plug-in framework for Unity games. It'll handle everything related to getting the plugin to actually load into the game, so we can focus on creating the plugin without having to worry about anything else.

You'll first want to install BepInEx to your game. Follow their great [installation guide](https://docs.bepinex.dev/articles/user_guide/installation/index.html) to get this done. You'll want [this](https://github.com/BepInEx/BepInEx/releases/download/v5.4.22/BepInEx_x64_5.4.22.0.zip) version of BepInEx.

Once installation is complete, boot up the game once to have it generate some configuration files. Then, refresh the folder you just installed BepInEx into, and go into the `BepInEx/config` folder. Here, you'll find a file named `BepInEx.cfg`. Open it, and find and edit the following section:

```ini
[Logging.Console]

## Enables showing a console for log output.
# Setting type: Boolean
# Default value: false
Enabled = false
```

to

```ini
[Logging.Console]

## Enables showing a console for log output.
# Setting type: Boolean
# Default value: false
Enabled = true
```

### Decompiler (*highly recommended / near essential*)
A decompiler allows you to decompile an existing program. This is technical terminology that can roughly be translated to "it allows you to peek behind the curtain and see what the code of a program looks like". Why is this important, you may ask? Well, if we're going to mod a game, we first need to know *what* to mod. Do we want to reduce the price of items? We'll need to know in what part of the code items are displayed and sold to the player. Do we want to add a weather condition? We'll need to know in what parts of the code the game handles and spawns weather.

We recommend one (or all) of three free options:
- [dnSpy](https://github.com/dnSpy/dnSpy)
- [ILSpy](https://github.com/icsharpcode/ILSpy)
- [dotPeek](https://www.jetbrains.com/decompiler/)

!> **Note you do not necessarily need this if you have Rider or Visual Studio, since they come with built-in decompilers. Note that different decompilers offer slightly different results, and have different interfaces.**

### Unity Explorer (optional)
[Unity Explorer](https://github.com/sinai-dev/UnityExplorer) is a tool which adds an in-game UI that allows you to explore, debug, and modify the game while it's running. This tool can be highly useful to get to know the game's technical side better, and his hence strongly recommended.

You will want to download the version compatible with the latest version of BepInEx (5).

[![image](https://github.com/LethalCompany/LethalCompanyModdingWiki/assets/89798523/56027c1a-dfd8-4b99-8756-a496c7dd18ca)](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx5.Mono.zip)

### Additional tools (optional)
There are a number of BepInEx plugins and tools that might be useful as you get more experienced with modding. The BepInEx devs have helpfully listed them [here](https://docs.bepinex.dev/articles/dev_guide/dev_tools.html).

## Creating a GitHub account

We strongly recommend using git - a "version control system". The most popular website that offers this as a (free) service is GitHub; the website you're on right now.

The following video is a short primer on what git (and a version control systems in general) is: https://www.youtube.com/watch?v=2ReR1YJrNOM

For additional reading, please see [GitHub's documentation](https://docs.github.com/en/get-started/quickstart/hello-world).

In short, Git(Hub) allows you to do the following things without hassle:
- Keep a *complete* history of your project
- Allows you to revert to a previous version if you made a mistake
- Allows you to retrieve your code if your hard drive fails, or you delete something by accident
- Allows you to revisit previous updates and patch notes, adding implicit documentation to your project (when done right)
- Collaborate with others
- Others can send *requests* to update files of your project
- Others can download your code and learn from it
- Others can continue updating your project, *long* after you've stopped caring about it
- Others can help you fix a bug, and you can easily get that bug fixed version of your project

Without going into too much detail, there is a difference between "Git", and "GitHub". Git is a program that anyone can run. GitHub is a website that makes this program available to others through the cloud - allowing for collaborating, and remote backups. You *can* just use Git locally, but you'll lose a lot of the benefits. An alternative to GitHub is [GitLab](https://about.gitlab.com/).

To create an account, simply go to [GitHub's home page](https://github.com/) and follow the steps. GitHub also has a [guide](https://docs.github.com/en/get-started/onboarding/getting-started-with-your-github-account) on creating a new account (just ignore the step about checking pricing plans - you don't need a paid account, this is primarily for companies and professional users).

## Next steps

Now that you've set up everything, you'll want to proceed to the **[starting a mod]()** article!
94 changes: 94 additions & 0 deletions docs/user-guide/modding/starting-a-mod.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Starting a mod

## Setting up your project
> This guide assumes you've completed all the required steps in **[initial setup]()**, or that you know what you're doing.
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

We have created a [template repository](https://github.com/LethalCompany/LethalCompanyTemplate) on GitHub. If you're remotely familiar with GitHub, or willing to [learn](#TODO-LINK-TO-CORRECT-PAGE-AND-HEADER), this might serve as a quick start. It does come with some minor drawbacks such as it using "LethalCompanyTemplate" as project name in a number of files, but you can edit this. It should build out-of-the-box with no edits required; though you may need to add BepInEx as a NuGet source (see the [relevant](#adding-nuget-source) section below).

### Creating your project

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:

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

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)

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 `insert your IDE name here, for example "Rider" or "Visual Studio"`"*), use the `BepInEx 5 Plugin Template`.

#### Using the console (simpler)

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:

```cmd
dotnet new bepinex5plugin -n MyFirstPlugin -T "netstandard2.1" -U "2022.3.9"
```

### Organising your modding projects

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.

### Adding NuGet source

BepInEx uses a separate NuGet source. You'll need to add the BepInEx NuGet source to your global source list.

The BepInEx NuGet source has the following configuration:
```
name: BepInEx
url: https://nuget.bepinex.dev/v3/index.json
```

For Rider, you can do this by going to the NuGet window, going to its `Sources` tab, and then clicking on the green "+" icon in the `Feeds` sub-tab. There, add a new entry using the above configuration. See [Rider's docs](https://www.jetbrains.com/help/rider/Using_NuGet.html#sources) for more info.

![29diyCjTfG](https://github.com/LethalCompany/LethalCompanyModdingWiki/assets/89798523/879e8346-edc2-4841-85f8-7f0da90ee676)

![image](https://github.com/LethalCompany/LethalCompanyModdingWiki/assets/89798523/e71d17e7-bcd7-45e0-8d8d-bbf0c4002e93)

For Visual Studio, please follow [this documentation](https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio#package-sources).

### Making sure your mod is set up correctly

Mods are developed for specific versions of Unity and .NET, which can be specified in a configuration file. This file is a `.csproj` file, and has as name the name of your mod (e.g. `MyFirstPlugin.csproj`). If you used the console command correctly, it should work out of the box. However, you'll want to double check this to prevent any easy-to-fix problems that can result from not having it set up correctly. When using an IDE, the template might not use the correct version, so in this case you'll definitely have to check things.

Our [template project](https://github.com/LethalCompany/LethalCompanyTemplate) has an example `.csproj` file that is properly configured, which can be found [here](https://github.com/LethalCompany/LethalCompanyTemplate/blob/main/LethalCompanyTemplate/LethalCompanyTemplate.csproj). Please check and compare your local mod's file with this file, and make sure the following segment is the same (except for the `AssemblyName`, `Description`, and `Version`).

![firefox_2GJuWUWtfR](https://github.com/LethalCompany/LethalCompanyModdingWiki/assets/89798523/412f0870-a806-42ef-a7e7-a3a63c79f6c4)

### "Building" your mod

Your IDE is capable of turning your code into a file that can be run (in this case by BepInEx as a mod). This process is called "building" or "compiling". In this case, it will turn your code into a `.dll` file. This file *is* your mod.

Depending on your IDE, the build button may be placed differently. For Rider, it is in the top right:

![image](https://github.com/LethalCompany/LethalCompanyModdingWiki/assets/89798523/fe4bd6d2-8948-4045-a05c-b9703916feea)

Once built, you should be able to find the `.dll` file in your project's folder, in the following subfolder path (once again replacing `MyFirstPlugin` with the name you gave your mod/project): `MyFirstPlugin/bin/(Release or Debug)/netstandard2.1/MyFirstPlugin.dll`

Simply copy & paste this `.dll` file into the `BepInEx/plugins` folder, in your game directory, and it should run the mod. We recommend keeping the default `LogInfo` statement in your `Awake` method that comes with the template. If you have this statement, you should see it appear in the console that opens when you run the game (after installing BepInEx, and enabling the console as per the first wiki article).

### Adding game assemblies

To actually use the game's methods and classes, you'll need to add the game's `Assembly-CSharp.dll` to your project's references. You can either do this manually by editing your `.csproj` file, or through a GUI your IDE provides. You will want to google how to do this for your specific IDE.

You will very likely also need the `UnityEngine.dll`, since this is required to use any of Unity's methods and classes.

The [template project](https://github.com/LethalCompany/LethalCompanyTemplate) has both of these set up, so you can copy that part of the `.csproj` file. You **will** need to edit the path to be correct, however.

The assemblies can be found in the `Lethal Company_Data/Managed` folder, in the game's directory.

### Additional guides

We highly recommend reading through the rest of the [official BepInEx guide](https://docs.bepinex.dev/articles/dev_guide/plugin_tutorial/2_plugin_start.html) for extra information.

## Next steps

We recommend reading through our very short guide on [open-source & ethics](), to help foster a healthy modding community.

Once you've finished a mod, you can [publish it]().
3 changes: 0 additions & 3 deletions docs/user-guide/modding/writing-mods.md

This file was deleted.

Loading

0 comments on commit a7a45c4

Please sign in to comment.