Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
Solve some Traverso.Create calls differently to avoid lag
  • Loading branch information
NeoKaios committed Jun 26, 2022
1 parent 2c26a7b commit 39ee973
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 22 deletions.
12 changes: 6 additions & 6 deletions src/Patches/EnemyPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ namespace DebugUtilityMod
{
class EnemyPatch
{

// Weak elites and bosses
[HarmonyPatch(typeof(BossSpawner), "LoadSpawners")]
[HarmonyPrefix]
static void BossLoadSpawners_prefix(ref List<BossSpawn> spawners)
{
foreach (BossSpawn bs in spawners)
{
Health h = bs.bossPrefab.GetComponent<Health>();
h.maxHP = 100;
Health bossHealth = bs.bossPrefab.GetComponent<Health>();
bossHealth.maxHP = 100;
}
}

[HarmonyPatch(typeof(HordeSpawner), "LoadSpawners")]
[HarmonyPrefix]
static void HordeLoadSpawners_prefix(ref List<SpawnSession> spawnSessions)
{
foreach (SpawnSession ss in spawnSessions)
foreach (SpawnSession spawnSession in spawnSessions)
{
if (ss.isElite)
if (spawnSession.isElite)
{
ss.HP = 100;
spawnSession.HP = 100;
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/Patches/FastGamePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static void HordeLoadSpawners_prefix(ref List<SpawnSession> spawnSessions)
}
}

// This is useful trust me, avoid reducing twice spawn timers,
// This is useful trust me, avoid reducing twice spawn timers,
static private bool IsDone(bool isBoss)
{
bool isStandard = SelectedMap.MapData.nameStringID.key == "standard_mode_name";
Expand All @@ -92,7 +92,6 @@ static private bool IsDone(bool isBoss)
return false;
}


[HarmonyPatch(typeof(SummonEgg), "Start")]
[HarmonyPrefix]
static void SummonnEggStart_prefix(ref float ___secondsToHatch)
Expand Down
4 changes: 2 additions & 2 deletions src/Patches/InvincibilityPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace DebugUtilityMod
{
class InvincibilityPatch
{
[HarmonyPatch(typeof(CombatState), "Enter")]
[HarmonyPatch(typeof(InitState), "Exit")]
[HarmonyPostfix]
static void CombatStateEnter_postfix(ref CombatState __instance)
static void InitStateExit_postfix(ref InitState __instance)
{
//Flip invincibility bool
((Health)Traverse.Create(__instance).Property("playerHealth").GetValue()).isInvincible.Flip();
Expand Down
16 changes: 5 additions & 11 deletions src/Patches/RerollPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,23 @@ namespace DebugUtilityMod
{
static class RerollPatch
{
static Button reroolButton;
[HarmonyPatch(typeof(InitState), "Enter")]
[HarmonyPrefix]
static void Enter_prefix(ref PowerupMenuState __instance)
static void InitStateEnter_prefix(ref PowerupMenuState __instance)
{
// Set reroll button active to give the reroll passive to every character
//((Button)Traverse.Create(__instance).Property("powerupRerollButton").GetValue()).gameObject.SetActive(true);
PowerupGenerator.CanReroll = true;
reroolButton = ((Button)Traverse.Create(__instance).Property("powerupRerollButton").GetValue());
}
/*
[HarmonyPatch(typeof(PowerupMenuState), "Enter")]
[HarmonyPostfix]
static void Enter_postfix(ref PowerupMenuState __instance)
{
// Set reroll button active to give the reroll passive to every character
((Button)Traverse.Create(__instance).Property("powerupRerollButton").GetValue()).gameObject.SetActive(true);
}
*/

[HarmonyPatch(typeof(PowerupMenuState), "OnReroll")]
[HarmonyPostfix]
static void OnReroll_postfix(ref PowerupMenuState __instance)
{
// Set reroll button active after reroll, to obtain infinite reroll
((Button)Traverse.Create(__instance).Property("powerupRerollButton").GetValue()).gameObject.SetActive(true);
reroolButton.gameObject.SetActive(true);
}
}
}
4 changes: 3 additions & 1 deletion src/Patches/XPPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ static class XPPatch
{
static bool doGainXP = true;
static int lvl = 1;

[HarmonyPatch(typeof(PlayerXP), "Awake")]
[HarmonyPostfix]
static void PlayerXPAwake_postfix(ref StatMod ___xpMultiplier)
Expand All @@ -24,9 +25,10 @@ static void PlayerXPAwake_postfix(ref StatMod ___xpMultiplier)
[HarmonyPrefix]
static bool GainXP_prefix()
{
//Skip XP gain if playerLVL >= maxLVL
return doGainXP;
}

[HarmonyPatch(typeof(CombatState), "OnLevelUP")]
[HarmonyPrefix]
static void OnLevelUp_prefix()
Expand Down

0 comments on commit 39ee973

Please sign in to comment.