internal void Write(ContentWriter output)
        {
            output.Write(name);
            output.WriteObject<TimeSpan>(duration);

            // Write animation clip channels
            output.Write(channels.Count);
            foreach (KeyValuePair<string, AnimationChannelContent> pair in channels)
            {
                output.Write(pair.Key);
                AnimationChannelContent animationChannel = pair.Value;

                // Write the animation channel keyframes
                output.Write(animationChannel.Count);
                foreach (AnimationKeyframeContent keyframe in animationChannel)
                {
                    output.WriteObject<TimeSpan>(keyframe.Time);

                    // Write pose
                    output.Write(keyframe.Pose.Translation);
                    output.Write(keyframe.Pose.Orientation);
                    output.Write(keyframe.Pose.Scale);
                }
            }
        }
 internal void Write(ContentWriter output)
 {
     output.Write(numVertices);
     output.Write(numTriangles);
     output.WriteObject<VertexBufferContent>(vertices);
     output.WriteObject<IndexCollection>(indices);
     output.WriteObject<MaterialContent>(material);
 }
Example #3
0
 public void write(ContentWriter output)
 {
     output.Write(m_width);
     output.Write(m_height);
     for (int x = 0; x < m_width; x++) {
         for (int y = 0; y < m_height; y++) {
             output.Write(m_verts[x, y]);
         }
     }
 }
Example #4
0
 //Simple helper method for handling developer IDs
 public void DeveloperIDWriter(ContentWriter output, object obj)
 {
     if (obj != null && Did.ContainsKey(obj))
     {
         output.Write(true);
         output.Write(Did[obj]);
     }
     else
     {
         output.Write(false);
     }
 }
Example #5
0
        public static void WritePropertyBlock(ContentWriter output, IEnumerable<Property> properties)
        {
            short pcount = 0;
            foreach (Property p in properties) {
                pcount++;
            }

            output.Write((short)pcount);
            foreach (Property p in properties) {
                output.Write(p.Name);
                output.Write(p.ToString());
            }
        }
        private void WriteAnimationClips(ContentWriter output)
        {
            output.Write(animationClips.Count);
            foreach (AnimationClipContent animationClipContent in animationClips.Values)
                output.WriteSharedResource(animationClipContent);

            /*
            foreach (AnimationClipContent animationTrack in animationClips.Values)
            {
                output.Write(animationTrack.Name);
                output.WriteObject<TimeSpan>(animationTrack.Duration);

                output.Write(animationTrack.Channels.Count);
                foreach (KeyValuePair<string, AnimationChannelContent> pairKeyChannel in
                    animationTrack.Channels)
                {
                    output.Write(pairKeyChannel.Key);
                    output.Write(pairKeyChannel.Value.Count);
                    foreach (AnimationKeyframeContent keyframe in pairKeyChannel.Value)
                    {
                        output.WriteObject<TimeSpan>(keyframe.Time);
                        output.Write(keyframe.Transform);
                    }
                }
            }
             */
        }
Example #7
0
 private void WriteBones(ContentWriter output)
 {
     output.Write(skeleton.Count);
     foreach (SkinnedModelBoneContent bone in skeleton)
     {
         output.WriteSharedResource(bone);
     }
 }
Example #8
0
 private void WriteAnimationClips(ContentWriter output)
 {
     output.Write(animationClips.Count);
     foreach (AnimationClipContent animationClipContent in animationClips.Values)
     {
         output.WriteSharedResource(animationClipContent);
     }
 }
        /// <summary>
        /// Saves instanced model data into an XNB file.
        /// </summary>
        public void Write(ContentWriter output)
        {
            output.Write(modelParts.Count);

            foreach (ModelPart modelPart in modelParts)
            {
                output.Write(modelPart.IndexCount);
                output.Write(modelPart.VertexCount);
                output.Write(modelPart.VertexStride);

                output.WriteObject(modelPart.VertexElements);
                output.WriteObject(modelPart.VertexBufferContent);
                output.WriteObject(modelPart.IndexCollection);

                output.WriteSharedResource(modelPart.MaterialContent);
            }
        }
Example #10
0
 private void WriteMeshes(ContentWriter output)
 {
     output.Write(meshes.Count);
     for (int i = 0; i < meshes.Count; i++)
     {
         output.WriteObject<SkinnedModelMeshContent>(meshes[i]);
     }
 }
        private void WriteBones(ContentWriter output)
        {
            output.Write(skeleton.Count);
            foreach (SkinnedModelBoneContent bone in skeleton)
                //{
                output.WriteSharedResource(bone);
            /*
                output.Write(skeleton[i].Name);
                output.Write(skeleton[i].BindPoseTransform);
                output.Write(skeleton[i].InverseBindPoseTransform);

                output.WriteSharedResource(skeleton[i].Parent);

                // Write children
                output.Write(skeleton[i].Children.Count);
                for (int j = 0; j < skeleton.Count; j++)
                {
                    output.WriteSharedResource(skeleton[i].Children[j]);
                }
                 */
            //}
            /*
            // Write root bone
            output.Write(rootBoneContent.Name);

            // Write each bone
            output.Write(skinnedModelBoneContentDictionary.Values.Count);
            foreach (SkinnedModelBoneContent bone in skinnedModelBoneContentDictionary.Values)
            {
                output.Write(bone.Name);
                output.Write(bone.Transform);
                output.Write(bone.AbsoluteTransform);
                output.Write(bone.InverseBindPoseTransform);
            }

            // Write the parent and children of each bone
            foreach (SkinnedModelBoneContent bone in skinnedModelBoneContentDictionary.Values)
            {
                string parentBoneName = null;
                if (bone.Parent != null)
                    parentBoneName = bone.Parent.Name;
                output.WriteObject<string>(parentBoneName);

                // Children
                output.Write(bone.Children.Count);
                foreach (SkinnedModelBoneContent childBbone in bone.Children)
                    output.Write(childBbone.Name);
            }
             */
        }
        /// <summary>
        /// Saves custom model data into an XNB file.
        /// </summary>
        public void Write( ContentWriter output )
        {
            output.Write( modelParts.Count );

              foreach ( ModelPart modelPart in modelParts )
              {
            // Simple data types like integers can be written directly.
            output.Write( modelPart.TriangleCount );
            output.Write( modelPart.VertexCount );
            output.Write( modelPart.VertexStride );

            // These design time graphics types will be automatically translated
            // into actual GPU data types when they are loaded back in at runtime.
            output.WriteObject( modelPart.VertexElements );
            output.WriteObject( modelPart.VertexBufferContent );
            output.WriteObject( modelPart.IndexCollection );

            // A single material instance may be shared by more than one ModelPart,
            // in which case we only want to write a single copy of the material
            // data into the XNB file. The WriteSharedResource method takes care
            // of this merging for us.
            output.WriteSharedResource( modelPart.MaterialContent );
              }
        }
        internal void Write(ContentWriter output)
        {
            output.Write(index);
            output.Write(name);

            // Write bind pose
            output.Write(bindPose.Translation);
            output.Write(bindPose.Orientation);
            output.Write(bindPose.Scale);

            output.Write(inverseBindPoseTransform);

            // Write parent and children
            output.WriteSharedResource(parent);
            output.Write(children.Count);
            foreach (SkinnedModelBoneContent childBone in children)
                output.WriteSharedResource(childBone);
        }
