Esempio n. 1
0
        public DGRP(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            m_Version = Reader.ReadUShort();

            switch(m_Version)
            {
                case 20000:
                    ImageCount = Reader.ReadUShort();
                    break;
                case 20001:
                    ImageCount = Reader.ReadUShort();
                    break;
                case 20003:
                    ImageCount = Reader.ReadUInt32();
                    break;
                case 20004:
                    ImageCount = Reader.ReadUInt32();
                    break;
            }

            for(int i = 0; i < ImageCount; i++)
            {
                Images.Add(new DGRPImg(Reader, m_Version));
            }

            Reader.Close();
            m_Data = null;
        }
Esempio n. 2
0
        public ExportTable(Stream Data)
        {
            FileReader Reader = new FileReader(Data, false);

            int StartLocation = Data.BinaryContains(new byte[] { (byte)'E', (byte)'N', (byte)'T', (byte)'P' });
            Reader.Seek(StartLocation);

            while (true)
            {
                string EndTest = ASCIIEncoding.ASCII.GetString(Reader.ReadBytes(4));

                if (!EndTest.Equals("EENT", StringComparison.InvariantCultureIgnoreCase))
                {
                    Reader.Seek(Reader.Position - 4);
                    uint TrackID = Reader.ReadUInt32();
                    uint Address = Reader.ReadUInt32();
                    //TrackID, Address
                    m_SubRoutines.Add(TrackID, Address);
                }
                else
                {
                    break;
                }
            }
        }
Esempio n. 3
0
        public Outfit(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            uint Version = m_Reader.ReadUInt32(); //Version
            m_Reader.ReadUInt32(); //Unknown

            LightAppearance = ReadBackwardsID();
            MediumAppearance = ReadBackwardsID();
            DarkAppearance = ReadBackwardsID();
            m_HandGroup = m_Reader.ReadUInt32();
            Region = (OutfitRegion)Endian.SwapUInt32(m_Reader.ReadUInt32());
        }
Esempio n. 4
0
        public PALT(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Reader.ReadUInt32(); //Version

            m_Colors = new Color[Reader.ReadUInt32()];
            Reader.ReadBytes(8); //Reserved

            for (int i = 0; i < m_Colors.Length; i++)
                m_Colors[i] = new Color(new Vector3(Reader.ReadByte(), Reader.ReadByte(), Reader.ReadByte()));

            Reader.Close();
            m_Data = null;
        }
Esempio n. 5
0
        public FCNS(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Reader.ReadInt32(); //4 bytes always set to 0.
            int Version = Reader.ReadInt32();
            Reader.ReadInt32(); //'SNCF'

            uint Count = Reader.ReadUInt32();

            for(int i = 0; i < Count; i++)
            {
                if(Version == 1)
                {
                    FCNSConstant Constant = new FCNSConstant();
                    Constant.Name = Reader.ReadPaddedCString();
                    Constant.Value = Reader.ReadPaddedCString();
                    Reader.ReadPaddedCString(); //Description
                }
                else
                {
                    FCNSConstant Constant = new FCNSConstant();
                    Constant.Name = Reader.ReadString();
                    Constant.Value = Reader.ReadString();
                    Reader.ReadString(); //Description
                }
            }

            Reader.Close();
            m_Data = null;
        }
Esempio n. 6
0
        public Collection(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            uint Count = m_Reader.ReadUInt32();
            uint FileID = 0, TypeID = 0;

            for(int i = 0; i < Count; i++)
            {
                m_Reader.ReadUInt32(); //Index

                FileID = m_Reader.ReadUInt32();
                TypeID = m_Reader.ReadUInt32();

                PurchasableOutfitIDs.Add(new UniqueFileID(TypeID, FileID));
            }
        }
Esempio n. 7
0
        public Thumbnail(byte[] thumbnail,ThumbnailType type)
        {
            thumbType = type;
            Stream stream = new MemoryStream(thumbnail);
            FileReader reader = new FileReader(stream);
            reader.ReadBytes(4);//skip Tag 'THUM'

            width = (int)(reader.ReadUInt32());
            height = (int)(reader.ReadUInt32());

            byte[] readBytes = reader.ReadBytes(thumbnail.Length-12);
            pngBytes = new byte[readBytes.Length];
            readBytes.CopyTo(pngBytes, 0);

            stream.Close();
            reader.Close();
        }
