package com.zombie.game.ecs.components;

import lombok.Data;

/** Component storing entity health points / 存储实体生命值的组件 */
@Data
public class Health {
    // Current health value / 当前生命值
    private float health;
    // Maximum health value / 最大生命值
    private float maxHealth;

    // Constructor setting initial and max health / 构造函数，设置初始和最大生命值
    public Health(float maxHealth) {
        this.health = maxHealth;
        this.maxHealth = maxHealth;
    }

    // Checks if the entity is still alive / 检查实体是否仍然存活
    public boolean isAlive() {
        return health > 0;
    }

    // Resets health to maximum value / 将生命值重置为最大值
    public void reset() {
        this.health = maxHealth;
    }
}
