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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user