示例#1
0
 public NBTag SerializeNBT()
 {
     NBTCompound tag = new NBTCompound( "Shape" );
     tag.Append( "Color", Color );
     NBTList points = new NBTList( "Points", NBTType.PointF, Points.Length );
     for( int p = 0; p < Points.Length; p++ ) {
         points[p] = new NBTag( NBTType.PointF, null, Points[p], points );
     }
     tag.Append( points );
     return tag;
 }
示例#2
0
        public NBTCompound SerializeNBT()
        {
            HasChangedSinceSave = false;
            NBTCompound tag = new NBTCompound( "SuperImageEvolver" );
            tag.Append( "FormatVersion", FormatVersion );
            tag.Append( "Shapes", Shapes );
            tag.Append( "Vertices", Vertices );
            tag.Append( "ImprovementCounter", ImprovementCounter );
            tag.Append( "MutationCounter", MutationCounter );
            tag.Append( "RiskyMoveCounter", RiskyMoveCounter );
            tag.Append( "ElapsedTime", DateTime.UtcNow.Subtract( TaskStart ).Ticks );

            tag.Append( ProjectOptions.SerializeNBT() );

            tag.Append( BestMatch.SerializeNBT( "BestMatch" ) );

            NBTag initializerTag = ModuleManager.WriteModule( "Initializer", Initializer );
            tag.Append( initializerTag );

            NBTag mutatorTag = ModuleManager.WriteModule( "Mutator", Mutator );
            tag.Append( mutatorTag );

            NBTag evaluatorTag = ModuleManager.WriteModule( "Evaluator", Evaluator );
            tag.Append( evaluatorTag );

            byte[] imageData;
            using( MemoryStream ms = new MemoryStream() ) {
                lock( OriginalImage ) {
                    OriginalImage.Save( ms, ImageFormat.Png );
                }
                ms.Flush();
                imageData = new byte[ms.Length];
                Buffer.BlockCopy( ms.GetBuffer(), 0, imageData, 0, imageData.Length );
            }

            tag.Append( "ImageData", imageData );

            List<NBTCompound> statTags = new List<NBTCompound>();
            foreach( MutationType mtype in Enum.GetValues( typeof( MutationType ) ) ) {
                NBTCompound stat = new NBTCompound( "MutationTypeStat" );
                stat.Append( "Type", mtype.ToString() );
                stat.Append( "Count", MutationCounts[mtype] );
                stat.Append( "Sum", MutationImprovements[mtype] );
                statTags.Add( stat );
            }
            var stats = new NBTList( "MutationStats", NBTType.Compound, statTags.ToArray() );
            tag.Append( stats );

            return tag;
        }
示例#3
0
 public NBTag SerializeNBT(string tagName)
 {
     NBTCompound compound = new NBTCompound(tagName);
     compound.Append("Divergence", Divergence);
     NBTList tag = new NBTList("Shapes", NBTType.Compound, Shapes.Length);
     for (int i = 0; i < Shapes.Length; i++) {
         tag[i] = Shapes[i].SerializeNBT();
     }
     compound.Append(tag);
     return compound;
 }