-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
25 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,33 @@ | ||
using MonoMod.RuntimeDetour; | ||
|
||
namespace GodSeekerPlus.Modules.BossChallenge; | ||
|
||
[ToggleableLevel(ToggleableLevel.ChangeScene)] | ||
internal sealed class P5Health : Module { | ||
private protected override void Load() => | ||
On.BossSceneController.Awake += OverrideLevel; | ||
private Detour? detour = null; | ||
|
||
private protected override void Load() { | ||
detour = new( | ||
ReflectionHelper.GetPropertyInfo(typeof(BossSceneController), "BossLevel").GetGetMethod(), | ||
ReflectionHelper.GetMethodInfo(typeof(P5Health), nameof(OverrideLevel)) | ||
); | ||
|
||
private protected override void Unload() => | ||
On.BossSceneController.Awake -= OverrideLevel; | ||
ModHooks.TakeDamageHook += FixDamage; | ||
} | ||
|
||
private void OverrideLevel(On.BossSceneController.orig_Awake orig, BossSceneController self) { | ||
orig(self); | ||
private protected override void Unload() { | ||
detour?.Dispose(); | ||
|
||
self.BossLevel = 0; | ||
ModHooks.TakeDamageHook -= FixDamage; | ||
} | ||
|
||
private int OverrideLevel() => 0; | ||
|
||
private int FixDamage(ref int hazardType, int damage) => BossSceneController.IsBossScene | ||
? ReflectionHelper.GetField<BossSceneController, int>(BossSceneController.Instance, "bossLevel") switch { | ||
1 => damage * 2, | ||
2 => 9999, | ||
_ => damage, | ||
} | ||
: damage; | ||
} |