Skip to content
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

Procedural node configuration #347

Closed
elementbound opened this issue Dec 7, 2024 · 0 comments · Fixed by #354
Closed

Procedural node configuration #347

elementbound opened this issue Dec 7, 2024 · 0 comments · Fixed by #354
Labels
feature New feature or request

Comments

@elementbound
Copy link
Contributor

elementbound commented Dec 7, 2024

✨ Description

Currently, netfox nodes have @exported variables to configure state and input to track and synchronize. These are arrays and can be manipulated.

It would be better to have more specialized options for configuring these properties.

Implementation notes

Procedural configuration

Implement the following methods:

  • StateSynchronizer::add_state(node, property)
  • TickInterpolator::add_property(node, property)
  • RollbackSynchronizer::add_state(node, property)
  • RollbackSynchronizer::add_input(node, property)

Each of these would add a new property to the appropriate configuration. They return true if a new property was added. If the property was already tracked, it they would return false without modifying anything. The node parameter can be a Node, a NodePath, or a string that can be used as a node path. The property parameter is a string, denoting the property name.

Example usage:

@onready var rollback_synchronizer := $RollbackSynchronizer as RollbackSynchronizer
@onready var input := $Input as Input

func _ready():
    rollback_synchronizer.add_state(self, "transform")
    rollback_synchronizer.add_state("", "velocity") # Same as self

    rollback_synchronizer.add_input(input, "movement")
    rollback_synchronizer.add_input("Input", "jump")

Exploration

To avoid having to call the above methods in _ready() or _enter_tree() ( and therefore making scene instantiation take more time ), netfox nodes should recognize nodes with state / input / interpolated properties and add them to their configuration from the editor. Preferably, there should be a way to trigger this exploration manually too.

The following methods should be recognized on any node:

  • _get_interpolated_properties()
  • _get_synchronized_state_properties()
  • _get_rollback_state_properties()
  • _get_rollback_input_properties()

These return arrays of tuples, that are then passed to the relevant methods from above. For example:

func _get_rollback_state_properties():
    return [
        [self, "transform"],
        ["", "velocity"]
    ]

func _get_rollback_input_properties():
    return [
        [input, "movement"],
        ["Input", "jump"]
    ]

In the editor, RollbackSynchronizer should call these methods and configure itself.

Use case

This would affect all current netfox nodes, so all games.

This API would be great for programmatically ensuring correct configuration and cutting down on manual effort. Expecting these to be mostly useful past the prototype phase, where any given mechanic is already solved, and the required properties are known in advance.

Distribution

netfox core

Notes

  • ❓ Should the add_* methods automatically process configuration?
@elementbound elementbound added feature New feature or request draft Not final labels Dec 7, 2024
@elementbound elementbound changed the title Procedural state and input configuration Procedural node configuration Dec 7, 2024
@elementbound elementbound removed the draft Not final label Dec 14, 2024
elementbound added a commit that referenced this issue Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant