public static GameObjectsSnapshot Deserialize(byte[] input) { if (input == null || input.Length == 0) return null; GameObjectsSnapshot result = new GameObjectsSnapshot(); ComposedByteStream stream = ComposedByteStream.FromByteArray(CLZF.Decompress(input)); result.gameObjects = ExposedGameObject.DeserializeArray(stream.ReadNextStream<byte>()); result.components = ExposedComponent.DeserializeArray(stream.ReadNextStream<byte>()); stream.Dispose(); return result; }
//--------------- Serialize / Deserialize -------------------- public static byte[] Serialize(GameObjectsSnapshot input) { if (input == null) return null; ComposedByteStream stream = ComposedByteStream.FetchStream(2); stream.AddStream(ExposedGameObject.SerializeArray(input.gameObjects)); stream.AddStream(ExposedComponent.SerializeArray(input.components)); return CLZF.Compress(stream.Compose()); }
//Todo:Add material data and make all dispose calls recursive. public override void Dispose() { base.Dispose(); if (header != null) header.Dispose(); if (systemInfo != null) systemInfo.Dispose(); if (debugLogs != null) debugLogs.Dispose(); if (humanInput != null) humanInput.Dispose(); if (meshData != null) meshData.Dispose(); if (particleData != null) particleData.Dispose(); if (materialData != null) materialData.Dispose(); if (gameObjectsSnapshot != null) gameObjectsSnapshot.Dispose(); header = null; systemInfo = null; debugLogs = null; humanInput = null; meshData = null; particleData = null; materialData = null; gameObjectsSnapshot = null; screenCapture = null; }