Files
open-wc/src/domain/identity/wow_guid.gd
T
sindoring c1dc07c705 feat(M01): add typed domain identities
Work-Package: M01-FND-DOMAIN-IDENTITIES-001

Agent: sindo-main-codex
2026-07-13 16:11:00 +04:00

54 lines
1.5 KiB
GDScript

class_name WowGuid
extends RefCounted
## Opaque 64-bit WoW wire GUID stored as two lossless unsigned 32-bit words.
## Build-specific high-type decoding belongs to the protocol adapter and must be
## fixture-backed before becoming a domain contract.
const MAXIMUM_UNSIGNED_32_BIT_VALUE := 0xffffffff
var high_32_bits: int:
get:
return _high_32_bits
var low_32_bits: int:
get:
return _low_32_bits
var _high_32_bits: int
var _low_32_bits: int
## Preserves both wire words without signed 64-bit conversion.
func _init(high_32_bits_value: int, low_32_bits_value: int) -> void:
_high_32_bits = high_32_bits_value
_low_32_bits = low_32_bits_value
## Reports whether both words fit their unsigned wire ranges.
func has_valid_word_ranges() -> bool:
return _is_unsigned_32_bit_word(_high_32_bits) and _is_unsigned_32_bit_word(_low_32_bits)
## Reports the all-zero protocol sentinel without assigning gameplay meaning.
func is_empty() -> bool:
return _high_32_bits == 0 and _low_32_bits == 0
## Compares all 64 opaque wire bits.
func equals(other_wow_guid: WowGuid) -> bool:
return (
other_wow_guid != null
and _high_32_bits == other_wow_guid.high_32_bits
and _low_32_bits == other_wow_guid.low_32_bits
)
## Returns exactly sixteen lowercase hexadecimal digits for diagnostics/replays.
func to_hex_string() -> String:
return "%08x%08x" % [_high_32_bits, _low_32_bits]
func _is_unsigned_32_bit_word(word_value: int) -> bool:
return word_value >= 0 and word_value <= MAXIMUM_UNSIGNED_32_BIT_VALUE