class_name FrameSkipper extends Node
## Disables child processing every N frames for some N

@export var frame_skip := 1

@onready var frame_counter := frame_skip


func _set_child_process_mode(mode: ProcessMode) -> void:
	for c: Node in get_children():
		c.process_mode = mode


func _process(_delta: float) -> void:
	if frame_counter == 0:
		_set_child_process_mode(Node.PROCESS_MODE_INHERIT)
		frame_counter = frame_skip
	else:
		_set_child_process_mode(Node.PROCESS_MODE_DISABLED)
		frame_counter -= 1
