From c26b281b969b5eef7d1c9b54a27841206d1daffd Mon Sep 17 00:00:00 2001 From: anyreso Date: Sat, 11 May 2024 15:44:35 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20health=20display?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entities/components/explosive_damage_component.gd | 2 +- entities/components/health_component.gd | 4 ++-- entities/weapons/chaingun/projectile.gd | 2 +- interfaces/hud/hud.tscn | 7 ++++--- tests/test_health_component.gd | 10 +++++----- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/entities/components/explosive_damage_component.gd b/entities/components/explosive_damage_component.gd index 94ef489..7830027 100644 --- a/entities/components/explosive_damage_component.gd +++ b/entities/components/explosive_damage_component.gd @@ -17,7 +17,7 @@ class_name ExplosiveDamageComponent extends Area3D ## Emitted when the scale tween is finished signal finished -@export var damage : int = 35 +@export var damage : float = .35 @export var impulse_force : int = 1000 var damage_dealer : MatchParticipantComponent diff --git a/entities/components/health_component.gd b/entities/components/health_component.gd index 8a0a770..b2d94eb 100644 --- a/entities/components/health_component.gd +++ b/entities/components/health_component.gd @@ -14,8 +14,8 @@ # along with this program. If not, see . class_name HealthComponent extends Area3D -@export var max_health : float = 100.0 -@export var health : float = 100.0: +@export var max_health : float = 1. +@export var health : float = 1.: set(value): health = value health_changed.emit(value) diff --git a/entities/weapons/chaingun/projectile.gd b/entities/weapons/chaingun/projectile.gd index 0834c44..0690902 100644 --- a/entities/weapons/chaingun/projectile.gd +++ b/entities/weapons/chaingun/projectile.gd @@ -38,7 +38,7 @@ func _physics_process(delta : float) -> void: if collider is Player: if is_multiplayer_authority(): assert(shooter) - collider.health_component.damage.rpc(18, shooter.player_id, shooter.team_id) + collider.health_component.damage.rpc(.1, shooter.player_id, shooter.team_id) queue_free() ## This method is a parameterized constructor for the [ChainGunProjectile] scene of the [ChainGun] diff --git a/interfaces/hud/hud.tscn b/interfaces/hud/hud.tscn index 742c51b..1fe538d 100644 --- a/interfaces/hud/hud.tscn +++ b/interfaces/hud/hud.tscn @@ -25,8 +25,8 @@ class_name HUD extends CanvasLayer @export var _energy_bar : ProgressBar func _ready() -> void: - _update_health_bar(100.) - _update_energy_bar(100.) + _update_health_bar(1.) + _update_energy_bar(1.) func _update_energy_bar(energy : float) -> void: _energy_bar.value = energy @@ -146,7 +146,8 @@ layout_mode = 2 mouse_filter = 2 theme_override_styles/background = ExtResource("1_gmv44") theme_override_styles/fill = ExtResource("2_6ejsl") -value = 60.0 +max_value = 1.0 +value = 1.0 show_percentage = false [node name="EnergyBar" type="ProgressBar" parent="MarginContainer/HBoxContainer/VBoxContainer"] diff --git a/tests/test_health_component.gd b/tests/test_health_component.gd index 8a3e2e0..e73f4fd 100644 --- a/tests/test_health_component.gd +++ b/tests/test_health_component.gd @@ -15,7 +15,7 @@ extends GutTest var _subject : HealthComponent -const TEST_MAX_HEALTH : float = 100.0 +const TEST_MAX_HEALTH : float = 1. const TEST_PLAYER_ID : int = 1 const TEST_TEAM_ID : int = 1 @@ -36,17 +36,17 @@ func test_that_it_has_max_health_when_ready() -> void: assert_eq(_subject.health, _subject.max_health) func test_that_it_takes_damage_from_opponent_team() -> void: - var damage_amount : float = 10.0 + var damage_amount : float = .1 _subject.damage(damage_amount, -1, -1) assert_eq(_subject.health, TEST_MAX_HEALTH - damage_amount) func test_that_it_takes_no_damage_from_same_team() -> void: - var damage_amount : float = 10.0 + var damage_amount : float = .1 _subject.damage(damage_amount, -1, TEST_TEAM_ID) assert_eq(_subject.health, TEST_MAX_HEALTH) func test_that_it_can_self_damage() -> void: - var damage_amount : float = 10.0 + var damage_amount : float = .1 _subject.damage(damage_amount, TEST_PLAYER_ID, TEST_TEAM_ID) assert_eq(_subject.health, TEST_MAX_HEALTH - damage_amount) @@ -59,7 +59,7 @@ func test_that_it_emits_health_zeroed() -> void: assert_signal_emitted_with_parameters(_subject, 'health_zeroed', [-1]) func test_that_it_heals_fully() -> void: - _subject.health = 10 + _subject.health = .1 _subject.heal_full() assert_eq(_subject.health, TEST_MAX_HEALTH)