HPComponent
public class HPComponent : MonoBehaviour, IEntityComponent
{
// Start is called before the first frame update
public int hp = 100, hpMax = 100;
public int invincibleTimer = 0;
//...
This component holds the concepts for health and invincibility time. Its rather simple, so if you need more from it either extend from this class or change it.
Methods
public void Revive()
Sets hp to equal max and puts the invincibleTimer to 10 frames/ticks
public void UpdateComponent()
Updates the invincibleTimer
public bool IsInvincible()
returns true if invincibleTimer > 0, else false
public void TakeDamage(int dmg, int invincibleFrames)
If not invincible, take damage and set invincibleTimer = invincibleFrames
public void SetInvincibleTimer(int i)
Set invincibleTimer to whatever you need to. Helps for say dodge rolls or whatever