ASStateUtils
Inherits:
RefCountedUtility 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
| Return | Name |
|---|---|
bool | compare_states(
a: ASStateSnapshot, b: ASStateSnapshot)
static |
Performs deep equality comparison between two state snapshots. | |
PackedByteArray | compress_state(
state: ASStateSnapshot)
static |
Compresses a state snapshot using compression algorithms.
Significantly reduces data size for network bandwidth optimization. | |
float | compute_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. | |
ASStateSnapshot | decompress_state(
data: PackedByteArray)
static |
Decompresses state snapshot data created by compress_state(). | |
ASStateSnapshot | deserialize_state(
data: PackedByteArray)
static |
Deserializes a state snapshot from binary data created by serialize_state(). | |
void | dump_state(
state: ASStateSnapshot)
static |
Prints detailed state information to the console for debugging. | |
Array | get_validation_errors(
state: ASStateSnapshot)
static |
Returns an array of validation error messages for a state snapshot.
Empty array indicates no validation errors found. | |
PackedByteArray | serialize_state(
state: ASStateSnapshot)
static |
Serializes a state snapshot to compact binary format.
Optimized for network transmission and file storage. | |
String | state_to_string(
state: ASStateSnapshot)
static |
Returns a compact string representation of the state snapshot.
Useful for logging and quick state identification. | |
bool | validate_state(
state: ASStateSnapshot)
static |
Validates the integrity and consistency of a state snapshot.
Checks for invalid data, corrupted values, and logical inconsistencies. | |
Constants
| Name | Value |
|---|---|
| ADD | 0 |
| MULTIPLY | 1 |
| DIVIDE | 2 |
| OVERRIDE | 3 |