ReadBlock() public method

public ReadBlock ( ) : string
return string
Example #1
0
        private void Parse( string _Content )
        {
            Parser	P = new Parser( _Content );

            List<Entity>	Entities = new List<Entity>();

            P.ConsumeString( "Version" );
            int	Version = P.ReadInteger();
            if ( Version != 4 )
                P.Error( "Unsupported file version!" );

            while ( P.OK ) {
                P.ConsumeString( "entity" );
                string	Block = P.ReadBlock();

                Entity	E = new Entity( this );
                if ( E.Parse( Block ) ) {
                    Entities.Add( E );
                }

                P.SkipSpaces();
            }

            m_Entities.AddRange( Entities );

            // Parse all refmaps
            foreach ( Entity E in Entities )
                if ( E.m_Type == Entity.TYPE.REF_MAP ) {
                    using ( StreamReader R = new FileInfo( E.m_RefMapName ).OpenText() ) {
                        string	Content = R.ReadToEnd();
                        Parse( Content );
                    }
                }
        }
Example #2
0
            public bool             Parse(string _Block)
            {
                Parser P = new Parser(_Block);

                P.ConsumeString("entityDef");
                m_Name = P.ReadString();

                string entityDef = P.ReadBlock();

                return(ParseEntityDef(entityDef));
            }
Example #3
0
            private bool    ParseEntityDef(string _Block)
            {
                Parser P = new Parser(_Block);

                P.ConsumeString("inherit =");
                string inherit = P.ReadString(true, true);

                if (inherit == "func/static")
                {
                    m_Type = TYPE.MODEL;
                }
                else if (inherit == "player/start")
                {
                    m_Type = TYPE.PLAYER_START;
                }
                else if (inherit == "blacksparrow/probe")
                {
                    m_Type = TYPE.PROBE;
                }
                else if (inherit == "func/reference")
                {
                    m_Type = TYPE.REF_MAP;
                }
                if (m_Type == TYPE.UNKNOWN)
                {
                    return(false);
                }

                P.ConsumeString("editorVars");
                P.ReadBlock();
                P.ConsumeString("edit =");

                string Content = P.ReadBlock();

                ParseContent(Content);

                return(true);
            }
Example #4
0
        private void    Parse(string _Content)
        {
            Parser P = new Parser(_Content);

            List <Entity> Entities = new List <Entity>();

            P.ConsumeString("Version");
            int Version = P.ReadInteger();

            if (Version != 4)
            {
                P.Error("Unsupported file version!");
            }

            while (P.OK)
            {
                P.ConsumeString("entity");
                string Block = P.ReadBlock();

                Entity E = new Entity(this);
                if (E.Parse(Block))
                {
                    Entities.Add(E);
                }

                P.SkipSpaces();
            }

            m_Entities.AddRange(Entities);

            // Parse all refmaps
            foreach (Entity E in Entities)
            {
                if (E.m_Type == Entity.TYPE.REF_MAP)
                {
                    using (StreamReader R = new FileInfo(E.m_RefMapName).OpenText()) {
                        string Content = R.ReadToEnd();
                        Parse(Content);
                    }
                }
            }
        }
Example #5
0
            private void    ParseOrientation(string _Orientation)
            {
                Parser P = new Parser(_Orientation);

                P.ConsumeString("mat = ");

                string Rows = P.ReadBlock();

                P = new Parser(Rows);
                string row = P.ReadString();

                while (P.OK)
                {
                    P.ConsumeString("= ");
                    switch (row)
                    {
                    case "mat[0]": {
                        float3 value = P.ReadFloat3(float3.UnitX);
                        m_Local2World.r0.Set(value, m_Local2World.r0.w);
                        break;
                    }

                    case "mat[1]": {
                        float3 value = P.ReadFloat3(float3.UnitY);
                        m_Local2World.r1.Set(value, m_Local2World.r1.w);
                        break;
                    }

                    case "mat[2]": {
                        float3 value = P.ReadFloat3(float3.UnitZ);
                        m_Local2World.r2.Set(value, m_Local2World.r2.w);
                        break;
                    }

                    default: P.Error("Unexpected coordinate!"); break;
                    }
                    row = P.ReadString();
                }
            }
Example #6
0
            private void ParseOrientation( string _Orientation )
            {
                Parser	P = new Parser( _Orientation );
                P.ConsumeString( "mat = " );

                string	Rows = P.ReadBlock();

                P = new Parser( Rows );
                string	row = P.ReadString();
                while ( P.OK ) {
                    P.ConsumeString( "= " );
                    switch ( row ) {
                        case "mat[0]": {
                            float3	value = P.ReadFloat3( float3.UnitX );
                            m_Local2World.r0.Set( value, m_Local2World.r0.w );
                            break;
                        }
                        case "mat[1]": {
                            float3	value = P.ReadFloat3( float3.UnitY );
                            m_Local2World.r1.Set( value, m_Local2World.r1.w );
                            break;
                        }
                        case "mat[2]": {
                            float3	value = P.ReadFloat3( float3.UnitZ );
                            m_Local2World.r2.Set( value, m_Local2World.r2.w );
                            break;
                        }
                        default: P.Error( "Unexpected coordinate!" ); break;
                    }
                    row = P.ReadString();
                }
            }
