Skip to content

Commit cba4d23

Browse files
committed
Add regeneratives cells
1 parent 4d29586 commit cba4d23

15 files changed

Lines changed: 586 additions & 1 deletion

components/health/component_health.gd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ signal health_depleted()
1010
max_health = value
1111
max_health_changed.emit(value)
1212

13+
@export var health_regeneration_rate := 0.0
14+
1315
var current_health := 1.0:
1416
set(value):
1517
print("%s new health is %s." % [owner.name, value])
@@ -20,10 +22,17 @@ var current_health := 1.0:
2022
health_depleted.emit()
2123

2224

25+
2326
func _ready() -> void:
2427
# Since current health won't consider value from @export.
2528
current_health = max_health
2629

30+
func _physics_process(delta: float) -> void:
31+
if not is_zero_approx(health_regeneration_rate) \
32+
and not is_equal_approx(current_health, max_health):
33+
34+
current_health += health_regeneration_rate * delta
35+
2736

2837
func get_current_health_percentage() -> float:
2938
return current_health / max_health

game/ship_skeleton/cell/cells/basic_cell/big_basic_cell.tscn

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,27 @@
22

33
[ext_resource type="PackedScene" uid="uid://cm6tq3xwihkxl" path="res://game/ship_skeleton/cell/cells/basic_cell/medium_basic_cell.tscn" id="1_654sg"]
44
[ext_resource type="Texture2D" uid="uid://dw8eyhjagpbgk" path="res://game/ship_skeleton/cell/cells/basic_cell/big_basic_cell.svg" id="2_2qipr"]
5+
[ext_resource type="Shader" uid="uid://4ojyrld7fshk" path="res://game/ship_skeleton/cell/cell.gdshader" id="2_q1gn2"]
6+
7+
[sub_resource type="ShaderMaterial" id="ShaderMaterial_w17yd"]
8+
resource_local_to_scene = true
9+
shader = ExtResource("2_q1gn2")
10+
shader_parameter/hp_ratio = 1.0
11+
shader_parameter/is_hit_flash_active = false
512

613
[sub_resource type="CircleShape2D" id="CircleShape2D_2qipr"]
714
radius = 36.013885
815

916
[node name="BigBasicCell" unique_id=1435320636 instance=ExtResource("1_654sg")]
1017

1118
[node name="Sprite2D" parent="." index="0" unique_id=1975990942]
19+
material = SubResource("ShaderMaterial_w17yd")
1220
texture = ExtResource("2_2qipr")
1321

1422
[node name="CollisionShape2D" parent="Hurtbox2D" parent_id_path=PackedInt32Array(146611675) index="0" unique_id=2074960276]
1523
shape = SubResource("CircleShape2D_2qipr")
1624

25+
[node name="Health" parent="." index="2" unique_id=562956058]
26+
max_health = 15.0
27+
1728
[editable path="Hurtbox2D"]

game/ship_skeleton/cell/cells/basic_cell/large_basic_cell.tscn

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
[gd_scene format=3 uid="uid://g7r6jujgrh5a"]
22

33
[ext_resource type="PackedScene" uid="uid://cm6tq3xwihkxl" path="res://game/ship_skeleton/cell/cells/basic_cell/medium_basic_cell.tscn" id="1_sr7xj"]
4+
[ext_resource type="Shader" uid="uid://4ojyrld7fshk" path="res://game/ship_skeleton/cell/cell.gdshader" id="2_4ip4w"]
45
[ext_resource type="Texture2D" uid="uid://bbriutj3tbq66" path="res://game/ship_skeleton/cell/cells/basic_cell/large_basic_cell.svg" id="2_iy7jg"]
56

7+
[sub_resource type="ShaderMaterial" id="ShaderMaterial_lbegn"]
8+
resource_local_to_scene = true
9+
shader = ExtResource("2_4ip4w")
10+
shader_parameter/hp_ratio = 1.0
11+
shader_parameter/is_hit_flash_active = false
12+
613
[sub_resource type="CircleShape2D" id="CircleShape2D_sr7xj"]
714
radius = 53.037724
815

