From 733d42438524ee7fa178e1f85d00f8b8f9772b6a Mon Sep 17 00:00:00 2001 From: Quentin <837334+xiaoxiao921@users.noreply.github.com> Date: Wed, 4 Sep 2024 02:45:53 +0200 Subject: [PATCH] Fix dotapi, fix commandhelper, and very small damagetype fix (#535) * fix(damageapi): fix wrong unset hook event unsub * fix(dotapi): OnHitEnemy -> ProcessHitEnemy gearbox useless function rename * damagetype: always set hooks when debug * dotapi: always set hooks when debug * fix commandhelper for sots * damagetype: bump ver, changelog * fix(dotapi): fix usage of compile time constant that'd break on any vanilla dot count change --- R2API.CommandHelper/CommandHelper.cs | 10 +++++----- R2API.CommandHelper/README.md | 3 +++ R2API.CommandHelper/thunderstore.toml | 2 +- R2API.DamageType/DamageAPI.cs | 2 +- R2API.DamageType/DamageTypePlugin.cs | 4 ++++ R2API.DamageType/README.md | 3 +++ R2API.DamageType/thunderstore.toml | 2 +- R2API.Dot/DotAPI.cs | 9 ++++----- R2API.Dot/DotPlugin.cs | 4 ++++ R2API.Dot/README.md | 3 +++ R2API.Dot/thunderstore.toml | 2 +- 11 files changed, 30 insertions(+), 14 deletions(-) diff --git a/R2API.CommandHelper/CommandHelper.cs b/R2API.CommandHelper/CommandHelper.cs index 6fa327db..defb8c47 100644 --- a/R2API.CommandHelper/CommandHelper.cs +++ b/R2API.CommandHelper/CommandHelper.cs @@ -55,21 +55,21 @@ internal static void SetHooks() return; } - On.RoR2.Console.InitConVars += ConsoleReady; + On.RoR2.Console.InitConVarsCoroutine += ConsoleReady; _hooksEnabled = true; } internal static void UnsetHooks() { - On.RoR2.Console.InitConVars -= ConsoleReady; + On.RoR2.Console.InitConVarsCoroutine -= ConsoleReady; _hooksEnabled = false; } - private static void ConsoleReady(On.RoR2.Console.orig_InitConVars orig, RoR2.Console self) + private static System.Collections.IEnumerator ConsoleReady(On.RoR2.Console.orig_InitConVarsCoroutine orig, RoR2.Console self) { - orig(self); + yield return orig(self); _console = self; HandleCommandsConvars(); @@ -173,7 +173,7 @@ private static void RegisterConVars(Assembly assembly) } else if (baseConVar.defaultValue != null) { - baseConVar.SetString(baseConVar.defaultValue); + baseConVar.AttemptSetString(baseConVar.defaultValue); } } } diff --git a/R2API.CommandHelper/README.md b/R2API.CommandHelper/README.md index 3ed71274..de208eaa 100644 --- a/R2API.CommandHelper/README.md +++ b/R2API.CommandHelper/README.md @@ -9,6 +9,9 @@ by simply using the `[assembly: HG.Reflection.SearchableAttribute.OptInAttribute ## Changelog +### '1.0.2' +* Initial fixes for SOTS DLC2 Release. + ### '1.0.1' * Fix the NuGet package which had a dependency on a non-existent version of `R2API.Core`. diff --git a/R2API.CommandHelper/thunderstore.toml b/R2API.CommandHelper/thunderstore.toml index a488bd9d..8f41d983 100644 --- a/R2API.CommandHelper/thunderstore.toml +++ b/R2API.CommandHelper/thunderstore.toml @@ -5,7 +5,7 @@ schemaVersion = "0.0.1" [package] namespace = "RiskofThunder" name = "R2API_CommandHelper" -versionNumber = "1.0.1" +versionNumber = "1.0.2" description = "API for registering console commands" websiteUrl = "https://github.com/risk-of-thunder/R2API" containsNsfwContent = false diff --git a/R2API.DamageType/DamageAPI.cs b/R2API.DamageType/DamageAPI.cs index 8e4dc75f..eff4cb92 100644 --- a/R2API.DamageType/DamageAPI.cs +++ b/R2API.DamageType/DamageAPI.cs @@ -154,7 +154,7 @@ internal static void UnsetHooks() On.RoR2.OverlapAttack.OverlapAttackMessage.Serialize -= OverlapAttackMessageSerialize; On.RoR2.OverlapAttack.OverlapAttackMessage.Deserialize -= OverlapAttackMessageDeserialize; - IL.RoR2.GlobalEventManager.OnHitAll -= GlobalEventManagerOnHitAllIL; + IL.RoR2.GlobalEventManager.OnHitAllProcess -= GlobalEventManagerOnHitAllIL; IL.RoR2.HealthComponent.SendDamageDealt -= HealthComponentSendDamageDealtIL; On.RoR2.DamageDealtMessage.Serialize -= DamageDealtMessageSerialize; diff --git a/R2API.DamageType/DamageTypePlugin.cs b/R2API.DamageType/DamageTypePlugin.cs index 9eaf21e3..28d60b3e 100644 --- a/R2API.DamageType/DamageTypePlugin.cs +++ b/R2API.DamageType/DamageTypePlugin.cs @@ -11,6 +11,10 @@ public sealed class DamageTypePlugin : BaseUnityPlugin private void Awake() { Logger = base.Logger; + +#if DEBUG + DamageAPI.SetHooks(); +#endif } private void OnDestroy() diff --git a/R2API.DamageType/README.md b/R2API.DamageType/README.md index 02249f04..d5c4f60b 100644 --- a/R2API.DamageType/README.md +++ b/R2API.DamageType/README.md @@ -23,6 +23,9 @@ This is done via the DamageAPI class, which is used for reserving DamageTypes an ## Changelog +### '1.1.2' +* More fixes for SOTS DLC2 Release. + ### '1.1.1' * Initial fixes for SOTS DLC2 Release. diff --git a/R2API.DamageType/thunderstore.toml b/R2API.DamageType/thunderstore.toml index 7e2a54cb..ddd92e8e 100644 --- a/R2API.DamageType/thunderstore.toml +++ b/R2API.DamageType/thunderstore.toml @@ -5,7 +5,7 @@ schemaVersion = "0.0.1" [package] namespace = "RiskofThunder" name = "R2API_DamageType" -versionNumber = "1.1.1" +versionNumber = "1.1.2" description = "API for registering damage types" websiteUrl = "https://github.com/risk-of-thunder/R2API" containsNsfwContent = false diff --git a/R2API.Dot/DotAPI.cs b/R2API.Dot/DotAPI.cs index ad1b6558..b1d20579 100644 --- a/R2API.Dot/DotAPI.cs +++ b/R2API.Dot/DotAPI.cs @@ -159,7 +159,7 @@ internal static void SetHooks() On.RoR2.DotController.HasDotActive += OnHasDotActive; IL.RoR2.DotController.EvaluateDotStacksForType += EvaluateDotStacksForType; - IL.RoR2.GlobalEventManager.OnHitEnemy += FixDeathMark; + IL.RoR2.GlobalEventManager.ProcessHitEnemy += FixDeathMark; _hooksEnabled = true; } @@ -177,7 +177,7 @@ internal static void UnsetHooks() On.RoR2.DotController.HasDotActive -= OnHasDotActive; IL.RoR2.DotController.EvaluateDotStacksForType -= EvaluateDotStacksForType; - IL.RoR2.GlobalEventManager.OnHitEnemy -= FixDeathMark; + IL.RoR2.GlobalEventManager.ProcessHitEnemy -= FixDeathMark; _hooksEnabled = false; } @@ -300,7 +300,7 @@ static void ILFailMessage(int index) if (c.TryGotoNext(MoveType.After, x => x.MatchLdarg(0), x => x.MatchLdfld(typeof(InflictDotInfo), nameof(InflictDotInfo.dotIndex)), - x => x.MatchLdcI4((int)DotController.DotIndex.Count) + x => x.MatchLdcI4(VanillaDotCount) )) { c.Prev.OpCode = OpCodes.Ldc_I4; @@ -404,7 +404,6 @@ static void ILFailMessage(int index) static int CountCustomDots(DotController dotController, int numberOfDebuffAndDotLoc) { - if (dotController) { for (var i = VanillaDotCount; i < VanillaDotCount + CustomDotCount; i++) @@ -422,7 +421,7 @@ static int CountCustomDots(DotController dotController, int numberOfDebuffAndDot c.Emit(OpCodes.Ldloc, dotControllerLoc); c.Emit(OpCodes.Ldloc, numberOfDebuffAndDotLoc); - c.EmitDelegate>(CountCustomDots); + c.EmitDelegate(CountCustomDots); c.Emit(OpCodes.Stloc, numberOfDebuffAndDotLoc); } else diff --git a/R2API.Dot/DotPlugin.cs b/R2API.Dot/DotPlugin.cs index 9ad53f5f..818cc2f1 100644 --- a/R2API.Dot/DotPlugin.cs +++ b/R2API.Dot/DotPlugin.cs @@ -11,6 +11,10 @@ public sealed class DotPlugin : BaseUnityPlugin private void Awake() { Logger = base.Logger; + +#if DEBUG + DotAPI.SetHooks(); +#endif } private void OnDestroy() diff --git a/R2API.Dot/README.md b/R2API.Dot/README.md index 101dfd4b..a1bb9e53 100644 --- a/R2API.Dot/README.md +++ b/R2API.Dot/README.md @@ -17,6 +17,9 @@ Alongside adding new DotIndices and DotDefs, One can also provide CustomDotBehav ## Changelog +### '1.0.3' +* Initial fixes for SOTS DLC2 Release. + ### '1.0.2' * Fix custom DOTs counting as active upon infliction and not only after having ticked once. diff --git a/R2API.Dot/thunderstore.toml b/R2API.Dot/thunderstore.toml index f9b4469c..71438d49 100644 --- a/R2API.Dot/thunderstore.toml +++ b/R2API.Dot/thunderstore.toml @@ -5,7 +5,7 @@ schemaVersion = "0.0.1" [package] namespace = "RiskofThunder" name = "R2API_Dot" -versionNumber = "1.0.2" +versionNumber = "1.0.3" description = "API for adding custom damage over time effects" websiteUrl = "https://github.com/risk-of-thunder/R2API" containsNsfwContent = false