Esempio n. 8
0
        /// <summary>
        /// Constructs a new instance of the HandGroup class.
        /// </summary>
        /// <param name="Data">A stream of data retrieved from a FAR3 archive.</param>
        public HandGroup(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version.

            Light = new HandSet(m_Reader);
            Medium = new HandSet(m_Reader);
            Dark = new HandSet(m_Reader);
        }
Esempio n. 9
0
        public Anim(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version

            ASCIIEncoding Enc = new ASCIIEncoding();
            Name = Enc.GetString(m_Reader.ReadBytes(m_Reader.ReadUShort()));
            Duration = m_Reader.ReadFloat();
            Distance = m_Reader.ReadFloat();
            IsMoving = (m_Reader.ReadByte() != 0) ? true : false;
            TranslationsCount = m_Reader.ReadUInt32();

            Translations = new float[TranslationsCount, 3];

            for(int i = 0; i < TranslationsCount; i++)
            {
                Translations[i, 0] = m_Reader.ReadFloat();
                Translations[i, 1] = m_Reader.ReadFloat();
                Translations[i, 2] = m_Reader.ReadFloat();
            }

            RotationsCount = m_Reader.ReadUInt32();

            Rotations = new float[RotationsCount, 4];

            for (int i = 0; i < RotationsCount; i++)
            {
                Rotations[i, 0] = m_Reader.ReadFloat();
                Rotations[i, 1] = m_Reader.ReadFloat();
                Rotations[i, 2] = m_Reader.ReadFloat();
                Rotations[i, 3] = m_Reader.ReadFloat();
            }

            MotionCount = m_Reader.ReadUInt32();

            for(int i = 0; i < MotionCount; i++)
                Motions.Add(new Motion(m_Reader));

            m_Reader.Close();
        }
Esempio n. 10
0
        public SPR2(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Version = Reader.ReadUInt32();
            uint SpriteCount = 0;

            if(Version == 1000)
            {
                SpriteCount = Reader.ReadUInt32();
                m_PaletteID = Reader.ReadUInt32();

                for (int i = 0; i < SpriteCount; i++)
                    m_OffsetTable.Add(Reader.ReadUInt32());
            }
            else
            {
                m_PaletteID = Reader.ReadUInt32();
                SpriteCount = Reader.ReadUInt32();

                m_OffsetTable.Add((uint)Reader.Position);
            }

            Reader.Close();
            //m_Data = null; //Don't do this here!
        }
Esempio n. 11
0
        public Hit(Stream Data)
        {
            m_Reader = new FileReader(Data, false);

            ASCIIEncoding Enc = new ASCIIEncoding();
            string MagicNumber = Enc.GetString(m_Reader.ReadBytes(4));

            if (!MagicNumber.Equals("HIT!", StringComparison.InvariantCultureIgnoreCase))
                throw new HitException("MagicNumber was wrong - Hit.cs!");

            m_Reader.ReadUInt32(); //MajorVersion
            m_Reader.ReadUInt32(); //MinorVersion

            string Trax = Enc.GetString(m_Reader.ReadBytes(4));
            if (!Trax.Equals("TRAX", StringComparison.InvariantCultureIgnoreCase))
                throw new HitException("Invalid TRAX header - Hit.cs!");

            ExTable = new ExportTable(Data);
            m_Reader.Seek(0);
            InstructionData = m_Reader.ReadBytes((int)m_Reader.StreamLength);

            m_Reader.Close();
        }