916
[node name="LargeBasicCell" unique_id=1435320636 instance=ExtResource("1_sr7xj")]
1017

1118
[node name="Sprite2D" parent="." index="0" unique_id=1975990942]
19+
material = SubResource("ShaderMaterial_lbegn")
1220
texture = ExtResource("2_iy7jg")
1321

1422
[node name="CollisionShape2D" parent="Hurtbox2D" parent_id_path=PackedInt32Array(146611675) index="0" unique_id=2074960276]

game/ship_skeleton/cell/cells/basic_cell/medium_basic_cell.tscn

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
[gd_scene format=3 uid="uid://cm6tq3xwihkxl"]
22

33
[ext_resource type="PackedScene" uid="uid://73o17dpehsvx" path="res://game/ship_skeleton/cell/cell.tscn" id="1_pff0w"]
4+
[ext_resource type="Shader" uid="uid://4ojyrld7fshk" path="res://game/ship_skeleton/cell/cell.gdshader" id="2_4ec4m"]
5+
6+
[sub_resource type="ShaderMaterial" id="ShaderMaterial_4ec4m"]
7+
resource_local_to_scene = true
8+
shader = ExtResource("2_4ec4m")
9+
shader_parameter/hp_ratio = 1.0
10+
shader_parameter/is_hit_flash_active = false
411

512
[sub_resource type="CircleShape2D" id="CircleShape2D_r4tuq"]
613
radius = 24.0
714

815
[node name="MediumBasicCell" unique_id=1435320636 instance=ExtResource("1_pff0w")]
916

17+
[node name="Sprite2D" parent="." index="0" unique_id=1975990942]
18+
material = SubResource("ShaderMaterial_4ec4m")
19+
1020
[node name="CollisionShape2D" parent="Hurtbox2D" parent_id_path=PackedInt32Array(146611675) index="0" unique_id=2074960276]
1121
shape = SubResource("CircleShape2D_r4tuq")
1222

Lines changed: 140 additions & 0 deletions
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[remap]
2+
3+
importer="svg"
4+
type="DPITexture"
5+
uid="uid://dfovxa0jo1yl5"
6+
path="res://.godot/imported/big_regenerative_cell.svg-106acaca82dfafe9e521cabbec8ac2f8.dpitex"
7+
8+
[deps]
9+
10+
source_file="res://game/ship_skeleton/cell/cells/regenerative_cell/big_regenerative_cell.svg"
11+
dest_files=["res://.godot/imported/big_regenerative_cell.svg-106acaca82dfafe9e521cabbec8ac2f8.dpitex"]
12+
13+
[params]
14+
15+
base_scale=1.0
16+
saturation=1.0
17+
color_map={}
18+
compress=true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[gd_scene format=3 uid="uid://ci0c6ij7neval"]
2+
3+
[ext_resource type="PackedScene" uid="uid://uwcx77t1tjb" path="res://game/ship_skeleton/cell/cells/basic_cell/big_basic_cell.tscn" id="1_p3kry"]
4+
[ext_resource type="Shader" uid="uid://4ojyrld7fshk" path="res://game/ship_skeleton/cell/cell.gdshader" id="2_5gf46"]
5+
[ext_resource type="Texture2D" uid="uid://dfovxa0jo1yl5" path="res://game/ship_skeleton/cell/cells/regenerative_cell/big_regenerative_cell.svg" id="3_5gf46"]
6+
7+
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ubvuo"]
8+
resource_local_to_scene = true
9+
shader = ExtResource("2_5gf46")
10+
shader_parameter/hp_ratio = 1.0
11+
shader_parameter/is_hit_flash_active = false
12+
13+
[node name="BigRegenerativeCell" unique_id=1435320636 instance=ExtResource("1_p3kry")]
14+
15+
[node name="Sprite2D" parent="." index="0" unique_id=1975990942]
16+
material = SubResource("ShaderMaterial_ubvuo")
17+
texture = ExtResource("3_5gf46")
18+
19+
[node name="Health" parent="." index="2" unique_id=562956058]
20+
max_health = 10.0
21+
health_regeneration_rate = 2.0
22+
23+
[editable path="Hurtbox2D"]

0 commit comments

Comments
 (0)