Exemplo n.º 1
0
 public void read(Reader reader)
 {
     parallaxFactor = reader.ReadInt16();
     scrollSpeed    = reader.ReadInt16();
     deform         = reader.ReadBoolean();
     unknown        = reader.ReadByte();
 }
Exemplo n.º 2
0
        internal void Read(Reader reader)
        {
            X.Low  = reader.ReadUInt16();
            X.High = reader.ReadInt16();

            Y.Low  = reader.ReadUInt16();
            Y.High = reader.ReadInt16();
        }
Exemplo n.º 3
0
            public AnimationEntry(Reader reader, Animation anim = null)
            {
                AnimName = reader.ReadRSDKString().Replace("" + '\0', "");
                short frameCount = reader.ReadInt16();

                SpeedMultiplyer = reader.ReadInt16();
                LoopIndex       = reader.ReadByte();
                RotationFlags   = reader.ReadByte();
                for (int i = 0; i < frameCount; ++i)
                {
                    Frames.Add(new Frame(reader, anim));
                }
            }
Exemplo n.º 4
0
        internal void Read(Reader reader, bool vec3 = false)
        {
            X.Low  = reader.ReadUInt16();
            X.High = reader.ReadInt16();

            Y.Low  = reader.ReadUInt16();
            Y.High = reader.ReadInt16();

            if (vec3)
            {
                Z.Low  = reader.ReadUInt16();
                Z.High = reader.ReadInt16();
            }
        }
Exemplo n.º 5
0
            public void read(Reader reader, Animation anim = null)
            {
                name = reader.readRSDKString();
                short frameCount = reader.ReadInt16();

                speed         = reader.ReadInt16();
                loopIndex     = reader.ReadByte();
                rotationStyle = (RotationStyles)reader.ReadByte();

                frames.Clear();
                for (int f = 0; f < frameCount; ++f)
                {
                    frames.Add(new Frame(reader, anim));
                }
            }
Exemplo n.º 6
0
            public AnimationEntry(Reader reader, Animation anim = null)
            {
                AnimName = reader.ReadRSDKString();
                string tmp = "";

                for (int ii = 0; ii < AnimName.Length - 1; ii++) //Fixes a crash when using the string to load (by trimming the null char off)
                {
                    tmp += AnimName[ii];
                }
                AnimName = tmp;
                short frameCount = reader.ReadInt16();

                SpeedMultiplyer = reader.ReadInt16();
                LoopIndex       = reader.ReadByte();
                RotationFlags   = reader.ReadByte();
                for (int i = 0; i < frameCount; ++i)
                {
                    Frames.Add(new Frame(reader, anim));
                }
            }
Exemplo n.º 7
0
        public void read(Reader reader)
        {
            switch (type)
            {
            case VariableTypes.UINT8:
                value_uint8 = reader.ReadByte();
                break;

            case VariableTypes.UINT16:
                value_uint16 = reader.ReadUInt16();
                break;

            case VariableTypes.UINT32:
                value_uint32 = reader.ReadUInt32();
                break;

            case VariableTypes.INT8:
                value_int8 = reader.ReadSByte();
                break;

            case VariableTypes.INT16:
                value_int16 = reader.ReadInt16();
                break;

            case VariableTypes.INT32:
                value_int32 = reader.ReadInt32();
                break;

            case VariableTypes.ENUM:
                value_enum = reader.ReadInt32();
                break;

            case VariableTypes.BOOL:
                value_bool = reader.readBool32();
                break;

            case VariableTypes.STRING:
                value_string = reader.readRSDKUTF16String();
                break;

            case VariableTypes.VECTOR2:
                value_vector2.x = reader.ReadInt32();
                value_vector2.y = reader.ReadInt32();
                break;

            case VariableTypes.UNKNOWN:
                value_unknown = reader.ReadInt32();
                break;

            case VariableTypes.COLOR:
                value_color = new Color(reader);
                break;
            }
        }
