HDeDeDe.Mods.RiskOfRain2.HealthComponentAPI
1.2.0
dotnet add package HDeDeDe.Mods.RiskOfRain2.HealthComponentAPI --version 1.2.0
NuGet\Install-Package HDeDeDe.Mods.RiskOfRain2.HealthComponentAPI -Version 1.2.0
<PackageReference Include="HDeDeDe.Mods.RiskOfRain2.HealthComponentAPI" Version="1.2.0" />
paket add HDeDeDe.Mods.RiskOfRain2.HealthComponentAPI --version 1.2.0
#r "nuget: HDeDeDe.Mods.RiskOfRain2.HealthComponentAPI, 1.2.0"
// Install HDeDeDe.Mods.RiskOfRain2.HealthComponentAPI as a Cake Addin #addin nuget:?package=HDeDeDe.Mods.RiskOfRain2.HealthComponentAPI&version=1.2.0 // Install HDeDeDe.Mods.RiskOfRain2.HealthComponentAPI as a Cake Tool #tool nuget:?package=HDeDeDe.Mods.RiskOfRain2.HealthComponentAPI&version=1.2.0
HealthComponentAPI
is api for healthcomponent. designed to be like RecalculateStatsAPI.
For Developers
To set up the api, either download the latest ThunderStore release then add a reference to the dll to your project or install the nuget package to your project.
Before you do anything else, be sure to add the API as a dependency for your mod.
[BepInDependency(HDeMods.HealthComponentAPI.PluginGUID)]
If you want to make it easier, you can add this whenever you access the API
using HDeMods;
And that's it. All you have to do is reference the section below and use it as if it were RecalculateStatsAPI.
How it works
There are 5 Events you can subscribe to, HDeMods.HealthComponentAPI.GetHealthStats
, HDeMods.HealthComponentAPI.GetHealStats
, HDeMods.HealthComponentAPI.GetTakeDamageStats
, HDeMods.HealthComponentAPI.OnTakeDamageProcess
and HDeMods.HealthComponentAPI.OnHealServerProcess
.
GetHealthStats
fires every fixed update on the server and provides the following values to change:
- Final Regen: Regen value after all regen related calculations but before it's applied as healing.
- Barrier Decay Rate: The amount of time it takes for barrier to decay. This is exposed in CharacterBody.RecalculateStats but RecalculateStatsAPI doesn't provide any bindings for it.
- Shield Recharge Rate: The amount of time it takes for shields to recharge once you are out of danger.
- Adaptive Armor Decay Rate: The amount of time it takes for adaptive armor stacks to decay.
- Instated like this:
HDeMods.HealthComponentAPI.GetHealthStats += MyDelegate;
MyDelegate(HealthComponent sender, UpdateHealthEventArgs args)
GetHealStats
runs every time HealthComponent.Heal and HealthComponent.TakeDamageProcess are ran and provides the following values to change:
- Enable Eclipse Heal Reduction: Cuts healing in half as if you were on Eclipse 5 or higher. Does not count the run as Eclipse 5 or higher on its own. Applies regardless of team.
- Damage Coyote Timer: The grace period in between damage frames. This value is read by HealthComponent.TakeDamageProcess.
- Crit Heal: Unused in the base game, the multiplier for critical heals.
- Final Heal Amount: The final healing value after all healing calculations but before it's applied.
- Instated like this:
HDeMods.HealthComponentAPI.GetHealStats += MyDelegate;
MyDelegate(HealthComponent sender, HealEventArgs args)
GetTakeDamageStats
Is not intended to be a replacement for IOnIncomingDamageServerReceiver
, as its scope is much greater than IOnIncomingDamageServerReceiver. Due to this, DamageInfo
is readonly, and you should not try to modify it from GetTakeDamageStats. That being said, GetTakeDamageStats
runs every time HealthComponent.TakeDamageProcess is ran and provides the following values to change:
- Reject Damage: Forces damage to be rejected. This should only be used if
IOnIncomingDamageServerReceiver
is not practical for your use case. - Reject Force: Prevent damage forces from being applied. Note that this sets
DamageInfo.canRejectForce
to false. - Damage Force: The push force attacks apply. The multiplier is provided as a float while the flat addition is provided as a Vector3
- Adaptive Armor Build Rate: The rate at which adaptive armor is built up.
- Adaptive Armor Max: The maximum amount of Adaptive Armor that can be built.
- Final Damage Amount: The final damage number after all item calculations (including things like warped echo), but before it is applied.
- Instated like this:
HDeMods.HealthComponentAPI.GetTakeDamageStats += MyDelegate;
MyDelegate(HealthComponent sender, DamageInfo damageInfo, TakeDamageArgs args)
OnTakeDamageProcess
is an On hook for the TakeDamage function. It provides access to all values passed before the function is called internally. It is instated like so:
HDeMods.HealthComponentAPI.OnTakeDamageProcess += MyDelegate;
MyDelegate(HealthComponent self, DamageInfo damageInfo);
OnHealServerProcess
is an On hook for the Heal function. It provides access to all values passed before the function is called internally. It is instated like so:
HDeMods.HealthComponentAPI.OnHealServerProcess += MyDelegate;
float MyDelegate(HealthComponent self, float amount, ProcChainMask procChainMask, bool nonRegen = true);
That's it.
Feedback
Any and all feedback is appreciated, if you want to let me know anything please feel free to open an issue on the GitHub Page or @ me on the modding discord (hdedede).
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- BepInEx.Core (>= 5.4.21)
- MMHOOK.RoR2 (>= 2024.12.10)
- RiskOfRain2.GameLibs (>= 1.3.6-r.0)
- UnityEngine.Modules (>= 2021.3.33)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.