Example #14
0
        protected override void Write(ContentWriter output, PlayerData value)
        {
            var json = JsonConvert.SerializeObject(value.json);

            output.Write(json);
        }
Example #15
0
        protected override void Write(ContentWriter writer, TmxMap map)
        {
            int largestTileWidth = 0, largestTileHeight = 0;

            foreach (var tileset in map.tilesets)
            {
                largestTileWidth  = Math.Max(largestTileWidth, tileset.tileWidth);
                largestTileHeight = Math.Max(largestTileHeight, tileset.tileHeight);
            }

            writer.Write(hexToColor(map.backgroundColor));
            writer.Write(map.renderOrder.ToString());
            writer.Write(map.firstGid);
            writer.Write(map.width);
            writer.Write(map.height);
            writer.Write(map.tileWidth);
            writer.Write(map.tileHeight);
            writer.Write(Convert.ToInt32(map.orientation));
            writer.Write(largestTileWidth);
            writer.Write(largestTileHeight);
            writeCustomProperties(writer, map.properties);

            writer.Write(map.tilesets.Count);
            foreach (var tileset in map.tilesets)
            {
                if (tileset.image != null)
                {
                    TiledMapProcessor.logger.LogMessage("\nExpecting texture asset: {0}\n", tileset.image.source);
                }

                writer.Write(tileset.isStandardTileset);

                if (tileset.image != null)
                {
                    writer.Write(removeExtension(tileset.image.source));
                }
                else
                {
                    writer.Write(string.Empty);
                }

                writer.Write(tileset.firstGid);
                writer.Write(tileset.tileWidth);
                writer.Write(tileset.tileHeight);
                writer.Write(tileset.spacing);
                writer.Write(tileset.margin);
                writeCustomProperties(writer, tileset.properties);

                writer.Write(tileset.tiles.Count);
                foreach (var tile in tileset.tiles)
                {
                    TiledMapProcessor.logger.LogMessage("writing tile: {0}", tile);
                    writer.Write(tile.id);

                    // animation frames
                    writer.Write(tile.animationFrames.Count);
                    foreach (var anim in tile.animationFrames)
                    {
                        writer.Write(anim.tileId);
                        writer.Write(anim.duration);
                    }

                    // image is optional
                    if (tile.image != null)
                    {
                        writer.Write(true);
                        writer.Write(tile.sourceRect.X);
                        writer.Write(tile.sourceRect.Y);
                        writer.Write(tile.sourceRect.Width);
                        writer.Write(tile.sourceRect.Height);
                    }
                    else
                    {
                        writer.Write(false);
                    }

                    writer.Write(tile.objectGroups.Count);
                    foreach (var group in tile.objectGroups)
                    {
                        writeObjectGroup(writer, group);
                    }

                    writeCustomProperties(writer, tile.properties);
                }
            }


            writer.Write(map.layers.Count);
            foreach (var layer in map.layers)
            {
                writer.Write(layer.name);
                writer.Write(layer.visible);
                writer.Write(layer.opacity);
                writer.Write(new Vector2(layer.offsetx, layer.offsety));

                var tileLayer = layer as TmxTileLayer;
                if (tileLayer != null)
                {
                    writer.Write((int)TiledLayerType.Tile);
                    writer.Write(tileLayer.data.tiles.Count);
                    foreach (var tile in tileLayer.data.tiles)
                    {
                        // Read out the flags
                        var flippedHorizontally = (tile.gid & FLIPPED_HORIZONTALLY_FLAG) != 0;
                        var flippedVertically   = (tile.gid & FLIPPED_VERTICALLY_FLAG) != 0;
                        var flippedDiagonally   = (tile.gid & FLIPPED_DIAGONALLY_FLAG) != 0;

                        if (flippedHorizontally || flippedVertically || flippedDiagonally)
                        {
                            // Clear the flags
                            tile.gid &= ~(FLIPPED_HORIZONTALLY_FLAG | FLIPPED_VERTICALLY_FLAG | FLIPPED_DIAGONALLY_FLAG);
                            tile.flippedHorizontally = flippedHorizontally;
                            tile.flippedVertically   = flippedVertically;
                            tile.flippedDiagonally   = flippedDiagonally;
                        }
                        writer.Write(tile.gid);
                        writer.Write(tile.flippedHorizontally);
                        writer.Write(tile.flippedVertically);
                        writer.Write(tile.flippedDiagonally);
                    }

                    writer.Write(tileLayer.width);
                    writer.Write(tileLayer.height);
                }

                var imageLayer = layer as TmxImageLayer;
                if (imageLayer != null)
                {
                    writer.Write((int)TiledLayerType.Image);
                    writer.Write(removeExtension(imageLayer.image.source));

                    TiledMapProcessor.logger.LogMessage("Expecting texture asset: {0}\n", imageLayer.image.source);
                }

                writeCustomProperties(writer, layer.properties);
                TiledMapProcessor.logger.LogMessage("done writing Layer: {0}", layer);
            }

            writer.Write(map.objectGroups.Count);
            foreach (var group in map.objectGroups)
            {
                writeObjectGroup(writer, group);
            }
        }
Example #16
0
 protected override void Write(ContentWriter output, Vector2D value)
 {
     output.Write(value.X);
     output.Write(value.Y);
 }
Example #17
0
 void WriteRectangleObject(ContentWriter output) =>
 output.Write((byte)TiledObjectType.Rectangle);
Example #18
0
 void WritePolygonObject(ContentWriter output, TiledPolygonObject obj)
 {
     output.Write((byte)TiledObjectType.Polygon);
     output.Write(obj.Closed);
     output.WriteObject(obj.Points);
 }
