public void Save(IResource resource, object asset) { var procedure = asset as IChunkProcedure; componentBundleBuilder.Add(ComponentName, procedure); ComponentBundleDefinition definition; componentBundleBuilder.BuildDefinition(out definition); serializer.Serialize(resource, definition); }
public void Save(IResource resource, object asset) { var biomeManager = asset as IBiomeManager; // TODO // // アセット参照のプロパティをどうするのか? componentBundleBuilder.Add(ComponentName, biomeManager); ComponentBundleDefinition definition; componentBundleBuilder.BuildDefinition(out definition); serializer.Serialize(resource, definition); }
public void Save(IResource resource, object asset) { var noiseSource = asset as INoiseSource; // TODO // // アセット参照のプロパティをどうするのか? componentBundleBuilder.Add(ComponentName, noiseSource); ComponentBundleDefinition definition; componentBundleBuilder.BuildDefinition(out definition); serializer.Serialize(resource, definition); }
static void Main(string[] args) { //================================================================ // // Shared ComponentTypeRegistory // var typeRegistory = new ComponentTypeRegistory(); typeRegistory.SetTypeDefinitionName(typeof(SCurve5)); typeRegistory.SetTypeDefinitionName(typeof(Perlin)); typeRegistory.SetTypeDefinitionName(typeof(SumFractal)); typeRegistory.SetTypeDefinitionName(typeof(ScaleBias)); //================================================================ // // ComponentInfoManager // var componentInfoManager = new ComponentInfoManager(typeRegistory); //================================================================ // // ComponentBundleBuilder // var myNoise = new ScaleBias { Scale = 0.5f, Bias = 0.5f, Source = new SumFractal { Source = new Perlin { Seed = 300, FadeCurve = new SCurve5() } } }; var builder = new ComponentBundleBuilder(componentInfoManager); builder.Add("scaleBias", myNoise); //================================================================ // // Serialization // ComponentBundleDefinition definition; builder.BuildDefinition(out definition); var xmlSerializer = new XmlSerializerAdapter(typeof(ComponentBundleDefinition)); xmlSerializer.WriterSettings.Indent = true; xmlSerializer.WriterSettings.OmitXmlDeclaration = true; var resource = FileResourceLoader.Instance.LoadResource("file:///" + Directory.GetCurrentDirectory() + "/Noise.xml"); using (var stream = resource.Create()) { xmlSerializer.Serialize(stream, definition); } //================================================================ // // Deserialization // ComponentBundleDefinition deserializedDefinition; using (var stream = resource.Open()) { deserializedDefinition = (ComponentBundleDefinition)xmlSerializer.Deserialize(stream, null); } //================================================================ // // Exit // Console.WriteLine("Press Enter to exit."); Console.ReadLine(); }