예제 #1
0
파일: Script.cs 프로젝트: senny970/2007
        public OpsScript(OpsCommandLibrary library, string script)
        {
            OpsParsedStatement[] parsedStatements = OpsParser.ParseScript(script);
            if (parsedStatements != null)
            {
                if (OpsConsole.Verbose)
                {
                    OpsConsole.WriteLine("Prevalidating script starting.");
                }

                Statements = new OpsStatement[parsedStatements.Length];
                for (int i = 0; i < parsedStatements.Length; i++)
                {
                    OpsParsedStatement parsed    = parsedStatements[i] as OpsParsedStatement;
                    IOpsCommand        command   = null;
                    object             arguments = null;

                    if (OpsConsole.Verbose)
                    {
                        OpsConsole.WriteLine("Prevalidating statement #{0}: \"{1}\"", i, parsed);
                    }


                    try
                    {
                        command = library.GetCommand(parsed.Command);
                    }
                    catch (Exception e)
                    {
                        OpsConsole.WriteError(i + 1, e, "Unable to fetch command: " + parsed.Command);
                        throw;
                    }

                    if (command is IOpsRemappable)
                    {
                        try
                        {
                            command = (command as IOpsRemappable).RemapCommand(parsed);
                        }
                        catch (Exception e)
                        {
                            OpsConsole.WriteError(i + 1, e, "Unable to remap command: " + parsed.Command);
                            throw;
                        }
                    }

                    try
                    {
                        arguments = command.ParseArguments(parsed);
                    }
                    catch (Exception e)
                    {
                        OpsConsole.WriteError(i + 1, e, "Command failed to interpret the arguments.");
                        throw;
                    }

                    Statements[i] = new OpsStatement(parsed, command, arguments);
                }

                if (OpsConsole.Verbose)
                {
                    OpsConsole.WriteLine("Prevalidating script finished.");
                }
            }
        }
예제 #2
0
        public OpsScript(OpsCommandLibrary library, string script)
        {

            OpsParsedStatement[] parsedStatements = OpsParser.ParseScript(script);
            if(parsedStatements != null)
            {
                if(OpsConsole.Verbose)
                    OpsConsole.WriteLine("Prevalidating script starting.");

                Statements = new OpsStatement[parsedStatements.Length];
                for( int i = 0; i < parsedStatements.Length; i++)
                {
                    OpsParsedStatement parsed = parsedStatements[i] as OpsParsedStatement;
                    IOpsCommand command = null;
                    object arguments = null;

                    if(OpsConsole.Verbose)
                        OpsConsole.WriteLine("Prevalidating statement #{0}: \"{1}\"", i, parsed);

                    
                    try
                    {
                        command = library.GetCommand(parsed.Command);
                    }
                    catch( Exception e )
                    {
                        OpsConsole.WriteError(i+1, e, "Unable to fetch command: " +    parsed.Command);
                        throw;
                    }

                    if(command is IOpsRemappable)
                    {
                        try
                        {
                            command = (command as IOpsRemappable).RemapCommand(parsed);
                        }
                        catch( Exception e )
                        {
                            OpsConsole.WriteError(i+1, e, "Unable to remap command: " + parsed.Command);
                            throw;
                        }
                    }

                    try
                    {
                        arguments = command.ParseArguments(parsed);    
                    }
                    catch( Exception e )
                    {
                        OpsConsole.WriteError(i+1, e, "Command failed to interpret the arguments.");
                        throw;
                    }

                    Statements[i] = new OpsStatement(parsed, command, arguments);

                }

                if(OpsConsole.Verbose)
                    OpsConsole.WriteLine("Prevalidating script finished.");
            }

        }
예제 #3
0
        //IOpsCommand
        public void Run(OpsContext context, OpsStatement statement)
        {
    
            UnloadArguments args = statement.Arguments as UnloadArguments;


            if( args.Type == ContentType.GENERIC || args.Type == ContentType.MODELS )
            {
                ArrayList models = context.FindModels(args.Src);
                foreach( OpsModel model in models )
                {
                    OpsConsole.WriteLine( "Unloading model: '{0}'", model.Name );
                    context.RemoveModel(model.Name);
                }
            }

            if( args.Type == ContentType.GENERIC || args.Type == ContentType.TEXTURES )
            {
                ArrayList textures = context.FindTextures(args.Src);    
                foreach( OpsTexture texture in textures )
                {
                    OpsConsole.WriteLine( "Unloading texture: '{0}'", texture.Name );
                    context.RemoveTexture(texture.Name);
                }
            }
        }