risk-of-thunder / R2API

A modding API for Risk of Rain 2
https://thunderstore.io/package/tristanmcpherson/R2API/
MIT License
134 stars 55 forks source link

CrocoDamageTypeController Support For DamageAPI #514

Closed yekoc closed 3 months ago

yekoc commented 8 months ago

Not being able to support modded damage types made CrocoDamageTypeController almost entirely useless for mods and made compatibility between mods adding new passives to Acrid difficult. However it's conceptually really useful,so here is an effort to make it work like we'd want it to.Includes additions to CompressedFlagArrayUtilities to facilitate non-destructive copying of ModdedDamageTypeHolders Draft PR currently only implements support for projectiles,putting it up to gather feedback on changes to API surface and on the following: The transfer of modded damage types from the holder assigned to the CrocoDamageTypeController needs to be deferred due to the way the vanilla component is setup (which is why it was such a pain),signalling for this is available through the remaining unused vanilla damage type.While projectiles have a very convenient place to do this in (ProjectileManager.InitProjectile),there is no direct equivalent to handle non-projectile attacks. One option to keep the implementation simple is to delay this operation until TakeDamage/OnHitAll,this seems ideal but makes it so that the damage type coming from the CrocoDamageTypeController is not visible to checks before that point (HasModdedDamageType on a BulletAttack,for example). The opposite approach would be to check for the signal and perform it in every current hook,this guarantees total visiblity for the moddeddamagetypes in question but will complicate the implementation. (Might cause performance/maintenance burden)

yekoc commented 8 months ago

Solved delayed work consideration by making HasModdedDamageType checks lazily evaluate the conversion,this doesn't affect semantics due to the modification being invisible from the outside.This is the case as any pre-modification copies would also copy the signal to modify.