Skip to content

Commit

Permalink
Fix dotapi, fix commandhelper, and very small damagetype fix (#535)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
xiaoxiao921 authored Sep 4, 2024
1 parent 72c6f06 commit 733d424
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 14 deletions.
10 changes: 5 additions & 5 deletions R2API.CommandHelper/CommandHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -173,7 +173,7 @@ private static void RegisterConVars(Assembly assembly)
}
else if (baseConVar.defaultValue != null)
{
baseConVar.SetString(baseConVar.defaultValue);
baseConVar.AttemptSetString(baseConVar.defaultValue);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions R2API.CommandHelper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
2 changes: 1 addition & 1 deletion R2API.CommandHelper/thunderstore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R2API.DamageType/DamageAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions R2API.DamageType/DamageTypePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ public sealed class DamageTypePlugin : BaseUnityPlugin
private void Awake()
{
Logger = base.Logger;

#if DEBUG
DamageAPI.SetHooks();
#endif
}

private void OnDestroy()
Expand Down
3 changes: 3 additions & 0 deletions R2API.DamageType/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion R2API.DamageType/thunderstore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions R2API.Dot/DotAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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++)
Expand All @@ -422,7 +421,7 @@ static int CountCustomDots(DotController dotController, int numberOfDebuffAndDot

c.Emit(OpCodes.Ldloc, dotControllerLoc);
c.Emit(OpCodes.Ldloc, numberOfDebuffAndDotLoc);
c.EmitDelegate<Func<DotController, int, int>>(CountCustomDots);
c.EmitDelegate(CountCustomDots);
c.Emit(OpCodes.Stloc, numberOfDebuffAndDotLoc);
}
else
Expand Down
4 changes: 4 additions & 0 deletions R2API.Dot/DotPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ public sealed class DotPlugin : BaseUnityPlugin
private void Awake()
{
Logger = base.Logger;

#if DEBUG
DotAPI.SetHooks();
#endif
}

private void OnDestroy()
Expand Down
3 changes: 3 additions & 0 deletions R2API.Dot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion R2API.Dot/thunderstore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 733d424

Please sign in to comment.