Skip to content

Commit

Permalink
Merge pull request #23 from Tobi-Mob/Skul_1_7_1
Browse files Browse the repository at this point in the history
Update to Skul 1.7.1
  • Loading branch information
Tobi-Mob authored Jan 23, 2023
2 parents 1f864cc + 2fd8c23 commit ac47e89
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 181 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Features

Compability
===
- Skul Version 1.5.2
- Skul Unity Version 2020.3.22f1
- Skul Version 1.7.1
- Skul Unity Version 2020.3.34
- BepInEx Version 6.0.0.549

Installation
Expand All @@ -32,9 +32,9 @@ Installation
`$(SkulDirectory)` would be the folder where the Skul.exe is.
For Windows it usually is: `C:\Program Files (x86)\Steam\steamapps\common\Skul` or something like that.

* Extract [Unstripped Unity files 2020.3.22 ](https://unity.bepinex.dev/libraries/2020.3.22.zip) into `$(SkulDirectory)\Skul_Data\Managed\`
* Extract [Unstripped Unity files 2020.3.34](https://unity.bepinex.dev/libraries/2020.3.34.zip) into `$(SkulDirectory)\Skul_Data\Managed\`

* Extract [Unstripped corelibs 2020.3.22](https://unity.bepinex.dev/corlibs/2020.3.22.zip) into `$(SkulDirectory)\Skul_Data\Managed\`
* Extract [Unstripped corelibs 2020.3.34](https://unity.bepinex.dev/corlibs/2020.3.34.zip) into `$(SkulDirectory)\Skul_Data\Managed\`

* Extract [BepInEx 6.0.0.549](https://builds.bepinex.dev/projects/bepinex_be/549/BepInEx_UnityMono_x64_f2c0e0f_6.0.0-be.549.zip) into `$(SkulDirectory)`

Expand Down
8 changes: 0 additions & 8 deletions Skul.Mod/NuGet.Config

This file was deleted.

24 changes: 14 additions & 10 deletions Skul.Mod/Patches/DropRatePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using BepInEx.Logging;
using GameResources;
using HarmonyLib;
using Level;
using Services;
Expand Down Expand Up @@ -44,11 +45,11 @@ public static class DropRatePatch
[HarmonyPatch(typeof(GearManager), "GetWeaponToTake", new Type[]{typeof(Random), typeof(Rarity)})]
[HarmonyPrefix]
static bool GetWeaponToTakePrefix(
ref Resource.WeaponReference __result,
ref WeaponReference __result,
GearManager __instance,
Random random,
Rarity rarity,
EnumArray<Rarity, Resource.WeaponReference[]> ____weapons,
EnumArray<Rarity, WeaponReference[]> ____weapons,
List<Characters.Gear.Gear> ____weaponInstances)
{
if (!Enabled)
Expand All @@ -62,7 +63,7 @@ static bool GetWeaponToTakePrefix(
Logger.LogInfo("GetWeaponToTakePrefix for rarity " + rarity);

// Get all weapons up to the requested rarity
IEnumerable<Resource.WeaponReference> possibleDrops = weapons[Rarity.Common];
IEnumerable<WeaponReference> possibleDrops = weapons[Rarity.Common];

if (rarity >= Rarity.Rare)
possibleDrops = possibleDrops.Concat(weapons[Rarity.Rare]);
Expand All @@ -82,7 +83,7 @@ static bool GetWeaponToTakePrefix(
possibleDrops = possibleDrops.Where(item => !equipped.Contains(item.name));
}

List<Resource.WeaponReference> list = possibleDrops.ToList();
List<WeaponReference> list = possibleDrops.ToList();

if (list.Count > 0)
{
Expand All @@ -92,10 +93,13 @@ static bool GetWeaponToTakePrefix(
while (__result.rarity < rarity)
{
Logger.LogInfo("Rarity to low. Upgrading");

// Load the weapon to find out its upgrade.
// TODO: possible without the load?
var realWeapon = __result.Load();
var request = __result.LoadAsync();
request.WaitForCompletion();

var realWeapon = request.asset;

if (realWeapon.upgradable)
{
Expand Down Expand Up @@ -125,11 +129,11 @@ static bool GetWeaponToTakePrefix(
[HarmonyPatch(typeof(GearManager), "GetItemToTake", new Type[]{typeof(Random), typeof(Rarity)})]
[HarmonyPrefix]
static bool GetItemToTakePrefix(
ref Resource.ItemInfo __result,
ref ItemReference __result,
GearManager __instance,
Random random,
Rarity rarity,
EnumArray<Rarity, Resource.ItemInfo[]> ____items,
EnumArray<Rarity, ItemReference[]> ____items,
List<Characters.Gear.Gear> ____itemInstances)
{
if (!Enabled)
Expand Down Expand Up @@ -165,7 +169,7 @@ static bool GetItemToTakePrefix(

var allItems = ____items;

IEnumerable<Resource.ItemInfo> possibleDrops = allItems[rarity];
IEnumerable<ItemReference> possibleDrops = allItems[rarity];

// all unlocked/obtainable items
possibleDrops = possibleDrops.Where(w => w.unlocked && w.obtainable);
Expand All @@ -177,7 +181,7 @@ static bool GetItemToTakePrefix(
possibleDrops = possibleDrops.Where(item => !equipped.Contains(item.name));
}

List<Resource.ItemInfo> itemInfos = possibleDrops.ToList();
List<ItemReference> itemInfos = possibleDrops.ToList();

if (itemInfos.Count > 0)
{
Expand Down
207 changes: 103 additions & 104 deletions Skul.Mod/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,104 +1,103 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mime;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using BepInEx.Unity;
using BepInEx.Unity.Bootstrap;
using Characters.Controllers;
using Data;
using HarmonyLib;
using InControl;
using Level;
using MonoMod.RuntimeDetour;
using Services;
using Singletons;
using Steamworks;
using UI.TestingTool;
using UnityEngine;
using Action = Characters.Actions.Action;
using Random = System.Random;

namespace Skul.Mod
{
[BepInPlugin("Tobi.Mob.Skul.Mod", PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{
public Harmony _harmony = null;

private void Awake()
{
Helper.Logger = Logger;

// Plugin startup logic
Logger.LogInfo("Plugin " + PluginInfo.PLUGIN_GUID + " is loaded!");

// Execute all patches
_harmony = new Harmony("Skul.Mod");
_harmony.PatchAll(typeof(DropRatePatch));
_harmony.PatchAll(typeof(PathPatch));

// Active Turbo-Button-Worker
TurboButtonMode.StartSetTurboCoroutine(this);
}

private LevelManager levelManager => Singleton<Service>.Instance.levelManager;

private void Update()
{
// Only run, if a player is running around
if (!Helper.IsInGame)
return;

// print some infos
if(Input.GetKeyDown(KeyCode.F1))
{
Vector3 v = levelManager.player.transform.position;
float offset = 0.4f;

Helper.TextSpawner.SpawnBuff(" Mod running ", v);
v += Vector3.down * offset;
Helper.TextSpawner.SpawnBuff("F2: Toggle turbo attack", v);
v += Vector3.down * offset;
Helper.TextSpawner.SpawnBuff("F3: Toggle item modifications", v);
v += Vector3.down * offset;
Helper.TextSpawner.SpawnBuff("F4: Toggle path modifications", v);
v += Vector3.down * offset;
Helper.TextSpawner.SpawnBuff("F5: Get some dark quartz", v);
}

if (Input.GetKeyDown(KeyCode.F2))
{
TurboButtonMode.ToggleTurbo();
}

if (Input.GetKeyDown(KeyCode.F3))
{
DropRatePatch.ToggleEnabled();
}

if (Input.GetKeyDown(KeyCode.F4))
{
PathPatch.ToggleEnabled();
}

// Get some Quartz
if (Input.GetKeyDown(KeyCode.F5))
{
if (GameData.Currency.darkQuartz != null)
{
Helper.TextSpawner.SpawnBuff("Got some quartz", levelManager.player.transform.position);
GameData.Currency.darkQuartz.balance += 10000;
}
}
}


}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mime;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using BepInEx.Unity;
using BepInEx.Unity.Bootstrap;
using Characters.Controllers;
using Data;
using HarmonyLib;
using InControl;
using Level;
using MonoMod.RuntimeDetour;
using Services;
using Singletons;
using UI.TestingTool;
using UnityEngine;
using Action = Characters.Actions.Action;
using Random = System.Random;

namespace Skul.Mod
{
[BepInPlugin("Tobi.Mob.Skul.Mod", PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{
public Harmony _harmony = null;

private void Awake()
{
Helper.Logger = Logger;

// Plugin startup logic
Logger.LogInfo("Plugin " + PluginInfo.PLUGIN_GUID + " is loaded!");

// Execute all patches
_harmony = new Harmony("Skul.Mod");
_harmony.PatchAll(typeof(DropRatePatch));
_harmony.PatchAll(typeof(PathPatch));

// Active Turbo-Button-Worker
TurboButtonMode.StartSetTurboCoroutine(this);
}

private LevelManager levelManager => Singleton<Service>.Instance.levelManager;

private void Update()
{
// Only run, if a player is running around
if (!Helper.IsInGame)
return;

// print some infos
if(Input.GetKeyDown(KeyCode.F1))
{
Vector3 v = levelManager.player.transform.position;
float offset = 0.4f;

Helper.TextSpawner.SpawnBuff(" Mod running ", v);
v += Vector3.down * offset;
Helper.TextSpawner.SpawnBuff("F2: Toggle turbo attack", v);
v += Vector3.down * offset;
Helper.TextSpawner.SpawnBuff("F3: Toggle item modifications", v);
v += Vector3.down * offset;
Helper.TextSpawner.SpawnBuff("F4: Toggle path modifications", v);
v += Vector3.down * offset;
Helper.TextSpawner.SpawnBuff("F5: Get some dark quartz", v);
}

if (Input.GetKeyDown(KeyCode.F2))
{
TurboButtonMode.ToggleTurbo();
}

if (Input.GetKeyDown(KeyCode.F3))
{
DropRatePatch.ToggleEnabled();
}

if (Input.GetKeyDown(KeyCode.F4))
{
PathPatch.ToggleEnabled();
}

// Get some Quartz
if (Input.GetKeyDown(KeyCode.F5))
{
if (GameData.Currency.darkQuartz != null)
{
Helper.TextSpawner.SpawnBuff("Got some quartz", levelManager.player.transform.position);
GameData.Currency.darkQuartz.balance += 10000;
}
}
}


}
}
Loading

0 comments on commit ac47e89

Please sign in to comment.