Example #19
0
 public static void Write(this ContentWriter output, IntVec v)
 {
     output.Write(v.X);
     output.Write(v.Y);
 }
        protected override void Write(ContentWriter writer, ParticleDesignerProcessorResult value)
        {
            var emissionRate = value.particleEmitterConfig.maxParticles / value.particleEmitterConfig.particleLifeSpan;

            if (float.IsInfinity(emissionRate))
            {
                ParticleDesignerProcessor.logger.LogMessage("---- emissionRate (maxParticles / particleLifespace) is infinity. Resetting to 10000");
                emissionRate = 10000;
            }

            // Write out all the members
            writer.Write((Vector2)value.particleEmitterConfig.sourcePosition);
            writer.Write((Vector2)value.particleEmitterConfig.sourcePositionVariance);
            writer.Write(value.particleEmitterConfig.speed.value);
            writer.Write(value.particleEmitterConfig.speedVariance.value);
            writer.Write(value.particleEmitterConfig.particleLifeSpan.value);
            writer.Write(value.particleEmitterConfig.particleLifespanVariance.value);
            writer.Write(value.particleEmitterConfig.angle.value);
            writer.Write(value.particleEmitterConfig.angleVariance.value);
            writer.Write((Vector2)value.particleEmitterConfig.gravity);
            writer.Write(value.particleEmitterConfig.radialAcceleration.value);
            writer.Write(value.particleEmitterConfig.radialAccelVariance.value);
            writer.Write(value.particleEmitterConfig.tangentialAcceleration.value);
            writer.Write(value.particleEmitterConfig.tangentialAccelVariance.value);
            writer.Write(value.particleEmitterConfig.startColor);
            writer.Write(value.particleEmitterConfig.startColorVariance);
            writer.Write(value.particleEmitterConfig.finishColor);
            writer.Write(value.particleEmitterConfig.finishColorVariance);
            writer.Write(value.particleEmitterConfig.maxParticles.value);
            writer.Write(value.particleEmitterConfig.startParticleSize.value);
            writer.Write(value.particleEmitterConfig.startParticleSizeVariance.value);
            writer.Write(value.particleEmitterConfig.finishParticleSize.value);
            writer.Write(value.particleEmitterConfig.finishParticleSizeVariance.value);
            writer.Write(value.particleEmitterConfig.duration.value);
            writer.Write(value.particleEmitterConfig.emitterType.value);

            writer.Write(value.particleEmitterConfig.maxRadius.value);
            writer.Write(value.particleEmitterConfig.maxRadiusVariance.value);
            writer.Write(value.particleEmitterConfig.minRadius.value);
            writer.Write(value.particleEmitterConfig.minRadiusVariance.value);
            writer.Write(value.particleEmitterConfig.rotatePerSecond.value);
            writer.Write(value.particleEmitterConfig.rotatePerSecondVariance.value);

            writer.Write(value.particleEmitterConfig.rotationStart.value);
            writer.Write(value.particleEmitterConfig.rotationStartVariance.value);
            writer.Write(value.particleEmitterConfig.rotationEnd.value);
            writer.Write(value.particleEmitterConfig.rotationEndVariance.value);
            writer.Write(emissionRate);
            writer.Write((int)blendForParticleDesignerInt(value.particleEmitterConfig.blendFuncSource));
            writer.Write((int)blendForParticleDesignerInt(value.particleEmitterConfig.blendFuncDestination));

            // use raw tiff data for now
            writer.WriteObject(value.texture);

                        #if USE_RAW_TIFFS
            if (value.textureTiffData != null)
            {
                writer.Write(value.textureTiffData.Length);
                writer.Write(value.textureTiffData);
            }
            else
            {
                writer.Write(0);
            }
                        #endif
        }
        protected override void Write(ContentWriter output, PaletteMaterialContent value)
        {
            output.WriteRawObject <byte[]>(value.ByteCode);
            output.Write(value.PaletteSize);
            bool hasTexture = value.Textures.ContainsKey("Texture");

            output.Write(hasTexture);
            if (hasTexture)
            {
                output.WriteExternalReference <TextureContent>(value.Textures["Texture"]);
            }
            output.Write(value.SpecularPower != null);
            if (value.SpecularPower != null)
            {
                output.Write((float)value.SpecularPower);
            }
            output.Write(value.SpecularColor != null);
            if (value.SpecularColor != null)
            {
                output.Write((Vector3)value.SpecularColor);
            }
            output.Write(value.EmissiveColor != null);
            if (value.EmissiveColor != null)
            {
                output.Write((Vector3)value.EmissiveColor);
            }
            output.Write(value.DiffuseColor != null);
            if (value.DiffuseColor != null)
            {
                output.Write((Vector3)value.DiffuseColor);
            }
            output.Write(value.Alpha != null);
            if (value.Alpha != null)
            {
                output.Write((float)value.Alpha);
            }
        }