Example #7
0
            private bool ParseEntityDef( string _Block )
            {
                Parser	P = new Parser( _Block );
                P.ConsumeString( "inherit =" );
                string	inherit = P.ReadString( true, true );

                if ( inherit == "func/static" ) {
                    m_Type = TYPE.MODEL;
                } else if ( inherit == "player/start" ) {
                    m_Type = TYPE.PLAYER_START;
                } else if ( inherit == "blacksparrow/probe" ) {
                    m_Type = TYPE.PROBE;
                } else if ( inherit == "func/reference" ) {
                    m_Type = TYPE.REF_MAP;
                }
                if ( m_Type == TYPE.UNKNOWN )
                    return false;

                P.ConsumeString( "editorVars" );
                P.ReadBlock();
                P.ConsumeString( "edit =" );

                string	Content = P.ReadBlock();
                ParseContent( Content );

                return true;
            }
Example #8
0
            private void ParseContent( string _Content )
            {
                Parser	P = new Parser( _Content );

                string	property = P.ReadString();
                while ( P.OK ) {
                    switch ( property ) {
                        case "spawnPosition":
                            P.ConsumeString( "= " );
                            float3	Position = P.ReadFloat3( float3.Zero );
                            m_Local2World.r0.w = Position.x;
                            m_Local2World.r1.w = Position.y;
                            m_Local2World.r2.w = Position.z;
                            break;
                        case "spawnOrientation":
                            P.ConsumeString( "= " );
                            string	Orientation = P.ReadBlock();
                            ParseOrientation( Orientation );
                            break;
                        case "renderModelInfo":
                            P.ConsumeString( "= ! " );
                            string	Model = P.ReadBlock();
                            ParseModel( Model );
                            break;
                        case "m_probe":
                            P.ConsumeString( "= " );
                            string	ProbeName = P.UnQuote( P.ReadToEOL(), true );
                            break;
                        case "mapname":
                            P.ConsumeString( "= " );
                            m_RefMapName = RebaseFileName( P.UnQuote( P.ReadToEOL(), true ), "T:/", null );
                            break;
                        case "m_usedForIBL":
                            P.ReadToEOL();
                            m_IBL = true;
                            break;

                        // Don't care... (single line)
                        case "entityPrefix":
                            P.ReadToEOL();
                            break;

                        // Don't care... (block)
                        case "m_bounceFactorSun":
                        case "m_kiscule":
                            P.ConsumeString( "= " );
                            P.ReadBlock();
                            break;

                        case "//":	// Skip comment
                            P.ReadToEOL();
                            break;

                        default:
                            P.Error( "Unexpected property!" );
                            break;
                    }
                    property = P.ReadString();
                }
            }
Example #9
0
            public bool Parse( string _Block )
            {
                Parser	P = new Parser( _Block );
                P.ConsumeString( "entityDef" );
                m_Name = P.ReadString();

                string	entityDef = P.ReadBlock();

                return ParseEntityDef( entityDef );
            }
Example #10
0
            private void    ParseContent(string _Content)
            {
                Parser P = new Parser(_Content);

                string property = P.ReadString();

                while (P.OK)
                {
                    switch (property)
                    {
                    case "spawnPosition":
                        P.ConsumeString("= ");
                        float3 Position = P.ReadFloat3(float3.Zero);
                        m_Local2World.r0.w = Position.x;
                        m_Local2World.r1.w = Position.y;
                        m_Local2World.r2.w = Position.z;
                        break;

                    case "spawnOrientation":
                        P.ConsumeString("= ");
                        string Orientation = P.ReadBlock();
                        ParseOrientation(Orientation);
                        break;

                    case "renderModelInfo":
                        P.ConsumeString("= ! ");
                        string Model = P.ReadBlock();
                        ParseModel(Model);
                        break;

                    case "m_probe":
                        P.ConsumeString("= ");
                        string ProbeName = P.UnQuote(P.ReadToEOL(), true);
                        break;

                    case "mapname":
                        P.ConsumeString("= ");
                        m_RefMapName = RebaseFileName(P.UnQuote(P.ReadToEOL(), true), "T:/", null);
                        break;

                    case "m_usedForIBL":
                        P.ReadToEOL();
                        m_IBL = true;
                        break;

                    // Don't care... (single line)
                    case "entityPrefix":
                        P.ReadToEOL();
                        break;

                    // Don't care... (block)
                    case "m_bounceFactorSun":
                    case "m_kiscule":
                        P.ConsumeString("= ");
                        P.ReadBlock();
                        break;

                    case "//":                                  // Skip comment
                        P.ReadToEOL();
                        break;

                    default:
                        P.Error("Unexpected property!");
                        break;
                    }
                    property = P.ReadString();
                }
            }