style: apply gdformat formatting across the entire project
Auto-format all GDScript files using gdformat from gdtoolkit. This is a baseline formatting pass to ensure consistent style: - Normalizes indentation and spacing - Wraps long lines to 100 characters - Removes trailing whitespace - Standardizes blank lines between functions 68 files reformatted, 8 files left unchanged (3rd-party addon files with parse errors excluded).
This commit is contained in:
@@ -6,17 +6,18 @@ extends Node
|
||||
@export var rest_marker: Marker3D
|
||||
@export var pantry_marker: Marker3D
|
||||
|
||||
|
||||
func get_resource_candidates(action_id: StringName) -> Array[Dictionary]:
|
||||
var candidates: Array[Dictionary] = []
|
||||
for node in ResourceNode.get_all():
|
||||
if node.action_id != action_id or node.interaction_point == null:
|
||||
continue
|
||||
candidates.append({
|
||||
"target_id": String(node.node_id),
|
||||
"position": node.interaction_point.global_position
|
||||
})
|
||||
candidates.append(
|
||||
{"target_id": String(node.node_id), "position": node.interaction_point.global_position}
|
||||
)
|
||||
return candidates
|
||||
|
||||
|
||||
func get_activity_target(action_id: StringName) -> Dictionary:
|
||||
var marker: Marker3D
|
||||
match action_id:
|
||||
@@ -33,10 +34,13 @@ func get_activity_target(action_id: StringName) -> Dictionary:
|
||||
if marker == null:
|
||||
return {}
|
||||
var target_id := ""
|
||||
if action_id in [
|
||||
SimulationIds.ACTION_EAT,
|
||||
SimulationIds.ACTION_DEPOSIT_FOOD,
|
||||
SimulationIds.ACTION_WITHDRAW_FOOD
|
||||
]:
|
||||
if (
|
||||
action_id
|
||||
in [
|
||||
SimulationIds.ACTION_EAT,
|
||||
SimulationIds.ACTION_DEPOSIT_FOOD,
|
||||
SimulationIds.ACTION_WITHDRAW_FOOD
|
||||
]
|
||||
):
|
||||
target_id = String(SimulationIds.STORAGE_VILLAGE_PANTRY)
|
||||
return {"target_id": target_id, "position": marker.global_position}
|
||||
|
||||
@@ -17,6 +17,7 @@ const COLORS := {
|
||||
|
||||
const WIND_SHADER := preload("res://world/jajce/materials/wind.gdshader")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
for child in get_children():
|
||||
child.queue_free()
|
||||
|
||||
@@ -4,9 +4,11 @@ extends Camera3D
|
||||
@export var orbit_speed := 0.025
|
||||
@export var animate_orbit := true
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
look_at(focus_point, Vector3.UP)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not animate_orbit:
|
||||
return
|
||||
|
||||
@@ -2,9 +2,11 @@ extends Node3D
|
||||
|
||||
@onready var terrain: Terrain3D = $TerrainRoot/Terrain3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
call_deferred("_initialize_world_presentation")
|
||||
|
||||
|
||||
func _initialize_world_presentation() -> void:
|
||||
var active_camera := get_viewport().get_camera_3d()
|
||||
if active_camera != null:
|
||||
@@ -16,7 +18,7 @@ func _initialize_world_presentation() -> void:
|
||||
for child in $VillageRoot.get_children():
|
||||
groups_to_snap.append(child)
|
||||
for item in groups_to_snap:
|
||||
var pos := item.global_position
|
||||
var pos: Vector3 = item.global_position
|
||||
var h: float = terrain.data.get_height(pos)
|
||||
if not is_nan(h):
|
||||
item.global_position.y = h
|
||||
|
||||
@@ -21,6 +21,7 @@ static var _all: Array[ResourceNode] = []
|
||||
|
||||
var state: ResourceStateRecord
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if node_id.is_empty():
|
||||
push_error("ResourceNode at %s has empty node_id" % get_path())
|
||||
@@ -30,8 +31,10 @@ func _ready() -> void:
|
||||
var existing := get_by_id(node_id)
|
||||
if existing != null:
|
||||
push_error(
|
||||
"Duplicate ResourceNode node_id '%s' at %s; first registered at %s"
|
||||
% [node_id, get_path(), existing.get_path()]
|
||||
(
|
||||
"Duplicate ResourceNode node_id '%s' at %s; first registered at %s"
|
||||
% [node_id, get_path(), existing.get_path()]
|
||||
)
|
||||
)
|
||||
initial_enabled = false
|
||||
_update_presentation()
|
||||
@@ -41,6 +44,7 @@ func _ready() -> void:
|
||||
_try_register_with_simulation()
|
||||
_update_presentation()
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
_all.erase(self)
|
||||
if state != null and state.changed.is_connected(_on_state_changed):
|
||||
@@ -49,6 +53,7 @@ func _exit_tree() -> void:
|
||||
state.depleted.disconnect(_on_state_depleted)
|
||||
state = null
|
||||
|
||||
|
||||
func bind_state(resource_state: ResourceStateRecord) -> bool:
|
||||
if resource_state == null or resource_state.get_node_id() != node_id:
|
||||
return false
|
||||
@@ -64,6 +69,7 @@ func bind_state(resource_state: ResourceStateRecord) -> bool:
|
||||
_update_presentation()
|
||||
return true
|
||||
|
||||
|
||||
func _try_register_with_simulation() -> void:
|
||||
var managers := get_tree().get_nodes_in_group("simulation_manager")
|
||||
if managers.size() != 1:
|
||||
@@ -72,21 +78,27 @@ func _try_register_with_simulation() -> void:
|
||||
if manager.has_method("register_resource_node"):
|
||||
manager.register_resource_node(self)
|
||||
|
||||
|
||||
func get_amount_remaining() -> float:
|
||||
return state.get_amount_remaining() if state != null else initial_amount
|
||||
|
||||
|
||||
func get_reserved_by() -> int:
|
||||
return state.get_reserved_by() if state != null else -1
|
||||
|
||||
|
||||
func is_enabled() -> bool:
|
||||
return state.is_enabled() if state != null else initial_enabled
|
||||
|
||||
|
||||
func is_depleted() -> bool:
|
||||
return state.is_depleted() if state != null else initial_amount <= 0.0
|
||||
|
||||
|
||||
func can_extract() -> bool:
|
||||
return state.can_extract() if state != null else initial_enabled and not is_depleted()
|
||||
|
||||
|
||||
func _on_state_changed(changed_state: ResourceStateRecord) -> void:
|
||||
if changed_state != state:
|
||||
return
|
||||
@@ -94,21 +106,19 @@ func _on_state_changed(changed_state: ResourceStateRecord) -> void:
|
||||
reservation_changed.emit(node_id, state.get_reserved_by())
|
||||
_update_presentation()
|
||||
|
||||
|
||||
func _on_state_depleted(depleted_state: ResourceStateRecord) -> void:
|
||||
if depleted_state == state:
|
||||
depleted.emit(node_id)
|
||||
|
||||
|
||||
func _update_presentation() -> void:
|
||||
if has_node("Visual"):
|
||||
$Visual.visible = not (hide_visual_when_depleted and is_depleted())
|
||||
if not has_node("DebugLabel"):
|
||||
return
|
||||
var label := $DebugLabel as Label3D
|
||||
var text := "%s\n%s %.1f" % [
|
||||
node_id,
|
||||
resource_id,
|
||||
get_amount_remaining()
|
||||
]
|
||||
var text := "%s\n%s %.1f" % [node_id, resource_id, get_amount_remaining()]
|
||||
if get_reserved_by() >= 0:
|
||||
text += "\nheld:%d" % get_reserved_by()
|
||||
if is_depleted():
|
||||
@@ -117,11 +127,13 @@ func _update_presentation() -> void:
|
||||
text += "\nUNBOUND"
|
||||
label.text = text
|
||||
|
||||
|
||||
static func get_by_id(search_id: StringName) -> ResourceNode:
|
||||
for node in _all:
|
||||
if node.node_id == search_id:
|
||||
return node
|
||||
return null
|
||||
|
||||
|
||||
static func get_all() -> Array[ResourceNode]:
|
||||
return _all.duplicate()
|
||||
|
||||
+16
-11
@@ -6,6 +6,7 @@ const DEBUG_LOGS := false
|
||||
|
||||
@onready var village_stats_label: Label = $VillagePanel/MarginContainer/VillageStatsLabel
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if simulation_manager == null:
|
||||
push_error("VillageUI: simulation_manager missing")
|
||||
@@ -19,8 +20,10 @@ func _ready() -> void:
|
||||
if "village" in simulation_manager:
|
||||
_on_village_changed(simulation_manager.village)
|
||||
|
||||
|
||||
func _on_village_changed(village: SimVillage) -> void:
|
||||
village_stats_label.text = """
|
||||
village_stats_label.text = (
|
||||
"""
|
||||
Village
|
||||
|
||||
Food: %s
|
||||
@@ -32,13 +35,15 @@ func _on_village_changed(village: SimVillage) -> void:
|
||||
Food Mod: %.2f
|
||||
Safety Mod: %.2f
|
||||
Knowledge Mod: %.2f
|
||||
""" % [
|
||||
round(village.food),
|
||||
round(village.wood),
|
||||
round(village.safety),
|
||||
round(village.knowledge),
|
||||
simulation_manager.get_starving_count(),
|
||||
village.food_modifier,
|
||||
village.safety_modifier,
|
||||
village.knowledge_modifier
|
||||
]
|
||||
"""
|
||||
% [
|
||||
round(village.food),
|
||||
round(village.wood),
|
||||
round(village.safety),
|
||||
round(village.knowledge),
|
||||
simulation_manager.get_starving_count(),
|
||||
village.food_modifier,
|
||||
village.safety_modifier,
|
||||
village.knowledge_modifier
|
||||
]
|
||||
)
|
||||
|
||||
+27
-44
@@ -8,25 +8,24 @@ const DEBUG_LOGS := true
|
||||
|
||||
var active_npc_visuals := {}
|
||||
|
||||
|
||||
func debug_log(message: String) -> void:
|
||||
if DEBUG_LOGS:
|
||||
print("[WorldViewManager] ", message)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
call_deferred("initialize_world_view")
|
||||
|
||||
|
||||
func initialize_world_view() -> void:
|
||||
await get_tree().physics_frame
|
||||
if simulation_manager.has_signal("npc_target_requested"):
|
||||
simulation_manager.npc_target_requested.connect(
|
||||
_on_npc_target_requested
|
||||
)
|
||||
simulation_manager.npc_target_requested.connect(_on_npc_target_requested)
|
||||
else:
|
||||
push_error("WorldViewManager: missing npc_target_requested signal")
|
||||
if simulation_manager.has_signal("npc_travel_requested"):
|
||||
simulation_manager.npc_travel_requested.connect(
|
||||
_on_npc_travel_requested
|
||||
)
|
||||
simulation_manager.npc_travel_requested.connect(_on_npc_travel_requested)
|
||||
else:
|
||||
push_error("WorldViewManager: missing npc_travel_requested signal")
|
||||
if simulation_manager.has_signal("npc_died"):
|
||||
@@ -34,19 +33,16 @@ func initialize_world_view() -> void:
|
||||
else:
|
||||
push_error("WorldViewManager: SimulationManager has no npc_died signal")
|
||||
if simulation_manager.has_signal("npc_inventory_changed"):
|
||||
simulation_manager.npc_inventory_changed.connect(
|
||||
_on_npc_inventory_changed
|
||||
)
|
||||
simulation_manager.npc_inventory_changed.connect(_on_npc_inventory_changed)
|
||||
else:
|
||||
push_error(
|
||||
"WorldViewManager: SimulationManager has no npc_inventory_changed signal"
|
||||
)
|
||||
push_error("WorldViewManager: SimulationManager has no npc_inventory_changed signal")
|
||||
if simulation_manager.has_signal("state_restored"):
|
||||
simulation_manager.state_restored.connect(_on_simulation_state_restored)
|
||||
else:
|
||||
push_error("WorldViewManager: SimulationManager has no state_restored signal")
|
||||
spawn_initial_npcs()
|
||||
|
||||
|
||||
func spawn_initial_npcs() -> void:
|
||||
if simulation_manager == null:
|
||||
push_error("WorldViewManager: simulation_manager is missing")
|
||||
@@ -61,6 +57,7 @@ func spawn_initial_npcs() -> void:
|
||||
for npc in simulation_manager.npcs:
|
||||
spawn_npc_visual(npc)
|
||||
|
||||
|
||||
func spawn_npc_visual(npc: SimNPC) -> void:
|
||||
if active_npc_visuals.has(npc.id):
|
||||
return
|
||||
@@ -87,18 +84,17 @@ func spawn_npc_visual(npc: SimNPC) -> void:
|
||||
elif npc.task_state == SimNPC.TASK_STATE_TRAVELING:
|
||||
simulation_manager.request_current_travel(npc.id)
|
||||
|
||||
|
||||
func despawn_npc_visual(npc_id: int) -> bool:
|
||||
var visual = active_npc_visuals.get(npc_id) as Node3D
|
||||
if visual == null:
|
||||
return false
|
||||
simulation_manager.synchronize_npc_position(
|
||||
npc_id,
|
||||
visual.global_position
|
||||
)
|
||||
simulation_manager.synchronize_npc_position(npc_id, visual.global_position)
|
||||
active_npc_visuals.erase(npc_id)
|
||||
visual.queue_free()
|
||||
return true
|
||||
|
||||
|
||||
func reload_npc_visual(npc_id: int) -> bool:
|
||||
if active_npc_visuals.has(npc_id):
|
||||
return false
|
||||
@@ -108,25 +104,22 @@ func reload_npc_visual(npc_id: int) -> bool:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _on_npc_target_requested(npc: SimNPC) -> void:
|
||||
var visual = active_npc_visuals.get(npc.id) as Node3D
|
||||
if visual == null:
|
||||
return
|
||||
if not simulation_manager.resolve_npc_target(
|
||||
npc.id,
|
||||
visual.global_position
|
||||
):
|
||||
if not simulation_manager.resolve_npc_target(npc.id, visual.global_position):
|
||||
debug_log("Target resolution failed for %s" % npc.npc_name)
|
||||
|
||||
func _on_npc_travel_requested(
|
||||
npc: SimNPC,
|
||||
target_position: Vector3
|
||||
) -> void:
|
||||
|
||||
func _on_npc_travel_requested(npc: SimNPC, target_position: Vector3) -> void:
|
||||
var visual = active_npc_visuals.get(npc.id)
|
||||
if visual == null:
|
||||
return
|
||||
visual.set_target_position(target_position)
|
||||
|
||||
|
||||
func _on_npc_visual_arrived(sim_id: int) -> void:
|
||||
debug_log("NPC visual arrived. sim_id=%s" % sim_id)
|
||||
if simulation_manager == null:
|
||||
@@ -134,12 +127,10 @@ func _on_npc_visual_arrived(sim_id: int) -> void:
|
||||
return
|
||||
var visual = active_npc_visuals.get(sim_id) as Node3D
|
||||
if visual != null:
|
||||
simulation_manager.synchronize_npc_position(
|
||||
sim_id,
|
||||
visual.global_position
|
||||
)
|
||||
simulation_manager.synchronize_npc_position(sim_id, visual.global_position)
|
||||
simulation_manager.notify_npc_arrived(sim_id)
|
||||
|
||||
|
||||
func _on_npc_visual_navigation_failed(sim_id: int) -> void:
|
||||
debug_log("NPC visual navigation failed. sim_id=%s" % sim_id)
|
||||
if simulation_manager == null:
|
||||
@@ -147,18 +138,14 @@ func _on_npc_visual_navigation_failed(sim_id: int) -> void:
|
||||
return
|
||||
var visual = active_npc_visuals.get(sim_id) as Node3D
|
||||
if visual != null:
|
||||
simulation_manager.synchronize_npc_position(
|
||||
sim_id,
|
||||
visual.global_position
|
||||
)
|
||||
simulation_manager.synchronize_npc_position(sim_id, visual.global_position)
|
||||
simulation_manager.notify_npc_navigation_failed(sim_id)
|
||||
|
||||
func _on_npc_visual_position_changed(
|
||||
sim_id: int,
|
||||
active_position: Vector3
|
||||
) -> void:
|
||||
|
||||
func _on_npc_visual_position_changed(sim_id: int, active_position: Vector3) -> void:
|
||||
simulation_manager.synchronize_npc_position(sim_id, active_position)
|
||||
|
||||
|
||||
func _on_npc_died(npc: SimNPC) -> void:
|
||||
if not active_npc_visuals.has(npc.id):
|
||||
return
|
||||
@@ -168,11 +155,8 @@ func _on_npc_died(npc: SimNPC) -> void:
|
||||
else:
|
||||
push_error("WorldViewManager: NPCVisual has no apply_dead_visual_state")
|
||||
|
||||
func _on_npc_inventory_changed(
|
||||
npc: SimNPC,
|
||||
item_id: StringName,
|
||||
amount: float
|
||||
) -> void:
|
||||
|
||||
func _on_npc_inventory_changed(npc: SimNPC, item_id: StringName, amount: float) -> void:
|
||||
if item_id != SimulationIds.RESOURCE_FOOD:
|
||||
return
|
||||
var visual = active_npc_visuals.get(npc.id)
|
||||
@@ -181,9 +165,8 @@ func _on_npc_inventory_changed(
|
||||
if visual.has_method("set_carried_food_visible"):
|
||||
visual.set_carried_food_visible(amount > 0.0)
|
||||
else:
|
||||
push_error(
|
||||
"WorldViewManager: NPCVisual has no set_carried_food_visible method"
|
||||
)
|
||||
push_error("WorldViewManager: NPCVisual has no set_carried_food_visible method")
|
||||
|
||||
|
||||
func _on_simulation_state_restored() -> void:
|
||||
for visual in active_npc_visuals.values():
|
||||
|
||||
Reference in New Issue
Block a user