Example #22
0
        protected override void Write(ContentWriter output, ProcessedAseprite value)
        {
            AsepriteFile aseprite = value.Aseprite;

            output.Write(aseprite.Width);
            output.Write(aseprite.Height);

            // Layers
            output.Write(aseprite.Layers.Count);

            foreach (var layer in aseprite.Layers)
            {
                output.Write(layer.Name);
                output.Write(layer.Opacity);
                output.Write((int)layer.BlendMode);
                output.Write(layer.Flag.HasFlag(AsepriteLayer.Flags.Visible));
            }

            // Frames
            output.Write(aseprite.Frames.Count);
            var f = 0;

            foreach (var frame in aseprite.Frames)
            {
                output.Write(frame.Duration);
                output.Write(frame.Cels.Count);

                for (int i = 0; i < frame.Cels.Count; i++)
                {
                    var cel = frame.Cels[i];
                    output.Write(aseprite.Layers.IndexOf(cel.Layer));
                    output.Write(cel.X);
                    output.Write(cel.Y);
                    output.Write(cel.Width);
                    output.Write(cel.Height);

                    for (int celY = 0; celY < cel.Height; celY++)
                    {
                        for (int celX = 0; celX < cel.Width; celX++)
                        {
                            int ind = celX + celY * cel.Width;
                            output.Write(cel.Pixels[ind]);
                        }
                    }
                }

                f++;
            }

            // Animations
            output.Write(aseprite.Tags.Count);

            foreach (var animation in aseprite.Tags)
            {
                output.Write(animation.Name);
                output.Write(animation.From);
                output.Write(animation.To);
                output.Write((byte)animation.LoopDirection);
            }
        }
        /// <summary>
        /// Write the binary (xnb) file corresponding to the supplied
        /// TilesetContent that will be imported into our game
        /// as a Tileset
        /// </summary>
        /// <param name="output">The ContentWriter that writes the binary output</param>
        /// <param name="value">The TilesetContent we are writing</param>
        protected override void Write(ContentWriter output, TWrite value)
        {
            // We only need to write the data that is needed in-game.
            // For the TiledSpriteSheet, this is the texture and the tiles.
            // Everything else can be thrown away at this point.

            // Write the texture
            output.WriteObject <TextureContent>(value.Texture);

            // Write the tile width & height
            output.Write(value.TileWidth);
            output.Write(value.TileHeight);
            output.Write(value.Margin);
            output.Write(value.Spacing);

            // Write the number of tiles - this will be used to
            // specify the expected number of tiles in the reader
            output.Write(value.TileCount);

            // Write the individual tile data
            for (int i = 0; i < value.TileCount; i++)
            {
                // We only need to specify the X and Y of the source
                // rectangles, as they are all the same width and height
                var tile = value.Tiles[i];
                output.Write(tile.Source.X);
                output.Write(tile.Source.Y);
                output.Write(tile.BoxCollisions.Count);
                foreach (KeyValuePair <string, List <Box> > pair in tile.BoxCollisions)
                {
                    output.Write(pair.Key);
                    output.Write(pair.Value.Count);
                    foreach (Box box in pair.Value)
                    {
                        output.Write(box.Col.X);
                        output.Write(box.Col.Y);
                        output.Write(box.Col.Width);
                        output.Write(box.Col.Height);
                        output.Write(box.TriggerOnly);
                        output.Write(box.Name);
                    }
                }
                output.Write(tile.Animation.Name);
                output.Write(tile.Animation.Frames.Count);
                foreach (Frame frame in tile.Animation.Frames)
                {
                    output.Write(frame.Source.X);
                    output.Write(frame.Source.Y);
                    output.Write(frame.Source.Width);
                    output.Write(frame.Source.Height);
                    output.Write(frame.Duration);
                    output.Write(frame.Id);
                }
                output.Write(tile.Properties.Count);
                foreach (KeyValuePair <string, string> prop in tile.Properties)
                {
                    output.Write(prop.Key);
                    output.Write(prop.Value);
                }
            }
        }
        protected override void Write(ContentWriter writer, LibGdxAtlasProcessorResult result)
        {
            var data = result.data;

            LibGdxAtlasProcessor.logger.LogMessage("Writing {0} pages", data.pages.Count);
            writer.Write(data.pages.Count);
            foreach (var page in data.pages)
            {
                LibGdxAtlasProcessor.logger.LogMessage("Writing page: {0}", page.textureFile);
                writer.Write(Path.GetFileNameWithoutExtension(page.textureFile));
                int count = 0;
                foreach (var region in data.regions)
                {
                    if (region.page == page.textureFile)
                    {
                        count++;
                    }
                }

                LibGdxAtlasProcessor.logger.LogMessage("Writing {0} regions", count);
                writer.Write(count);
                foreach (var region in data.regions)
                {
                    if (region.page == page.textureFile)
                    {
                        LibGdxAtlasProcessor.logger.LogMessage("Writing region: {0}", region.name);
                        writer.Write(region.name);
                        writer.Write(region.sourceRectangle.x);
                        writer.Write(region.sourceRectangle.y);
                        writer.Write(region.sourceRectangle.w);
                        writer.Write(region.sourceRectangle.h);

                        if (region.splits == null)
                        {
                            writer.Write(false);
                        }
                        else
                        {
                            writer.Write(true);
                            writer.Write(region.splits[0]);
                            writer.Write(region.splits[1]);
                            writer.Write(region.splits[2]);
                            writer.Write(region.splits[3]);
                            LibGdxAtlasProcessor.logger.LogMessage("Writing splits for region: {0}", region.name);
                        }

                        if (region.pads == null)
                        {
                            writer.Write(false);
                        }
                        else
                        {
                            writer.Write(true);
                            writer.Write(region.pads[0]);
                            writer.Write(region.pads[1]);
                            writer.Write(region.pads[2]);
                            writer.Write(region.pads[3]);
                            LibGdxAtlasProcessor.logger.LogMessage("Writing pads for region: {0}", region.name);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Compiles a strongly typed object into binary format.
        /// </summary>
        /// <param name="output">The content writer serializing the value.</param>
        /// <param name="value">The value to write.</param>
        protected override void Write(ContentWriter output, SkeletonKeyFrameAnimation value)
        {
            value.Freeze();

            dynamic internals = value.Internals;

            TimeSpan[]       times              = internals.Times;
            int[]            channels           = internals.Channels;
            float[]          weights            = internals.Weights;
            int[]            indices            = internals.Indices;
            int[]            keyFrameTypes      = internals.KeyFrameTypes;
            TimeSpan[][]     keyFrameTimes      = internals.KeyFrameTimes;
            SrtTransform[][] keyFrameTransforms = internals.KeyFrameTransforms;

            // _totalDuration
            output.WriteRawObject(value.GetTotalDuration());

            // _times
            output.Write(times.Length);
            for (int i = 0; i < times.Length; i++)
            {
                output.WriteRawObject(times[i]);
            }

            // _channels
            int numberOfChannels = channels.Length;

            output.Write(numberOfChannels);
            for (int channelIndex = 0; channelIndex < numberOfChannels; channelIndex++)
            {
                output.Write(channels[channelIndex]);
            }

            // _weights
            for (int channelIndex = 0; channelIndex < numberOfChannels; channelIndex++)
            {
                output.Write(weights[channelIndex]);
            }

            // _indices
            Debug.Assert(indices.Length == numberOfChannels * times.Length, "Number of indices expected to be: number of channels * number of times");
            for (int i = 0; i < indices.Length; i++)
            {
                output.Write(indices[i]);
            }

            // _keyFrameTypes, _keyFrames
            for (int channelIndex = 0; channelIndex < numberOfChannels; channelIndex++)
            {
                int boneKeyFrameType = keyFrameTypes[channelIndex];
                output.Write(boneKeyFrameType);

                int numberOfKeyFrames = keyFrameTimes[channelIndex].Length;
                output.Write(numberOfKeyFrames);

                if (boneKeyFrameType == 0 /*BoneKeyFrameType.R*/)
                {
                    for (int keyFrameIndex = 0; keyFrameIndex < numberOfKeyFrames; keyFrameIndex++)
                    {
                        output.WriteRawObject(keyFrameTimes[channelIndex][keyFrameIndex]);
                        output.WriteRawObject(keyFrameTransforms[channelIndex][keyFrameIndex].Rotation);
                    }
                }
                else if (boneKeyFrameType == 1 /*BoneKeyFrameType.RT*/)
                {
                    for (int keyFrameIndex = 0; keyFrameIndex < numberOfKeyFrames; keyFrameIndex++)
                    {
                        output.WriteRawObject(keyFrameTimes[channelIndex][keyFrameIndex]);
                        output.WriteRawObject(keyFrameTransforms[channelIndex][keyFrameIndex].Rotation);
                        output.WriteRawObject(keyFrameTransforms[channelIndex][keyFrameIndex].Translation);
                    }
                }
                else
                {
                    for (int keyFrameIndex = 0; keyFrameIndex < numberOfKeyFrames; keyFrameIndex++)
                    {
                        output.WriteRawObject(keyFrameTimes[channelIndex][keyFrameIndex]);
                        output.WriteRawObject(keyFrameTransforms[channelIndex][keyFrameIndex].Scale);
                        output.WriteRawObject(keyFrameTransforms[channelIndex][keyFrameIndex].Rotation);
                        output.WriteRawObject(keyFrameTransforms[channelIndex][keyFrameIndex].Translation);
                    }
                }
            }

            output.Write(value.EnableInterpolation);
            output.Write((int)value.FillBehavior);
            output.Write(value.IsAdditive);

            output.Write(value.TargetObject != null);
            if (value.TargetObject != null)
            {
                output.Write(value.TargetObject);
            }

            output.Write(value.TargetProperty != null);
            if (value.TargetProperty != null)
            {
                output.Write(value.TargetProperty);
            }
        }
 protected override void Write(ContentWriter output, CapsuleShape value)
 {
     output.Write(value.Radius);
     output.Write(value.Height);
 }
Example #27
0
        protected override void Write(ContentWriter output, AsepriteJson value)
        {
            // WRITE FRAMES
            output.Write(value.Frames.Length);
            foreach (var frame in value.Frames)
            {
                output.Write(frame.Filename);
                writeAsepriteRect(output, frame.Frame);
                writeAsepriteRect(output, frame.SpriteSourceSize);
                writeAsepriteRect(output, frame.SourceSize);
                output.Write(frame.Rotated);
                output.Write(frame.Trimmed);
                output.Write(frame.Duration);
            }

            // WRITE META
            output.Write(value.Meta.App);
            output.Write(value.Meta.Version);
            output.Write(value.Meta.Image);
            output.Write(value.Meta.Format);
            writeAsepriteRect(output, value.Meta.Size);
            output.Write(value.Meta.Scale);
            output.Write(value.Meta.FrameTags.Length);
            foreach (var frameTag in value.Meta.FrameTags)
            {
                output.Write(frameTag.Name);
                output.Write(frameTag.From);
                output.Write(frameTag.To);
                output.Write(frameTag.Direction);
            }
        }
 internal static void Write(ContentWriter writer, LayerContent content)
 {
     if (content is GridLayerContent)
     {
         GridLayerContent gridLayer = content as GridLayerContent;
         writer.Write("g");
         writer.Write(gridLayer.Name);
         if (gridLayer.RectangleData != null && gridLayer.RectangleData.Count > 0)
         {
             writer.Write(gridLayer.RectangleData.Count);
             foreach (Rectangle rect in gridLayer.RectangleData)
             {
                 writer.Write(rect.X);
                 writer.Write(rect.Y);
                 writer.Write(rect.Width);
                 writer.Write(rect.Height);
             }
         }
         else if (!string.IsNullOrEmpty(gridLayer.RawData))
             writer.Write(gridLayer.RawData);
     }
     else if (content is TileLayerContent)
     {
         TileLayerContent tileLayer = content as TileLayerContent;
         writer.Write("t");
         writer.Write(tileLayer.Name);
         writer.Write(tileLayer.TileHeight);
         writer.Write(tileLayer.TileWidth);
         writer.Write(tileLayer.Tilesets.Count);
         if (tileLayer.Tilesets.Count > 0)
         {
             foreach (string tileset in tileLayer.Tilesets)
                 writer.Write(tileset);
         }
         writer.Write(tileLayer.Tiles.Count);
         if (tileLayer.Tiles.Count > 0)
         {
             foreach (TileContent tile in tileLayer.Tiles)
             {
                 writer.Write(tile.Height);
                 writer.Write(tile.Position);
                 writer.Write(tile.SourceIndex);
                 writer.Write(tile.TextureOffset);
                 writer.Write(tile.TilesetName);
                 writer.Write(tile.Width);
             }
         }
     }
     else if (content is ObjectLayerContent)
     {
         ObjectLayerContent objLayer = content as ObjectLayerContent;
         writer.Write("o");
         writer.Write(objLayer.Name);
         writer.Write(objLayer.Objects.Count);
         if (objLayer.Objects.Count > 0)
         {
             foreach (ObjectContent obj in objLayer.Objects)
             {
                 writer.Write(obj.Name);
                 writer.Write(obj.Origin);
                 writer.Write(obj.Position);
                 writer.Write(obj.Rotation);
                 writer.Write(obj.Width);
                 writer.Write(obj.Height);
                 writer.Write(obj.Source.X);
                 writer.Write(obj.Source.Y);
                 writer.Write(obj.Source.Width);
                 writer.Write(obj.Source.Height);
                 writer.Write(obj.IsTiled);
                 writer.WriteExternalReference(obj.TextureReference);
                 writer.Write(obj.Values.Count);
                 if (obj.Values.Count > 0)
                 {
                     foreach (ValueContent valueContent in obj.Values)
                         ValueContentWriter.Write(writer, valueContent);
                 }
                 writer.Write(obj.Nodes.Count);
                 if (obj.Nodes.Count > 0)
                 {
                     foreach (OgmoXNAPipelineExtensions.ContentItems.NodeContent nodeContent in obj.Nodes)
                         writer.Write(nodeContent.Position);
                 }
             }
         }
     }
 }
        /// <summary>
        /// Write the binary (xnb) file corresponding to the supplied
        /// TilesetContent that will be imported into our game
        /// as a Tileset
        /// </summary>
        /// <param name="output">The ContentWriter that writes the binary output</param>
        /// <param name="value">The TilesetContent we are writing</param>
        protected override void Write(ContentWriter output, TWrite value)
        {
            // We only need to write the data that is needed in-game.

            // Write the map width & height
            output.Write(value.MapWidth);
            output.Write(value.MapHeight);

            // Write the tile width & height
            output.Write(value.TileWidth);
            output.Write(value.TileHeight);

            // Write the layer count
            output.Write(value.Layers.Count);

            // Write the layer data
            foreach (var layer in value.Layers)
            {
                // Write the layer single-value data
                output.Write(layer.Data.Length);
                foreach (uint id in layer.Data)
                {
                    output.Write(id);
                }
            }

            // Write the tileset data
            output.Write(value.Tilesets.Count);
            foreach (var tileset in value.Tilesets)
            {
                output.Write(tileset.FirstGID);
                output.WriteExternalReference(tileset.Reference);
            }

            //Write out how many objectgroups there are
            output.Write(value.ObjectGroups.Count);
            foreach (var objectGroup in value.ObjectGroups)
            {
                //Write out the name of the objectgroup and how many objects it has
                output.Write(objectGroup.Name);
                output.Write(objectGroup.Objects.Count);
                foreach (var groupObject in objectGroup.Objects)
                {
                    //Write out each object's info
                    output.Write(groupObject.SheetIndex);
                    output.Write(groupObject.X);
                    output.Write(groupObject.Y);
                    output.Write(groupObject.Width);
                    output.Write(groupObject.Height);
                }
            }
        }
Example #30
0
 protected override void Write(ContentWriter output, Spell value)
 {
     output.Write(value.Name);
     output.Write(value.Description);
     output.Write(value.MagicPointCost);
     output.Write(value.IconTextureName);
     output.Write(value.IsOffensive);
     output.Write(value.TargetDuration);
     output.WriteObject(value.InitialTargetEffectRange);
     output.Write(value.AdjacentTargets);
     output.WriteObject(value.LevelingProgression);
     output.Write(value.CreatingCueName);
     output.Write(value.TravelingCueName);
     output.Write(value.ImpactCueName);
     output.Write(value.BlockCueName);
     output.WriteObject(value.SpellSprite);
     output.WriteObject(value.Overlay);
 }
Example #31
0
        protected override void Write(ContentWriter output, MapContent value)
        {
            // write the map information
            output.Write(value.Version);
            output.Write((byte)value.Orientation);
            output.Write(value.Width);
            output.Write(value.Height);
            output.Write(value.TileWidth);
            output.Write(value.TileHeight);
            WritePropertyList(output, value.Properties);

            // write out our tile sets. we don't use a runtime TileSet, we read in as
            // a list of tile objects. so we don't write out a lot of the TileSet
            // information as most of it isn't useful.
            output.Write(value.TileSets.Count);
            foreach (var tileSet in value.TileSets)
            {
                // write out the first global ID of these tiles
                output.Write(tileSet.FirstId);

                // write out the name of the tileset
                output.Write(tileSet.Name);

                output.Write(tileSet.CollisionSet);

                // write out the texture used by the tiles
                output.WriteExternalReference(tileSet.Texture);

                //output.WriteExternalReference(tileSet.WhiteTexture);

                // write out all the tiles in the tile set
                output.Write(tileSet.Tiles.Count);
                foreach (var tile in tileSet.Tiles)
                {
                    output.WriteObject(tile.Source);
                    WritePropertyList(output, tile.Properties);
                }
            }

            // write each layer
            output.Write(value.Layers.Count);
            foreach (var layer in value.Layers)
            {
                // basic information
                output.Write(layer.Type);
                output.Write(layer.Name);
                output.Write(layer.Width);
                output.Write(layer.Height);
                output.Write(layer.Visible);
                output.Write(layer.Opacity);
                WritePropertyList(output, layer.Properties);

                // figure out specific type of layer
                TileLayerContent      tileLayer = layer as TileLayerContent;
                MapObjectLayerContent objLayer  = layer as MapObjectLayerContent;

                // tile layers just write out index data
                if (tileLayer != null)
                {
                    output.WriteObject(tileLayer.Data);
                }

                // object layers write out all the objects
                else if (objLayer != null)
                {
                    output.Write(objLayer.Objects.Count);
                    foreach (var mapObj in objLayer.Objects)
                    {
                        output.Write(mapObj.Name);
                        output.Write(mapObj.Type);
                        output.WriteObject(mapObj.Location);
                        output.WriteObject(mapObj.LinePoints);
                        WritePropertyList(output, mapObj.Properties);
                    }
                }
            }
        }
 protected override void Write(ContentWriter output, AdaptiveAabbTree <T> value)
 {
     output.Write(value.EnableSelfOverlaps);
     output.Write(value.BottomUpBuildThreshold);
     output.WriteSharedResource(value.Filter);
 }
Example #33
0
 void WritePointObject(ContentWriter output) =>
 output.Write((byte)TiledObjectType.Point);
 internal static void Write(ContentWriter writer, ValueContent content)
 {
     if (content is BooleanValueContent)
     {
         BooleanValueContent bContent = content as BooleanValueContent;
         writer.Write("b");
         writer.Write(bContent.Name);
         writer.Write(bContent.Value);
     }
     else if (content is IntegerValueContent)
     {
         IntegerValueContent iContent = content as IntegerValueContent;
         writer.Write("i");
         writer.Write(iContent.Name);
         writer.Write(iContent.Value);
     }
     else if (content is NumberValueContent)
     {
         NumberValueContent nContent = content as NumberValueContent;
         writer.Write("n");
         writer.Write(nContent.Name);
         writer.Write(nContent.Value);
     }
     else if (content is StringValueContent)
     {
         StringValueContent sContent = content as StringValueContent;
         writer.Write("s");
         writer.Write(sContent.Name);
         writer.Write(sContent.Value);
     }
 }
Example #35
0
 void WriteEllipseObject(ContentWriter output) =>
 output.Write((byte)TiledObjectType.Ellipse);
 internal static void Write(ContentWriter writer, LayerSettingsContent content)
 {
     if (content is GridLayerSettingsContent)
     {
         GridLayerSettingsContent gContent = content as GridLayerSettingsContent;
         writer.Write("g");
         writer.Write(gContent.GridColor);
         writer.Write(gContent.GridDrawSize);
         writer.Write(gContent.GridSize);
         writer.Write(gContent.Name);
         writer.Write(gContent.ExportAsObjects);
         writer.Write(gContent.NewLine);
     }
     else if (content is ObjectLayerSettingsContent)
     {
         ObjectLayerSettingsContent oContent = content as ObjectLayerSettingsContent;
         writer.Write("o");
         writer.Write(oContent.GridColor);
         writer.Write(oContent.GridDrawSize);
         writer.Write(oContent.GridSize);
         writer.Write(oContent.Name);
     }
     else if (content is TileLayerSettingsContent)
     {
         TileLayerSettingsContent tContent = content as TileLayerSettingsContent;
         writer.Write("t");
         writer.Write(tContent.GridColor);
         writer.Write(tContent.GridDrawSize);
         writer.Write(tContent.GridSize);
         writer.Write(tContent.Name);
         writer.Write(tContent.ExportTileIDs);
         writer.Write(tContent.ExportTileSize);
         writer.Write(tContent.MultipleTilesets);
     }
 }
Example #37
0
        void WriteTilesets(ContentWriter output, TiledMapTileset[] tilesets)
        {
            output.Write(tilesets.Length);
            foreach (var tileset in tilesets)
            {
                output.Write(tileset.Name);
                output.WriteObject(tileset.TexturePaths);

                if (
                    tileset.Properties.ContainsKey(TilesetParser.IgnoreTilesetTextureFlag) &&
                    bool.Parse(tileset.Properties[TilesetParser.IgnoreTilesetTextureFlag])
                    )
                {
                    output.Write(false);
                }
                else
                {
                    output.Write(true);
                    output.Write(tileset.TexturePaths.Length);
                    for (var i = 0; i < tileset.TexturePaths.Length; i += 1)
                    {
                        var externalReference = TiledMapProcessor.TextureReferences[tileset.TexturePaths[i]];
                        output.WriteExternalReference(externalReference);
                    }
                }

                output.Write(tileset.FirstGID);
                output.Write(tileset.TileWidth);
                output.Write(tileset.TileHeight);
                output.Write(tileset.Spacing);
                output.Write(tileset.Margin);
                output.Write(tileset.TileCount);
                output.Write(tileset.Columns);

                output.Write(tileset.Offset);

                foreach (var tile in tileset.Tiles)
                {
                    WriteTilesetTile(output, tile);
                }

                output.WriteObject(tileset.BackgroundColor);
                output.WriteObject(tileset.Properties);
            }
        }
 private void writeTextures(ContentWriter output)
 {
     output.Write(built_textures.Count);
       for (int i = 0; i < built_textures.Count; ++i)
       {
     output.Write(built_textures[i].Name);
     output.WriteExternalReference<TextureContent>(built_textures[i]);
       }
 }
Example #39
0
        static void writeObjectGroup(ContentWriter writer, TmxObjectGroup group)
        {
            writer.Write(group.name ?? string.Empty);
            writer.Write(hexToColor(group.color));
            writer.Write(group.visible);
            writer.Write(group.opacity);

            writeCustomProperties(writer, group.properties);

            writer.Write(group.objects.Count);
            foreach (var obj in group.objects)
            {
                writer.Write(obj.gid);
                writer.Write(obj.name ?? string.Empty);
                writer.Write(obj.type ?? string.Empty);
                writer.Write((int)obj.x);
                writer.Write((int)obj.y);
                writer.Write((int)obj.width);
                writer.Write((int)obj.height);
                writer.Write(obj.rotation);
                writer.Write(obj.visible);

                if (obj.ellipse != null)
                {
                    writer.Write("ellipse");
                }
                else if (obj.image != null)
                {
                    writer.Write("image");
                }
                else if (obj.polygon != null)
                {
                    writer.Write("polygon");
                    writePointList(writer, obj, obj.polygon.points);
                }
                else if (obj.polyline != null)
                {
                    writer.Write("polyline");
                    writePointList(writer, obj, obj.polyline.points);
                }
                else
                {
                    writer.Write("none");
                }

                writer.Write(obj.type ?? string.Empty);

                writeCustomProperties(writer, obj.properties);
            }

            TiledMapProcessor.logger.LogMessage("done writing ObjectGroup: {0}", group);
        }
Example #40
0
 protected override void Write(ContentWriter output, SkinnedBone value)
 {
     output.Write(value.Name);
     output.Write(value.InverseBindTransform);
     output.Write(value.Index);
 }
Example #41
0
        protected override void Write(ContentWriter writer, BezierSpline input)
        {
            writer.Write(Setup.SplineMarkerResolution);
            writer.Write(input.CatMulRom);
            writer.Write(input.Loop);

            Transform[] points = input.GetAllPoints();
            writer.Write(points.Length);
            for (int i = 0; i < points.Length; i++)
            {
                writer.Write(points[i].Position);
            }

            BezierSpline.BezierControlPointMode[] pointModes = input.GetAllPointModes();
            writer.Write(pointModes.Length);
            for (int i = 0; i < pointModes.Length; i++)
            {
                writer.Write(pointModes[i].ToString());
            }

            Trigger[] trigger = input.GetAllTrigger().ToArray();
            writer.Write(trigger.Length);
            for (int i = 0; i < trigger.Length; i++)
            {
                writer.Write(trigger[i].Name);
                writer.Write(trigger[i].GetPlainProgress);
                writer.Write(trigger[i].TriggerRange);
                writer.Write(trigger[i].ID.ToString());
            }
        }
Example #42
0
 protected override void Write(ContentWriter output, BoundsInfo value)
 {
     output.Write(value.MaxScale);
     output.Write(value.MaxOffset);
 }
Example #43
0
 protected override void Write(ContentWriter output, AnimationTrack value)
 {
     output.Write(value.BoneIndex);
     output.WriteObject(value.Keyframes);
     output.Write(value.Name);
 }
    protected override void Write(ContentWriter output, SpriteStrip value)
    {
        // Version
        output.Write(_version);

        output.Write(value.Name);
        output.Write(value.Origin.X);
        output.Write(value.Origin.Y);
        output.Write(value.BoundingBox.Left);
        output.Write(value.BoundingBox.Right);
        output.Write(value.BoundingBox.Top);
        output.Write(value.BoundingBox.Bottom);
        output.Write(value.Size.Width);
        output.Write(value.Size.Height);
        output.Write(value.FrameCount);
        output.Write(value.AnimationSpeed);
        // Framespeeds
        int frameCount = value.FrameSpeeds.Count;

        output.Write(frameCount);
        for (int i = 0; i < frameCount; i++)
        {
            output.Write(value.FrameSpeeds[i]);
        }
        // Anchors
        int anchorCount = value.Anchors.Count;

        output.Write(anchorCount);
        for (int i = 0; i < anchorCount; i++)
        {
            SpriteAnchor anchor = value.Anchors[i];
            output.Write(anchor.Name);
            // Frames
            int anchorFrameCount = anchor.Frames.Count;
            for (int j = 0; j < anchorFrameCount; j++)
            {
                output.Write(anchor.Frames[j].X1);
                output.Write(anchor.Frames[j].Y1);
                output.Write(anchor.Frames[j].X2);
                output.Write(anchor.Frames[j].Y2);
                output.Write(anchor.Frames[j].Angle);
                output.Write(anchor.Frames[j].Length);
                output.Write(anchor.Frames[j].Visible);
            }
        }
    }
Example #45
0
 protected override void Write(ContentWriter _output, GameEngine1.UnitType _value)
 {
     _output.Write(_value.AirAttack);
     _output.Write(_value.AirDefense);
     _output.Write(_value.Ammo);
     _output.WriteObject <DateTime>(_value.AvailabilityEnd);
     _output.WriteObject <DateTime>(_value.AvailabilityStart);
     _output.Write(_value.Characteristics);
     _output.Write(_value.CloseDefense);
     _output.Write(_value.CombatRange);
     _output.Write(_value.Cost);
     _output.Write(_value.EntrenchmentRate);
     _output.Write(_value.Fuel);
     _output.Write(_value.GroundDefense);
     _output.Write(_value.HardAttack);
     _output.Write(_value.ID);
     _output.Write(_value.Initiative);
     _output.WriteObject <GameEngine1.GroundMovementClass>(_value.MovementClass);
     _output.Write(_value.Moves);
     _output.Write(_value.Name);
     _output.Write(_value.Nationality);
     _output.Write(_value.SoftAttack);
     _output.Write(_value.SpottingRange);
     _output.Write(_value.SpritesheetX);
     _output.Write(_value.SpritesheetY);
 }
 public void write(ContentWriter output, CPK3Loader pk3)
 {
     int t = 0;
       if (md3_type == TMD3Part.LOWER)
     t = 1;
       else if (md3_type == TMD3Part.UPPER)
     t = 2;
       output.Write(t);
       output.Write(header.numFrames);
       output.Write(sub_meshes.Count);
       for (int i = 0; i < sub_meshes.Count; ++i) {
     string texture_name = pk3.getMaterialByMeshName(sub_meshes[i].meshinfo.strName);
     output.Write(texture_name);
     output.WriteObject(sub_meshes[i].indices);
     output.WriteObject(sub_meshes[i].vertices);
     output.WriteObject(sub_meshes[i].normals);
     output.WriteObject(sub_meshes[i].text_coord);
     //falta mesh info
       }
       output.Write(tag.Count);
       for (int i = 0; i < tag.Count; ++i)
       {
     output.Write(tag[i].strName);
     output.Write(tag[i].vPosition);
     output.Write(tag[i].rotation);
       }
       output.Write(bones.Count);
       for (int i = 0; i < bones.Count; ++i)
       {
     output.Write(bones[i].mins);
     output.Write(bones[i].maxs);
       }
 }
        private byte[] WriteTypeReadersData(IList<ContentTypeWriter> usedTypeWriters)
        {
            byte[] data = null;
            List<string> typeReaderNames = usedTypeWriters.Select(w => w.GetReaderTypeName()).ToList();

            using (MemoryStream stream = new MemoryStream())
            {
                using (ContentWriter writer = new ContentWriter(stream, this))
                {
                    writer.WriteEncodedInt32(typeReaderNames.Count);

                    foreach (var typeReader in typeReaderNames)
                    {
                        writer.Write(typeReader.ToString());
                        writer.Write(0);
                    }

                    data = stream.GetBuffer().Take((int)stream.Length).ToArray();
                }
            }

            return data;
        }
Example #48
0
        protected override void Write(ContentWriter writer, TiledMapProcessorResult value)
        {
            var map = value.map;

            writer.Write(hexToColor(map.backgroundColor));
            writer.Write(map.renderOrder.ToString());
            writer.Write(map.firstGid);
            writer.Write(map.width);
            writer.Write(map.height);
            writer.Write(map.tileWidth);
            writer.Write(map.tileHeight);
            writer.Write(Convert.ToInt32(map.orientation));
            writeCustomProperties(writer, map.properties);

            writer.Write(map.tilesets.Count);
            foreach (var tileset in map.tilesets)
            {
                TiledMapProcessor.logger.LogMessage("Expecting texture asset: {0}\n", tileset.image.source);
                writer.Write(removeExtension(tileset.image.source));
                writer.Write(tileset.firstGid);
                writer.Write(tileset.tileWidth);
                writer.Write(tileset.tileHeight);
                writer.Write(tileset.spacing);
                writer.Write(tileset.margin);
                writeCustomProperties(writer, tileset.properties);

                writer.Write(tileset.tiles.Count);
                foreach (var tile in tileset.tiles)
                {
                    TiledMapProcessor.logger.LogMessage("writing tile: {0}", tile);
                    writer.Write(tile.id);

                    // animation frames
                    writer.Write(tile.animationFrames.Count);
                    foreach (var anim in tile.animationFrames)
                    {
                        writer.Write(anim.tileId);
                        writer.Write(anim.duration);
                    }

                    writeCustomProperties(writer, tile.properties);
                }
            }


            writer.Write(map.layers.Count);
            foreach (var layer in map.layers)
            {
                writer.Write(layer.name);
                writer.Write(layer.visible);
                writer.Write(layer.opacity);

                var tileLayer = layer as TmxTileLayer;
                if (tileLayer != null)
                {
                    writer.Write((int)TiledLayerType.Tile);
                    writer.Write(tileLayer.data.tiles.Count);

                    foreach (var tile in tileLayer.data.tiles)
                    {
                        // Read out the flags
                        var flippedHorizontally = (tile.gid & FLIPPED_HORIZONTALLY_FLAG) != 0;
                        var flippedVertically   = (tile.gid & FLIPPED_VERTICALLY_FLAG) != 0;
                        var flippedDiagonally   = (tile.gid & FLIPPED_DIAGONALLY_FLAG) != 0;

                        if (flippedHorizontally || flippedVertically || flippedDiagonally)
                        {
                            // Clear the flags
                            tile.gid &= ~(FLIPPED_HORIZONTALLY_FLAG | FLIPPED_VERTICALLY_FLAG | FLIPPED_DIAGONALLY_FLAG);
                            tile.flippedHorizontally = flippedHorizontally;
                            tile.flippedVertically   = flippedVertically;
                            tile.flippedDiagonally   = flippedDiagonally;
                        }
                        writer.Write(tile.gid);
                        writer.Write(tile.flippedHorizontally);
                        writer.Write(tile.flippedVertically);
                        writer.Write(tile.flippedDiagonally);
                    }

                    writer.Write(tileLayer.width);
                    writer.Write(tileLayer.height);
                }

                var imageLayer = layer as TmxImageLayer;
                if (imageLayer != null)
                {
                    writer.Write((int)TiledLayerType.Image);
                    writer.Write(removeExtension(imageLayer.image.source));
                    writer.Write(new Vector2(imageLayer.x, imageLayer.y));

                    TiledMapProcessor.logger.LogMessage("Expecting texture asset: {0}\n", imageLayer.image.source);
                }

                writeCustomProperties(writer, layer.properties);
                TiledMapProcessor.logger.LogMessage("done writing Layer: {0}", layer);
            }

            writer.Write(map.objectGroups.Count);
            foreach (var group in map.objectGroups)
            {
                writer.Write(group.name);
                writer.Write(hexToColor(group.color));
                writer.Write(group.visible);
                writer.Write(group.opacity);

                writeCustomProperties(writer, group.properties);

                writer.Write(group.objects.Count);
                foreach (var obj in group.objects)
                {
                    writer.Write(obj.gid);
                    writer.Write(obj.name ?? string.Empty);
                    writer.Write(obj.type ?? string.Empty);
                    writer.Write((int)obj.x);
                    writer.Write((int)obj.y);
                    writer.Write((int)obj.width);
                    writer.Write((int)obj.height);
                    writer.Write(obj.rotation);
                    writer.Write(obj.visible);

                    if (obj.ellipse != null)
                    {
                        writer.Write("ellipse");
                    }
                    else if (obj.image != null)
                    {
                        writer.Write("image");
                    }
                    else if (obj.polygon != null)
                    {
                        writer.Write("polygon");
                        writePointList(writer, obj, obj.polygon.points);
                    }
                    else if (obj.polyline != null)
                    {
                        writer.Write("polyline");
                        writePointList(writer, obj, obj.polyline.points);
                    }
                    else
                    {
                        writer.Write("none");
                    }

                    writer.Write(obj.type ?? string.Empty);

                    writeCustomProperties(writer, obj.properties);
                }

                TiledMapProcessor.logger.LogMessage("done writing ObjectGroup: {0}", group.name);
            }
        }
Example #49
0
 protected override void Write(ContentWriter output, Matrix44F value)
 {
     output.Write(value.M00);
     output.Write(value.M01);
     output.Write(value.M02);
     output.Write(value.M03);
     output.Write(value.M10);
     output.Write(value.M11);
     output.Write(value.M12);
     output.Write(value.M13);
     output.Write(value.M20);
     output.Write(value.M21);
     output.Write(value.M22);
     output.Write(value.M23);
     output.Write(value.M30);
     output.Write(value.M31);
     output.Write(value.M32);
     output.Write(value.M33);
 }
 public void write(ContentWriter output)
 {
     writeTextures(output);
       output.Write(md3_list.Count);
       for (int i = 0; i < md3_list.Count; ++i)
       {
     md3_list[i].write(output,this);
       }
       output.Write(animations_list.Count);
       for (int i = 0; i < animations_list.Count; ++i)
       {
     output.Write(animations_list[i].strName);
     output.Write(animations_list[i].startFrame);
     output.Write(animations_list[i].numFrames);
     output.Write(animations_list[i].loopingFrames);
     output.Write(animations_list[i].framesPerSecond);
       }
 }