Exemplo n.º 8
0
        internal void Read(Reader reader)
        {
            switch (Type)
            {
            case AttributeTypes.UINT8:
                value_uint8 = reader.ReadByte();
                break;

            case AttributeTypes.UINT16:
                value_uint16 = reader.ReadUInt16();
                break;

            case AttributeTypes.UINT32:
                value_uint32 = reader.ReadUInt32();
                break;

            case AttributeTypes.INT8:
                value_int8 = reader.ReadSByte();
                break;

            case AttributeTypes.INT16:
                value_int16 = reader.ReadInt16();
                break;

            case AttributeTypes.INT32:
                value_int32 = reader.ReadInt32();
                break;

            case AttributeTypes.ENUM:
                value_enum = reader.ReadInt32();
                break;

            case AttributeTypes.BOOL:
                value_bool = reader.ReadUInt32() != 0;
                break;

            case AttributeTypes.STRING:
                value_string = reader.ReadRSDKUnicodeString();
                break;

            case AttributeTypes.VECTOR2:
                value_vector2 = new Position(reader);
                break;

            case AttributeTypes.VECTOR3:
                value_vector2 = new Position(reader);
                break;

            case AttributeTypes.COLOR:
                value_color = new Color(reader);
                break;
            }
        }
Exemplo n.º 9
0
        public void read(Reader reader)
        {
            visible = reader.ReadBoolean();

            name = reader.readRSDKString();

            type      = (Types)reader.ReadByte();
            drawOrder = reader.ReadByte();

            width  = reader.ReadUInt16();
            height = reader.ReadUInt16();

            parallaxFactor = reader.ReadInt16();
            scrollSpeed    = reader.ReadInt16();

            ushort scrollInfoCount = reader.ReadUInt16();

            scrollInfo.Clear();
            for (int i = 0; i < scrollInfoCount; ++i)
            {
                scrollInfo.Add(new ScrollInfo(reader));
            }

            // Read Line Scroll, its compressed using ZLib compression
            lineScroll = reader.readCompressed();

            // Read tile map, its compressed using ZLib compression
            layout = new Tile[height][];
            using (Reader creader = reader.getCompressedStream())
            {
                for (int y = 0; y < height; ++y)
                {
                    layout[y] = new Tile[width];
                    for (int x = 0; x < width; ++x)
                    {
                        layout[y][x] = creader.ReadUInt16();
                    }
                }
            }
        }
Exemplo n.º 10
0
        public Animation(Reader reader)
        {
            if (!reader.ReadBytes(4).SequenceEqual(MAGIC))
            {
                throw new Exception("Invalid config file header magic");
            }

            TotalFrameCount = reader.ReadInt32();

            int spriteSheetCount = reader.ReadByte();

            for (int i = 0; i < spriteSheetCount; ++i)
            {
                SpriteSheets.Add(reader.ReadRSDKString());
                string tmp = "";
                for (int ii = 0; ii < SpriteSheets[i].Length - 1; ii++) //Fixes a crash when using the string to load (by trimming the null char off)
                {
                    tmp += SpriteSheets[i][ii];
                }
                SpriteSheets[i] = tmp;
            }

            int collisionBoxCount = reader.ReadByte();

            for (int i = 0; i < collisionBoxCount; ++i)
            {
                CollisionBoxes.Add(reader.ReadRSDKString());
                string tmp = "";
                for (int ii = 0; ii < CollisionBoxes[i].Length - 1; ii++) //Fixes a crash when using the string to load (by trimming the null char off)
                {
                    tmp += CollisionBoxes[i][ii];
                }
                CollisionBoxes[i] = tmp;
            }

            var animationCount = reader.ReadInt16();

            for (int i = 0; i < animationCount; ++i)
            {
                Animations.Add(new AnimationEntry(reader, this));
            }
            reader.Close();
        }
Exemplo n.º 11
0
        public Animation(Reader reader)
        {
            // Header
            if (!reader.readBytes(4).SequenceEqual(signature))
            {
                reader.Close();
                throw new Exception("Invalid Animation v5 signature");
            }

            // used by RSDKv5 to allocate space for all the frames, automatically handled here
            uint totalFrameCount = reader.ReadUInt32();

            // SpriteSheets
            int spriteSheetCount = reader.ReadByte();

            spriteSheets.Clear();
            for (int s = 0; s < spriteSheetCount; ++s)
            {
                spriteSheets.Add(reader.readRSDKString());
            }

            // Hitboxes
            int hitboxTypeCount = reader.ReadByte();

            hitboxTypes.Clear();
            for (int h = 0; h < hitboxTypeCount; ++h)
            {
                hitboxTypes.Add(reader.readRSDKString());
            }

            // Animations
            int animationCount = reader.ReadInt16();

            animations.Clear();
            for (int a = 0; a < animationCount; ++a)
            {
                animations.Add(new AnimationEntry(reader, this));
            }

            reader.Close();
        }
