update
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user