mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-16 13:30:07 +01:00
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:
@@ -24,4 +24,4 @@ func set_dead(value):
|
||||
|
||||
|
||||
func set_look_direction(value):
|
||||
emit_signal("direction_changed", value)
|
||||
direction_changed.emit(value)
|
||||
|
||||
@@ -5,4 +5,4 @@ func enter():
|
||||
|
||||
|
||||
func _on_Sword_attack_finished():
|
||||
emit_signal("finished", "previous")
|
||||
finished.emit("previous")
|
||||
|
||||
@@ -9,4 +9,4 @@ func enter():
|
||||
|
||||
func _on_animation_finished(anim_name):
|
||||
assert(anim_name == "stagger")
|
||||
emit_signal("finished", "previous")
|
||||
finished.emit("previous")
|
||||
|
||||
@@ -7,4 +7,4 @@ func enter():
|
||||
|
||||
|
||||
func _on_animation_finished(_anim_name):
|
||||
emit_signal("finished", "dead")
|
||||
finished.emit("dead")
|
||||
|
||||
@@ -46,7 +46,7 @@ func update(delta):
|
||||
move_horizontally(delta, input_direction)
|
||||
animate_jump_height(delta)
|
||||
if height <= 0.0:
|
||||
emit_signal("finished", "previous")
|
||||
finished.emit("previous")
|
||||
|
||||
|
||||
func move_horizontally(delta, direction):
|
||||
|
||||
@@ -3,7 +3,7 @@ extends "res://state_machine/state.gd"
|
||||
|
||||
func handle_input(event):
|
||||
if event.is_action_pressed("simulate_damage"):
|
||||
emit_signal("finished", "stagger")
|
||||
finished.emit("stagger")
|
||||
|
||||
|
||||
func get_input_direction():
|
||||
|
||||
@@ -11,4 +11,4 @@ func handle_input(event):
|
||||
func update(_delta):
|
||||
var input_direction = get_input_direction()
|
||||
if input_direction:
|
||||
emit_signal("finished", "move")
|
||||
finished.emit("move")
|
||||
|
||||
@@ -19,7 +19,7 @@ func handle_input(event):
|
||||
func update(_delta):
|
||||
var input_direction = get_input_direction()
|
||||
if input_direction.is_zero_approx():
|
||||
emit_signal("finished", "idle")
|
||||
finished.emit("idle")
|
||||
update_look_direction(input_direction)
|
||||
|
||||
if Input.is_action_pressed("run"):
|
||||
|
||||
@@ -6,5 +6,5 @@ var velocity = Vector2()
|
||||
|
||||
func handle_input(event):
|
||||
if event.is_action_pressed("jump"):
|
||||
emit_signal("finished", "jump")
|
||||
finished.emit("jump")
|
||||
return super.handle_input(event)
|
||||
|
||||
@@ -31,8 +31,8 @@ var combo = [{
|
||||
var hit_objects = []
|
||||
|
||||
func _ready():
|
||||
$AnimationPlayer.animation_finished.connect(self._on_animation_finished)
|
||||
body_entered.connect(self._on_body_entered)
|
||||
$AnimationPlayer.animation_finished.connect(_on_animation_finished)
|
||||
body_entered.connect(_on_body_entered)
|
||||
_change_state(States.IDLE)
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ func _on_animation_finished(_name):
|
||||
attack()
|
||||
else:
|
||||
_change_state(States.IDLE)
|
||||
emit_signal("attack_finished")
|
||||
attack_finished.emit()
|
||||
|
||||
|
||||
func _on_StateMachine_state_changed(current_state):
|
||||
|
||||
@@ -3,7 +3,7 @@ extends Marker2D
|
||||
var z_index_start = 0
|
||||
|
||||
func _ready():
|
||||
owner.direction_changed.connect(self._on_Parent_direction_changed)
|
||||
owner.direction_changed.connect(_on_Parent_direction_changed)
|
||||
z_index_start = z_index
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ func _enter_tree():
|
||||
if start_state.is_empty():
|
||||
start_state = get_child(0).get_path()
|
||||
for child in get_children():
|
||||
var err = child.finished.connect(self._change_state)
|
||||
var err = child.finished.connect(_change_state)
|
||||
if err:
|
||||
printerr(err)
|
||||
initialize(start_state)
|
||||
@@ -70,7 +70,7 @@ func _change_state(state_name):
|
||||
states_stack[0] = states_map[state_name]
|
||||
|
||||
current_state = states_stack[0]
|
||||
emit_signal("state_changed", current_state)
|
||||
state_changed.emit(current_state)
|
||||
|
||||
if state_name != "previous":
|
||||
current_state.enter()
|
||||
|
||||
@@ -191,7 +191,7 @@ func _shot_bullet() -> void:
|
||||
else:
|
||||
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)
|
||||
|
||||
bullet.linear_velocity = Vector2(400.0 * speed_scale, -40)
|
||||
@@ -204,5 +204,5 @@ func _shot_bullet() -> void:
|
||||
|
||||
func _spawn_enemy_above() -> void:
|
||||
var enemy := Enemy.instantiate() as RigidBody2D
|
||||
enemy.position = self.position + 50 * Vector2.UP
|
||||
enemy.position = position + 50 * Vector2.UP
|
||||
get_parent().add_child(enemy)
|
||||
|
||||
@@ -32,7 +32,7 @@ func _physics_process(_delta):
|
||||
if _wait_physics_ticks_counter > 0:
|
||||
_wait_physics_ticks_counter -= 1
|
||||
if _wait_physics_ticks_counter == 0:
|
||||
emit_signal("wait_done")
|
||||
wait_done.emit()
|
||||
|
||||
|
||||
func add_line(pos_start, pos_end, color):
|
||||
@@ -111,7 +111,7 @@ func start_timer(timeout):
|
||||
_timer = Timer.new()
|
||||
_timer.one_shot = true
|
||||
add_child(_timer)
|
||||
_timer.timeout.connect(self._on_timer_done)
|
||||
_timer.timeout.connect(_on_timer_done)
|
||||
else:
|
||||
cancel_timer()
|
||||
|
||||
@@ -124,7 +124,7 @@ func start_timer(timeout):
|
||||
func cancel_timer():
|
||||
if _timer_started:
|
||||
_timer.paused = true
|
||||
_timer.emit_signal("timeout")
|
||||
_timer.timeout.emit()
|
||||
_timer.paused = false
|
||||
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ var _moving_body: PhysicsBody2D = null
|
||||
|
||||
|
||||
func _ready():
|
||||
options.option_selected.connect(self._on_option_selected)
|
||||
options.option_changed.connect(self._on_option_changed)
|
||||
options.option_selected.connect(_on_option_selected)
|
||||
options.option_changed.connect(_on_option_changed)
|
||||
|
||||
_character_body_template = find_child("CharacterBody2D")
|
||||
if _character_body_template:
|
||||
|
||||
@@ -42,8 +42,8 @@ func _ready():
|
||||
options.add_menu_item(OPTION_SHAPE_CONCAVE_POLYGON, true, true)
|
||||
options.add_menu_item(OPTION_SHAPE_CONCAVE_SEGMENTS, true, true)
|
||||
|
||||
options.option_selected.connect(self._on_option_selected)
|
||||
options.option_changed.connect(self._on_option_changed)
|
||||
options.option_selected.connect(_on_option_selected)
|
||||
options.option_changed.connect(_on_option_changed)
|
||||
|
||||
await start_timer(0.5).timeout
|
||||
if is_timer_canceled():
|
||||
|
||||
@@ -43,8 +43,8 @@ func _ready():
|
||||
options.add_menu_item(OPTION_TEST_CASE_DESTROY_BODY, true, false)
|
||||
options.add_menu_item(OPTION_TEST_CASE_CHANGE_POSITIONS, true, false)
|
||||
|
||||
options.connect(&"option_selected", Callable(self, "_on_option_selected"))
|
||||
options.connect(&"option_changed", Callable(self, "_on_option_changed"))
|
||||
options.option_selected.connect(_on_option_selected)
|
||||
options.option_changed.connect(_on_option_changed)
|
||||
|
||||
_selected_joint = _joint_types.values()[0]
|
||||
_update_joint = true
|
||||
|
||||
@@ -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_CHARACTER)
|
||||
|
||||
options.option_selected.connect(self._on_option_selected)
|
||||
options.option_selected.connect(_on_option_selected)
|
||||
|
||||
$Controls/PlatformSize/HSlider.value = _platform_size
|
||||
$Controls/PlatformAngle/HSlider.value = _platform_angle
|
||||
$Controls/BodyAngle/HSlider.value = _body_angle
|
||||
|
||||
remove_child(_target_area)
|
||||
_target_area.body_entered.connect(self._on_target_entered)
|
||||
$Timer.timeout.connect(self._on_timeout)
|
||||
_target_area.body_entered.connect(_on_target_entered)
|
||||
$Timer.timeout.connect(_on_timeout)
|
||||
|
||||
_rigid_body_template = $RigidBody2D
|
||||
remove_child(_rigid_body_template)
|
||||
@@ -236,13 +236,13 @@ func _start_test_case(option):
|
||||
|
||||
await _on_option_selected(option)
|
||||
|
||||
await self.all_tests_done
|
||||
await all_tests_done
|
||||
|
||||
|
||||
func _wait_for_test():
|
||||
await _reset_test()
|
||||
|
||||
await self.test_done
|
||||
await test_done
|
||||
|
||||
|
||||
func _test_all_rigid_body():
|
||||
@@ -331,7 +331,7 @@ func _test_moving_platform():
|
||||
return
|
||||
|
||||
_platform_speed = 0.0
|
||||
emit_signal("all_tests_done")
|
||||
all_tests_done.emit()
|
||||
|
||||
|
||||
func _test_all():
|
||||
@@ -373,7 +373,7 @@ func _start_test():
|
||||
test_label += String(_rigid_body_template.name)
|
||||
_moving_body = _rigid_body_template.duplicate()
|
||||
_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)
|
||||
|
||||
if _platform_speed != 0.0:
|
||||
@@ -411,7 +411,7 @@ func _reset_test(cancel_test = true):
|
||||
if cancel_test:
|
||||
Log.print_log("*** Stop around the clock tests")
|
||||
_test_all_angles = false
|
||||
emit_signal("all_tests_done")
|
||||
all_tests_done.emit()
|
||||
else:
|
||||
Log.print_log("*** Start around the clock tests")
|
||||
_platform_body.rotation = deg_to_rad(_platform_angle)
|
||||
@@ -487,8 +487,8 @@ func _on_timeout():
|
||||
$Timer.stop()
|
||||
|
||||
if _test_canceled:
|
||||
emit_signal("test_done")
|
||||
emit_signal("all_tests_done")
|
||||
test_done.emit()
|
||||
all_tests_done.emit()
|
||||
return
|
||||
|
||||
if not _contact_detected and not _target_entered:
|
||||
@@ -497,18 +497,18 @@ func _on_timeout():
|
||||
|
||||
await start_timer(0.5).timeout
|
||||
if _test_canceled:
|
||||
emit_signal("test_done")
|
||||
emit_signal("all_tests_done")
|
||||
test_done.emit()
|
||||
all_tests_done.emit()
|
||||
return
|
||||
|
||||
var was_all_angles = _test_all_angles
|
||||
|
||||
_next_test()
|
||||
|
||||
emit_signal("test_done")
|
||||
test_done.emit()
|
||||
|
||||
if was_all_angles and not _test_all_angles:
|
||||
emit_signal("all_tests_done")
|
||||
all_tests_done.emit()
|
||||
|
||||
|
||||
func _set_result():
|
||||
|
||||
@@ -12,7 +12,7 @@ func _ready():
|
||||
|
||||
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
|
||||
if is_timer_canceled():
|
||||
|
||||
@@ -39,7 +39,7 @@ func _ready():
|
||||
options.add_menu_item(OPTION_TYPE_CAPSULE)
|
||||
options.add_menu_item(OPTION_TYPE_CONVEX_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()
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ var _current_test_scene: Node = null
|
||||
|
||||
|
||||
func _ready():
|
||||
option_selected.connect(self._on_option_selected)
|
||||
option_selected.connect(_on_option_selected)
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
|
||||
@@ -7,7 +7,7 @@ var _entry_template
|
||||
|
||||
|
||||
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
|
||||
remove_child(_entry_template)
|
||||
|
||||
@@ -62,10 +62,10 @@ func _on_item_pressed(item_index, popup_menu, path):
|
||||
for other_index in range(popup_menu.get_item_count()):
|
||||
if other_index != item_index:
|
||||
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):
|
||||
var checked = not popup_menu.is_item_checked(item_index)
|
||||
popup_menu.set_item_checked(item_index, checked)
|
||||
emit_signal("option_changed", item_path, checked)
|
||||
option_changed.emit(item_path, checked)
|
||||
else:
|
||||
emit_signal("option_selected", item_path)
|
||||
option_selected.emit(item_path)
|
||||
|
||||
@@ -6,7 +6,7 @@ extends ScrollContainer
|
||||
|
||||
func _ready():
|
||||
var scrollbar = get_v_scroll_bar()
|
||||
scrollbar.scrolling.connect(self._on_scrolling)
|
||||
scrollbar.scrolling.connect(_on_scrolling)
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
|
||||
@@ -11,10 +11,10 @@ signal entry_logged(message, type)
|
||||
|
||||
func print_log(message):
|
||||
print(message)
|
||||
emit_signal("entry_logged", message, LogType.LOG)
|
||||
entry_logged.emit(message, LogType.LOG)
|
||||
|
||||
|
||||
func print_error(message):
|
||||
push_error(message)
|
||||
printerr(message)
|
||||
emit_signal("entry_logged", message, LogType.ERROR)
|
||||
entry_logged.emit(message, LogType.ERROR)
|
||||
|
||||
@@ -9,7 +9,7 @@ func initialize(combat_combatants):
|
||||
combatant = combatant.instantiate()
|
||||
if combatant is 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:
|
||||
combatant.queue_free()
|
||||
$UI.initialize()
|
||||
@@ -24,7 +24,7 @@ func clear_combat():
|
||||
|
||||
|
||||
func finish_combat(winner, loser):
|
||||
emit_signal("combat_finished", winner, loser)
|
||||
combat_finished.emit(winner, loser)
|
||||
|
||||
|
||||
func _on_combatant_death(combatant):
|
||||
|
||||
@@ -24,21 +24,21 @@ func set_active(value):
|
||||
|
||||
func attack(target):
|
||||
target.take_damage(damage)
|
||||
emit_signal("turn_finished")
|
||||
turn_finished.emit()
|
||||
|
||||
|
||||
func consume(item):
|
||||
item.use(self)
|
||||
emit_signal("turn_finished")
|
||||
turn_finished.emit()
|
||||
|
||||
|
||||
func defend():
|
||||
$Health.armor += defense
|
||||
emit_signal("turn_finished")
|
||||
turn_finished.emit()
|
||||
|
||||
|
||||
func flee():
|
||||
emit_signal("turn_finished")
|
||||
turn_finished.emit()
|
||||
|
||||
|
||||
func take_damage(damage_to_take):
|
||||
|
||||
@@ -17,15 +17,15 @@ func _ready():
|
||||
func take_damage(damage):
|
||||
life = life - damage + armor
|
||||
if life <= 0:
|
||||
emit_signal("dead")
|
||||
dead.emit()
|
||||
else:
|
||||
emit_signal("health_changed", life)
|
||||
health_changed.emit(life)
|
||||
|
||||
|
||||
func heal(amount):
|
||||
life += amount
|
||||
life = clamp(life, life, max_life)
|
||||
emit_signal("health_changed", life)
|
||||
health_changed.emit(life)
|
||||
|
||||
|
||||
func get_health_ratio():
|
||||
|
||||
@@ -13,7 +13,7 @@ func initialize():
|
||||
health_info.value = health.life
|
||||
health_info.max_value = health.max_life
|
||||
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)
|
||||
$Buttons/GridContainer/Attack.grab_focus()
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func get_next_in_queue():
|
||||
var current_combatant = queue.pop_front()
|
||||
current_combatant.active = false
|
||||
queue.append(current_combatant)
|
||||
self.active_combatant = queue[0]
|
||||
active_combatant = queue[0]
|
||||
return active_combatant
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ func remove(combatant):
|
||||
new_queue.append(n)
|
||||
new_queue.remove(new_queue.find(combatant))
|
||||
combatant.queue_free()
|
||||
self.queue = new_queue
|
||||
queue = new_queue
|
||||
|
||||
|
||||
func set_queue(new_queue):
|
||||
@@ -44,10 +44,10 @@ func set_queue(new_queue):
|
||||
queue.append(node)
|
||||
node.active = false
|
||||
if queue.size() > 0:
|
||||
self.active_combatant = queue[0]
|
||||
active_combatant = queue[0]
|
||||
|
||||
|
||||
func _set_active_combatant(new_combatant):
|
||||
active_combatant = new_combatant
|
||||
active_combatant.active = true
|
||||
emit_signal("active_combatant_changed", active_combatant)
|
||||
active_combatant_changed.emit(active_combatant)
|
||||
|
||||
@@ -12,7 +12,7 @@ var dialogue_text = ""
|
||||
|
||||
|
||||
func start_dialogue():
|
||||
emit_signal("dialogue_started")
|
||||
dialogue_started.emit()
|
||||
current = 0
|
||||
index_dialogue()
|
||||
dialogue_text = dialogue_keys[current].text
|
||||
@@ -22,7 +22,7 @@ func start_dialogue():
|
||||
func next_dialogue():
|
||||
current += 1
|
||||
if current == dialogue_keys.size():
|
||||
emit_signal("dialogue_finished")
|
||||
dialogue_finished.emit()
|
||||
return
|
||||
dialogue_text = dialogue_keys[current].text
|
||||
dialogue_name = dialogue_keys[current].name
|
||||
|
||||
@@ -18,10 +18,10 @@ func show_dialogue(player, dialogue):
|
||||
$Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]"
|
||||
$Text.text = dialogue_node.dialogue_text
|
||||
return
|
||||
dialogue_node.connect("dialogue_started", Callable(player, "set_active").bind(false))
|
||||
dialogue_node.connect("dialogue_finished", Callable(player, "set_active").bind(true))
|
||||
dialogue_node.connect("dialogue_finished", Callable(self, "hide"))
|
||||
dialogue_node.connect("dialogue_finished", Callable(self, "_on_dialogue_finished").bind(player))
|
||||
dialogue_node.dialogue_started.connect(player.set_active.bind(false))
|
||||
dialogue_node.dialogue_finished.connect(player.set_active.bind(true))
|
||||
dialogue_node.dialogue_finished.connect(hide)
|
||||
dialogue_node.dialogue_finished.connect(_on_dialogue_finished.bind(player))
|
||||
dialogue_node.start_dialogue()
|
||||
$Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]"
|
||||
$Text.text = dialogue_node.dialogue_text
|
||||
@@ -34,7 +34,7 @@ func _on_Button_button_up():
|
||||
|
||||
|
||||
func _on_dialogue_finished(player):
|
||||
dialogue_node.disconnect("dialogue_started", Callable(player, "set_active"))
|
||||
dialogue_node.disconnect("dialogue_finished", Callable(player, "set_active"))
|
||||
dialogue_node.disconnect("dialogue_finished", Callable(self, "hide"))
|
||||
dialogue_node.disconnect("dialogue_finished", Callable(self, "_on_dialogue_finished"))
|
||||
dialogue_node.dialogue_started.disconnect(player.set_active)
|
||||
dialogue_node.dialogue_finished.disconnect(player.set_active)
|
||||
dialogue_node.dialogue_finished.disconnect(hide)
|
||||
dialogue_node.dialogue_finished.disconnect(_on_dialogue_finished)
|
||||
|
||||
@@ -22,7 +22,7 @@ var viewport_start_size := Vector2(
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
get_viewport().size_changed.connect(self.update_resolution_label)
|
||||
get_viewport().size_changed.connect(update_resolution_label)
|
||||
update_resolution_label()
|
||||
|
||||
# Disable V-Sync to uncap framerate on supported platforms. This makes performance comparison
|
||||
|
||||
@@ -4,7 +4,7 @@ extends Button
|
||||
|
||||
|
||||
func _ready():
|
||||
pressed.connect(self.change_scene)
|
||||
pressed.connect(change_scene)
|
||||
|
||||
|
||||
func change_scene():
|
||||
|
||||
@@ -57,7 +57,7 @@ var simple_bullet = preload("res://fps/simple_bullet.tscn")
|
||||
|
||||
|
||||
func _ready():
|
||||
anim_player.animation_finished.connect(self.animation_finished)
|
||||
anim_player.animation_finished.connect(animation_finished)
|
||||
|
||||
set_physics_process(true)
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
@@ -23,7 +23,7 @@ func _physics_process(_delta):
|
||||
if _wait_physics_ticks_counter > 0:
|
||||
_wait_physics_ticks_counter -= 1
|
||||
if _wait_physics_ticks_counter == 0:
|
||||
emit_signal("wait_done")
|
||||
wait_done.emit()
|
||||
|
||||
|
||||
func add_sphere(pos, radius, color):
|
||||
@@ -95,7 +95,7 @@ func start_timer(timeout):
|
||||
_timer = Timer.new()
|
||||
_timer.one_shot = true
|
||||
add_child(_timer)
|
||||
_timer.connect(&"timeout", Callable(self, "_on_timer_done"))
|
||||
_timer.timeout.connect(_on_timer_done)
|
||||
else:
|
||||
cancel_timer()
|
||||
|
||||
@@ -108,7 +108,7 @@ func start_timer(timeout):
|
||||
func cancel_timer():
|
||||
if _timer_started:
|
||||
_timer.paused = true
|
||||
_timer.emit_signal("timeout")
|
||||
_timer.timeout.emit()
|
||||
_timer.paused = false
|
||||
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ func _ready():
|
||||
$Options.add_menu_item(OPTION_SHAPE_CONVEX_POLYGON, true, true)
|
||||
$Options.add_menu_item(OPTION_SHAPE_CONCAVE_POLYGON, true, true)
|
||||
|
||||
$Options.option_selected.connect(self._on_option_selected)
|
||||
$Options.option_changed.connect(self._on_option_changed)
|
||||
$Options.option_selected.connect(_on_option_selected)
|
||||
$Options.option_changed.connect(_on_option_changed)
|
||||
|
||||
await start_timer(0.5).timeout
|
||||
if is_timer_canceled():
|
||||
|
||||
@@ -42,8 +42,8 @@ func _ready():
|
||||
options.add_menu_item(OPTION_TEST_CASE_DESTROY_BODY, true, false)
|
||||
options.add_menu_item(OPTION_TEST_CASE_CHANGE_POSITIONS, true, false)
|
||||
|
||||
options.connect(&"option_selected", Callable(self, "_on_option_selected"))
|
||||
options.connect(&"option_changed", Callable(self, "_on_option_changed"))
|
||||
options.option_selected.connect(_on_option_selected)
|
||||
options.option_changed.connect(_on_option_changed)
|
||||
|
||||
_selected_joint = _joint_types.values()[0]
|
||||
_update_joint = true
|
||||
|
||||
@@ -55,8 +55,8 @@ func _ready():
|
||||
options.add_menu_item(OPTION_ROUGH, true, false)
|
||||
options.add_menu_item(OPTION_PROCESS_PHYSICS, true, false)
|
||||
|
||||
options.option_selected.connect(self._on_option_selected)
|
||||
options.option_changed.connect(self._on_option_changed)
|
||||
options.option_selected.connect(_on_option_selected)
|
||||
options.option_changed.connect(_on_option_changed)
|
||||
|
||||
_shapes[SHAPE_CAPSULE] = "Capsule"
|
||||
_shapes[SHAPE_BOX] = "Box"
|
||||
|
||||
@@ -15,7 +15,7 @@ func _ready():
|
||||
|
||||
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.vertex_color_use_as_albedo = true
|
||||
|
||||
@@ -36,7 +36,7 @@ func _ready():
|
||||
options.add_menu_item(SHAPE_CONVEX)
|
||||
options.add_menu_item(SHAPE_BOX)
|
||||
|
||||
options.option_selected.connect(self._on_option_selected)
|
||||
options.option_selected.connect(_on_option_selected)
|
||||
restart_scene()
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ func _ready():
|
||||
$Options.add_menu_item(OPTION_TYPE_CAPSULE)
|
||||
$Options.add_menu_item(OPTION_TYPE_CYLINDER)
|
||||
$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()
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ var _current_test_scene: Node = null
|
||||
|
||||
|
||||
func _ready():
|
||||
option_selected.connect(self._on_option_selected)
|
||||
option_selected.connect(_on_option_selected)
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
|
||||
@@ -8,7 +8,7 @@ var _rotation_pivot
|
||||
|
||||
|
||||
func _ready():
|
||||
call_deferred("_initialize_pivot")
|
||||
_initialize_pivot.call_deferred()
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
|
||||
@@ -7,7 +7,7 @@ var _entry_template
|
||||
|
||||
|
||||
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
|
||||
remove_child(_entry_template)
|
||||
|
||||
@@ -55,6 +55,6 @@ func _on_item_pressed(item_index, popup_menu, path):
|
||||
if popup_menu.is_item_checkable(item_index):
|
||||
var checked = not popup_menu.is_item_checked(item_index)
|
||||
popup_menu.set_item_checked(item_index, checked)
|
||||
emit_signal("option_changed", item_path, checked)
|
||||
option_changed.emit(item_path, checked)
|
||||
else:
|
||||
emit_signal("option_selected", item_path)
|
||||
option_selected.emit(item_path)
|
||||
|
||||
@@ -11,10 +11,10 @@ signal entry_logged(message, type)
|
||||
|
||||
func print_log(message):
|
||||
print(message)
|
||||
emit_signal("entry_logged", message, LogType.LOG)
|
||||
entry_logged.emit(message, LogType.LOG)
|
||||
|
||||
|
||||
func print_error(message):
|
||||
push_error(message)
|
||||
printerr(message)
|
||||
emit_signal("entry_logged", message, LogType.ERROR)
|
||||
entry_logged.emit(message, LogType.ERROR)
|
||||
|
||||
@@ -24,7 +24,7 @@ func _integrate_forces(state: PhysicsDirectBodyState3D):
|
||||
var grav := state.get_total_gravity()
|
||||
# get_total_gravity returns zero for the first few frames, leading to errors.
|
||||
if grav.is_zero_approx():
|
||||
grav = self.gravity
|
||||
grav = gravity
|
||||
|
||||
lin_velocity += grav * delta # Apply gravity.
|
||||
var up := -grav.normalized()
|
||||
|
||||
@@ -66,7 +66,7 @@ func _physics_process(delta):
|
||||
|
||||
|
||||
func die():
|
||||
emit_signal("hit")
|
||||
hit.emit()
|
||||
queue_free()
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ var town: Node3D = null
|
||||
|
||||
func _ready():
|
||||
# Automatically focus the first item for gamepad accessibility.
|
||||
$HBoxContainer/MiniVan.call_deferred("grab_focus")
|
||||
$HBoxContainer/MiniVan.grab_focus.call_deferred()
|
||||
|
||||
func _process(_delta: float):
|
||||
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.get_node(^"InstancePos").add_child(car)
|
||||
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)
|
||||
hide()
|
||||
@@ -29,7 +29,7 @@ func _on_back_pressed():
|
||||
town.queue_free()
|
||||
show()
|
||||
# Automatically focus the first item for gamepad accessibility.
|
||||
$HBoxContainer/MiniVan.call_deferred("grab_focus")
|
||||
$HBoxContainer/MiniVan.grab_focus.call_deferred()
|
||||
else:
|
||||
# In main menu, exit the game.
|
||||
get_tree().quit()
|
||||
|
||||
@@ -30,7 +30,7 @@ func _ready():
|
||||
_generate_chunk_collider()
|
||||
# However, we can use a thread for mesh generation.
|
||||
_thread = Thread.new()
|
||||
_thread.start(self._generate_chunk_mesh)
|
||||
_thread.start(_generate_chunk_mesh)
|
||||
|
||||
|
||||
func regenerate():
|
||||
|
||||
@@ -12,25 +12,25 @@ extends Panel
|
||||
|
||||
func _ready():
|
||||
# Assign all of the needed signals for the oppersation buttons.
|
||||
$ButtonUndo.pressed.connect(self.button_pressed.bind("undo_stroke"))
|
||||
$ButtonSave.pressed.connect(self.button_pressed.bind("save_picture"))
|
||||
$ButtonClear.pressed.connect(self.button_pressed.bind("clear_picture"))
|
||||
$ButtonUndo.pressed.connect(button_pressed.bind("undo_stroke"))
|
||||
$ButtonSave.pressed.connect(button_pressed.bind("save_picture"))
|
||||
$ButtonClear.pressed.connect(button_pressed.bind("clear_picture"))
|
||||
|
||||
# Assign all of the needed signals for the brush buttons.
|
||||
$ButtonToolPencil.pressed.connect(self.button_pressed.bind("mode_pencil"))
|
||||
$ButtonToolEraser.pressed.connect(self.button_pressed.bind("mode_eraser"))
|
||||
$ButtonToolRectangle.pressed.connect(self.button_pressed.bind("mode_rectangle"))
|
||||
$ButtonToolCircle.pressed.connect(self.button_pressed.bind("mode_circle"))
|
||||
$BrushSettings/ButtonShapeBox.pressed.connect(self.button_pressed.bind("shape_rectangle"))
|
||||
$BrushSettings/ButtonShapeCircle.pressed.connect(self.button_pressed.bind("shape_circle"))
|
||||
$ButtonToolPencil.pressed.connect(button_pressed.bind("mode_pencil"))
|
||||
$ButtonToolEraser.pressed.connect(button_pressed.bind("mode_eraser"))
|
||||
$ButtonToolRectangle.pressed.connect(button_pressed.bind("mode_rectangle"))
|
||||
$ButtonToolCircle.pressed.connect(button_pressed.bind("mode_circle"))
|
||||
$BrushSettings/ButtonShapeBox.pressed.connect(button_pressed.bind("shape_rectangle"))
|
||||
$BrushSettings/ButtonShapeCircle.pressed.connect(button_pressed.bind("shape_circle"))
|
||||
|
||||
# Assign all of the needed signals for the other brush settings (and ColorPickerBackground).
|
||||
$ColorPickerBrush.color_changed.connect(self.brush_color_changed)
|
||||
$ColorPickerBackground.color_changed.connect(self.background_color_changed)
|
||||
$BrushSettings/HScrollBarBrushSize.value_changed.connect(self.brush_size_changed)
|
||||
$ColorPickerBrush.color_changed.connect(brush_color_changed)
|
||||
$ColorPickerBackground.color_changed.connect(background_color_changed)
|
||||
$BrushSettings/HScrollBarBrushSize.value_changed.connect(brush_size_changed)
|
||||
|
||||
# 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(true)
|
||||
|
||||
@@ -26,8 +26,8 @@ func _ready():
|
||||
# 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
|
||||
# uses a Full Rect anchor, so its size will always be equal to the window size.
|
||||
resized.connect(self._on_resized)
|
||||
call_deferred("update_container")
|
||||
resized.connect(_on_resized)
|
||||
update_container.call_deferred()
|
||||
|
||||
|
||||
func update_container():
|
||||
@@ -75,17 +75,17 @@ func _on_gui_aspect_ratio_item_selected(index):
|
||||
6: # 21:9
|
||||
gui_aspect_ratio = 21.0 / 9.0
|
||||
|
||||
call_deferred("update_container")
|
||||
update_container.call_deferred()
|
||||
|
||||
|
||||
func _on_resized():
|
||||
call_deferred("update_container")
|
||||
update_container.call_deferred()
|
||||
|
||||
|
||||
func _on_gui_margin_drag_ended(_value_changed):
|
||||
gui_margin = $"Panel/AspectRatioContainer/Panel/CenterContainer/Options/GUIMargin/HSlider".value
|
||||
$"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):
|
||||
@@ -108,7 +108,7 @@ func _on_window_base_size_item_selected(index):
|
||||
base_window_size = Vector2(1680, 720)
|
||||
|
||||
get_viewport().content_scale_size = base_window_size
|
||||
call_deferred("update_container")
|
||||
update_container.call_deferred()
|
||||
|
||||
|
||||
func _on_window_stretch_mode_item_selected(index):
|
||||
|
||||
@@ -252,9 +252,9 @@ func _on_random_button_pressed() -> void:
|
||||
|
||||
func _on_create_button_gpu_pressed() -> void:
|
||||
var heightmap = prepare_image()
|
||||
call_deferred("compute_island_gpu", heightmap)
|
||||
compute_island_gpu.call_deferred(heightmap)
|
||||
|
||||
|
||||
func _on_create_button_cpu_pressed() -> void:
|
||||
var heightmap = prepare_image()
|
||||
call_deferred("compute_island_cpu", heightmap)
|
||||
compute_island_cpu.call_deferred(heightmap)
|
||||
|
||||
@@ -23,7 +23,7 @@ var axis_value
|
||||
@onready var joypad_number = $DeviceInfo/JoyNumber
|
||||
|
||||
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():
|
||||
print_rich("Found joypad #%d: [b]%s[/b] - %s" % [joypad, Input.get_joy_name(joypad), Input.get_joy_guid(joypad)])
|
||||
|
||||
@@ -14,29 +14,29 @@ func _ready():
|
||||
|
||||
payment = Engine.get_singleton("GodotGooglePlayBilling")
|
||||
# No params.
|
||||
payment.connected.connect(self._on_connected)
|
||||
payment.connected.connect(_on_connected)
|
||||
# No params.
|
||||
payment.disconnected.connect(self._on_disconnected)
|
||||
payment.disconnected.connect(_on_disconnected)
|
||||
# Response ID (int), Debug message (string).
|
||||
payment.connect_error.connect(self._on_connect_error)
|
||||
payment.connect_error.connect(_on_connect_error)
|
||||
# Purchases (Dictionary[]).
|
||||
payment.purchases_updated.connect(self._on_purchases_updated)
|
||||
payment.purchases_updated.connect(_on_purchases_updated)
|
||||
# Response ID (int), Debug message (string).
|
||||
payment.purchase_error.connect(self._on_purchase_error)
|
||||
payment.purchase_error.connect(_on_purchase_error)
|
||||
# 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[]).
|
||||
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).
|
||||
payment.purchase_acknowledged.connect(self._on_purchase_acknowledged)
|
||||
payment.purchase_acknowledged.connect(_on_purchase_acknowledged)
|
||||
# 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).
|
||||
payment.purchase_consumed.connect(self._on_purchase_consumed)
|
||||
payment.purchase_consumed.connect(_on_purchase_consumed)
|
||||
# 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[])
|
||||
payment.query_purchases_response.connect(self._on_query_purchases_response)
|
||||
payment.query_purchases_response.connect(_on_query_purchases_response)
|
||||
payment.startConnection()
|
||||
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.")
|
||||
|
||||
@@ -142,8 +142,8 @@ func end_game():
|
||||
|
||||
|
||||
func _ready():
|
||||
multiplayer.peer_connected.connect(self._player_connected)
|
||||
multiplayer.peer_disconnected.connect(self._player_disconnected)
|
||||
multiplayer.connected_to_server.connect(self._connected_ok)
|
||||
multiplayer.connection_failed.connect(self._connected_fail)
|
||||
multiplayer.server_disconnected.connect(self._server_disconnected)
|
||||
multiplayer.peer_connected.connect(_player_connected)
|
||||
multiplayer.peer_disconnected.connect(_player_disconnected)
|
||||
multiplayer.connected_to_server.connect(_connected_ok)
|
||||
multiplayer.connection_failed.connect(_connected_fail)
|
||||
multiplayer.server_disconnected.connect(_server_disconnected)
|
||||
|
||||
@@ -2,11 +2,11 @@ extends Control
|
||||
|
||||
func _ready():
|
||||
# Called every time the node is added to the scene.
|
||||
gamestate.connection_failed.connect(self._on_connection_failed)
|
||||
gamestate.connection_succeeded.connect(self._on_connection_success)
|
||||
gamestate.player_list_changed.connect(self.refresh_lobby)
|
||||
gamestate.game_ended.connect(self._on_game_ended)
|
||||
gamestate.game_error.connect(self._on_game_error)
|
||||
gamestate.connection_failed.connect(_on_connection_failed)
|
||||
gamestate.connection_succeeded.connect(_on_connection_success)
|
||||
gamestate.player_list_changed.connect(refresh_lobby)
|
||||
gamestate.game_ended.connect(_on_game_ended)
|
||||
gamestate.game_error.connect(_on_game_error)
|
||||
# Set the player name according to the system username. Fallback to the path.
|
||||
if OS.has_environment("USERNAME"):
|
||||
$Connect/Name.text = OS.get_environment("USERNAME")
|
||||
|
||||
@@ -17,11 +17,11 @@ var peer = null
|
||||
|
||||
func _ready():
|
||||
# Connect all the callbacks related to networking.
|
||||
multiplayer.peer_connected.connect(self._player_connected)
|
||||
multiplayer.peer_disconnected.connect(self._player_disconnected)
|
||||
multiplayer.connected_to_server.connect(self._connected_ok)
|
||||
multiplayer.connection_failed.connect(self._connected_fail)
|
||||
multiplayer.server_disconnected.connect(self._server_disconnected)
|
||||
multiplayer.peer_connected.connect(_player_connected)
|
||||
multiplayer.peer_disconnected.connect(_player_disconnected)
|
||||
multiplayer.connected_to_server.connect(_connected_ok)
|
||||
multiplayer.connection_failed.connect(_connected_fail)
|
||||
multiplayer.server_disconnected.connect(_server_disconnected)
|
||||
|
||||
#### Network callbacks from SceneTree ####
|
||||
|
||||
@@ -30,7 +30,7 @@ func _player_connected(_id):
|
||||
# Someone connected, start the game!
|
||||
var pong = load("res://pong.tscn").instantiate()
|
||||
# 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)
|
||||
hide()
|
||||
|
||||
@@ -50,4 +50,4 @@ func update_score(add_to_left):
|
||||
|
||||
|
||||
func _on_exit_game_pressed():
|
||||
emit_signal("game_finished")
|
||||
game_finished.emit()
|
||||
|
||||
@@ -8,8 +8,8 @@ var channel = peer.create_data_channel("chat", {"negotiated": true, "id": 1})
|
||||
|
||||
func _ready():
|
||||
# Connect all functions.
|
||||
peer.ice_candidate_created.connect(self._on_ice_candidate)
|
||||
peer.session_description_created.connect(self._on_session)
|
||||
peer.ice_candidate_created.connect(_on_ice_candidate)
|
||||
peer.session_description_created.connect(_on_session)
|
||||
|
||||
# Register to the local signaling server (see below for the implementation).
|
||||
Signaling.register(String(get_path()))
|
||||
|
||||
@@ -4,24 +4,24 @@ var rtc_mp: WebRTCMultiplayerPeer = WebRTCMultiplayerPeer.new()
|
||||
var sealed := false
|
||||
|
||||
func _init():
|
||||
connected.connect(self._connected)
|
||||
disconnected.connect(self._disconnected)
|
||||
connected.connect(_connected)
|
||||
disconnected.connect(_disconnected)
|
||||
|
||||
offer_received.connect(self._offer_received)
|
||||
answer_received.connect(self._answer_received)
|
||||
candidate_received.connect(self._candidate_received)
|
||||
offer_received.connect(_offer_received)
|
||||
answer_received.connect(_answer_received)
|
||||
candidate_received.connect(_candidate_received)
|
||||
|
||||
lobby_joined.connect(self._lobby_joined)
|
||||
lobby_sealed.connect(self._lobby_sealed)
|
||||
peer_connected.connect(self._peer_connected)
|
||||
peer_disconnected.connect(self._peer_disconnected)
|
||||
lobby_joined.connect(_lobby_joined)
|
||||
lobby_sealed.connect(_lobby_sealed)
|
||||
peer_connected.connect(_peer_connected)
|
||||
peer_disconnected.connect(_peer_disconnected)
|
||||
|
||||
|
||||
func start(url, lobby = "", mesh:=true):
|
||||
func start(url, _lobby = "", _mesh := true):
|
||||
stop()
|
||||
sealed = false
|
||||
self.mesh = mesh
|
||||
self.lobby = lobby
|
||||
mesh = _mesh
|
||||
lobby = _lobby
|
||||
connect_to_url(url)
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ func _create_peer(id):
|
||||
peer.initialize({
|
||||
"iceServers": [ { "urls": ["stun:stun.l.google.com:19302"] } ]
|
||||
})
|
||||
peer.session_description_created.connect(self._offer_created.bind(id))
|
||||
peer.ice_candidate_created.connect(self._new_ice_candidate.bind(id))
|
||||
peer.session_description_created.connect(_offer_created.bind(id))
|
||||
peer.ice_candidate_created.connect(_new_ice_candidate.bind(id))
|
||||
rtc_mp.add_peer(peer, id)
|
||||
if id < rtc_mp.get_unique_id(): # So lobby creator never creates offers.
|
||||
peer.create_offer()
|
||||
@@ -68,8 +68,8 @@ func _connected(id, use_mesh):
|
||||
multiplayer.multiplayer_peer = rtc_mp
|
||||
|
||||
|
||||
func _lobby_joined(lobby):
|
||||
self.lobby = lobby
|
||||
func _lobby_joined(_lobby):
|
||||
lobby = _lobby
|
||||
|
||||
|
||||
func _lobby_sealed():
|
||||
|
||||
@@ -6,16 +6,16 @@ extends Control
|
||||
@onready var mesh = $VBoxContainer/Connect/Mesh
|
||||
|
||||
func _ready():
|
||||
client.lobby_joined.connect(self._lobby_joined)
|
||||
client.lobby_sealed.connect(self._lobby_sealed)
|
||||
client.connected.connect(self._connected)
|
||||
client.disconnected.connect(self._disconnected)
|
||||
client.lobby_joined.connect(_lobby_joined)
|
||||
client.lobby_sealed.connect(_lobby_sealed)
|
||||
client.connected.connect(_connected)
|
||||
client.disconnected.connect(_disconnected)
|
||||
|
||||
multiplayer.connected_to_server.connect(self._mp_server_connected)
|
||||
multiplayer.connection_failed.connect(self._mp_server_disconnect)
|
||||
multiplayer.server_disconnected.connect(self._mp_server_disconnect)
|
||||
multiplayer.peer_connected.connect(self._mp_peer_connected)
|
||||
multiplayer.peer_disconnected.connect(self._mp_peer_disconnected)
|
||||
multiplayer.connected_to_server.connect(_mp_server_connected)
|
||||
multiplayer.connection_failed.connect(_mp_server_disconnect)
|
||||
multiplayer.server_disconnected.connect(_mp_server_disconnect)
|
||||
multiplayer.peer_connected.connect(_mp_peer_connected)
|
||||
multiplayer.peer_disconnected.connect(_mp_peer_disconnected)
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local")
|
||||
|
||||
@@ -18,11 +18,11 @@ func _init():
|
||||
|
||||
|
||||
func _ready():
|
||||
multiplayer.peer_connected.connect(self._peer_connected)
|
||||
multiplayer.peer_disconnected.connect(self._peer_disconnected)
|
||||
multiplayer.server_disconnected.connect(self._close_network)
|
||||
multiplayer.connection_failed.connect(self._close_network)
|
||||
multiplayer.connected_to_server.connect(self._connected)
|
||||
multiplayer.peer_connected.connect(_peer_connected)
|
||||
multiplayer.peer_disconnected.connect(_peer_disconnected)
|
||||
multiplayer.server_disconnected.connect(_close_network)
|
||||
multiplayer.connection_failed.connect(_close_network)
|
||||
multiplayer.connected_to_server.connect(_connected)
|
||||
|
||||
$AcceptDialog.get_label().horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
$AcceptDialog.get_label().vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
|
||||
@@ -7,11 +7,11 @@ var editor_interface
|
||||
|
||||
func _ready():
|
||||
# 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/SaveButton").pressed.connect(self.save_pressed)
|
||||
get_node(^"VBoxContainer/LoadButton").pressed.connect(self.load_pressed)
|
||||
get_node(^"SaveMaterialDialog").file_selected.connect(self.save_file_selected)
|
||||
get_node(^"LoadMaterialDialog").file_selected.connect(self.load_file_selected)
|
||||
get_node(^"VBoxContainer/ApplyButton").pressed.connect(apply_pressed)
|
||||
get_node(^"VBoxContainer/SaveButton").pressed.connect(save_pressed)
|
||||
get_node(^"VBoxContainer/LoadButton").pressed.connect(load_pressed)
|
||||
get_node(^"SaveMaterialDialog").file_selected.connect(save_file_selected)
|
||||
get_node(^"LoadMaterialDialog").file_selected.connect(load_file_selected)
|
||||
RenderingServer.canvas_item_set_clip(get_canvas_item(), true)
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ var viewport_initial_size = Vector2()
|
||||
|
||||
func _ready():
|
||||
$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
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ func _ready():
|
||||
_on_size_changed()
|
||||
_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("viewport2", viewport2.get_texture())
|
||||
|
||||
@@ -12,9 +12,9 @@ var last_event_time: float = -1.0
|
||||
@onready var node_area = $Quad/Area3D
|
||||
|
||||
func _ready():
|
||||
node_area.mouse_entered.connect(self._mouse_entered_area)
|
||||
node_area.mouse_exited.connect(self._mouse_exited_area)
|
||||
node_area.input_event.connect(self._mouse_input_event)
|
||||
node_area.mouse_entered.connect(_mouse_entered_area)
|
||||
node_area.mouse_exited.connect(_mouse_exited_area)
|
||||
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 node_quad.get_surface_override_material(0).billboard_mode == BaseMaterial3D.BillboardMode.BILLBOARD_DISABLED:
|
||||
|
||||
@@ -24,11 +24,11 @@ func _ready():
|
||||
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
|
||||
|
||||
# Connect the OpenXR events
|
||||
xr_interface.connect("session_begun", _on_openxr_session_begun)
|
||||
xr_interface.connect("session_visible", _on_openxr_visible_state)
|
||||
xr_interface.connect("session_focussed", _on_openxr_focused_state)
|
||||
xr_interface.connect("session_stopping", _on_openxr_stopping)
|
||||
xr_interface.connect("pose_recentered", _on_openxr_pose_recentered)
|
||||
xr_interface.session_begun.connect(_on_openxr_session_begun)
|
||||
xr_interface.session_visible.connect(_on_openxr_visible_state)
|
||||
xr_interface.session_focussed.connect(_on_openxr_focused_state)
|
||||
xr_interface.session_stopping.connect(_on_openxr_stopping)
|
||||
xr_interface.pose_recentered.connect(_on_openxr_pose_recentered)
|
||||
else:
|
||||
# We couldn't start OpenXR.
|
||||
print("OpenXR not instantiated!")
|
||||
@@ -79,7 +79,7 @@ func _on_openxr_visible_state() -> void:
|
||||
# pause our game
|
||||
process_mode = Node.PROCESS_MODE_DISABLED
|
||||
|
||||
emit_signal("focus_lost")
|
||||
focus_lost.emit()
|
||||
|
||||
|
||||
# Handle OpenXR focused state
|
||||
@@ -90,7 +90,7 @@ func _on_openxr_focused_state() -> void:
|
||||
# unpause our game
|
||||
process_mode = Node.PROCESS_MODE_INHERIT
|
||||
|
||||
emit_signal("focus_gained")
|
||||
focus_gained.emit()
|
||||
|
||||
# Handle OpenXR stopping state
|
||||
func _on_openxr_stopping() -> void:
|
||||
@@ -101,4 +101,4 @@ func _on_openxr_stopping() -> void:
|
||||
func _on_openxr_pose_recentered() -> void:
|
||||
# User recentered view, we have to react to this by recentering the view.
|
||||
# This is game implementation dependent.
|
||||
emit_signal("pose_recentered")
|
||||
pose_recentered.emit()
|
||||
|
||||
@@ -24,11 +24,11 @@ func _ready():
|
||||
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
|
||||
|
||||
# Connect the OpenXR events
|
||||
xr_interface.connect("session_begun", _on_openxr_session_begun)
|
||||
xr_interface.connect("session_visible", _on_openxr_visible_state)
|
||||
xr_interface.connect("session_focussed", _on_openxr_focused_state)
|
||||
xr_interface.connect("session_stopping", _on_openxr_stopping)
|
||||
xr_interface.connect("pose_recentered", _on_openxr_pose_recentered)
|
||||
xr_interface.session_begun.connect(_on_openxr_session_begun)
|
||||
xr_interface.session_visible.connect(_on_openxr_visible_state)
|
||||
xr_interface.session_focussed.connect(_on_openxr_focused_state)
|
||||
xr_interface.session_stopping.connect(_on_openxr_stopping)
|
||||
xr_interface.pose_recentered.connect(_on_openxr_pose_recentered)
|
||||
else:
|
||||
# We couldn't start OpenXR.
|
||||
print("OpenXR not instantiated!")
|
||||
@@ -79,7 +79,7 @@ func _on_openxr_visible_state() -> void:
|
||||
# pause our game
|
||||
process_mode = Node.PROCESS_MODE_DISABLED
|
||||
|
||||
emit_signal("focus_lost")
|
||||
focus_lost.emit()
|
||||
|
||||
|
||||
# Handle OpenXR focused state
|
||||
@@ -90,7 +90,7 @@ func _on_openxr_focused_state() -> void:
|
||||
# unpause our game
|
||||
process_mode = Node.PROCESS_MODE_INHERIT
|
||||
|
||||
emit_signal("focus_gained")
|
||||
focus_gained.emit()
|
||||
|
||||
# Handle OpenXR stopping state
|
||||
func _on_openxr_stopping() -> void:
|
||||
@@ -101,4 +101,4 @@ func _on_openxr_stopping() -> void:
|
||||
func _on_openxr_pose_recentered() -> void:
|
||||
# User recentered view, we have to react to this by recentering the view.
|
||||
# This is game implementation dependent.
|
||||
emit_signal("pose_recentered")
|
||||
pose_recentered.emit()
|
||||
|
||||
Reference in New Issue
Block a user