This commit is contained in:
2026-05-14 19:11:10 +02:00
parent 2d4002bd3f
commit 52ad83a96d
15 changed files with 169 additions and 31 deletions

View File

@@ -11,6 +11,7 @@ extends StaticBody3D
var spawn_timer: float = 0.0
var spawned_count: int = 0
var dead: bool = false
var attacked: bool = false
func _enter_tree() -> void:
set_multiplayer_authority(1)
@@ -51,6 +52,8 @@ func _physics_process(delta: float) -> void:
return
if not multiplayer.is_server() and multiplayer.multiplayer_peer != null:
return
if not attacked:
return
spawn_timer = max(0.0, spawn_timer - delta)
if spawn_timer <= 0.0 and spawned_count < int(Stats.get_stat(self, "spawn_count", 5)):
var spawn_sys: Node = get_node_or_null("/root/World/Systems/SpawnSystem")
@@ -62,6 +65,8 @@ func _physics_process(delta: float) -> void:
func _on_health_changed(entity: Node, current: float, max: float) -> void:
if entity != self:
return
if not attacked and current < max:
attacked = true
var ratio: float = clamp(current / max if max > 0 else 0.0, 0.0, 1.0)
healthbar.scale.x = max(0.01, ratio * 2.0)

View File

@@ -37,7 +37,7 @@ func _ready() -> void:
func _process(_delta: float) -> void:
if nearby_player and nearby_player.is_multiplayer_authority():
prompt.visible = true
if Input.is_action_just_pressed("interact"):
if Input.is_action_just_pressed("interact") and not nearby_player.ui_capturing:
EventBus.dialog_opened.emit(nearby_player, self)
else:
prompt.visible = false

View File

@@ -35,6 +35,7 @@ func _ready() -> void:
if stats_resource == null:
stats_resource = PlayerStats.new()
Stats.register(self, stats_resource)
Stats.restore_player(peer_id, self)
Stats.set_stat(self, "role", role)
name_label.text = Net.player_names.get(peer_id, "P%d" % peer_id)
EventBus.entity_died.connect(_on_entity_died_clear_target)
@@ -63,6 +64,7 @@ func _request_target(path_str: String) -> void:
current_target = t
func _exit_tree() -> void:
Stats.cache_player(peer_id, self)
Stats.deregister(self)
func _input(event: InputEvent) -> void:
@@ -85,6 +87,8 @@ func _unhandled_input(event: InputEvent) -> void:
return
if build_mode:
return
if ui_capturing:
return
if event.is_action_pressed("class_tank"):
_request_role(GameState.ROLE_TANK)
elif event.is_action_pressed("class_damage"):

View File

@@ -2,6 +2,7 @@ extends StaticBody3D
@export var stats_resource: PortalStats
@export var is_red: bool = false
@export var is_return: bool = false
@onready var mesh: MeshInstance3D = $Mesh
@onready var name_label: Label3D = $NameLabel
@@ -22,7 +23,15 @@ func _ready() -> void:
stats_resource.is_red = is_red
Stats.register(self, stats_resource)
enter_area.body_entered.connect(_on_body_entered)
if is_red:
if is_return:
var mat: StandardMaterial3D = StandardMaterial3D.new()
mat.albedo_color = Color(1.0, 0.85, 0.3)
mat.emission_enabled = true
mat.emission = Color(1.0, 0.8, 0.2)
mat.emission_energy_multiplier = 1.2
mesh.material_override = mat
name_label.text = "Zurück"
elif is_red:
var mat: StandardMaterial3D = StandardMaterial3D.new()
mat.albedo_color = Color(0.95, 0.2, 0.2)
mat.emission_enabled = true
@@ -45,7 +54,10 @@ func _on_body_entered(body: Node) -> void:
return
triggered = true
EventBus.portal_entered.emit(self, body)
_request_enter.rpc_id(1, is_red, global_position)
if is_return:
_request_return.rpc_id(1)
else:
_request_enter.rpc_id(1, is_red, global_position)
@rpc("any_peer", "reliable", "call_local")
func _request_enter(red: bool, return_pos: Vector3) -> void:
@@ -60,3 +72,13 @@ func _do_enter(seed: int, red: bool, return_pos: Vector3) -> void:
GameState.dungeon_red = red
GameState.portal_return_position = return_pos
GameState.change_scene(GameState.SCENE_DUNGEON)
@rpc("any_peer", "reliable", "call_local")
func _request_return() -> void:
if not multiplayer.is_server() and multiplayer.multiplayer_peer != null:
return
_do_return.rpc()
@rpc("authority", "reliable", "call_local")
func _do_return() -> void:
GameState.change_scene(GameState.SCENE_WORLD)