class_name WmoRenderBuildJob
extends RefCounted

## Holds one lightweight-WMO build cursor and strong engine-object references.
## Releasing this record never frees the referenced Node or Resource.

var _placement_key: String
var _root: Node3D
var _render_resource: Resource
var _mesh_index: int = 0
var _multimesh_index: int = 0


func _init(placement_key: String, root: Node3D, render_resource: Resource) -> void:
	_placement_key = placement_key
	_root = root
	_render_resource = render_resource


## Returns the immutable placement identity used by the queue.
func placement_key() -> String:
	return _placement_key


## Returns the strongly referenced scene root without transferring ownership.
func root() -> Node3D:
	return _root


## Returns the strongly referenced render resource without transferring ownership.
func render_resource() -> Resource:
	return _render_resource


## Returns the current mesh-group cursor.
func mesh_index() -> int:
	return _mesh_index


## Returns the current doodad MultiMesh-group cursor.
func multimesh_index() -> int:
	return _multimesh_index


## Atomically adopts both cursor values returned by the pure step planner.
func adopt_cursors(next_mesh_index: int, next_multimesh_index: int) -> void:
	_mesh_index = next_mesh_index
	_multimesh_index = next_multimesh_index


## Returns detached scalar state and never exposes engine-object references.
func diagnostic_snapshot() -> Dictionary:
	return {
		"placement_key": _placement_key,
		"mesh_index": _mesh_index,
		"multimesh_index": _multimesh_index,
		"has_root": _root != null,
		"has_render_resource": _render_resource != null,
	}
