Skip to content

Commit

Permalink
Merge pull request #2 from NeoKaios/MTDUI-support-KaiosPR
Browse files Browse the repository at this point in the history
Full MTDUI 1.0.3 support, Thuderstore release
  • Loading branch information
NeoKaios committed Jul 2, 2022
2 parents 3ad36d2 + 85b5263 commit 61bd1b5
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 287 deletions.
6 changes: 5 additions & 1 deletion DebugUtilityMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>DebugUtilityMod</AssemblyName>
<Description>A mod for modders</Description>
<Version>1.1</Version>
<Version>2.0.1</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down Expand Up @@ -39,6 +39,9 @@
<Reference Include="Unity.TextMeshPro">
<HintPath>$(GameLibDir)\Unity.TextMeshPro.dll</HintPath>
</Reference>
<Reference Include="MTDUI">
<HintPath>$(BepInExDir)\plugins\MTDUI\MTDUI.dll</HintPath>
</Reference>
</ItemGroup>

<!--Automatic deploy-->
Expand All @@ -50,6 +53,7 @@
<Target Name="Package" AfterTargets="Publish">
<MakeDir Directories="$(MSBuildProjectDirectory)\release" />
<Copy SourceFiles="@(MainAssembly)" DestinationFolder="$(MSBuildProjectDirectory)\release" />
<Copy SourceFiles="README.md;icon.png;manifest.json" DestinationFolder="$(MSBuildProjectDirectory)\release"/>
<ZipDirectory SourceDirectory="$(MSBuildProjectDirectory)\release" DestinationFile="$(MSBuildProjectDirectory)\$(AssemblyName)-v$(Version).zip" />
</Target>
</Project>
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Debug Utility Mod
# Debug Utility Mod, aka DUM
A [BepInEx](https://github.com/BepInEx/BepInEx/releases) plugin for [20 Minutes Till Dawn](https://store.steampowered.com/app/1966900/20_Minutes_Till_Dawn/).

## Features
Expand All @@ -9,7 +9,7 @@ Modders can change config values via the BepInEx config file : BepInEx/config/ka

### Configurable feature
- XPPatch : Fast level up and max level
- FastGame : Reach endgame faster
- FastGame : Reach endgame faster (better to restart upon changes)
- Invincibility : Avoid any damage
- GunPatch : Infinite Ammo
- RerollPatch : Every character has infinite reroll
Expand All @@ -22,9 +22,13 @@ To avoid currupting save file during test runs, this mod prevents
- Unlocking new achievements
- Gaining soul currency

## Depedency

For the in-game UI, rely on [MTDUI](https://github.com/legoandmars/MTDUI). Thanks to [@Bobbie](https://github.com/legoandmars) for the contribution !

## For modders

- Clone the project
- Clone the [repo](https://github.com/NeoKaios/20MTD-DebugUtilityMod)
- Open repo in VSCode
- Setup $GameDir variable in *DebugUtilityMod.csproj*
- ```dotnet build``` to build and deploy mod
Expand Down
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "DebugUtilityMod",
"version_number": "2.0.1",
"website_url": "https://github.com/NeoKaios/20MTD-DebugUtilityMod",
"description": "This mod is useful while debugging other mod or the game",
"dependencies": [
"BepInExPackMTD-BepInExPack_20MTD-1.0.0",
"Bobbie-MTDUI-1.0.3"
]
}
81 changes: 81 additions & 0 deletions src/DUMPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using MTDUI;

namespace DebugUtilityMod
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class DUMPlugin : BaseUnityPlugin
{
public static ConfigEntry<bool> activateMod;


public static ConfigEntry<bool> hasXPPatch;
public static ConfigEntry<float> XPmult;
public static ConfigEntry<int> maxPlayerLevel;
public static ConfigEntry<bool> hasFastGame;
public static ConfigEntry<float> gametimerMult;
public static ConfigEntry<bool> hasWeakBossesAndElites;
public static ConfigEntry<bool> hasInvincibility;
public static ConfigEntry<bool> hasGunPatch;
public static ConfigEntry<bool> hasInfiniteReroll;

public void Awake()
{
activateMod = Config.Bind("Activation", "D.U.M.", true, "If false, the mod does not load");
MTDUI.ModOptions.RegisterOptionInModList(activateMod);
if (!activateMod.Value)
{
Logger.LogInfo("<Inactive>");
return;
}

hasXPPatch = Config.Bind("XP Patch", "XP Patch activation", false, "Set to True to activate XP Patch");
XPmult = Config.Bind("XP Patch", "XP multiplier", 2f, "Amount of multiplication bonus applied to XP pickup, 1 is baseXP");
maxPlayerLevel = Config.Bind("XP Patch", "Max level reachable", 100, "Level after which the player stop receiving XP");

hasFastGame = Config.Bind("Fast GameTimer", "FastGame activation", false, "Set to True to activate faster game");
gametimerMult = Config.Bind("Fast GameTimer", "GameTimer speed", 2f, "Increase the speed of the game; x is baseTime/x, 1 is baseTime");

hasWeakBossesAndElites = Config.Bind("Enemy", "Weak Bosses and Elite", false, "If active, Bosses and Elite have 100 HP");

hasInvincibility = Config.Bind("Invincibility", "Invincibility", false, "If active, the player cannot take damage");
hasGunPatch = Config.Bind("Gun", "Infinite Ammo", false, "If active, infinite ammo");
hasInfiniteReroll = Config.Bind("Reroll", "Infinite Reroll", false, "If active, every character can reroll indefinitly");


try
{
string mod = "D.U.M.";
ModOptions.Register(hasXPPatch, location: ConfigEntryLocationType.MainOnly, subMenuName: mod);
ModOptions.Register(XPmult, new List<float>() { 1f, 2f, 5f, 10f, 100f }, ConfigEntryLocationType.MainOnly, subMenuName: mod);
ModOptions.Register(maxPlayerLevel, new List<int>() { 0, 10, 100, 1000 }, ConfigEntryLocationType.MainOnly, subMenuName: mod);
ModOptions.Register(hasFastGame, location: ConfigEntryLocationType.MainOnly, subMenuName: mod);
ModOptions.Register(gametimerMult, new List<float>() { 0.5f, 2f, 5f, 10f, 20f }, location: ConfigEntryLocationType.MainOnly, subMenuName: mod);
ModOptions.Register(hasWeakBossesAndElites, location: ConfigEntryLocationType.MainOnly, subMenuName: mod);
ModOptions.Register(hasInvincibility, subMenuName: mod);
ModOptions.Register(hasGunPatch, subMenuName: mod);
ModOptions.Register(hasInfiniteReroll, subMenuName: mod);
}
catch (Exception ex)
{
Logger.LogError(ex);
}

try
{
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
}
catch
{
Logger.LogError($"{PluginInfo.PLUGIN_GUID} failed to patch methods.");
}
}
}
}
173 changes: 0 additions & 173 deletions src/DebugUtilityPlugin.cs

This file was deleted.

8 changes: 4 additions & 4 deletions src/Patches/EnemyPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ namespace DebugUtilityMod
class EnemyPatch
{

// Weak elites and bosses
// TODO: Make this work when adjusted in-game mid-match instead of only on init
// Weak bosses
[HarmonyPatch(typeof(BossSpawner), "LoadSpawners")]
[HarmonyPrefix]
static void BossLoadSpawners_prefix(ref List<BossSpawn> spawners)
{
if (!DebugUtilityPlugin.PatchEnabled(DebugUtilityPlugin.hasWeakBossesAndElites)) return;
if (!DUMPlugin.activateMod.Value || !DUMPlugin.hasWeakBossesAndElites.Value) return;

foreach (BossSpawn bs in spawners)
{
Expand All @@ -24,11 +23,12 @@ static void BossLoadSpawners_prefix(ref List<BossSpawn> spawners)
}
}

// Weak elites
[HarmonyPatch(typeof(HordeSpawner), "LoadSpawners")]
[HarmonyPrefix]
static void HordeLoadSpawners_prefix(ref List<SpawnSession> spawnSessions)
{
if (!DebugUtilityPlugin.PatchEnabled(DebugUtilityPlugin.hasWeakBossesAndElites)) return;
if (!DUMPlugin.activateMod.Value || !DUMPlugin.hasWeakBossesAndElites.Value) return;

foreach (SpawnSession spawnSession in spawnSessions)
{
Expand Down
Loading

0 comments on commit 61bd1b5

Please sign in to comment.