Esempio n. 12
0
        public TRK(Stream Data)
        {
            m_Reader = new FileReader(Data, false);
            string DataStr = "";
            string[] Elements;

            ASCIIEncoding Enc = new ASCIIEncoding();
            string MagicNumber = Enc.GetString(m_Reader.ReadBytes(4));

            if (!MagicNumber.Equals("2DKT", StringComparison.InvariantCultureIgnoreCase) && !MagicNumber.Equals("TKDT", StringComparison.InvariantCultureIgnoreCase))
                throw new HitException("Invalid TrackData header - TRK.cs");

            if (MagicNumber.Equals("2DKT", StringComparison.InvariantCultureIgnoreCase))
            {
                DataStr = Enc.GetString(m_Reader.ReadBytes((int)m_Reader.ReadUInt32()));
                Elements = DataStr.Split(',');
            }
            else
                Elements = Enc.GetString(m_Reader.ReadToEnd()).Split(',');

            m_Version = int.Parse(Elements[1], NumberStyles.Integer);
            TrackName = Elements[2];

            if (!Elements[3].Equals("", StringComparison.InvariantCultureIgnoreCase))
                SoundID = uint.Parse(Elements[3].Replace("0x", ""), NumberStyles.HexNumber);
            else
                SoundID = 0;

            if (Elements[5].Equals("\r\n", StringComparison.InvariantCultureIgnoreCase))
                return;

            if (!Elements[5].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Argument = (HITTrackArguments)Enum.Parse(typeof(HITTrackArguments), Elements[5]);

            if (!Elements[7].Equals("", StringComparison.InvariantCultureIgnoreCase))
                ControlGroup = (HITControlGroup)Enum.Parse(typeof(HITControlGroup), Elements[7]);

            if (!Elements[(m_Version != 2) ? 11 : 12].Equals("", StringComparison.InvariantCultureIgnoreCase))
                DuckingPriority = int.Parse(Elements[(m_Version != 2) ? 11 : 12], NumberStyles.Integer);

            if (!Elements[(m_Version != 2) ? 12 : 13].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Looped = (int.Parse(Elements[(m_Version != 2) ? 12 : 13], NumberStyles.Integer) != 0) ? true : false;

            if (!Elements[(m_Version != 2) ? 13 : 14].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Volume = int.Parse(Elements[(m_Version != 2) ? 13 : 14], NumberStyles.Integer);

            m_Reader.Close();
        }
Esempio n. 13
0
        public Skeleton(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version
            Name = m_Reader.ReadPascalString();
            BoneCount = m_Reader.ReadUShort();

            for(int i = 0; i < BoneCount; i++)
            {
                Bones.Add(new Bone(m_Reader, i));
            }

            /** Construct tree **/
            foreach (Bone bone in Bones)
                bone.Children = Bones.Where(x => x.ParentName == bone.Name).ToArray();

            RootBone = Bones.FirstOrDefault(x => x.ParentName == "NULL");

            m_Reader.Close();
        }
Esempio n. 14
0
        public OBJf(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Reader.ReadBytes(4); //Zero
            Reader.ReadBytes(4); //Version
            Reader.ReadBytes(4); //Magic

            uint Count = Reader.ReadUInt32();

            for (int i = 0; i < Count; i++)
            {
                OBJfFunctionPair FuncPair = new OBJfFunctionPair();
                FuncPair.ConditionFunction = Reader.ReadUShort();
                FuncPair.ActionFunction = Reader.ReadUShort();
                FunctionTable.Add(i, FuncPair);
            }

            Reader.Close();
            m_Data = null;
        }
        /// <summary>
        /// Constructs a new instance of the PurchasableOutfit class.
        /// </summary>
        /// <param name="Data">A Stream of data retrieved from a FAR3 archive.</param>
        public PurchasableOutfit(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version
            m_Reader.ReadUInt32(); //Unknown
            OutfitType = m_Reader.ReadUInt32();

            if(OutfitType != 0)
            {
                //A 4-byte unsigned integer specifying the type of data that follows; should be 0xA96F6D42 for cAssetKey
                m_Reader.ReadUInt32();
                uint FileID = m_Reader.ReadUInt32();
                uint TypeID = m_Reader.ReadUInt32();
                OutfitID = new UniqueFileID(TypeID, FileID);
            }

            m_Reader.ReadUInt32(); //Unknown.

            m_Reader.Close();
        }
Esempio n. 16
0
        public Appearance(Stream Data)
        {
            FileReader Reader = new FileReader(Data, true);

            Reader.ReadUInt32(); //Version

            uint FileID = Reader.ReadUInt32(), TypeID = Reader.ReadUInt32();

            ThumbnailID = new UniqueFileID(TypeID, FileID);

            uint BindingCount = Reader.ReadUInt32();
            for (uint i = 0; i < BindingCount; i++)
            {
                FileID = Reader.ReadUInt32();
                TypeID = Reader.ReadUInt32();
                BindingIDs.Add(new UniqueFileID(TypeID, FileID));
            }
        }
Esempio n. 17
0
        public SPR2Frame(FileReader Reader, GraphicsDevice Device, PALT Palette, uint SpriteVersion)
        {
            if(SpriteVersion == 1001)
            {
                Reader.ReadUInt32(); //Version
                Reader.ReadUInt32(); //Size
            }

            Width = Reader.ReadUShort();
            Height = Reader.ReadUShort();
            Texture = new Texture2D(Device, Width, Height);
            ZBuffer = new byte[Width * Height];

            uint Flags = Reader.ReadUInt32();
            Reader.ReadUShort(); //Palette.

            TransparentColor = Palette[Reader.ReadUShort()];

            HasZBuffer = (Flags & 0x02) == 0x02;
            HasAlphaChannel = (Flags & 0x04) == 0x04;

            XLocation = Reader.ReadUShort();
            YLocation = Reader.ReadUShort();

            bool EndMarker = false;

            while(!EndMarker)
            {
                ushort Marker = Reader.ReadUShort();
                var Command = Marker >> 13;
                var Count = Marker & 0x1FFF;

                switch(Command)
                {
                    //Fill this row with pixel data that directly follows; the count byte of the row command denotes
                    //the size in bytes of the row's command/count bytes together with the supplied pixel data. In
                    //the pixel data, each pixel command consists of a 3-bit/13-bit command/count header followed by a
                    //block of pixel data padded to a multiple of 2 bytes. If the row is not filled completely, the
                    //remainder is transparent. The pixel commands are:
                    case 0x00:
                        for(int i = 0; i < Count; i++)
                        {
                            ushort PxMarker = Reader.ReadUShort();
                            var PxCommand = PxMarker >> 13;
                            var PxCount = PxMarker & 0x1FFF;

                            Color[] Colors;

                            switch(PxCommand)
                            {
                                //Set the next pixel count pixels in the z-buffer and color channels to the values defined
                                //by the pixel data provided directly after this command. Every group of 2 bytes in the pixel
                                //data provides a luminosity (z-buffer) or color index (color) value to be copied to the row
                                //for the z-buffer channel and color channel, respectively, in that order, using the full
                                //opacity value of 255 for each pixel that is not the transparent color.
                                case 0x01:
                                    Colors = new Color[PxCount];

                                    for(int j = 0; j < PxCount; j++)
                                    {
                                        byte Luminosity = Reader.ReadByte();
                                        byte ColorIndex = Reader.ReadByte();
                                        Colors[j] = Palette[ColorIndex];
                                        ZBuffer[j] = Luminosity;
                                    }
                                    Texture.SetData<Color>(Colors, 0, Colors.Length);
                                    break;
                                    //Set the next pixel count pixels in the z-buffer, color, and alpha channels to the values
                                    //defined by the pixel data provided directly after this command. Every group of 3 bytes in
                                    //the pixel data, minus the padding byte at the very end (if it exists), provides a luminosity
                                    //(z-buffer and alpha) or color index (color) value to be copied to the row for the z-buffer,
                                    //color, and alpha channels, respectively, in that order. The alpha channel data is grayscale
                                    //in the range 0-31, and the z buffer is in range 0-255.
                                case 0x02:
                                    Colors = new Color[PxCount];

                                    for (int j = 0; j < PxCount; j++)
                                    {
                                        byte Luminosity = Reader.ReadByte();
                                        byte ColorIndex = Reader.ReadByte();
                                        byte Alpha = (byte)(Reader.ReadByte() * 8.2258064516129032258064516129032);
                                        Colors[j] = Palette[ColorIndex];
                                        Colors[j].A = Alpha;
                                        ZBuffer[j] = Luminosity;
                                    }
                                    Texture.SetData<Color>(Colors, 0, Colors.Length);
                                    break;
                                //Leave the next pixel count pixels in the color channel filled with the transparent color,
                                //in the z-buffer channel filled with 255, and in the alpha channel filled with 0. This pixel
                                //command has no pixel data.
                                case 0x03:
                                    Colors = new Color[PxCount];

                                    for (int j = 0; j < PxCount; j++)
                                    {
                                        Colors[j] = Color.Transparent;
                                        Colors[j].A = 0;
                                        ZBuffer[j] = 255;
                                    }
                                    Texture.SetData<Color>(Colors, 0, Colors.Length);
                                    break;
                                //Set the next pixel count pixels in the color channel to the palette color indices defined by
                                //the pixel data provided directly after this command.Every byte in the pixel data, minus the
                                //padding byte at the very end(if it exists), provides a color index value to be copied to the
                                //row for the color channel using the full opacity value of 255 and the closest z-buffer value
                                //of 0 if the pixel is not the transparent color, or otherwise the no opacity value of 0 and the
                                //farthest z-buffer value of 255.
                                case 0x06:
                                    Colors = new Color[PxCount];

                                    for (int j = 0; j < PxCount; j++)
                                    {
                                        byte ColorIndex = Reader.ReadByte();
                                        Colors[j] = Palette[ColorIndex];

                                        Colors[j].A = (Palette[ColorIndex] != Color.Transparent) ? (byte)255 : (byte)0;
                                        ZBuffer[j] = (Palette[ColorIndex] != Color.Transparent) ? (byte)0 : (byte)255;
                                    }
                                    Texture.SetData<Color>(Colors, 0, Colors.Length);
                                    break;
                            }
                        }
                        break;
                    //Leave the next count rows in the color channel filled with the transparent color,
                    //in the z-buffer channel filled with 255, and in the alpha channel filled with 0.
                    case 0x04:
                        for (int j = 0; j < Count; j++)
                        {
                            Color[] Colors = new Color[Width];

                            for (int k = 0; k < Width; k++)
                            {
                                Colors[k] = Color.Transparent;
                                Colors[k].A = 0;
                                ZBuffer[k] = 255;
                            }

                            Texture.SetData<Color>(Colors, 0, Colors.Length);
                        }
                        break;
                    case 0x05:
                        EndMarker = true;
                        break;
                }
            }
        }
Esempio n. 18
0
        private void Init(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            string MagicNumber = m_Reader.ReadString(60);

            if (!MagicNumber.Equals("IFF FILE 2.5:TYPE FOLLOWED BY SIZE\0 JAMIE DOORNBOS & MAXIS 1\0", StringComparison.InvariantCultureIgnoreCase))
                throw new IFFException("MagicNumber was wrong - IFF.cs!");

            m_Reader.ReadUInt32(); //RSMP offset

            //Size of a chunk header is 76 bytes.
            while ((m_Reader.StreamLength - m_Reader.Position) > 76)
            {
                IFFChunk Chunk;

                if (m_Device != null)
                    Chunk = new IFFChunk(m_Reader, m_Device, this);
                else
                    Chunk = new IFFChunk(m_Reader, this);

                switch (Chunk.Type)
                {
                    case IFFChunkTypes.FBMP:
                        FBMP FBMPChunk = new FBMP(Chunk);
                        m_FBMPChunks.Add(Chunk.ID, FBMPChunk);
                        break;
                    case IFFChunkTypes.FWAV:
                        FWAV FWAVChunk = new FWAV(Chunk);
                        m_FWAVChunks.Add(Chunk.ID, FWAVChunk);
                        break;
                    case IFFChunkTypes.BMP_:
                        BMP_ BMPChunk = new BMP_(Chunk);
                        m_BMP_Chunks.Add(Chunk.ID, BMPChunk);
                        break;
                    case IFFChunkTypes.DGRP:
                        DGRP DGRPChunk = new DGRP(Chunk);
                        m_DGRPChunks.Add(Chunk.ID, DGRPChunk);
                        break;
                    case IFFChunkTypes.BCON:
                        BCON BCONChunk = new BCON(Chunk);
                        m_BCONChunks.Add(Chunk.ID, BCONChunk);
                        break;
                    case IFFChunkTypes.GLOB:
                        GLOB GlobChunk = new GLOB(Chunk);
                        m_GLOBChunks.Add(Chunk.ID, GlobChunk);
                        break;
                    case IFFChunkTypes.OBJD:
                        OBJD OBJDChunk = new OBJD(Chunk);
                        m_OBJDs.Add(OBJDChunk);
                        break;
                    case IFFChunkTypes.TTAs:
                        TTAs TTAsChunk = new TTAs(Chunk);
                        m_TTAsChunks.Add(Chunk.ID, TTAsChunk);
                        break;
                    case IFFChunkTypes.TTAB:
                        TTAB TTABChunk = new TTAB(Chunk);
                        TTABChunk.Type = Chunk.Type;
                        TTABChunk.ID = Chunk.ID;
                        m_TTABChunks.Add(Chunk.ID, TTABChunk);
                        break;
                    case IFFChunkTypes.TPRP:
                        TPRP TPRPChunk = new TPRP(Chunk);
                        m_TPRPChunks.Add(Chunk.ID, TPRPChunk);
                        break;
                    case IFFChunkTypes.STR:
                        STR STRChunk = new STR(Chunk);
                        m_STRChunks.Add(Chunk.ID, STRChunk);
                        break;
                    case IFFChunkTypes.BHAV:
                        BHAV BHAVChunk = new BHAV(Chunk);
                        m_BHAVChunks.Add(Chunk.ID, BHAVChunk);
                        break;
                    case IFFChunkTypes.OBJf:
                        OBJf OBJfChunk = new OBJf(Chunk);
                        m_OBJfChunks.Add(Chunk.ID, OBJfChunk);
                        break;
                    case IFFChunkTypes.FCNS:
                        FCNS FCNSChunk = new FCNS(Chunk);
                        m_FCNSChunks.Add(Chunk.ID, FCNSChunk);
                        break;
                    case IFFChunkTypes.SPR:
                        SPR SPRChunk = new SPR(Chunk);
                        m_SPRChunks.Add(Chunk.ID, SPRChunk);
                        break;
                    case IFFChunkTypes.SPR2:
                        SPR2 SPR2Chunk = new SPR2(Chunk);
                        m_SPR2Chunks.Add(Chunk.ID, SPR2Chunk);
                        break;
                    case IFFChunkTypes.PALT:
                        PALT PALTChunk = new PALT(Chunk);
                        m_PALTChunks.Add(Chunk.ID, PALTChunk);
                        break;
                    case IFFChunkTypes.CTSS:
                        CTSS CTSSChunk = new CTSS(Chunk);
                        m_CTSSChunks.Add(Chunk.ID, CTSSChunk);
                        break;
                    case IFFChunkTypes.CST:
                        CST CSTChunk = new CST(Chunk);
                        m_CSTChunks.Add(Chunk.ID, CSTChunk);
                        break;
                }
            }
        }
Esempio n. 19
0
        public OBJD(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Version = Reader.ReadUInt32();

            switch(Version)
            {
                case 136:
                    m_NumFields = 80;
                    break;
                case 138:
                    m_NumFields = 95;
                    break;
                case 139:
                    m_NumFields = 96;
                    break;
                case 140:
                    m_NumFields = 97;
                    break;
                case 141:
                    m_NumFields = 97;
                    break;
                case 142:
                    m_NumFields = 105;
                    break;
            }

            InitialStackSize = Reader.ReadUShort();
            BaseGraphicID = Reader.ReadUShort();
            NumGraphics = Reader.ReadUShort();
            MainID = Reader.ReadUShort();
            GardeningID = Reader.ReadUShort();
            TTABID = Reader.ReadUShort();
            InteractionGroup = Reader.ReadUShort();
            ObjectType = (OBJDType)Reader.ReadUShort();
            MasterID = Reader.ReadUShort();
            SubIndex = Reader.ReadInt16();
            WashHandsID = Reader.ReadUShort();
            AnimTableID = Reader.ReadUShort();
            GUID = Reader.ReadUInt32();
            Disabled = Reader.ReadUShort();
            Portal = Reader.ReadUShort();
            Price = Reader.ReadUShort();
            BodyStringsID = Reader.ReadUShort();
            SLOTID = Reader.ReadUShort();
            AllowIntersection = Reader.ReadUShort();
            UsesFnTable = Reader.ReadUShort();
            Bitfield1 = Reader.ReadUShort();
            PrepareFoodID = Reader.ReadUShort();
            CookFoodID = Reader.ReadUShort();
            PlaceOnSurfaceID = Reader.ReadUShort();
            DisposeID = Reader.ReadUShort();
            EatFoodID = Reader.ReadUShort();
            PickupFromSLOTID = Reader.ReadUShort();
            WashDishID = Reader.ReadUShort();
            EatingSurfaceID = Reader.ReadUShort();
            Sit = Reader.ReadUShort();
            Stand = Reader.ReadUShort();
            SalePrice = Reader.ReadUShort();
            InitialDepreciation = Reader.ReadUShort();
            DailyDepreciation = Reader.ReadUShort();
            SelfDepreciating = Reader.ReadUShort();
            DepreciationLimit = Reader.ReadUShort();
            RoomFlags = Reader.ReadUShort();
            FunctionFlags = Reader.ReadUShort();
            CatalogStringsID = Reader.ReadUShort();

            Global = Reader.ReadUShort();
            BHAV_Init = Reader.ReadUShort();
            BHAV_Place = Reader.ReadUShort();
            BHAV_UserPickup = Reader.ReadUShort();
            WallStyle = Reader.ReadUShort();
            BHAV_Load = Reader.ReadUShort();
            BHAV_UserPlace = Reader.ReadUShort();
            ObjectVersion = Reader.ReadUShort();
            BHAV_RoomChange = Reader.ReadUShort();
            MotiveEffectsID = Reader.ReadUShort();
            BHAV_Cleanup = Reader.ReadUShort();
            BHAV_LevelInfo = Reader.ReadUShort();
            CatalogID = Reader.ReadUShort();
            BHAV_ServingSurface = Reader.ReadUShort();
            LevelOffset = Reader.ReadUShort();
            Shadow = Reader.ReadUShort();
            NumAttributes = Reader.ReadUShort();

            BHAV_Clean = Reader.ReadUShort();
            BHAV_QueueSkipped = Reader.ReadUShort();
            FrontDirection = Reader.ReadUShort();
            BHAV_WallAdjacencyChanged = Reader.ReadUShort();
            MyLeadObject = Reader.ReadUShort();
            DynamicSpriteBaseId = Reader.ReadUShort();
            NumDynamicSprites = Reader.ReadUShort();

            ChairEntryFlags = Reader.ReadUShort();
            TileWidth = Reader.ReadUShort();
            InhibitSuitCopying = Reader.ReadUShort();
            BuildModeType = Reader.ReadUShort();
            OriginalGUID1 = Reader.ReadUShort();
            OriginalGUID2 = Reader.ReadUShort();
            SuitGUID1 = Reader.ReadUShort();
            SuitGUID2 = Reader.ReadUShort();
            BHAV_Pickup = Reader.ReadUShort();
            ThumbnailGraphic = Reader.ReadUShort();
            ShadowFlags = Reader.ReadUShort();
            FootprintMask = Reader.ReadUShort();
            BHAV_DynamicMultiTileUpdate = Reader.ReadUShort();
            ShadowBrightness = Reader.ReadUShort();
            BHAV_Repair = Reader.ReadUShort();

            if (m_NumFields > 80)
            {
                WallStyleSpriteID = Reader.ReadUShort();
                RatingHunger = Reader.ReadUShort();
                RatingComfort = Reader.ReadUShort();
                RatingHygiene = Reader.ReadUShort();
                RatingBladder = Reader.ReadUShort();
                RatingEnergy = Reader.ReadUShort();
                RatingFun = Reader.ReadUShort();
                RatingRoom = Reader.ReadUShort();
                RatingSkillFlags = Reader.ReadUShort();
            }

            m_Data = null;
        }
Esempio n. 20
0
        public SPRFrame(FileReader Reader, GraphicsDevice Device, PALT Palette, uint SPRVersion)
        {
            if (Version == 1001)
            {
                Version = Reader.ReadUInt32();
                Size = Reader.ReadUInt32();
            }

            Reader.ReadUInt32(); //Reserved
            Height = Reader.ReadUShort();
            Width = Reader.ReadUShort();

            Texture = new Texture2D(Device, Width, Height);

            for(ushort i = 0; i < Height; i++)
            {
                byte Cmd = Reader.ReadByte();
                byte Count = Reader.ReadByte();

                switch(Cmd)
                {
                    case 0x04:
                        for(byte j = 0; j < Count; j++)
                        {
                            byte PxCmd = Reader.ReadByte();
                            byte PxCount = Reader.ReadByte();
                            Color[] Pixels;

                            switch(PxCmd)
                            {
                                case 0x01:
                                    //Leave the next pixel count pixels as transparent. This pixel command has no pixel data.
                                    Pixels = new Color[Count];
                                    for (int k = 0; k < Count; k++)
                                        Pixels[k] = Color.Transparent;

                                    Texture.SetData<Color>(Pixels, 0, Count);
                                    break;
                                case 0x02:
                                    //Fill the next pixel count pixels with a single palette color.
                                    //The pixel data is two bytes: the first byte denotes the palette color
                                    //index, and the second byte is padding (which is always equal to the
                                    //first byte but is ignored).
                                    Pixels = new Color[Count];
                                    byte ColorIndex = Reader.ReadByte();

                                    for (int k = 0; k < Count; k++)
                                        Pixels[k] = Palette[ColorIndex];

                                    Texture.SetData<Color>(Pixels, 0, Count);
                                    break;
                                case 0x03:
                                    //Set the next pixel count pixels to the palette color indices defined by
                                    //the pixel data provided directly after this command. Each byte in the pixel data,
                                    //minus the padding byte at the very end (if it exists), is a color index value to
                                    //be copied to the row.
                                    Pixels = new Color[Count];

                                    for (int k = 0; k < Count; k++)
                                        Pixels[k] = Palette[Reader.ReadByte()];

                                    Texture.SetData<Color>(Pixels, 0, Count);
                                    break;
                                case 0x09:
                                    //Leave the next count rows as transparent.
                                    for (int k = 0; k < Count; k++)
                                    {
                                        Pixels = new Color[Width];
                                        for (int l = 0; l < Width; l++)
                                            Pixels[l] = Color.Transparent;

                                        Texture.SetData<Color>(Pixels, 0, Width);
                                    }
                                    break;
                            }
                        }
                        break;
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Loads an *.xa file, setting things up for decompression.
        /// Should always be called before DecompressFile().
        /// </summary>
        /// <param name="Data">The data of the *.xa file to process.</param>
        public void LoadFile(byte[] Data)
        {
            m_Reader = new FileReader(new MemoryStream(Data), false);

            m_ID = Convert.ToString(m_Reader.ReadBytes(4));
            m_DecompressedSize = m_Reader.ReadUInt32();
            m_Tag = m_Reader.ReadUShort();
            m_Channels = m_Reader.ReadUShort();
            m_SampleRate = m_Reader.ReadUInt32();
            m_AvgByteRate = m_Reader.ReadUInt32();
            m_Align = m_Reader.ReadUShort();
            m_Bits = m_Reader.ReadUShort();

            m_DecompressedStream = new MemoryStream((int)m_DecompressedSize);
            m_Writer = new BinaryWriter(m_DecompressedStream);
        }
Esempio n. 22
0
        public DGRPImg(FileReader Reader, uint Version)
        {
            if (Version == 20000 || Version == 20001)
            {
                SpriteCount = Reader.ReadUShort();
                DirectionFlags = Reader.ReadByte();
                ZoomLevel = Reader.ReadByte();

                for (int i = 0; i < SpriteCount; i++)
                    Info.Add(new SpriteInfo(Reader, Version));
            }
            else
            {
                DirectionFlags = Reader.ReadUInt32();
                ZoomLevel = Reader.ReadUInt32();
                SpriteCount = Reader.ReadUInt32();

                for (int i = 0; i < SpriteCount; i++)
                    Info.Add(new SpriteInfo(Reader, Version));
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Loads a *.xa file, setting things up for decompression.
        /// Should always be called before DecompressFile().
        /// </summary>
        /// <param name="Path">The path to the *.xa file to load.</param>
        public void LoadFile(string Path)
        {
            m_Reader = new FileReader(File.Open(Path, FileMode.Open, FileAccess.Read, FileShare.Read), false);

            m_ID = Convert.ToString(m_Reader.ReadBytes(4));
            m_DecompressedSize = m_Reader.ReadUInt32();
            m_Tag = m_Reader.ReadUShort();
            m_Channels = m_Reader.ReadUShort();
            m_SampleRate = m_Reader.ReadUInt32();
            m_AvgByteRate = m_Reader.ReadUInt32();
            m_Align = m_Reader.ReadUShort();
            m_Bits = m_Reader.ReadUShort();

            m_DecompressedStream = new MemoryStream((int)m_DecompressedSize);
            m_Writer = new BinaryWriter(m_DecompressedStream);
        }
Esempio n. 24
0
        public Mesh(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version
            BoneCount = m_Reader.ReadUInt32();

            for (int i = 0; i < BoneCount; i++)
                Bones.Add(m_Reader.ReadPascalString());

            FaceCount = m_Reader.ReadUInt32();

            for (int i = 0; i < FaceCount; i++)
                Faces.Add(new Vector3(m_Reader.ReadUInt32(), m_Reader.ReadUInt32(), m_Reader.ReadUInt32()));

            BindingCount = m_Reader.ReadUInt32();

            for (int i = 0; i < BindingCount; i++)
                BoneBindings.Add(new BoneBinding(m_Reader));

            RealVertexCount = m_Reader.ReadUInt32();
            List<Vector2> TexVertices = new List<Vector2>();

            for (int i = 0; i < RealVertexCount; i++)
                TexVertices.Add(new Vector2(m_Reader.ReadFloat(), m_Reader.ReadFloat()));

            BlendVertexCount = m_Reader.ReadUInt32();

            for (int i = 0; i < BlendVertexCount; i++)
                BlendVertexProps.Add(new BlendVertexProperty(m_Reader));

            TotalVertexCount = m_Reader.ReadUInt32();
            TransformedVertices = new VertexPositionNormalTexture[TotalVertexCount];

            for (int i = 0; i < RealVertexCount; i++)
            {
                RealVertices.Add(new VertexPositionNormalTexture(new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()),
                    new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()), TexVertices[i]));
            }

            for(int i = 0; i < BlendVertexCount; i++)
            {
                BlendedVertices.Add(new VertexPositionNormalTexture(new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()),
                    new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()), TexVertices[i]));
            }

            m_Reader.Close();
        }