Skip to content

Commit

Permalink
Merge pull request #631 from valheimPlus/development
Browse files Browse the repository at this point in the history
Updating master branch to development state
  • Loading branch information
nxPublic committed Sep 18, 2021
2 parents 73c1565 + b7c2c50 commit 5ba876e
Show file tree
Hide file tree
Showing 132 changed files with 11,803 additions and 1,543 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

patreon: valheimPlus
22 changes: 17 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,42 @@ assignees: ''

---

- OS: [e.g. Windows Client, Windows Server, or Linux Server]
- Valheim Game Version [e.g. 0.4.11, etc]
- Mod Version [e.g. 0.9, 0.9.2, etc.]
- **OS:** [e.g. Windows Client, Windows Server, or Linux Server]
- **Valheim Game Version:** [e.g. 0.4.11, etc]
- **V+ Mod Version:** [e.g. 0.9, 0.9.2, etc.]

**Describe the bug**

A clear and concise description of what the bug is and how you found it.


**To Reproduce**
Steps to reproduce the behavior:

Steps for the devs to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error


**Expected behavior**

A clear and concise description of what you expected to happen.


**Troubleshooting**

What steps have you taken to try to fix?


**Screenshots**

If applicable, add screenshots to help explain your problem.


**Link to [pastebin](https://pastebin.com) containing .cfg configuration if applicable:**


**Additional context**
Add any other context about the problem here.

*Please list any other mods besides V+ that you have installed* here. Add any other context about the problem here.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,6 @@ packages/HarmonyX.2.3.1/LICENSE
packages/HarmonyX.2.3.1/lib/netstandard2.0/0Harmony.xml
packages/HarmonyX.2.3.1/lib/net45/0Harmony.xml
packages/HarmonyX.2.3.1/lib/net35/0Harmony.xml

# include libraries folder
!libraries/*
38 changes: 29 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,40 @@
## How to setup your environment for V+ development
How to setup the development enviroment to compile ValheimPlus yourself.

1. Download the [BepInEx for Valheim package](https://valheim.thunderstore.io/package/download/denikson/BepInExPack_Valheim/5.4.701/).
- Unpack into your Valheim root folder and overwrite every file when asked.
1. Download the [BepInEx for Valheim package](https://valheim.thunderstore.io/package/download/denikson/BepInExPack_Valheim/5.4.1100/).
- Extract zip contents and copy the contents inside `/BepInExPack_Valheim/` and paste them in your Valheim root folder and overwrite every file when asked.
- This package sets up your Valheim game with BepInEx configurations specifically for mod devs. Created by [BepInEx](https://github.com/BepInEx).
1. Copy over all the DLLs from Valheim/unstripped_corlib to Valheim/valheim_Data/Managed *(overwrite when asked)*
1. Download the [AssemblyPublicizer package](https://mega.nz/file/oQxEjCJI#_XPXEjwLfv9zpcF2HRakYzepMwaUXflA9txxhx4tACA).
- This package has a tool that you'll use to create publicized versions of the `assembly_*.dll` files for your local development.
- Repo: https://github.com/MrPurple6411/Bepinex-Tools/releases/tag/1.0.0-Publicizer by [MrPurple6411](https://github.com/MrPurple6411).
1. Drag and drop all `assembly_*.dll` files from "\Valheim\valheim_Data\Managed\" folder onto "AssemblyPublicizer.exe". This will create a new folder called "/publicized_assemblies/".
1. Add all `.dll`s (Except `mscorlib.dll`, `System.Configuration.dll`, `System.Core.dll`, `System.dll`, and `System.Xml.dll`) of "\Valheim\valheim_Data\Managed\" and "publicized_assemblies" folder as references to the project.
1. Add all BepInEx `.dll`s (Except `0Harmony.dll` and `0Harmony20.dll`) as references to the project.
1. Use Nuget to add "Ini-parser" and "HarmonyX" references.
1. Define Enviroment Variable `VALHEIM_INSTALL` with path to Valheim Install Directory
1. Define Environment Variable `VALHEIM_INSTALL` with path to Valheim Install Directory
- example: `setx VALHEIM_INSTALL "C:\Program Files\Steam\steamapps\common\Valheim" /M`

## Debugging with dnSpy

Thanks to mono and unity-mono being open source, we patched and compiled our own mono runtime and enabled actual live debugging of the game and the mod itself with dnSpy.

1. Download [dnSpy-net-win64](https://github.com/dnSpy/dnSpy/releases) and extract the exe.
2. Load all assemblies from \<Valheim>\unstripped_corlib into dnSpy (just drag&drop the folder onto it).
3. Load all assembly_* from \<Valheim>\valheim_Data\Managed into dnSpy (*do not load the publicized ones, they will not be loaded into the process and therefore can not be debugged*).
4. Load ValheimPlus.dll from \<Valheim>\BepInEx\plugins into dnSpy.
5. Copy .\libraries\Debug\mono-2.0-bdwgc.dll from this repo to \<Valheim>\MonoBleedingEdge\EmbedRuntime and overwrite the existing file.
6. Now go to `Debug` -> `Start Debugging` and select Unity debug engine. Select your valheim.exe as the executable and hit OK.
7. If you did set some breakpoints, the game will halt when it hits the breakpoint in memory and dnSpy will show you the objects in memory and lets you do much more useful stuff.

## V+ Conventions
### C#
1. Please add all `Patch`ed methods to the file named for the type being patched. So if we patch a class type named `Humanoid`, add that patch to the `GameClasses/Humanoid.cs` file.
1. Patch naming convention update
- Any new classes for patches will follow the following naming convention. Please make sure future classes are named appropriately. The objective is to simplify and avoid clashes of method patching and a potential refactor in the future.

```csharp
File of patch == GameClass.cs file
// File of patch == GameClass.cs file
Class structure:
[HarmonayPatch(typeof(GameClass), "MethodName")]
[HarmonyPatch(typeof(GameClass), "MethodName")]
{modifiers} class GameClass_MethodName_Patch
{
bool Prefix...
Expand All @@ -41,21 +51,31 @@ How to setup the development enviroment to compile ValheimPlus yourself.

### Configuration .cfg
1. Always add new configurations to the .cfg file as well as the configuration class and set the value to the default value from the game.
1. Always add your new added configurations to the vplusconfig.json at the appropriate places with the most information you are able to fill out (for icons,[FontAwesome](https://fontawesome.com/icons?d=gallery) ).
- It is easy to forget test values in your code when you make a PR. Please double check your default values when creating a PR
- It is recommended when testing to test value inline with your code instead of altering the values on the .cfg/class to prevent this issue. If an inline hardcoded value gets pushed, it's easier to spot this mistake than a inaccurate cfg setting.
1. Try to find an appropriate existing configuration section before adding a new one. Generally, if your configuration changes something related to the player, for example, then add it to the `[Player]` section. Look at it from the perspective of a user who's looking for a specific configuration instead of the perspective of someone who's coding and looking for a class.
1. Add any new configuration Sections (`[Section]`) to the bottom of the .cfg file so that we're less likely to break existing config.
1. Check out our helpers in the /Utilities/ folder and use them where appropriate
1. For configuration modifiers that add a modifcation to the base value, always use a percentage configuration and use the `applyModifier()` utility.
1. For configuration modifiers that add a modification to the base value, always use a percentage configuration and use the `applyModifier()` utility.
1. For configuration modifier values make sure to add `"modifier": "true"` as entry stat to the vplusconfig.json.

## Making a Pull Request
1. Only make a pull request for finished work. Otherwise, if we pull the work down to test it and it doesn't work, we don't know if it's because it's unfinished or if there's an unintentional bug.
- If you'd like a review on your work before something it's finished, send us a link to a compare via Discord or make a "Draft" PR.
1. If you want credit, add your credit to the `README.md` in your pull request if the work is more than a documentation update. We will not be able to track this ourselves and rely on you to add your preferred way of being credited.
1. After you have made a GitHub contribution, reach out to one of the V+ devs on Discord if you'd like the "GitHub contributor" role.
2. Make sure that if your pull requests takes care of a suggestion from our website at https://valheim.plus/todo that you also remove it from the `vplusSuggestions/todo.json`

## Pull Request labels
1. pending merge - This work has been reviewed and accepted and will be merged after the coming release
1. pending close - This work has not been updated for a while and will be closed if no response/update is received in 2 days
1. needs updating - This work has received feedback and needs to be updated before being accepted
1. merge conflicts - This pr has merge conflicts that need to be resolved
1. question - The author of the PR needs to answer a question before the PR can move forward
1. in discussion - We want to implement the PR but have to make more preparations and tests before we can do so.

## Files
1. valheim_plus.cfg - the file responsible for loading the configuration on game start.
2. vplusconfig.json - the file responsible to generate the website documentation that can be found here https://valheim.plus/documentation
3. vplusSuggestions/todo.json - the file responsible to generate the website page https://valheim.plus/todo
Loading

0 comments on commit 5ba876e

Please sign in to comment.