This commit is contained in:
Marek Lenczewski
2026-03-30 22:56:58 +02:00
parent d6715e9c3f
commit 04749104a0
49 changed files with 1406 additions and 171 deletions

View File

@@ -10,6 +10,7 @@ func _ready() -> void:
health_regen = stats.health_regen
current_health = max_health
EventBus.damage_requested.connect(_on_damage_requested)
EventBus.heal_requested.connect(_on_heal_requested)
func _process(delta: float) -> void:
if current_health > 0 and current_health < max_health and health_regen > 0:
@@ -34,3 +35,11 @@ func take_damage(amount: float, attacker: Node) -> void:
EventBus.health_changed.emit(get_parent(), current_health, max_health)
if current_health <= 0:
EventBus.entity_died.emit(get_parent())
func heal(amount: float) -> void:
current_health = min(current_health + amount, max_health)
EventBus.health_changed.emit(get_parent(), current_health, max_health)
func _on_heal_requested(healer: Node, target: Node, amount: float) -> void:
if target == get_parent():
heal(amount)

View File

@@ -7,11 +7,15 @@ var regen_time: float
var current_shield: float
var regen_timer := 0.0
var base_max_shield: float
func _ready() -> void:
max_shield = stats.max_shield
base_max_shield = max_shield
regen_delay = stats.shield_regen_delay
regen_time = stats.shield_regen_time
current_shield = max_shield
EventBus.role_changed.connect(_on_role_changed)
func _process(delta: float) -> void:
if max_shield <= 0:
@@ -25,6 +29,22 @@ func _process(delta: float) -> void:
EventBus.shield_regenerated.emit(get_parent())
EventBus.shield_changed.emit(get_parent(), current_shield, max_shield)
func _on_role_changed(_player: Node, _role_type: int) -> void:
if get_parent() != _player:
return
var role: Node = get_parent().get_node_or_null("Role")
if not role:
return
var ability_set: AbilitySet = role.get_ability_set()
if not ability_set:
return
max_shield = base_max_shield
for ability in ability_set.abilities:
if ability and ability.type == Ability.Type.PASSIVE and ability.passive_stat == "shield":
max_shield = base_max_shield * (1.0 + ability.damage / 100.0)
current_shield = min(current_shield, max_shield)
EventBus.shield_changed.emit(get_parent(), current_shield, max_shield)
func absorb(amount: float) -> float:
if current_shield <= 0:
return amount