Update cooldown enum

This commit is contained in:
Sofia 2026-08-03 17:14:50 +03:00
parent cdf81a558f
commit 7ebef6172c
3 changed files with 8 additions and 10 deletions

View File

@ -126,8 +126,6 @@ stream = ExtResource("9_qpw6d")
bus = &"SFX" bus = &"SFX"
[node name="cooldown_icon" parent="." unique_id=1635472390 instance=ExtResource("10_h6dt6")] [node name="cooldown_icon" parent="." unique_id=1635472390 instance=ExtResource("10_h6dt6")]
max = 10.0
value = 0.0
[node name="hud" parent="." unique_id=2049159590 instance=ExtResource("5_cv68x")] [node name="hud" parent="." unique_id=2049159590 instance=ExtResource("5_cv68x")]

View File

@ -5,7 +5,6 @@
[node name="cooldown_icon" type="CooldownIcon" unique_id=1635472390 node_paths=PackedStringArray("text_rect", "label", "add_label")] [node name="cooldown_icon" type="CooldownIcon" unique_id=1635472390 node_paths=PackedStringArray("text_rect", "label", "add_label")]
max = 10.0 max = 10.0
value = 1.5116633333332667
text_rect = NodePath("texture_progress_bar") text_rect = NodePath("texture_progress_bar")
label = NodePath("cd_label") label = NodePath("cd_label")
add_label = NodePath("add_label") add_label = NodePath("add_label")
@ -34,7 +33,7 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
max_value = 10.0 max_value = 10.0
step = 0.05 step = 0.05
value = 8.5 value = 10.0
fill_mode = 4 fill_mode = 4
nine_patch_stretch = true nine_patch_stretch = true
texture_under = ExtResource("2_xkf6q") texture_under = ExtResource("2_xkf6q")
@ -43,13 +42,14 @@ tint_under = Color(0.30323282, 0.30323282, 0.30323282, 1)
metadata/_edit_lock_ = true metadata/_edit_lock_ = true
[node name="cd_label" type="Label" parent="." unique_id=694927561] [node name="cd_label" type="Label" parent="." unique_id=694927561]
visible = false
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
text = "1.5" text = "0.0"
horizontal_alignment = 1 horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
metadata/_edit_lock_ = true metadata/_edit_lock_ = true

View File

@ -7,7 +7,7 @@ use godot::{
#[godot(via = u8)] #[godot(via = u8)]
pub enum CooldownType { pub enum CooldownType {
#[default] #[default]
Fill, Cooldown,
Empty, Empty,
} }
@ -43,7 +43,7 @@ impl IControl for CooldownIcon {
fn process(&mut self, delta: f64) { fn process(&mut self, delta: f64) {
let delta = match self.cd_type { let delta = match self.cd_type {
CooldownType::Fill => -delta, CooldownType::Cooldown => -delta,
CooldownType::Empty => delta, CooldownType::Empty => delta,
}; };
self.value = (self.value + delta).clamp(self.min, self.max); self.value = (self.value + delta).clamp(self.min, self.max);
@ -56,7 +56,7 @@ impl CooldownIcon {
pub fn update(&mut self) { pub fn update(&mut self) {
if let Some(bar) = &mut self.text_rect { if let Some(bar) = &mut self.text_rect {
let fill_mode = match self.cd_type { let fill_mode = match self.cd_type {
CooldownType::Fill => FillMode::CLOCKWISE, CooldownType::Cooldown => FillMode::CLOCKWISE,
CooldownType::Empty => FillMode::COUNTER_CLOCKWISE, CooldownType::Empty => FillMode::COUNTER_CLOCKWISE,
}; };
bar.set_fill_mode(fill_mode); bar.set_fill_mode(fill_mode);
@ -64,14 +64,14 @@ impl CooldownIcon {
bar.set_max(self.max); bar.set_max(self.max);
bar.set_min(self.min); bar.set_min(self.min);
bar.set_value(match self.cd_type { bar.set_value(match self.cd_type {
CooldownType::Fill => self.max - self.value, CooldownType::Cooldown => self.max - self.value,
CooldownType::Empty => self.value, CooldownType::Empty => self.value,
}); });
} }
if let Some(label) = &mut self.label { if let Some(label) = &mut self.label {
label.set_text(&format!("{:.1}", self.value)); label.set_text(&format!("{:.1}", self.value));
label.set_visible(match self.cd_type { label.set_visible(match self.cd_type {
CooldownType::Fill => self.value > 0.05, CooldownType::Cooldown => self.value > 0.05,
CooldownType::Empty => self.value < 0.05, CooldownType::Empty => self.value < 0.05,
}); });
} }