refactor(world-map): ♻️ Implement modular scene architecture for the world map by reorganizing logic in world_map.gd and updating the scene file to improve maintainability and performance.
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
74d7c3d087
commit
cbf0977ceb
2 changed files with 14 additions and 6 deletions
|
|
@ -470,13 +470,16 @@ func _on_end_turn_pressed() -> void:
|
|||
|
||||
|
||||
func _on_turn_started(_turn_number: int, player_index: int) -> void:
|
||||
_hud.set_end_turn_disabled(false)
|
||||
_update_hud()
|
||||
|
||||
var player: RefCounted = GameState.get_player(player_index) # Player
|
||||
if player == null:
|
||||
return
|
||||
|
||||
# Only enable HUD controls for human players.
|
||||
var is_human: bool = player.is_human
|
||||
_hud.set_end_turn_disabled(not is_human)
|
||||
if is_human:
|
||||
_update_hud()
|
||||
|
||||
for unit: RefCounted in player.units:
|
||||
if unit is UnitScript:
|
||||
unit.refresh_turn()
|
||||
|
|
@ -485,9 +488,11 @@ func _on_turn_started(_turn_number: int, player_index: int) -> void:
|
|||
if game_map == null:
|
||||
return
|
||||
|
||||
WorldMapVisionScript.recalculate_vision(player, game_map)
|
||||
WorldMapVisionScript.record_observations(player, game_map)
|
||||
_update_fog(player, game_map)
|
||||
# Always update vision/fog for the local human player (index 0).
|
||||
if is_human:
|
||||
WorldMapVisionScript.recalculate_vision(player, game_map)
|
||||
WorldMapVisionScript.record_observations(player, game_map)
|
||||
_update_fog(player, game_map)
|
||||
_sync_units()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://turn_notification_01" path="res://engine/scenes/hud/turn_notification.tscn" id="5_turn_notif"]
|
||||
[ext_resource type="PackedScene" uid="uid://victory_screen" path="res://engine/scenes/menus/victory_screen.tscn" id="6_victory"]
|
||||
[ext_resource type="PackedScene" uid="uid://defeat_screen" path="res://engine/scenes/menus/defeat_screen.tscn" id="7_defeat"]
|
||||
[ext_resource type="PackedScene" uid="uid://ai_turn_overlay_01" path="res://engine/scenes/hud/ai_turn_overlay.tscn" id="8_ai_overlay"]
|
||||
|
||||
[node name="WorldMap" type="Node2D"]
|
||||
script = ExtResource("1")
|
||||
|
|
@ -55,3 +56,5 @@ script = ExtResource("2")
|
|||
[node name="VictoryScreen" parent="." instance=ExtResource("6_victory")]
|
||||
|
||||
[node name="DefeatScreen" parent="." instance=ExtResource("7_defeat")]
|
||||
|
||||
[node name="AiTurnOverlay" parent="." instance=ExtResource("8_ai_overlay")]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue