- Refactored VibrationComponent (RumbleComponent) -- Now supports multiple vibrations and adjustable curves. -- Inspired by the RumblePak addon. - Added a new startup scene.
27 lines
833 B
GDScript
27 lines
833 B
GDScript
class_name InstancePersister
|
|
|
|
var _node: Node
|
|
var _world: World
|
|
var _node_hash: String = ""
|
|
|
|
|
|
func _init(node: Node, world: World) -> void:
|
|
assert(is_instance_valid(world),
|
|
"'world' must be valid. Are you sure you have defined/set the reference correctly?")
|
|
_node = node
|
|
_node_hash = str(world.get_path_to(node).hash())
|
|
_world = world
|
|
_world.store_instance_state(str(_node_hash), world.get_path_to(node))
|
|
|
|
|
|
func get_property(property: StringName, default: Variant) -> Variant:
|
|
return _world.get_instance_state(str(_node_hash, ":", property), default)
|
|
|
|
|
|
func set_property_auto(property: StringName) -> void:
|
|
_world.store_instance_state(str(_node_hash, ":", property), _node.get(property))
|
|
|
|
|
|
func set_property(property: StringName, value: Variant) -> void:
|
|
_world.store_instance_state(str(_node_hash, ":", property), value)
|