Improve code style (#1021)

* Remove unnecessary use of `self`
* Connect to signals directly over `connect("name")`
* Use `call_deferred` on callables over `call_deferred("name"))`
* Emit signals directly over `emit_signal("name"...)`
This commit is contained in:
A Thousand Ships
2024-03-25 17:06:52 +01:00
committed by GitHub
parent 523c7d34c0
commit 82913393a8
70 changed files with 211 additions and 211 deletions

View File

@@ -24,4 +24,4 @@ func set_dead(value):
func set_look_direction(value): func set_look_direction(value):
emit_signal("direction_changed", value) direction_changed.emit(value)

View File

@@ -5,4 +5,4 @@ func enter():
func _on_Sword_attack_finished(): func _on_Sword_attack_finished():
emit_signal("finished", "previous") finished.emit("previous")

View File

@@ -9,4 +9,4 @@ func enter():
func _on_animation_finished(anim_name): func _on_animation_finished(anim_name):
assert(anim_name == "stagger") assert(anim_name == "stagger")
emit_signal("finished", "previous") finished.emit("previous")

View File

@@ -7,4 +7,4 @@ func enter():
func _on_animation_finished(_anim_name): func _on_animation_finished(_anim_name):
emit_signal("finished", "dead") finished.emit("dead")

View File

@@ -46,7 +46,7 @@ func update(delta):
move_horizontally(delta, input_direction) move_horizontally(delta, input_direction)
animate_jump_height(delta) animate_jump_height(delta)
if height <= 0.0: if height <= 0.0:
emit_signal("finished", "previous") finished.emit("previous")
func move_horizontally(delta, direction): func move_horizontally(delta, direction):

View File

@@ -3,7 +3,7 @@ extends "res://state_machine/state.gd"
func handle_input(event): func handle_input(event):
if event.is_action_pressed("simulate_damage"): if event.is_action_pressed("simulate_damage"):
emit_signal("finished", "stagger") finished.emit("stagger")
func get_input_direction(): func get_input_direction():

View File

@@ -11,4 +11,4 @@ func handle_input(event):
func update(_delta): func update(_delta):
var input_direction = get_input_direction() var input_direction = get_input_direction()
if input_direction: if input_direction:
emit_signal("finished", "move") finished.emit("move")

View File

@@ -19,7 +19,7 @@ func handle_input(event):
func update(_delta): func update(_delta):
var input_direction = get_input_direction() var input_direction = get_input_direction()
if input_direction.is_zero_approx(): if input_direction.is_zero_approx():
emit_signal("finished", "idle") finished.emit("idle")
update_look_direction(input_direction) update_look_direction(input_direction)
if Input.is_action_pressed("run"): if Input.is_action_pressed("run"):

View File

@@ -6,5 +6,5 @@ var velocity = Vector2()
func handle_input(event): func handle_input(event):
if event.is_action_pressed("jump"): if event.is_action_pressed("jump"):
emit_signal("finished", "jump") finished.emit("jump")
return super.handle_input(event) return super.handle_input(event)

View File

@@ -31,8 +31,8 @@ var combo = [{
var hit_objects = [] var hit_objects = []
func _ready(): func _ready():
$AnimationPlayer.animation_finished.connect(self._on_animation_finished) $AnimationPlayer.animation_finished.connect(_on_animation_finished)
body_entered.connect(self._on_body_entered) body_entered.connect(_on_body_entered)
_change_state(States.IDLE) _change_state(States.IDLE)
@@ -103,7 +103,7 @@ func _on_animation_finished(_name):
attack() attack()
else: else:
_change_state(States.IDLE) _change_state(States.IDLE)
emit_signal("attack_finished") attack_finished.emit()
func _on_StateMachine_state_changed(current_state): func _on_StateMachine_state_changed(current_state):

View File

@@ -3,7 +3,7 @@ extends Marker2D
var z_index_start = 0 var z_index_start = 0
func _ready(): func _ready():
owner.direction_changed.connect(self._on_Parent_direction_changed) owner.direction_changed.connect(_on_Parent_direction_changed)
z_index_start = z_index z_index_start = z_index

View File

@@ -24,7 +24,7 @@ func _enter_tree():
if start_state.is_empty(): if start_state.is_empty():
start_state = get_child(0).get_path() start_state = get_child(0).get_path()
for child in get_children(): for child in get_children():
var err = child.finished.connect(self._change_state) var err = child.finished.connect(_change_state)
if err: if err:
printerr(err) printerr(err)
initialize(start_state) initialize(start_state)
@@ -70,7 +70,7 @@ func _change_state(state_name):
states_stack[0] = states_map[state_name] states_stack[0] = states_map[state_name]
current_state = states_stack[0] current_state = states_stack[0]
emit_signal("state_changed", current_state) state_changed.emit(current_state)
if state_name != "previous": if state_name != "previous":
current_state.enter() current_state.enter()

View File

@@ -191,7 +191,7 @@ func _shot_bullet() -> void:
else: else:
speed_scale = 1.0 speed_scale = 1.0
bullet.position = self.position + bullet_shoot.position * Vector2(speed_scale, 1.0) bullet.position = position + bullet_shoot.position * Vector2(speed_scale, 1.0)
get_parent().add_child(bullet) get_parent().add_child(bullet)
bullet.linear_velocity = Vector2(400.0 * speed_scale, -40) bullet.linear_velocity = Vector2(400.0 * speed_scale, -40)
@@ -204,5 +204,5 @@ func _shot_bullet() -> void:
func _spawn_enemy_above() -> void: func _spawn_enemy_above() -> void:
var enemy := Enemy.instantiate() as RigidBody2D var enemy := Enemy.instantiate() as RigidBody2D
enemy.position = self.position + 50 * Vector2.UP enemy.position = position + 50 * Vector2.UP
get_parent().add_child(enemy) get_parent().add_child(enemy)

View File

@@ -32,7 +32,7 @@ func _physics_process(_delta):
if _wait_physics_ticks_counter > 0: if _wait_physics_ticks_counter > 0:
_wait_physics_ticks_counter -= 1 _wait_physics_ticks_counter -= 1
if _wait_physics_ticks_counter == 0: if _wait_physics_ticks_counter == 0:
emit_signal("wait_done") wait_done.emit()
func add_line(pos_start, pos_end, color): func add_line(pos_start, pos_end, color):
@@ -111,7 +111,7 @@ func start_timer(timeout):
_timer = Timer.new() _timer = Timer.new()
_timer.one_shot = true _timer.one_shot = true
add_child(_timer) add_child(_timer)
_timer.timeout.connect(self._on_timer_done) _timer.timeout.connect(_on_timer_done)
else: else:
cancel_timer() cancel_timer()
@@ -124,7 +124,7 @@ func start_timer(timeout):
func cancel_timer(): func cancel_timer():
if _timer_started: if _timer_started:
_timer.paused = true _timer.paused = true
_timer.emit_signal("timeout") _timer.timeout.emit()
_timer.paused = false _timer.paused = false

View File

@@ -44,8 +44,8 @@ var _moving_body: PhysicsBody2D = null
func _ready(): func _ready():
options.option_selected.connect(self._on_option_selected) options.option_selected.connect(_on_option_selected)
options.option_changed.connect(self._on_option_changed) options.option_changed.connect(_on_option_changed)
_character_body_template = find_child("CharacterBody2D") _character_body_template = find_child("CharacterBody2D")
if _character_body_template: if _character_body_template:

View File

@@ -42,8 +42,8 @@ func _ready():
options.add_menu_item(OPTION_SHAPE_CONCAVE_POLYGON, true, true) options.add_menu_item(OPTION_SHAPE_CONCAVE_POLYGON, true, true)
options.add_menu_item(OPTION_SHAPE_CONCAVE_SEGMENTS, true, true) options.add_menu_item(OPTION_SHAPE_CONCAVE_SEGMENTS, true, true)
options.option_selected.connect(self._on_option_selected) options.option_selected.connect(_on_option_selected)
options.option_changed.connect(self._on_option_changed) options.option_changed.connect(_on_option_changed)
await start_timer(0.5).timeout await start_timer(0.5).timeout
if is_timer_canceled(): if is_timer_canceled():

View File

@@ -43,8 +43,8 @@ func _ready():
options.add_menu_item(OPTION_TEST_CASE_DESTROY_BODY, true, false) options.add_menu_item(OPTION_TEST_CASE_DESTROY_BODY, true, false)
options.add_menu_item(OPTION_TEST_CASE_CHANGE_POSITIONS, true, false) options.add_menu_item(OPTION_TEST_CASE_CHANGE_POSITIONS, true, false)
options.connect(&"option_selected", Callable(self, "_on_option_selected")) options.option_selected.connect(_on_option_selected)
options.connect(&"option_changed", Callable(self, "_on_option_changed")) options.option_changed.connect(_on_option_changed)
_selected_joint = _joint_types.values()[0] _selected_joint = _joint_types.values()[0]
_update_joint = true _update_joint = true

View File

@@ -81,15 +81,15 @@ func _ready():
options.add_menu_item(OPTION_TEST_CASE_MOVING_PLATFORM_RIGID) options.add_menu_item(OPTION_TEST_CASE_MOVING_PLATFORM_RIGID)
options.add_menu_item(OPTION_TEST_CASE_MOVING_PLATFORM_CHARACTER) options.add_menu_item(OPTION_TEST_CASE_MOVING_PLATFORM_CHARACTER)
options.option_selected.connect(self._on_option_selected) options.option_selected.connect(_on_option_selected)
$Controls/PlatformSize/HSlider.value = _platform_size $Controls/PlatformSize/HSlider.value = _platform_size
$Controls/PlatformAngle/HSlider.value = _platform_angle $Controls/PlatformAngle/HSlider.value = _platform_angle
$Controls/BodyAngle/HSlider.value = _body_angle $Controls/BodyAngle/HSlider.value = _body_angle
remove_child(_target_area) remove_child(_target_area)
_target_area.body_entered.connect(self._on_target_entered) _target_area.body_entered.connect(_on_target_entered)
$Timer.timeout.connect(self._on_timeout) $Timer.timeout.connect(_on_timeout)
_rigid_body_template = $RigidBody2D _rigid_body_template = $RigidBody2D
remove_child(_rigid_body_template) remove_child(_rigid_body_template)
@@ -236,13 +236,13 @@ func _start_test_case(option):
await _on_option_selected(option) await _on_option_selected(option)
await self.all_tests_done await all_tests_done
func _wait_for_test(): func _wait_for_test():
await _reset_test() await _reset_test()
await self.test_done await test_done
func _test_all_rigid_body(): func _test_all_rigid_body():
@@ -331,7 +331,7 @@ func _test_moving_platform():
return return
_platform_speed = 0.0 _platform_speed = 0.0
emit_signal("all_tests_done") all_tests_done.emit()
func _test_all(): func _test_all():
@@ -373,7 +373,7 @@ func _start_test():
test_label += String(_rigid_body_template.name) test_label += String(_rigid_body_template.name)
_moving_body = _rigid_body_template.duplicate() _moving_body = _rigid_body_template.duplicate()
_moving_body.linear_velocity = _body_velocity _moving_body.linear_velocity = _body_velocity
_moving_body.body_entered.connect(self._on_contact_detected) _moving_body.body_entered.connect(_on_contact_detected)
add_child(_moving_body) add_child(_moving_body)
if _platform_speed != 0.0: if _platform_speed != 0.0:
@@ -411,7 +411,7 @@ func _reset_test(cancel_test = true):
if cancel_test: if cancel_test:
Log.print_log("*** Stop around the clock tests") Log.print_log("*** Stop around the clock tests")
_test_all_angles = false _test_all_angles = false
emit_signal("all_tests_done") all_tests_done.emit()
else: else:
Log.print_log("*** Start around the clock tests") Log.print_log("*** Start around the clock tests")
_platform_body.rotation = deg_to_rad(_platform_angle) _platform_body.rotation = deg_to_rad(_platform_angle)
@@ -487,8 +487,8 @@ func _on_timeout():
$Timer.stop() $Timer.stop()
if _test_canceled: if _test_canceled:
emit_signal("test_done") test_done.emit()
emit_signal("all_tests_done") all_tests_done.emit()
return return
if not _contact_detected and not _target_entered: if not _contact_detected and not _target_entered:
@@ -497,18 +497,18 @@ func _on_timeout():
await start_timer(0.5).timeout await start_timer(0.5).timeout
if _test_canceled: if _test_canceled:
emit_signal("test_done") test_done.emit()
emit_signal("all_tests_done") all_tests_done.emit()
return return
var was_all_angles = _test_all_angles var was_all_angles = _test_all_angles
_next_test() _next_test()
emit_signal("test_done") test_done.emit()
if was_all_angles and not _test_all_angles: if was_all_angles and not _test_all_angles:
emit_signal("all_tests_done") all_tests_done.emit()
func _set_result(): func _set_result():

View File

@@ -12,7 +12,7 @@ func _ready():
options.add_menu_item(OPTION_TEST_CASE_HIT_FROM_INSIDE, true, false) options.add_menu_item(OPTION_TEST_CASE_HIT_FROM_INSIDE, true, false)
options.option_changed.connect(self._on_option_changed) options.option_changed.connect(_on_option_changed)
await start_timer(0.5).timeout await start_timer(0.5).timeout
if is_timer_canceled(): if is_timer_canceled():

View File

@@ -39,7 +39,7 @@ func _ready():
options.add_menu_item(OPTION_TYPE_CAPSULE) options.add_menu_item(OPTION_TYPE_CAPSULE)
options.add_menu_item(OPTION_TYPE_CONVEX_POLYGON) options.add_menu_item(OPTION_TYPE_CONVEX_POLYGON)
options.add_menu_item(OPTION_TYPE_CONCAVE_POLYGON) options.add_menu_item(OPTION_TYPE_CONCAVE_POLYGON)
options.option_selected.connect(self._on_option_selected) options.option_selected.connect(_on_option_selected)
await _start_all_types() await _start_all_types()

View File

@@ -13,7 +13,7 @@ var _current_test_scene: Node = null
func _ready(): func _ready():
option_selected.connect(self._on_option_selected) option_selected.connect(_on_option_selected)
func _process(_delta): func _process(_delta):

View File

@@ -7,7 +7,7 @@ var _entry_template
func _enter_tree(): func _enter_tree():
Log.entry_logged.connect(self._on_log_entry) Log.entry_logged.connect(_on_log_entry)
_entry_template = get_child(0) as Label _entry_template = get_child(0) as Label
remove_child(_entry_template) remove_child(_entry_template)

View File

@@ -62,10 +62,10 @@ func _on_item_pressed(item_index, popup_menu, path):
for other_index in range(popup_menu.get_item_count()): for other_index in range(popup_menu.get_item_count()):
if other_index != item_index: if other_index != item_index:
popup_menu.set_item_checked(other_index, false) popup_menu.set_item_checked(other_index, false)
emit_signal("option_selected", item_path) option_selected.emit(item_path)
elif popup_menu.is_item_checkable(item_index): elif popup_menu.is_item_checkable(item_index):
var checked = not popup_menu.is_item_checked(item_index) var checked = not popup_menu.is_item_checked(item_index)
popup_menu.set_item_checked(item_index, checked) popup_menu.set_item_checked(item_index, checked)
emit_signal("option_changed", item_path, checked) option_changed.emit(item_path, checked)
else: else:
emit_signal("option_selected", item_path) option_selected.emit(item_path)

View File

@@ -6,7 +6,7 @@ extends ScrollContainer
func _ready(): func _ready():
var scrollbar = get_v_scroll_bar() var scrollbar = get_v_scroll_bar()
scrollbar.scrolling.connect(self._on_scrolling) scrollbar.scrolling.connect(_on_scrolling)
func _process(_delta): func _process(_delta):

View File

@@ -11,10 +11,10 @@ signal entry_logged(message, type)
func print_log(message): func print_log(message):
print(message) print(message)
emit_signal("entry_logged", message, LogType.LOG) entry_logged.emit(message, LogType.LOG)
func print_error(message): func print_error(message):
push_error(message) push_error(message)
printerr(message) printerr(message)
emit_signal("entry_logged", message, LogType.ERROR) entry_logged.emit(message, LogType.ERROR)

View File

@@ -9,7 +9,7 @@ func initialize(combat_combatants):
combatant = combatant.instantiate() combatant = combatant.instantiate()
if combatant is Combatant: if combatant is Combatant:
$Combatants.add_combatant(combatant) $Combatants.add_combatant(combatant)
combatant.get_node("Health").connect("dead", Callable(self, "_on_combatant_death").bind(combatant)) combatant.get_node("Health").dead.connect(_on_combatant_death.bind(combatant))
else: else:
combatant.queue_free() combatant.queue_free()
$UI.initialize() $UI.initialize()
@@ -24,7 +24,7 @@ func clear_combat():
func finish_combat(winner, loser): func finish_combat(winner, loser):
emit_signal("combat_finished", winner, loser) combat_finished.emit(winner, loser)
func _on_combatant_death(combatant): func _on_combatant_death(combatant):

View File

@@ -24,21 +24,21 @@ func set_active(value):
func attack(target): func attack(target):
target.take_damage(damage) target.take_damage(damage)
emit_signal("turn_finished") turn_finished.emit()
func consume(item): func consume(item):
item.use(self) item.use(self)
emit_signal("turn_finished") turn_finished.emit()
func defend(): func defend():
$Health.armor += defense $Health.armor += defense
emit_signal("turn_finished") turn_finished.emit()
func flee(): func flee():
emit_signal("turn_finished") turn_finished.emit()
func take_damage(damage_to_take): func take_damage(damage_to_take):

View File

@@ -17,15 +17,15 @@ func _ready():
func take_damage(damage): func take_damage(damage):
life = life - damage + armor life = life - damage + armor
if life <= 0: if life <= 0:
emit_signal("dead") dead.emit()
else: else:
emit_signal("health_changed", life) health_changed.emit(life)
func heal(amount): func heal(amount):
life += amount life += amount
life = clamp(life, life, max_life) life = clamp(life, life, max_life)
emit_signal("health_changed", life) health_changed.emit(life)
func get_health_ratio(): func get_health_ratio():

View File

@@ -13,7 +13,7 @@ func initialize():
health_info.value = health.life health_info.value = health.life
health_info.max_value = health.max_life health_info.max_value = health.max_life
info.get_node("VBoxContainer/NameContainer/Name").text = combatant.name info.get_node("VBoxContainer/NameContainer/Name").text = combatant.name
health.connect("health_changed", Callable(health_info, "set_value")) health.health_changed.connect(health_info.set_value)
$Combatants.add_child(info) $Combatants.add_child(info)
$Buttons/GridContainer/Attack.grab_focus() $Buttons/GridContainer/Attack.grab_focus()

View File

@@ -23,7 +23,7 @@ func get_next_in_queue():
var current_combatant = queue.pop_front() var current_combatant = queue.pop_front()
current_combatant.active = false current_combatant.active = false
queue.append(current_combatant) queue.append(current_combatant)
self.active_combatant = queue[0] active_combatant = queue[0]
return active_combatant return active_combatant
@@ -33,7 +33,7 @@ func remove(combatant):
new_queue.append(n) new_queue.append(n)
new_queue.remove(new_queue.find(combatant)) new_queue.remove(new_queue.find(combatant))
combatant.queue_free() combatant.queue_free()
self.queue = new_queue queue = new_queue
func set_queue(new_queue): func set_queue(new_queue):
@@ -44,10 +44,10 @@ func set_queue(new_queue):
queue.append(node) queue.append(node)
node.active = false node.active = false
if queue.size() > 0: if queue.size() > 0:
self.active_combatant = queue[0] active_combatant = queue[0]
func _set_active_combatant(new_combatant): func _set_active_combatant(new_combatant):
active_combatant = new_combatant active_combatant = new_combatant
active_combatant.active = true active_combatant.active = true
emit_signal("active_combatant_changed", active_combatant) active_combatant_changed.emit(active_combatant)

View File

@@ -12,7 +12,7 @@ var dialogue_text = ""
func start_dialogue(): func start_dialogue():
emit_signal("dialogue_started") dialogue_started.emit()
current = 0 current = 0
index_dialogue() index_dialogue()
dialogue_text = dialogue_keys[current].text dialogue_text = dialogue_keys[current].text
@@ -22,7 +22,7 @@ func start_dialogue():
func next_dialogue(): func next_dialogue():
current += 1 current += 1
if current == dialogue_keys.size(): if current == dialogue_keys.size():
emit_signal("dialogue_finished") dialogue_finished.emit()
return return
dialogue_text = dialogue_keys[current].text dialogue_text = dialogue_keys[current].text
dialogue_name = dialogue_keys[current].name dialogue_name = dialogue_keys[current].name

View File

@@ -18,10 +18,10 @@ func show_dialogue(player, dialogue):
$Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]" $Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]"
$Text.text = dialogue_node.dialogue_text $Text.text = dialogue_node.dialogue_text
return return
dialogue_node.connect("dialogue_started", Callable(player, "set_active").bind(false)) dialogue_node.dialogue_started.connect(player.set_active.bind(false))
dialogue_node.connect("dialogue_finished", Callable(player, "set_active").bind(true)) dialogue_node.dialogue_finished.connect(player.set_active.bind(true))
dialogue_node.connect("dialogue_finished", Callable(self, "hide")) dialogue_node.dialogue_finished.connect(hide)
dialogue_node.connect("dialogue_finished", Callable(self, "_on_dialogue_finished").bind(player)) dialogue_node.dialogue_finished.connect(_on_dialogue_finished.bind(player))
dialogue_node.start_dialogue() dialogue_node.start_dialogue()
$Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]" $Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]"
$Text.text = dialogue_node.dialogue_text $Text.text = dialogue_node.dialogue_text
@@ -34,7 +34,7 @@ func _on_Button_button_up():
func _on_dialogue_finished(player): func _on_dialogue_finished(player):
dialogue_node.disconnect("dialogue_started", Callable(player, "set_active")) dialogue_node.dialogue_started.disconnect(player.set_active)
dialogue_node.disconnect("dialogue_finished", Callable(player, "set_active")) dialogue_node.dialogue_finished.disconnect(player.set_active)
dialogue_node.disconnect("dialogue_finished", Callable(self, "hide")) dialogue_node.dialogue_finished.disconnect(hide)
dialogue_node.disconnect("dialogue_finished", Callable(self, "_on_dialogue_finished")) dialogue_node.dialogue_finished.disconnect(_on_dialogue_finished)

View File

@@ -22,7 +22,7 @@ var viewport_start_size := Vector2(
func _ready() -> void: func _ready() -> void:
get_viewport().size_changed.connect(self.update_resolution_label) get_viewport().size_changed.connect(update_resolution_label)
update_resolution_label() update_resolution_label()
# Disable V-Sync to uncap framerate on supported platforms. This makes performance comparison # Disable V-Sync to uncap framerate on supported platforms. This makes performance comparison

View File

@@ -4,7 +4,7 @@ extends Button
func _ready(): func _ready():
pressed.connect(self.change_scene) pressed.connect(change_scene)
func change_scene(): func change_scene():

View File

@@ -57,7 +57,7 @@ var simple_bullet = preload("res://fps/simple_bullet.tscn")
func _ready(): func _ready():
anim_player.animation_finished.connect(self.animation_finished) anim_player.animation_finished.connect(animation_finished)
set_physics_process(true) set_physics_process(true)
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

View File

@@ -23,7 +23,7 @@ func _physics_process(_delta):
if _wait_physics_ticks_counter > 0: if _wait_physics_ticks_counter > 0:
_wait_physics_ticks_counter -= 1 _wait_physics_ticks_counter -= 1
if _wait_physics_ticks_counter == 0: if _wait_physics_ticks_counter == 0:
emit_signal("wait_done") wait_done.emit()
func add_sphere(pos, radius, color): func add_sphere(pos, radius, color):
@@ -95,7 +95,7 @@ func start_timer(timeout):
_timer = Timer.new() _timer = Timer.new()
_timer.one_shot = true _timer.one_shot = true
add_child(_timer) add_child(_timer)
_timer.connect(&"timeout", Callable(self, "_on_timer_done")) _timer.timeout.connect(_on_timer_done)
else: else:
cancel_timer() cancel_timer()
@@ -108,7 +108,7 @@ func start_timer(timeout):
func cancel_timer(): func cancel_timer():
if _timer_started: if _timer_started:
_timer.paused = true _timer.paused = true
_timer.emit_signal("timeout") _timer.timeout.emit()
_timer.paused = false _timer.paused = false

View File

@@ -40,8 +40,8 @@ func _ready():
$Options.add_menu_item(OPTION_SHAPE_CONVEX_POLYGON, true, true) $Options.add_menu_item(OPTION_SHAPE_CONVEX_POLYGON, true, true)
$Options.add_menu_item(OPTION_SHAPE_CONCAVE_POLYGON, true, true) $Options.add_menu_item(OPTION_SHAPE_CONCAVE_POLYGON, true, true)
$Options.option_selected.connect(self._on_option_selected) $Options.option_selected.connect(_on_option_selected)
$Options.option_changed.connect(self._on_option_changed) $Options.option_changed.connect(_on_option_changed)
await start_timer(0.5).timeout await start_timer(0.5).timeout
if is_timer_canceled(): if is_timer_canceled():

View File

@@ -42,8 +42,8 @@ func _ready():
options.add_menu_item(OPTION_TEST_CASE_DESTROY_BODY, true, false) options.add_menu_item(OPTION_TEST_CASE_DESTROY_BODY, true, false)
options.add_menu_item(OPTION_TEST_CASE_CHANGE_POSITIONS, true, false) options.add_menu_item(OPTION_TEST_CASE_CHANGE_POSITIONS, true, false)
options.connect(&"option_selected", Callable(self, "_on_option_selected")) options.option_selected.connect(_on_option_selected)
options.connect(&"option_changed", Callable(self, "_on_option_changed")) options.option_changed.connect(_on_option_changed)
_selected_joint = _joint_types.values()[0] _selected_joint = _joint_types.values()[0]
_update_joint = true _update_joint = true

View File

@@ -55,8 +55,8 @@ func _ready():
options.add_menu_item(OPTION_ROUGH, true, false) options.add_menu_item(OPTION_ROUGH, true, false)
options.add_menu_item(OPTION_PROCESS_PHYSICS, true, false) options.add_menu_item(OPTION_PROCESS_PHYSICS, true, false)
options.option_selected.connect(self._on_option_selected) options.option_selected.connect(_on_option_selected)
options.option_changed.connect(self._on_option_changed) options.option_changed.connect(_on_option_changed)
_shapes[SHAPE_CAPSULE] = "Capsule" _shapes[SHAPE_CAPSULE] = "Capsule"
_shapes[SHAPE_BOX] = "Box" _shapes[SHAPE_BOX] = "Box"

View File

@@ -15,7 +15,7 @@ func _ready():
options.add_menu_item(OPTION_TEST_CASE_HIT_FROM_INSIDE, true, false) options.add_menu_item(OPTION_TEST_CASE_HIT_FROM_INSIDE, true, false)
options.option_changed.connect(self._on_option_changed) options.option_changed.connect(_on_option_changed)
_material.flags_unshaded = true _material.flags_unshaded = true
_material.vertex_color_use_as_albedo = true _material.vertex_color_use_as_albedo = true

View File

@@ -36,7 +36,7 @@ func _ready():
options.add_menu_item(SHAPE_CONVEX) options.add_menu_item(SHAPE_CONVEX)
options.add_menu_item(SHAPE_BOX) options.add_menu_item(SHAPE_BOX)
options.option_selected.connect(self._on_option_selected) options.option_selected.connect(_on_option_selected)
restart_scene() restart_scene()

View File

@@ -35,7 +35,7 @@ func _ready():
$Options.add_menu_item(OPTION_TYPE_CAPSULE) $Options.add_menu_item(OPTION_TYPE_CAPSULE)
$Options.add_menu_item(OPTION_TYPE_CYLINDER) $Options.add_menu_item(OPTION_TYPE_CYLINDER)
$Options.add_menu_item(OPTION_TYPE_CONVEX) $Options.add_menu_item(OPTION_TYPE_CONVEX)
$Options.option_selected.connect(self._on_option_selected) $Options.option_selected.connect(_on_option_selected)
await _start_all_types() await _start_all_types()

View File

@@ -13,7 +13,7 @@ var _current_test_scene: Node = null
func _ready(): func _ready():
option_selected.connect(self._on_option_selected) option_selected.connect(_on_option_selected)
func _process(_delta): func _process(_delta):

View File

@@ -8,7 +8,7 @@ var _rotation_pivot
func _ready(): func _ready():
call_deferred("_initialize_pivot") _initialize_pivot.call_deferred()
func _unhandled_input(event): func _unhandled_input(event):

View File

@@ -7,7 +7,7 @@ var _entry_template
func _enter_tree(): func _enter_tree():
Log.entry_logged.connect(self._on_log_entry) Log.entry_logged.connect(_on_log_entry)
_entry_template = get_child(0) as Label _entry_template = get_child(0) as Label
remove_child(_entry_template) remove_child(_entry_template)

View File

@@ -55,6 +55,6 @@ func _on_item_pressed(item_index, popup_menu, path):
if popup_menu.is_item_checkable(item_index): if popup_menu.is_item_checkable(item_index):
var checked = not popup_menu.is_item_checked(item_index) var checked = not popup_menu.is_item_checked(item_index)
popup_menu.set_item_checked(item_index, checked) popup_menu.set_item_checked(item_index, checked)
emit_signal("option_changed", item_path, checked) option_changed.emit(item_path, checked)
else: else:
emit_signal("option_selected", item_path) option_selected.emit(item_path)

View File

@@ -11,10 +11,10 @@ signal entry_logged(message, type)
func print_log(message): func print_log(message):
print(message) print(message)
emit_signal("entry_logged", message, LogType.LOG) entry_logged.emit(message, LogType.LOG)
func print_error(message): func print_error(message):
push_error(message) push_error(message)
printerr(message) printerr(message)
emit_signal("entry_logged", message, LogType.ERROR) entry_logged.emit(message, LogType.ERROR)

View File

@@ -24,7 +24,7 @@ func _integrate_forces(state: PhysicsDirectBodyState3D):
var grav := state.get_total_gravity() var grav := state.get_total_gravity()
# get_total_gravity returns zero for the first few frames, leading to errors. # get_total_gravity returns zero for the first few frames, leading to errors.
if grav.is_zero_approx(): if grav.is_zero_approx():
grav = self.gravity grav = gravity
lin_velocity += grav * delta # Apply gravity. lin_velocity += grav * delta # Apply gravity.
var up := -grav.normalized() var up := -grav.normalized()

View File

@@ -66,7 +66,7 @@ func _physics_process(delta):
func die(): func die():
emit_signal("hit") hit.emit()
queue_free() queue_free()

View File

@@ -4,7 +4,7 @@ var town: Node3D = null
func _ready(): func _ready():
# Automatically focus the first item for gamepad accessibility. # Automatically focus the first item for gamepad accessibility.
$HBoxContainer/MiniVan.call_deferred("grab_focus") $HBoxContainer/MiniVan.grab_focus.call_deferred()
func _process(_delta: float): func _process(_delta: float):
if Input.is_action_just_pressed(&"back"): if Input.is_action_just_pressed(&"back"):
@@ -17,7 +17,7 @@ func _load_scene(car_scene: PackedScene):
town = preload("res://town/town_scene.tscn").instantiate() town = preload("res://town/town_scene.tscn").instantiate()
town.get_node(^"InstancePos").add_child(car) town.get_node(^"InstancePos").add_child(car)
town.get_node(^"Spedometer").car_body = car.get_child(0) town.get_node(^"Spedometer").car_body = car.get_child(0)
town.get_node(^"Back").pressed.connect(self._on_back_pressed) town.get_node(^"Back").pressed.connect(_on_back_pressed)
get_parent().add_child(town) get_parent().add_child(town)
hide() hide()
@@ -29,7 +29,7 @@ func _on_back_pressed():
town.queue_free() town.queue_free()
show() show()
# Automatically focus the first item for gamepad accessibility. # Automatically focus the first item for gamepad accessibility.
$HBoxContainer/MiniVan.call_deferred("grab_focus") $HBoxContainer/MiniVan.grab_focus.call_deferred()
else: else:
# In main menu, exit the game. # In main menu, exit the game.
get_tree().quit() get_tree().quit()

View File

@@ -30,7 +30,7 @@ func _ready():
_generate_chunk_collider() _generate_chunk_collider()
# However, we can use a thread for mesh generation. # However, we can use a thread for mesh generation.
_thread = Thread.new() _thread = Thread.new()
_thread.start(self._generate_chunk_mesh) _thread.start(_generate_chunk_mesh)
func regenerate(): func regenerate():

View File

@@ -12,25 +12,25 @@ extends Panel
func _ready(): func _ready():
# Assign all of the needed signals for the oppersation buttons. # Assign all of the needed signals for the oppersation buttons.
$ButtonUndo.pressed.connect(self.button_pressed.bind("undo_stroke")) $ButtonUndo.pressed.connect(button_pressed.bind("undo_stroke"))
$ButtonSave.pressed.connect(self.button_pressed.bind("save_picture")) $ButtonSave.pressed.connect(button_pressed.bind("save_picture"))
$ButtonClear.pressed.connect(self.button_pressed.bind("clear_picture")) $ButtonClear.pressed.connect(button_pressed.bind("clear_picture"))
# Assign all of the needed signals for the brush buttons. # Assign all of the needed signals for the brush buttons.
$ButtonToolPencil.pressed.connect(self.button_pressed.bind("mode_pencil")) $ButtonToolPencil.pressed.connect(button_pressed.bind("mode_pencil"))
$ButtonToolEraser.pressed.connect(self.button_pressed.bind("mode_eraser")) $ButtonToolEraser.pressed.connect(button_pressed.bind("mode_eraser"))
$ButtonToolRectangle.pressed.connect(self.button_pressed.bind("mode_rectangle")) $ButtonToolRectangle.pressed.connect(button_pressed.bind("mode_rectangle"))
$ButtonToolCircle.pressed.connect(self.button_pressed.bind("mode_circle")) $ButtonToolCircle.pressed.connect(button_pressed.bind("mode_circle"))
$BrushSettings/ButtonShapeBox.pressed.connect(self.button_pressed.bind("shape_rectangle")) $BrushSettings/ButtonShapeBox.pressed.connect(button_pressed.bind("shape_rectangle"))
$BrushSettings/ButtonShapeCircle.pressed.connect(self.button_pressed.bind("shape_circle")) $BrushSettings/ButtonShapeCircle.pressed.connect(button_pressed.bind("shape_circle"))
# Assign all of the needed signals for the other brush settings (and ColorPickerBackground). # Assign all of the needed signals for the other brush settings (and ColorPickerBackground).
$ColorPickerBrush.color_changed.connect(self.brush_color_changed) $ColorPickerBrush.color_changed.connect(brush_color_changed)
$ColorPickerBackground.color_changed.connect(self.background_color_changed) $ColorPickerBackground.color_changed.connect(background_color_changed)
$BrushSettings/HScrollBarBrushSize.value_changed.connect(self.brush_size_changed) $BrushSettings/HScrollBarBrushSize.value_changed.connect(brush_size_changed)
# Assign the "file_selected" signal in SaveFileDialog. # Assign the "file_selected" signal in SaveFileDialog.
save_dialog.file_selected.connect(self.save_file_selected) save_dialog.file_selected.connect(save_file_selected)
# Set physics process so we can update the status label. # Set physics process so we can update the status label.
set_physics_process(true) set_physics_process(true)

View File

@@ -26,8 +26,8 @@ func _ready():
# The `resized` signal will be emitted when the window size changes, as the root Control node # The `resized` signal will be emitted when the window size changes, as the root Control node
# is resized whenever the window size changes. This is because the root Control node # is resized whenever the window size changes. This is because the root Control node
# uses a Full Rect anchor, so its size will always be equal to the window size. # uses a Full Rect anchor, so its size will always be equal to the window size.
resized.connect(self._on_resized) resized.connect(_on_resized)
call_deferred("update_container") update_container.call_deferred()
func update_container(): func update_container():
@@ -75,17 +75,17 @@ func _on_gui_aspect_ratio_item_selected(index):
6: # 21:9 6: # 21:9
gui_aspect_ratio = 21.0 / 9.0 gui_aspect_ratio = 21.0 / 9.0
call_deferred("update_container") update_container.call_deferred()
func _on_resized(): func _on_resized():
call_deferred("update_container") update_container.call_deferred()
func _on_gui_margin_drag_ended(_value_changed): func _on_gui_margin_drag_ended(_value_changed):
gui_margin = $"Panel/AspectRatioContainer/Panel/CenterContainer/Options/GUIMargin/HSlider".value gui_margin = $"Panel/AspectRatioContainer/Panel/CenterContainer/Options/GUIMargin/HSlider".value
$"Panel/AspectRatioContainer/Panel/CenterContainer/Options/GUIMargin/Value".text = str(gui_margin) $"Panel/AspectRatioContainer/Panel/CenterContainer/Options/GUIMargin/Value".text = str(gui_margin)
call_deferred("update_container") update_container.call_deferred()
func _on_window_base_size_item_selected(index): func _on_window_base_size_item_selected(index):
@@ -108,7 +108,7 @@ func _on_window_base_size_item_selected(index):
base_window_size = Vector2(1680, 720) base_window_size = Vector2(1680, 720)
get_viewport().content_scale_size = base_window_size get_viewport().content_scale_size = base_window_size
call_deferred("update_container") update_container.call_deferred()
func _on_window_stretch_mode_item_selected(index): func _on_window_stretch_mode_item_selected(index):

View File

@@ -252,9 +252,9 @@ func _on_random_button_pressed() -> void:
func _on_create_button_gpu_pressed() -> void: func _on_create_button_gpu_pressed() -> void:
var heightmap = prepare_image() var heightmap = prepare_image()
call_deferred("compute_island_gpu", heightmap) compute_island_gpu.call_deferred(heightmap)
func _on_create_button_cpu_pressed() -> void: func _on_create_button_cpu_pressed() -> void:
var heightmap = prepare_image() var heightmap = prepare_image()
call_deferred("compute_island_cpu", heightmap) compute_island_cpu.call_deferred(heightmap)

View File

@@ -23,7 +23,7 @@ var axis_value
@onready var joypad_number = $DeviceInfo/JoyNumber @onready var joypad_number = $DeviceInfo/JoyNumber
func _ready(): func _ready():
Input.joy_connection_changed.connect(self._on_joy_connection_changed) Input.joy_connection_changed.connect(_on_joy_connection_changed)
for joypad in Input.get_connected_joypads(): for joypad in Input.get_connected_joypads():
print_rich("Found joypad #%d: [b]%s[/b] - %s" % [joypad, Input.get_joy_name(joypad), Input.get_joy_guid(joypad)]) print_rich("Found joypad #%d: [b]%s[/b] - %s" % [joypad, Input.get_joy_name(joypad), Input.get_joy_guid(joypad)])

View File

@@ -14,29 +14,29 @@ func _ready():
payment = Engine.get_singleton("GodotGooglePlayBilling") payment = Engine.get_singleton("GodotGooglePlayBilling")
# No params. # No params.
payment.connected.connect(self._on_connected) payment.connected.connect(_on_connected)
# No params. # No params.
payment.disconnected.connect(self._on_disconnected) payment.disconnected.connect(_on_disconnected)
# Response ID (int), Debug message (string). # Response ID (int), Debug message (string).
payment.connect_error.connect(self._on_connect_error) payment.connect_error.connect(_on_connect_error)
# Purchases (Dictionary[]). # Purchases (Dictionary[]).
payment.purchases_updated.connect(self._on_purchases_updated) payment.purchases_updated.connect(_on_purchases_updated)
# Response ID (int), Debug message (string). # Response ID (int), Debug message (string).
payment.purchase_error.connect(self._on_purchase_error) payment.purchase_error.connect(_on_purchase_error)
# SKUs (Dictionary[]). # SKUs (Dictionary[]).
payment.sku_details_query_completed.connect(self._on_sku_details_query_completed) payment.sku_details_query_completed.connect(_on_sku_details_query_completed)
# Response ID (int), Debug message (string), Queried SKUs (string[]). # Response ID (int), Debug message (string), Queried SKUs (string[]).
payment.sku_details_query_error.connect(self._on_sku_details_query_error) payment.sku_details_query_error.connect(_on_sku_details_query_error)
# Purchase token (string). # Purchase token (string).
payment.purchase_acknowledged.connect(self._on_purchase_acknowledged) payment.purchase_acknowledged.connect(_on_purchase_acknowledged)
# Response ID (int), Debug message (string), Purchase token (string). # Response ID (int), Debug message (string), Purchase token (string).
payment.purchase_acknowledgement_error.connect(self._on_purchase_acknowledgement_error) payment.purchase_acknowledgement_error.connect(_on_purchase_acknowledgement_error)
# Purchase token (string). # Purchase token (string).
payment.purchase_consumed.connect(self._on_purchase_consumed) payment.purchase_consumed.connect(_on_purchase_consumed)
# Response ID (int), Debug message (string), Purchase token (string). # Response ID (int), Debug message (string), Purchase token (string).
payment.purchase_consumption_error.connect(self._on_purchase_consumption_error) payment.purchase_consumption_error.connect(_on_purchase_consumption_error)
# Purchases (Dictionary[]) # Purchases (Dictionary[])
payment.query_purchases_response.connect(self._on_query_purchases_response) payment.query_purchases_response.connect(_on_query_purchases_response)
payment.startConnection() payment.startConnection()
else: else:
show_alert("Android IAP support is not enabled. Make sure you have enabled 'Custom Build' and installed and enabled the GodotGooglePlayBilling plugin in your Android export settings! This application will not work.") show_alert("Android IAP support is not enabled. Make sure you have enabled 'Custom Build' and installed and enabled the GodotGooglePlayBilling plugin in your Android export settings! This application will not work.")

View File

@@ -142,8 +142,8 @@ func end_game():
func _ready(): func _ready():
multiplayer.peer_connected.connect(self._player_connected) multiplayer.peer_connected.connect(_player_connected)
multiplayer.peer_disconnected.connect(self._player_disconnected) multiplayer.peer_disconnected.connect(_player_disconnected)
multiplayer.connected_to_server.connect(self._connected_ok) multiplayer.connected_to_server.connect(_connected_ok)
multiplayer.connection_failed.connect(self._connected_fail) multiplayer.connection_failed.connect(_connected_fail)
multiplayer.server_disconnected.connect(self._server_disconnected) multiplayer.server_disconnected.connect(_server_disconnected)

View File

@@ -2,11 +2,11 @@ extends Control
func _ready(): func _ready():
# Called every time the node is added to the scene. # Called every time the node is added to the scene.
gamestate.connection_failed.connect(self._on_connection_failed) gamestate.connection_failed.connect(_on_connection_failed)
gamestate.connection_succeeded.connect(self._on_connection_success) gamestate.connection_succeeded.connect(_on_connection_success)
gamestate.player_list_changed.connect(self.refresh_lobby) gamestate.player_list_changed.connect(refresh_lobby)
gamestate.game_ended.connect(self._on_game_ended) gamestate.game_ended.connect(_on_game_ended)
gamestate.game_error.connect(self._on_game_error) gamestate.game_error.connect(_on_game_error)
# Set the player name according to the system username. Fallback to the path. # Set the player name according to the system username. Fallback to the path.
if OS.has_environment("USERNAME"): if OS.has_environment("USERNAME"):
$Connect/Name.text = OS.get_environment("USERNAME") $Connect/Name.text = OS.get_environment("USERNAME")

View File

@@ -17,11 +17,11 @@ var peer = null
func _ready(): func _ready():
# Connect all the callbacks related to networking. # Connect all the callbacks related to networking.
multiplayer.peer_connected.connect(self._player_connected) multiplayer.peer_connected.connect(_player_connected)
multiplayer.peer_disconnected.connect(self._player_disconnected) multiplayer.peer_disconnected.connect(_player_disconnected)
multiplayer.connected_to_server.connect(self._connected_ok) multiplayer.connected_to_server.connect(_connected_ok)
multiplayer.connection_failed.connect(self._connected_fail) multiplayer.connection_failed.connect(_connected_fail)
multiplayer.server_disconnected.connect(self._server_disconnected) multiplayer.server_disconnected.connect(_server_disconnected)
#### Network callbacks from SceneTree #### #### Network callbacks from SceneTree ####
@@ -30,7 +30,7 @@ func _player_connected(_id):
# Someone connected, start the game! # Someone connected, start the game!
var pong = load("res://pong.tscn").instantiate() var pong = load("res://pong.tscn").instantiate()
# Connect deferred so we can safely erase it from the callback. # Connect deferred so we can safely erase it from the callback.
pong.game_finished.connect(self._end_game, CONNECT_DEFERRED) pong.game_finished.connect(_end_game, CONNECT_DEFERRED)
get_tree().get_root().add_child(pong) get_tree().get_root().add_child(pong)
hide() hide()

View File

@@ -50,4 +50,4 @@ func update_score(add_to_left):
func _on_exit_game_pressed(): func _on_exit_game_pressed():
emit_signal("game_finished") game_finished.emit()

View File

@@ -8,8 +8,8 @@ var channel = peer.create_data_channel("chat", {"negotiated": true, "id": 1})
func _ready(): func _ready():
# Connect all functions. # Connect all functions.
peer.ice_candidate_created.connect(self._on_ice_candidate) peer.ice_candidate_created.connect(_on_ice_candidate)
peer.session_description_created.connect(self._on_session) peer.session_description_created.connect(_on_session)
# Register to the local signaling server (see below for the implementation). # Register to the local signaling server (see below for the implementation).
Signaling.register(String(get_path())) Signaling.register(String(get_path()))

View File

@@ -4,24 +4,24 @@ var rtc_mp: WebRTCMultiplayerPeer = WebRTCMultiplayerPeer.new()
var sealed := false var sealed := false
func _init(): func _init():
connected.connect(self._connected) connected.connect(_connected)
disconnected.connect(self._disconnected) disconnected.connect(_disconnected)
offer_received.connect(self._offer_received) offer_received.connect(_offer_received)
answer_received.connect(self._answer_received) answer_received.connect(_answer_received)
candidate_received.connect(self._candidate_received) candidate_received.connect(_candidate_received)
lobby_joined.connect(self._lobby_joined) lobby_joined.connect(_lobby_joined)
lobby_sealed.connect(self._lobby_sealed) lobby_sealed.connect(_lobby_sealed)
peer_connected.connect(self._peer_connected) peer_connected.connect(_peer_connected)
peer_disconnected.connect(self._peer_disconnected) peer_disconnected.connect(_peer_disconnected)
func start(url, lobby = "", mesh:=true): func start(url, _lobby = "", _mesh := true):
stop() stop()
sealed = false sealed = false
self.mesh = mesh mesh = _mesh
self.lobby = lobby lobby = _lobby
connect_to_url(url) connect_to_url(url)
@@ -36,8 +36,8 @@ func _create_peer(id):
peer.initialize({ peer.initialize({
"iceServers": [ { "urls": ["stun:stun.l.google.com:19302"] } ] "iceServers": [ { "urls": ["stun:stun.l.google.com:19302"] } ]
}) })
peer.session_description_created.connect(self._offer_created.bind(id)) peer.session_description_created.connect(_offer_created.bind(id))
peer.ice_candidate_created.connect(self._new_ice_candidate.bind(id)) peer.ice_candidate_created.connect(_new_ice_candidate.bind(id))
rtc_mp.add_peer(peer, id) rtc_mp.add_peer(peer, id)
if id < rtc_mp.get_unique_id(): # So lobby creator never creates offers. if id < rtc_mp.get_unique_id(): # So lobby creator never creates offers.
peer.create_offer() peer.create_offer()
@@ -68,8 +68,8 @@ func _connected(id, use_mesh):
multiplayer.multiplayer_peer = rtc_mp multiplayer.multiplayer_peer = rtc_mp
func _lobby_joined(lobby): func _lobby_joined(_lobby):
self.lobby = lobby lobby = _lobby
func _lobby_sealed(): func _lobby_sealed():

View File

@@ -6,16 +6,16 @@ extends Control
@onready var mesh = $VBoxContainer/Connect/Mesh @onready var mesh = $VBoxContainer/Connect/Mesh
func _ready(): func _ready():
client.lobby_joined.connect(self._lobby_joined) client.lobby_joined.connect(_lobby_joined)
client.lobby_sealed.connect(self._lobby_sealed) client.lobby_sealed.connect(_lobby_sealed)
client.connected.connect(self._connected) client.connected.connect(_connected)
client.disconnected.connect(self._disconnected) client.disconnected.connect(_disconnected)
multiplayer.connected_to_server.connect(self._mp_server_connected) multiplayer.connected_to_server.connect(_mp_server_connected)
multiplayer.connection_failed.connect(self._mp_server_disconnect) multiplayer.connection_failed.connect(_mp_server_disconnect)
multiplayer.server_disconnected.connect(self._mp_server_disconnect) multiplayer.server_disconnected.connect(_mp_server_disconnect)
multiplayer.peer_connected.connect(self._mp_peer_connected) multiplayer.peer_connected.connect(_mp_peer_connected)
multiplayer.peer_disconnected.connect(self._mp_peer_disconnected) multiplayer.peer_disconnected.connect(_mp_peer_disconnected)
@rpc("any_peer", "call_local") @rpc("any_peer", "call_local")

View File

@@ -18,11 +18,11 @@ func _init():
func _ready(): func _ready():
multiplayer.peer_connected.connect(self._peer_connected) multiplayer.peer_connected.connect(_peer_connected)
multiplayer.peer_disconnected.connect(self._peer_disconnected) multiplayer.peer_disconnected.connect(_peer_disconnected)
multiplayer.server_disconnected.connect(self._close_network) multiplayer.server_disconnected.connect(_close_network)
multiplayer.connection_failed.connect(self._close_network) multiplayer.connection_failed.connect(_close_network)
multiplayer.connected_to_server.connect(self._connected) multiplayer.connected_to_server.connect(_connected)
$AcceptDialog.get_label().horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER $AcceptDialog.get_label().horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
$AcceptDialog.get_label().vertical_alignment = VERTICAL_ALIGNMENT_CENTER $AcceptDialog.get_label().vertical_alignment = VERTICAL_ALIGNMENT_CENTER

View File

@@ -7,11 +7,11 @@ var editor_interface
func _ready(): func _ready():
# Connect all of the signals we'll need to save and load silly materials. # Connect all of the signals we'll need to save and load silly materials.
get_node(^"VBoxContainer/ApplyButton").pressed.connect(self.apply_pressed) get_node(^"VBoxContainer/ApplyButton").pressed.connect(apply_pressed)
get_node(^"VBoxContainer/SaveButton").pressed.connect(self.save_pressed) get_node(^"VBoxContainer/SaveButton").pressed.connect(save_pressed)
get_node(^"VBoxContainer/LoadButton").pressed.connect(self.load_pressed) get_node(^"VBoxContainer/LoadButton").pressed.connect(load_pressed)
get_node(^"SaveMaterialDialog").file_selected.connect(self.save_file_selected) get_node(^"SaveMaterialDialog").file_selected.connect(save_file_selected)
get_node(^"LoadMaterialDialog").file_selected.connect(self.load_file_selected) get_node(^"LoadMaterialDialog").file_selected.connect(load_file_selected)
RenderingServer.canvas_item_set_clip(get_canvas_item(), true) RenderingServer.canvas_item_set_clip(get_canvas_item(), true)

View File

@@ -7,7 +7,7 @@ var viewport_initial_size = Vector2()
func _ready(): func _ready():
$AnimatedSprite2D.play() $AnimatedSprite2D.play()
get_viewport().size_changed.connect(self._root_viewport_size_changed) get_viewport().size_changed.connect(_root_viewport_size_changed)
viewport_initial_size = viewport.size viewport_initial_size = viewport.size

View File

@@ -38,7 +38,7 @@ func _ready():
_on_size_changed() _on_size_changed()
_update_splitscreen() _update_splitscreen()
get_viewport().size_changed.connect(self._on_size_changed) get_viewport().size_changed.connect(_on_size_changed)
view.material.set_shader_parameter("viewport1", viewport1.get_texture()) view.material.set_shader_parameter("viewport1", viewport1.get_texture())
view.material.set_shader_parameter("viewport2", viewport2.get_texture()) view.material.set_shader_parameter("viewport2", viewport2.get_texture())

View File

@@ -12,9 +12,9 @@ var last_event_time: float = -1.0
@onready var node_area = $Quad/Area3D @onready var node_area = $Quad/Area3D
func _ready(): func _ready():
node_area.mouse_entered.connect(self._mouse_entered_area) node_area.mouse_entered.connect(_mouse_entered_area)
node_area.mouse_exited.connect(self._mouse_exited_area) node_area.mouse_exited.connect(_mouse_exited_area)
node_area.input_event.connect(self._mouse_input_event) node_area.input_event.connect(_mouse_input_event)
# If the material is NOT set to use billboard settings, then avoid running billboard specific code # If the material is NOT set to use billboard settings, then avoid running billboard specific code
if node_quad.get_surface_override_material(0).billboard_mode == BaseMaterial3D.BillboardMode.BILLBOARD_DISABLED: if node_quad.get_surface_override_material(0).billboard_mode == BaseMaterial3D.BillboardMode.BILLBOARD_DISABLED:

View File

@@ -24,11 +24,11 @@ func _ready():
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED) DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
# Connect the OpenXR events # Connect the OpenXR events
xr_interface.connect("session_begun", _on_openxr_session_begun) xr_interface.session_begun.connect(_on_openxr_session_begun)
xr_interface.connect("session_visible", _on_openxr_visible_state) xr_interface.session_visible.connect(_on_openxr_visible_state)
xr_interface.connect("session_focussed", _on_openxr_focused_state) xr_interface.session_focussed.connect(_on_openxr_focused_state)
xr_interface.connect("session_stopping", _on_openxr_stopping) xr_interface.session_stopping.connect(_on_openxr_stopping)
xr_interface.connect("pose_recentered", _on_openxr_pose_recentered) xr_interface.pose_recentered.connect(_on_openxr_pose_recentered)
else: else:
# We couldn't start OpenXR. # We couldn't start OpenXR.
print("OpenXR not instantiated!") print("OpenXR not instantiated!")
@@ -79,7 +79,7 @@ func _on_openxr_visible_state() -> void:
# pause our game # pause our game
process_mode = Node.PROCESS_MODE_DISABLED process_mode = Node.PROCESS_MODE_DISABLED
emit_signal("focus_lost") focus_lost.emit()
# Handle OpenXR focused state # Handle OpenXR focused state
@@ -90,7 +90,7 @@ func _on_openxr_focused_state() -> void:
# unpause our game # unpause our game
process_mode = Node.PROCESS_MODE_INHERIT process_mode = Node.PROCESS_MODE_INHERIT
emit_signal("focus_gained") focus_gained.emit()
# Handle OpenXR stopping state # Handle OpenXR stopping state
func _on_openxr_stopping() -> void: func _on_openxr_stopping() -> void:
@@ -101,4 +101,4 @@ func _on_openxr_stopping() -> void:
func _on_openxr_pose_recentered() -> void: func _on_openxr_pose_recentered() -> void:
# User recentered view, we have to react to this by recentering the view. # User recentered view, we have to react to this by recentering the view.
# This is game implementation dependent. # This is game implementation dependent.
emit_signal("pose_recentered") pose_recentered.emit()

View File

@@ -24,11 +24,11 @@ func _ready():
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED) DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
# Connect the OpenXR events # Connect the OpenXR events
xr_interface.connect("session_begun", _on_openxr_session_begun) xr_interface.session_begun.connect(_on_openxr_session_begun)
xr_interface.connect("session_visible", _on_openxr_visible_state) xr_interface.session_visible.connect(_on_openxr_visible_state)
xr_interface.connect("session_focussed", _on_openxr_focused_state) xr_interface.session_focussed.connect(_on_openxr_focused_state)
xr_interface.connect("session_stopping", _on_openxr_stopping) xr_interface.session_stopping.connect(_on_openxr_stopping)
xr_interface.connect("pose_recentered", _on_openxr_pose_recentered) xr_interface.pose_recentered.connect(_on_openxr_pose_recentered)
else: else:
# We couldn't start OpenXR. # We couldn't start OpenXR.
print("OpenXR not instantiated!") print("OpenXR not instantiated!")
@@ -79,7 +79,7 @@ func _on_openxr_visible_state() -> void:
# pause our game # pause our game
process_mode = Node.PROCESS_MODE_DISABLED process_mode = Node.PROCESS_MODE_DISABLED
emit_signal("focus_lost") focus_lost.emit()
# Handle OpenXR focused state # Handle OpenXR focused state
@@ -90,7 +90,7 @@ func _on_openxr_focused_state() -> void:
# unpause our game # unpause our game
process_mode = Node.PROCESS_MODE_INHERIT process_mode = Node.PROCESS_MODE_INHERIT
emit_signal("focus_gained") focus_gained.emit()
# Handle OpenXR stopping state # Handle OpenXR stopping state
func _on_openxr_stopping() -> void: func _on_openxr_stopping() -> void:
@@ -101,4 +101,4 @@ func _on_openxr_stopping() -> void:
func _on_openxr_pose_recentered() -> void: func _on_openxr_pose_recentered() -> void:
# User recentered view, we have to react to this by recentering the view. # User recentered view, we have to react to this by recentering the view.
# This is game implementation dependent. # This is game implementation dependent.
emit_signal("pose_recentered") pose_recentered.emit()