prototype vibe
This commit is contained in:
@@ -2,14 +2,17 @@ extends Node
|
||||
|
||||
var entities: Dictionary = {}
|
||||
|
||||
func register(entity: Node, base: EnemyStats) -> void:
|
||||
func register(entity: Node, base: EnemyStats, scale: float = 1.0) -> void:
|
||||
var max_hp: float = base.max_health * scale
|
||||
var max_sh: float = base.max_shield * scale
|
||||
entities[entity] = {
|
||||
"base": base,
|
||||
"health": base.max_health,
|
||||
"max_health": base.max_health,
|
||||
"health_regen": base.health_regen,
|
||||
"shield": base.max_shield,
|
||||
"max_shield": base.max_shield,
|
||||
"scale": scale,
|
||||
"health": max_hp,
|
||||
"max_health": max_hp,
|
||||
"health_regen": base.health_regen * scale,
|
||||
"shield": max_sh,
|
||||
"max_shield": max_sh,
|
||||
"shield_regen_delay": base.shield_regen_delay,
|
||||
"shield_regen_time": base.shield_regen_time,
|
||||
"shield_regen_timer": 0.0,
|
||||
@@ -24,6 +27,21 @@ func register(entity: Node, base: EnemyStats) -> void:
|
||||
"attack_timer": 0.0,
|
||||
}
|
||||
|
||||
func apply_scale(entity: Node, scale: float) -> void:
|
||||
if entity not in entities:
|
||||
return
|
||||
var data: Dictionary = entities[entity]
|
||||
var base: EnemyStats = data["base"]
|
||||
data["scale"] = scale
|
||||
data["max_health"] = base.max_health * scale
|
||||
data["health"] = data["max_health"]
|
||||
data["health_regen"] = base.health_regen * scale
|
||||
data["max_shield"] = base.max_shield * scale
|
||||
data["shield"] = data["max_shield"]
|
||||
EventBus.health_changed.emit(entity, data["health"], data["max_health"])
|
||||
if base.max_shield > 0:
|
||||
EventBus.shield_changed.emit(entity, data["shield"], data["max_shield"])
|
||||
|
||||
func deregister(entity: Node) -> void:
|
||||
entities.erase(entity)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user