class_name M2BuildResourceSnapshot
extends RefCounted

## Holds one M2 build-step resource observation without owning engine lifetime.

var _normalized_relative_path: String
var _animated_prototype: Node3D
var _animation_request_pending: bool
var _static_mesh: Mesh = null
var _static_model_missing: bool = false


func _init(
	normalized_relative_path: String,
	animated_prototype: Node3D,
	animation_request_pending: bool
) -> void:
	_normalized_relative_path = normalized_relative_path
	_animated_prototype = animated_prototype
	_animation_request_pending = animation_request_pending


## Returns the normalized M2 path observed by the loader.
func normalized_relative_path() -> String:
	return _normalized_relative_path


## Returns the borrowed animated prototype without transferring ownership.
func animated_prototype() -> Node3D:
	return _animated_prototype


## Returns whether an animated prototype was observed.
func has_animated_prototype() -> bool:
	return _animated_prototype != null


## Returns whether the animation request remains pending.
func animation_request_pending() -> bool:
	return _animation_request_pending


## Adopts the optional static Mesh and terminal missing-model observation.
func adopt_static_observation(static_mesh: Mesh, static_model_missing: bool) -> void:
	_static_mesh = static_mesh
	_static_model_missing = static_model_missing


## Returns the borrowed static Mesh without transferring ownership.
func static_mesh() -> Mesh:
	return _static_mesh


## Returns whether a prepared static Mesh was observed.
func has_static_mesh() -> bool:
	return _static_mesh != null


## Returns whether the static model lookup reached a terminal missing outcome.
func static_model_missing() -> bool:
	return _static_model_missing


## Returns detached path/availability diagnostics without engine references.
func diagnostic_snapshot() -> Dictionary:
	return {
		"normalized_relative_path": _normalized_relative_path,
		"has_animated_prototype": has_animated_prototype(),
		"animation_request_pending": _animation_request_pending,
		"has_static_mesh": has_static_mesh(),
		"static_model_missing": _static_model_missing,
	}
