This commit is contained in:
Marek Le
2026-05-09 23:37:26 +02:00
parent 6d28b04c12
commit 2d4002bd3f
263 changed files with 5250 additions and 4597 deletions

View File

@@ -0,0 +1,36 @@
extends StaticBody3D
@export var stats_resource: VillageStats
@onready var mesh: MeshInstance3D = $Mesh
@onready var label: Label3D = $Label
@onready var healthbar: MeshInstance3D = $Healthbar
func _enter_tree() -> void:
set_multiplayer_authority(1)
func _ready() -> void:
add_to_group("village")
if stats_resource == null:
stats_resource = VillageStats.new()
stats_resource.max_health = 1000.0
Stats.register(self, stats_resource)
EventBus.health_changed.connect(_on_health_changed)
EventBus.entity_died.connect(_on_entity_died)
label.text = "Village"
func _exit_tree() -> void:
Stats.deregister(self)
func _on_health_changed(entity: Node, current: float, max: float) -> void:
if entity != self:
return
EventBus.village_damaged.emit(current, max)
var ratio: float = clamp(current / max if max > 0 else 0.0, 0.0, 1.0)
healthbar.scale.x = max(0.01, ratio * 4.0)
func _on_entity_died(entity: Node) -> void:
if entity != self:
return
EventBus.village_destroyed.emit()
EventBus.game_over.emit()

View File

@@ -0,0 +1 @@
uid://n5yrsrsav4yx

View File

@@ -0,0 +1,47 @@
[gd_scene load_steps=6 format=3 uid="uid://b0village001"]
[ext_resource type="Script" path="res://scenes/entities/village/village.gd" id="1"]
[sub_resource type="BoxShape3D" id="BoxShape_1"]
size = Vector3(6, 4, 6)
[sub_resource type="BoxMesh" id="BoxMesh_1"]
size = Vector3(6, 4, 6)
[sub_resource type="StandardMaterial3D" id="VillageMat"]
albedo_color = Color(0.55, 0.4, 0.25, 1)
[sub_resource type="QuadMesh" id="QuadMesh_HB"]
size = Vector2(1.0, 0.25)
[sub_resource type="StandardMaterial3D" id="HBMat"]
shading_mode = 0
no_depth_test = true
albedo_color = Color(0.4, 0.85, 0.4, 1)
[node name="Village" type="StaticBody3D"]
collision_layer = 1
collision_mask = 0
script = ExtResource("1")
[node name="Collision" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
shape = SubResource("BoxShape_1")
[node name="Mesh" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
mesh = SubResource("BoxMesh_1")
material_override = SubResource("VillageMat")
[node name="Label" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.5, 0)
billboard = 1
text = "Village"
font_size = 28
outline_size = 4
[node name="Healthbar" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.0, 0)
mesh = SubResource("QuadMesh_HB")
material_override = SubResource("HBMat")
gi_mode = 0