diff --git a/components/UI/ColorBar.tscn b/components/UI/ColorBar.tscn index 975b667..f039234 100644 --- a/components/UI/ColorBar.tscn +++ b/components/UI/ColorBar.tscn @@ -36,6 +36,7 @@ anchors_preset = 0 offset_right = 100.0 offset_bottom = 10.0 script = ExtResource("1_a106p") +currentValue = 0.0 backBox = SubResource("StyleBoxFlat_kf2fc") middleBox1 = SubResource("StyleBoxFlat_sh754") middleBox2 = SubResource("StyleBoxFlat_8n8i8") diff --git a/scripts/Statemachine/BossBar.gd b/scripts/Statemachine/BossBar.gd index 81aba49..5b43a8f 100644 --- a/scripts/Statemachine/BossBar.gd +++ b/scripts/Statemachine/BossBar.gd @@ -4,9 +4,7 @@ class_name BossBar @onready var nameLabel: Label = $"%name" @onready var valueLabel: Label = $"%value" -func _ready(): - if is_instance_valid(entity): - nameLabel.text = entity.displayName func _process(_delta): if is_instance_valid(entity): + nameLabel.text = entity.displayName valueLabel.text = "%.2f" % (entity.health / entity.fields[FieldStore.Entity.MAX_HEALTH] * 100) diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index d97f224..bdcd512 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -202,8 +202,9 @@ func findWeaponAnchor(weaponName: String): return Vector2.ZERO func setBoss(boss: EntityBase): currentFocusedBoss = boss - if isPlayer(): + if isPlayer() and boss and UIState.bossbar.entity != boss: UIState.bossbar.entity = boss + boss.healthChanged.emit(boss.health) func playSound(type: String): var body = sounds.get_node_or_null(type) if body is AudioStreamPlayer2D: