Skip to content

Procedural node configuration #347

@elementbound

Description

@elementbound

✨ 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions