This chunk type holds Behavior code in SimAntics.
Inheritance: IFFChunk
Esempio n. 1
0
        /// <summary>
        /// Attempts to read an IFF file from a given stream.
        /// </summary>
        /// <param name="Data">The stream from which to open the IFF.</param>
        /// <param name="ThrowException">Should this method throw an exception if it couldn't open the file?</param>
        /// <returns>True if successful, false otherwise (if ThrowException is set to false).</returns>
        public bool Init(Stream Data, bool ThrowException)
        {
            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))
            {
                if (ThrowException)
                {
                    throw new IFFException("MagicNumber was wrong - IFF.cs!");
                }
                else
                {
                    return(false);
                }
            }

            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;
                }
            }

            return(true);
        }
Esempio n. 2
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;
                }
            }
        }