-
-
Notifications
You must be signed in to change notification settings - Fork 44
feat: Track and expose latest confirmed tick #518
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
b5f50ba
b5e8d6f
c72aa7f
26c679c
4df1031
3a51c30
e82043a
8be2429
537b04c
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 |
|---|---|---|
|
|
@@ -168,6 +168,7 @@ var _rollback_stage: String = "" | |
| var _is_rollback: bool = false | ||
| var _simulated_nodes: _Set = _Set.new() | ||
| var _mutated_nodes: Dictionary = {} | ||
| var _input_submissions: Dictionary = {} | ||
|
|
||
| const _STAGE_BEFORE := "B" | ||
| const _STAGE_PREPARE := "P" | ||
|
|
@@ -266,6 +267,35 @@ func is_just_mutated(target: Object, p_tick: int = tick) -> bool: | |
| else: | ||
| return false | ||
|
|
||
| ## Register that a node has submitted its input for a specific tick | ||
| func register_input_submission(root_node: Node, tick: int) -> void: | ||
| if not _input_submissions.has(root_node): | ||
| _input_submissions[root_node] = tick | ||
| else: | ||
| _input_submissions[root_node] = maxi(_input_submissions[root_node], tick) | ||
|
|
||
| ## Get the latest input tick submitted by a specific root node | ||
| ## [br][br] | ||
| ## Returns [code]-1[/code] if no input was submitted for the node, ever. | ||
| func get_latest_input_tick(root_node: Node) -> int: | ||
| if _input_submissions.has(root_node): | ||
| return _input_submissions[root_node] | ||
| return -1 | ||
|
|
||
| ## Get all root nodes that have submitted input | ||
| func get_input_submissions() -> Dictionary: | ||
|
Contributor
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. Do we want to keep this as a dictionary, or is it OK to expose an array of nodes that have inputs?
Contributor
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. Keep as a dictionary so the user can use however they want.
Contributor
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. That's fair. I'm a bit concerned that exposing this as-is can bite us in the back later on. The thinking is that we're exposing the underlying data structure, and if that changes, that would break compatibility. One option is to just not change the data structure 😄 at least until v2. Another one is exchange this method to something that lists all the nodes, plus a method that gets the exact tick for a node. What do you think?
Contributor
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 easy. It's not strictly needed so removing might be a better option. There's no private variables in Godot so it's not like we're restricting access if someone wants to use it. |
||
| return _input_submissions | ||
|
|
||
| ## Check if a node has submitted input for a specific tick (or later) | ||
| func has_input_for_tick(root_node: Node, tick: int) -> bool: | ||
| return _input_submissions.has(root_node) and _input_submissions[root_node] >= tick | ||
|
|
||
| ## Free all input submission data for a node | ||
| ## [br][br] | ||
| ## Use this once the node is freed. | ||
| func free_input_submission_data_for(root_node: Node) -> void: | ||
| _input_submissions.erase(root_node) | ||
|
|
||
| func _ready(): | ||
| NetfoxLogger.register_tag(_get_rollback_tag) | ||
| NetworkTime.after_tick_loop.connect(_rollback) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.