Exemplo n.º 12
0
                public void read(Reader reader, Animation anim = null)
                {
                    sheet       = reader.ReadByte();
                    duration    = reader.ReadUInt16();
                    unicodeChar = reader.ReadUInt16();
                    sprX        = reader.ReadUInt16();
                    sprY        = reader.ReadUInt16();
                    width       = reader.ReadUInt16();
                    height      = reader.ReadUInt16();
                    pivotX      = reader.ReadInt16();
                    pivotY      = reader.ReadInt16();

                    for (int i = 0; anim != null && i < anim.hitboxTypes.Count; ++i)
                    {
                        var hitBox = new Hitbox();
                        hitBox.left   = reader.ReadInt16();
                        hitBox.top    = reader.ReadInt16();
                        hitBox.right  = reader.ReadInt16();
                        hitBox.bottom = reader.ReadInt16();
                        hitboxes.Add(hitBox);
                    }
                }
Exemplo n.º 13
0
        public Model(Reader reader)
        {
            if (!reader.ReadBytes(4).SequenceEqual(MAGIC))
            {
                throw new Exception("Invalid config file header magic");
            }

            for (int a = 0; a < 256; a++)
            {
                MySin[a] = -Math.Sin(a * Math.PI / 128);
                MyCos[a] = Math.Cos(a * Math.PI / 128);
            }

            byte flags = reader.ReadByte();

            //HasNormals = (flags & 0x00000001) != 0;
            //HasUnknown = (flags & 0x00000010) != 0;
            //HasColours = (flags & 0x00000100) != 0;

            HasNormals  = GetBit(flags, 0);
            HasTextures = GetBit(flags, 1);
            HasColours  = GetBit(flags, 2);

            Console.WriteLine("MDL READ: FLAGS:" + Pad(flags));

            string Pad(byte b)
            {
                return(Convert.ToString(b, 2).PadLeft(8, '0'));
            }

            FaceVerticiesCount = reader.ReadByte();
            if (FaceVerticiesCount != 3 && FaceVerticiesCount != 4)
            {
                throw new Exception("Detected Vertex Type wasn't Tris or Quads! RSDKv5 doesn't support other N-gons!");
            }

            ushort VertexCount = 0;
            ushort FramesCount = 0;
            short  FaceCount   = 0;

            VertexCount = reader.ReadUInt16();
            FramesCount = reader.ReadUInt16();

            Console.WriteLine("Frame Count: " + FramesCount + Environment.NewLine + "Vertex Count: " + VertexCount);

            if (HasTextures)
            {
                for (int i = 0; i < VertexCount; ++i)
                {
                    TexturePositions.Add(new TexturePosition(reader));
                }
            }

            if (HasColours)
            {
                for (int i = 0; i < VertexCount; ++i)
                {
                    Colours.Add(new Colour(reader));
                }
            }

            FaceCount = reader.ReadInt16();
            for (int i = 0; i < FaceCount; ++i)
            {
                Faces.Add(reader.ReadInt16());
            }

            for (int i = 0; i < FramesCount; ++i)
            {
                Frames.Add(new Frame(reader, VertexCount, HasNormals));
            }

            Console.WriteLine("MDL READ: FileSize: {0}, Position: 0x{1:X8}, DataLeft: {2}", reader.BaseStream.Length, reader.BaseStream.Position, reader.BaseStream.Length - reader.BaseStream.Position);
        }
Exemplo n.º 14
0
                public Frame(Reader reader, Animation anim = null)
                {
                    SpriteSheet  = reader.ReadByte();
                    CollisionBox = 0;
                    Delay        = reader.ReadInt16();
                    ID           = reader.ReadInt16();
                    X            = reader.ReadInt16();
                    Y            = reader.ReadInt16();
                    Width        = reader.ReadInt16();
                    Height       = reader.ReadInt16();
                    PivotX       = reader.ReadInt16();
                    PivotY       = reader.ReadInt16();

                    for (int i = 0; i < anim.CollisionBoxes.Count; ++i)
                    {
                        var hitBox = new HitBox();
                        hitBox.Left   = reader.ReadInt16();
                        hitBox.Top    = reader.ReadInt16();
                        hitBox.Right  = reader.ReadInt16();
                        hitBox.Bottom = reader.ReadInt16();
                        HitBoxes.Add(hitBox);
                    }
                }