/// <summary> /// Saves the data into the given <paramref name="stream"/>. /// </summary> /// <param name="stream">The <see cref="Stream"/> to save the data to.</param> public void Save(Stream stream) { // Before saving all the instances, allow references to be resolved. Areas?.ForEach(x => x.SerializeReferences(this)); EnemyPaths?.ForEach(x => x.SerializeReferences(this)); GCameraPaths?.ForEach(x => x.SerializeReferences(this)); GlidePaths?.ForEach(x => x.SerializeReferences(this)); GravityPaths?.ForEach(x => x.SerializeReferences(this)); ItemPaths?.ForEach(x => x.SerializeReferences(this)); JugemPaths?.ForEach(x => x.SerializeReferences(this)); LapPaths?.ForEach(x => x.SerializeReferences(this)); PullPaths?.ForEach(x => x.SerializeReferences(this)); Objs.ForEach(x => x.SerializeReferences(this)); ReplayCameras?.ForEach(x => x.SerializeReferences(this)); // Save the serialized values. ByamlSerializer serializer = new ByamlSerializer(new ByamlSerializerSettings() { SupportPaths = true, Version = ByamlVersion.Version1 }); serializer.Serialize(stream, this); }
// ---- METHODS(PUBLIC) --------------------------------------------------------------------------------------- /// <summary> /// Loads the data from the given <paramref name="stream"/>. /// </summary> /// <param name="stream">The <see cref="Stream"/> to load the data from.</param> public void Load(Stream stream) { // Load all the values from the stream. ByamlSerializer serializer = new ByamlSerializer(new ByamlSerializerSettings() { SupportPaths = true, Version = ByamlVersion.Version1 }); serializer.Deserialize(stream, this); // After loading all the instances, allow references to be resolved. Areas?.ForEach(x => x.DeserializeReferences(this)); EnemyPaths?.ForEach(x => x.DeserializeReferences(this)); GCameraPaths?.ForEach(x => x.DeserializeReferences(this)); GlidePaths?.ForEach(x => x.DeserializeReferences(this)); GravityPaths?.ForEach(x => x.DeserializeReferences(this)); ItemPaths?.ForEach(x => x.DeserializeReferences(this)); JugemPaths?.ForEach(x => x.DeserializeReferences(this)); LapPaths?.ForEach(x => x.DeserializeReferences(this)); ObjPaths?.ForEach(x => x.DeserializeReferences(this)); Paths?.ForEach(x => x.DeserializeReferences(this)); PullPaths?.ForEach(x => x.DeserializeReferences(this)); Objs.ForEach(x => x.DeserializeReferences(this)); ReplayCameras?.ForEach(x => x.DeserializeReferences(this)); }