public static LevelData LoadLevel(byte[] data) { LevelData levelData = BinaryClassChunk.FromData <LevelData>(new BitBuffer(data, false)); if (levelData != null && levelData.GetResult() != DeserializeResult.InvalidMagicNumber) { return(levelData); } Promise <LevelData> promise = Tasker.Task <LevelData>((Func <LevelData>)(() => DuckFile.ConvertLevel(data))); promise.WaitForComplete(); return(promise.Result); }
public static T LoadChunk <T>(string path) where T : BinaryClassChunk { DuckFile.CreatePath(Path.GetDirectoryName(path)); DuckFile.PrepareToLoadCloudFile(path); return(!File.Exists(path) ? default(T) : BinaryClassChunk.FromData <T>(new BitBuffer(File.ReadAllBytes(path), 0, false))); }