-
Notifications
You must be signed in to change notification settings - Fork 481
Fix townies walking speed issue #2620 #2809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,38 +9,86 @@ extends Node2D | |
| ## | ||
| ## Coordinate an array of townies to join the StoryWeaver at the Eternal Loom | ||
| ## for listening the retelling. | ||
| ## Call [member RetellingTownie.go_to_the_loom()] on each townie so they join. | ||
| ## Call [member EternalLoom.show_retelling_dialogue()] when all townies have joined. | ||
| ## May call [member RetellingTownie.become_helper()] on one townie (at random). | ||
| ## Call [member RetellingTownie.leave_the_loom()] on each townie so they leave. | ||
| ## Call RetellingTownie.go_to_the_loom() on each townie so they join. | ||
| ## Call EternalLoom.show_retelling_dialogue() when all townies have joined. | ||
| ## May call RetellingTownie.become_helper() on one townie (at random). | ||
| ## Call RetellingTownie.leave_the_loom() on each townie so they leave. | ||
|
|
||
| ## The array of retelling townies in Fray's End. | ||
| @export var townies: Array[RetellingTownie] = [] | ||
|
|
||
| var _waiting_for_townies: Array[RetellingTownie] = [] | ||
|
|
||
| ## The Eternal Loom, for listening to signals and calling | ||
| ## [member EternalLoom.show_retelling_dialogue()]. | ||
| ## EternalLoom.show_retelling_dialogue(). | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
| @onready var eternal_loom: EternalLoom = %EternalLoom | ||
|
|
||
|
|
||
| func _ready() -> void: | ||
| if Engine.is_editor_hint(): | ||
| return | ||
| eternal_loom.retelling_started.connect(_on_eternal_loom_retelling_started) | ||
| eternal_loom.retelling_finished.connect(_on_eternal_loom_retelling_finished) | ||
| eternal_loom.give_retelling_upgrade.connect(_on_eternal_loom_give_retelling_upgrade) | ||
|
|
||
| eternal_loom.retelling_started.connect( | ||
| _on_eternal_loom_retelling_started | ||
| ) | ||
| eternal_loom.retelling_finished.connect( | ||
| _on_eternal_loom_retelling_finished | ||
| ) | ||
| eternal_loom.give_retelling_upgrade.connect( | ||
| _on_eternal_loom_give_retelling_upgrade | ||
| ) | ||
|
Comment on lines
-30
to
+39
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why change the format here? Check https://github.com/endlessm/threadbare/actions/runs/33290260227/job/99564258513?pr=2809 and please consider installing pre-commit like our Contributing guide mentions.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry. |
||
|
|
||
|
|
||
| func _on_eternal_loom_retelling_started() -> void: | ||
| _waiting_for_townies = townies.duplicate() | ||
|
|
||
| var travel_times: Array[float] = [] | ||
|
|
||
| # Prepare each townie and calculate its travel time. | ||
| for t: RetellingTownie in townies: | ||
| t.go_to_the_loom() | ||
| t.loom_reached.connect(_on_loom_reached.bind(t)) | ||
| var travel_time: float = t.prepare_walk() | ||
| travel_times.append(travel_time) | ||
|
|
||
| # The slowest townie determines the target arrival time. | ||
| var target_time: float = float(travel_times.max()) | ||
|
|
||
| print("================================") | ||
| print("Tiempo objetivo: ", target_time, " s") | ||
| print("================================") | ||
|
|
||
| # Start each townie with a delay so they arrive together. | ||
| for i in range(townies.size()): | ||
| var townie: RetellingTownie = townies[i] | ||
| var delay: float = target_time - travel_times[i] | ||
|
|
||
| print( | ||
| "Townie: ", | ||
| townie.name, | ||
| " | Retraso: ", | ||
| delay, | ||
| " s" | ||
| ) | ||
|
|
||
| _start_townie_after_delay(townie, delay) | ||
|
|
||
|
|
||
| func _start_townie_after_delay( | ||
| townie: RetellingTownie, | ||
| delay: float | ||
| ) -> void: | ||
| # Connect before starting the townie so the arrival signal is captured. | ||
| if not townie.loom_reached.is_connected(_on_loom_reached.bind(townie)): | ||
| townie.loom_reached.connect(_on_loom_reached.bind(townie)) | ||
|
|
||
| if delay > 0.0: | ||
| await get_tree().create_timer(delay).timeout | ||
|
|
||
| townie.go_to_the_loom() | ||
|
|
||
|
|
||
| func _on_loom_reached(townie: RetellingTownie) -> void: | ||
| _waiting_for_townies.erase(townie) | ||
|
|
||
| if _waiting_for_townies.size() == 0: | ||
| eternal_loom.show_retelling_dialogue() | ||
|
|
||
|
|
@@ -50,6 +98,8 @@ func _on_eternal_loom_retelling_finished() -> void: | |
| t.leave_the_loom() | ||
|
|
||
|
|
||
| func _on_eternal_loom_give_retelling_upgrade(type: InventoryItem.ItemType) -> void: | ||
| func _on_eternal_loom_give_retelling_upgrade( | ||
| type: InventoryItem.ItemType | ||
| ) -> void: | ||
| var t: RetellingTownie = townies.pick_random() | ||
| t.become_helper(type) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain why you changed the documentation comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! My apologies for that. I slightly modified the format of the comments just to make them easier to read while I was working on the code, but I didn't mean to change them. I'll fix them so they're back to their original version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I believe both the old and new formats were wrong - based on https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_documentation_comments.html#bbcode-and-class-reference the
()should not be included and since these are methods they should be e.g.[method RetellingTownie.go_to_the_loom]rather than[member RetellingTownie.go_to_the_loom()]