ConsumeString() public method

public ConsumeString ( string _ExpectedString ) : void
_ExpectedString string
return void
コード例 #1
0
ファイル: Parser.cs プロジェクト: vr3d/GodComplex
        public float3   ReadFloat3(float3 _InitialValue)
        {
            string Block = ReadBlock();
            Parser P     = new Parser(Block);

            float3 Result = _InitialValue;
            string coord  = P.ReadString();

            while (P.OK)
            {
                P.ConsumeString("= ");
                float value = P.ReadFloat();
                P.ConsumeString(";");

                switch (coord)
                {
                case "x": Result.x = value; break;

                case "y": Result.y = value; break;

                case "z": Result.z = value; break;

                default: Error("Unexpected coordinate!"); break;
                }
                coord = P.ReadString();
            }
            return(Result);
        }
コード例 #2
0
ファイル: Map.cs プロジェクト: Patapom/GodComplex
        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 );
                    }
                }
        }
コード例 #3
0
ファイル: Map.cs プロジェクト: vr3d/GodComplex
            private void    ParseModel(string _Model)
            {
                Parser P = new Parser(_Model);

                P.ConsumeString("model = ");

                string ModelFileName = RebaseFileName(P.ReadString(true, true), "T:/generated/model/", ".bmodel");

                m_Model = new Model(ModelFileName);
            }
コード例 #4
0
ファイル: Map.cs プロジェクト: vr3d/GodComplex
        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);
                    }
                }
            }
        }
コード例 #5
0
ファイル: Map.cs プロジェクト: vr3d/GodComplex
            public bool             Parse(string _Block)
            {
                Parser P = new Parser(_Block);

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

                string entityDef = P.ReadBlock();

                return(ParseEntityDef(entityDef));
            }
コード例 #6
0
ファイル: Map.cs プロジェクト: vr3d/GodComplex
            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);
            }
コード例 #7
0
ファイル: Map.cs プロジェクト: vr3d/GodComplex
            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();
                }
            }
コード例 #8
0
ファイル: Map.cs プロジェクト: Patapom/GodComplex
            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();
                }
            }
コード例 #9
0
ファイル: Map.cs プロジェクト: Patapom/GodComplex
            private void ParseModel( string _Model )
            {
                Parser	P = new Parser( _Model );
                P.ConsumeString( "model = " );

                string	ModelFileName = RebaseFileName( P.ReadString( true, true ), "T:/generated/model/", ".bmodel" );
                m_Model = new Model( ModelFileName );
            }
コード例 #10
0
ファイル: Map.cs プロジェクト: Patapom/GodComplex
            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;
            }
コード例 #11
0
ファイル: Map.cs プロジェクト: Patapom/GodComplex
            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();
                }
            }
コード例 #12
0
ファイル: Map.cs プロジェクト: Patapom/GodComplex
            public bool Parse( string _Block )
            {
                Parser	P = new Parser( _Block );
                P.ConsumeString( "entityDef" );
                m_Name = P.ReadString();

                string	entityDef = P.ReadBlock();

                return ParseEntityDef( entityDef );
            }
コード例 #13
0
ファイル: Map.cs プロジェクト: vr3d/GodComplex
            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();
                }
            }
コード例 #14
0
ファイル: Parser.cs プロジェクト: Patapom/GodComplex
        public float3 ReadFloat3( float3 _InitialValue)
        {
            string	Block = ReadBlock();
            Parser	P = new Parser( Block );

            float3	Result = _InitialValue;
            string	coord = P.ReadString();
            while ( P.OK ) {
                P.ConsumeString( "= " );
                float	value = P.ReadFloat();
                P.ConsumeString( ";" );

                switch ( coord ) {
                    case "x": Result.x = value; break;
                    case "y": Result.y = value; break;
                    case "z": Result.z = value; break;
                    default: Error( "Unexpected coordinate!" ); break;
                }
                coord = P.ReadString();
            }
            return Result;
        }