


![]()
is api for healthcomponent. designed to be like RecalculateStatsAPI.
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.
There are 3 Events you can subscribe to, HDeMods.HealthComponentAPI.GetHealthStats, HDeMods.HealthComponentAPI.GetHealStats and HDeMods.HealthComponentAPI.GetTakeDamageStats.
GetHealthStats fires every fixed update on the server and provides the following values to change:
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:
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:
IOnIncomingDamageServerReceiver is not practical for your use case.DamageInfo.canRejectForce to false.HDeMods.HealthComponentAPI.GetTakeDamageStats += MyDelegate;
MyDelegate(HealthComponent sender, DamageInfo damageInfo, TakeDamageArgs args)
That's it.
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).