class_name EntityId
extends RefCounted

## Session-local runtime entity identity.
## This sequence is never a stable content ID, server entry or WoW wire GUID.

var session_sequence: int:
	get:
		return _session_sequence

var _session_sequence: int


## Stores an allocator-issued session sequence without persistence semantics.
func _init(session_sequence_value: int) -> void:
	_session_sequence = session_sequence_value


## Reports whether this is a positive allocator-issued sequence.
func is_valid() -> bool:
	return _session_sequence > 0


## Compares identity inside the same explicitly owned runtime session.
func equals(other_entity_id: EntityId) -> bool:
	return other_entity_id != null and _session_sequence == other_entity_id.session_sequence


## Returns a diagnostic key; it must not be persisted across sessions.
func to_debug_key() -> String:
	return "entity:%d" % _session_sequence
