Skip to content

ASStateUtils

PT | EN
Inherits: RefCounted

Utility functions for state management and serialization.

Description

ASStateUtils provides a comprehensive set of utility functions for working with [ASStateSnapshot] objects. Includes state comparison, serialization, compression, validation, and debugging capabilities.

These utilities are designed to support advanced features like:

  • Network optimization through state diffing and compression
  • Save/load system integration with binary serialization
  • Debugging and validation tools for state integrity
  • State analysis and comparison for testing

All functions are static and can be called without instantiation.

Methods

ReturnName
boolcompare_states( a: ASStateSnapshot, b: ASStateSnapshot) static
Performs deep equality comparison between two state snapshots.
PackedByteArraycompress_state( state: ASStateSnapshot) static
Compresses a state snapshot using compression algorithms. Significantly reduces data size for network bandwidth optimization.
floatcompute_state_difference( a: ASStateSnapshot, b: ASStateSnapshot) static
Computes a numerical difference score between two snapshots. Higher values indicate greater differences. Useful for state change detection.
ASStateSnapshotdecompress_state( data: PackedByteArray) static
Decompresses state snapshot data created by compress_state().
ASStateSnapshotdeserialize_state( data: PackedByteArray) static
Deserializes a state snapshot from binary data created by serialize_state().
voiddump_state( state: ASStateSnapshot) static
Prints detailed state information to the console for debugging.
Arrayget_validation_errors( state: ASStateSnapshot) static
Returns an array of validation error messages for a state snapshot. Empty array indicates no validation errors found.
PackedByteArrayserialize_state( state: ASStateSnapshot) static
Serializes a state snapshot to compact binary format. Optimized for network transmission and file storage.
Stringstate_to_string( state: ASStateSnapshot) static
Returns a compact string representation of the state snapshot. Useful for logging and quick state identification.
boolvalidate_state( state: ASStateSnapshot) static
Validates the integrity and consistency of a state snapshot. Checks for invalid data, corrupted values, and logical inconsistencies.

Constants

NameValue
ADD0
MULTIPLY1
DIVIDE2
OVERRIDE3