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:
@@ -1,6 +1,7 @@
|
||||
class_name ActionExecutionSystem
|
||||
extends RefCounted
|
||||
|
||||
|
||||
func advance_npc(npc: SimNPC, village: SimVillage) -> void:
|
||||
if npc.is_dead:
|
||||
return
|
||||
@@ -12,6 +13,7 @@ func advance_npc(npc: SimNPC, village: SimVillage) -> void:
|
||||
npc.task_complete = true
|
||||
npc.task_state = SimNPC.TASK_STATE_COMPLETE
|
||||
|
||||
|
||||
func _update_needs(npc: SimNPC, village: SimVillage) -> void:
|
||||
npc.hunger += 3.0 * village.food_modifier
|
||||
match npc.task_state:
|
||||
|
||||
@@ -4,9 +4,7 @@ extends RefCounted
|
||||
var action_id: StringName
|
||||
var duration_override := -1.0
|
||||
|
||||
func _init(
|
||||
selected_action_id: StringName,
|
||||
selected_duration_override: float = -1.0
|
||||
) -> void:
|
||||
|
||||
func _init(selected_action_id: StringName, selected_duration_override: float = -1.0) -> void:
|
||||
action_id = selected_action_id
|
||||
duration_override = selected_duration_override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class_name ActionSelectionSystem
|
||||
extends RefCounted
|
||||
|
||||
|
||||
func select_action(npc: SimNPC, village: SimVillage) -> ActionSelectionResult:
|
||||
if npc.is_dead:
|
||||
return null
|
||||
@@ -8,10 +9,7 @@ func select_action(npc: SimNPC, village: SimVillage) -> ActionSelectionResult:
|
||||
if npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) >= 1.0:
|
||||
return ActionSelectionResult.new(SimulationIds.ACTION_EAT, 1.0)
|
||||
if village.food > 0:
|
||||
return ActionSelectionResult.new(
|
||||
SimulationIds.ACTION_WITHDRAW_FOOD,
|
||||
1.0
|
||||
)
|
||||
return ActionSelectionResult.new(SimulationIds.ACTION_WITHDRAW_FOOD, 1.0)
|
||||
return ActionSelectionResult.new(SimulationIds.ACTION_GATHER_FOOD, 4.0)
|
||||
if npc.hunger > 75.0:
|
||||
if npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) >= 1.0:
|
||||
@@ -25,34 +23,58 @@ func select_action(npc: SimNPC, village: SimVillage) -> ActionSelectionResult:
|
||||
return ActionSelectionResult.new(SimulationIds.ACTION_REST)
|
||||
return ActionSelectionResult.new(_choose_best_work_action(npc, village))
|
||||
|
||||
func _choose_best_work_action(
|
||||
npc: SimNPC,
|
||||
village: SimVillage
|
||||
) -> StringName:
|
||||
|
||||
func _choose_best_work_action(npc: SimNPC, village: SimVillage) -> StringName:
|
||||
var scores := {
|
||||
SimulationIds.ACTION_GATHER_FOOD: _calculate_score(
|
||||
npc, SimulationIds.ACTION_GATHER_FOOD, village.food_priority,
|
||||
village.food, 15.0, 30.0, 3.0, 1.5
|
||||
SimulationIds.ACTION_GATHER_FOOD:
|
||||
_calculate_score(
|
||||
npc,
|
||||
SimulationIds.ACTION_GATHER_FOOD,
|
||||
village.food_priority,
|
||||
village.food,
|
||||
15.0,
|
||||
30.0,
|
||||
3.0,
|
||||
1.5
|
||||
),
|
||||
SimulationIds.ACTION_GATHER_WOOD: _calculate_score(
|
||||
npc, SimulationIds.ACTION_GATHER_WOOD, village.wood_priority,
|
||||
village.wood, 10.0, 20.0, 2.5, 1.0
|
||||
SimulationIds.ACTION_GATHER_WOOD:
|
||||
_calculate_score(
|
||||
npc,
|
||||
SimulationIds.ACTION_GATHER_WOOD,
|
||||
village.wood_priority,
|
||||
village.wood,
|
||||
10.0,
|
||||
20.0,
|
||||
2.5,
|
||||
1.0
|
||||
),
|
||||
SimulationIds.ACTION_PATROL: _calculate_score(
|
||||
npc, SimulationIds.ACTION_PATROL, village.safety_priority,
|
||||
village.safety, 30.0, 50.0, 3.0, 1.5
|
||||
SimulationIds.ACTION_PATROL:
|
||||
_calculate_score(
|
||||
npc,
|
||||
SimulationIds.ACTION_PATROL,
|
||||
village.safety_priority,
|
||||
village.safety,
|
||||
30.0,
|
||||
50.0,
|
||||
3.0,
|
||||
1.5
|
||||
),
|
||||
SimulationIds.ACTION_STUDY: _calculate_score(
|
||||
npc, SimulationIds.ACTION_STUDY, village.knowledge_priority,
|
||||
village.knowledge, 10.0, 25.0, 1.5, 0.75
|
||||
SimulationIds.ACTION_STUDY:
|
||||
_calculate_score(
|
||||
npc,
|
||||
SimulationIds.ACTION_STUDY,
|
||||
village.knowledge_priority,
|
||||
village.knowledge,
|
||||
10.0,
|
||||
25.0,
|
||||
1.5,
|
||||
0.75
|
||||
)
|
||||
}
|
||||
var best_action := SimulationIds.ACTION_GATHER_FOOD
|
||||
var best_score: float = scores[best_action]
|
||||
for action_id in [
|
||||
SimulationIds.ACTION_GATHER_WOOD,
|
||||
SimulationIds.ACTION_PATROL,
|
||||
SimulationIds.ACTION_STUDY
|
||||
SimulationIds.ACTION_GATHER_WOOD, SimulationIds.ACTION_PATROL, SimulationIds.ACTION_STUDY
|
||||
]:
|
||||
var score: float = scores[action_id]
|
||||
if score > best_score:
|
||||
@@ -60,6 +82,7 @@ func _choose_best_work_action(
|
||||
best_score = score
|
||||
return best_action
|
||||
|
||||
|
||||
func _calculate_score(
|
||||
npc: SimNPC,
|
||||
action_id: StringName,
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
class_name ActionTargetResolver
|
||||
extends RefCounted
|
||||
|
||||
|
||||
func resolve(
|
||||
npc: SimNPC,
|
||||
origin: Vector3,
|
||||
simulation_manager: Node,
|
||||
active_world_adapter: Node
|
||||
npc: SimNPC, origin: Vector3, simulation_manager: Node, active_world_adapter: Node
|
||||
) -> Dictionary:
|
||||
var definition := SimulationDefinitions.get_action(npc.current_task)
|
||||
if definition == null:
|
||||
@@ -13,18 +11,17 @@ func resolve(
|
||||
match definition.target_type:
|
||||
SimulationIds.TARGET_RESOURCE:
|
||||
return _resolve_resource(
|
||||
npc, origin, definition, simulation_manager,
|
||||
active_world_adapter
|
||||
npc, origin, definition, simulation_manager, active_world_adapter
|
||||
)
|
||||
SimulationIds.TARGET_ACTIVITY:
|
||||
return active_world_adapter.get_activity_target(npc.current_task)
|
||||
SimulationIds.TARGET_FREE:
|
||||
return {
|
||||
"target_id": "",
|
||||
"position": origin + simulation_manager.get_wander_offset(npc.id)
|
||||
"target_id": "", "position": origin + simulation_manager.get_wander_offset(npc.id)
|
||||
}
|
||||
return {}
|
||||
|
||||
|
||||
func _resolve_resource(
|
||||
npc: SimNPC,
|
||||
origin: Vector3,
|
||||
@@ -34,18 +31,10 @@ func _resolve_resource(
|
||||
) -> Dictionary:
|
||||
var best: Dictionary = {}
|
||||
var best_distance := INF
|
||||
for candidate in active_world_adapter.get_resource_candidates(
|
||||
definition.resource_action_id
|
||||
):
|
||||
for candidate in active_world_adapter.get_resource_candidates(definition.resource_action_id):
|
||||
var node_id := StringName(candidate["target_id"])
|
||||
var state: ResourceStateRecord = simulation_manager.get_resource_state(
|
||||
node_id
|
||||
)
|
||||
if (
|
||||
state == null
|
||||
or not state.can_npc_use()
|
||||
or not state.is_available_for(npc.id)
|
||||
):
|
||||
var state: ResourceStateRecord = simulation_manager.get_resource_state(node_id)
|
||||
if state == null or not state.can_npc_use() or not state.is_available_for(npc.id):
|
||||
continue
|
||||
var position: Vector3 = candidate["position"]
|
||||
var distance := origin.distance_squared_to(position)
|
||||
|
||||
Reference in New Issue
Block a user