Пример #1
0
 public kOSException(String message, ExecutionContext context)
     : this(message)
 {
     this.LineNumber = context.Line;
     this.Context = context;
     this.Program = context.FindClosestParentOfType<ContextRunProgram>();
 }
Пример #2
0
        public ImmediateMode(ExecutionContext parent)
            : base(parent)
        {
            StdOut("kOS Operating System");
            StdOut("KerboScript v" + Core.VersionInfo.ToString());
            StdOut("");

            bool autoexecExists = false;
            if (SelectedVolume.GetByName("autoexec") != null) {
                autoexecExists = true;
            } else {
                Volume ArchiveVolume = GetVolume("Archive");

                if (ArchiveVolume.GetByName("autoexec") != null) {
                    Add("copy autoexec from archive.");
                    autoexecExists = true;
                }
            }

            if (autoexecExists) {
                StdOut("Executing autoexec...");
                Add("run autoexec.");
            } else {
                StdOut("Autoexec was not found.");
            }

            StdOut("Proceed.");
        }
Пример #3
0
        public Atmosphere(CelestialBody body, ExecutionContext context)
        {
            BodyRef = body;

            AddSuffix("HEIGHT", null, ()=>{ return BodyRef.atmosphereDepth; });
            AddSuffix("OXYGEN", null, () => { return BodyRef.atmosphere && BodyRef.atmosphereContainsOxygen; });
            AddSuffix("SEALEVELPRESSURE", null, () => { return BodyRef.atmospherePressureSeaLevel; });
        }
Пример #4
0
 public ImmediateMode(ExecutionContext parent)
     : base(parent)
 {
     StdOut("kOS Operating System Build " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Revision);
     StdOut("KerboScript v0.8");
     StdOut("");
     StdOut("Proceed.");
 }
Пример #5
0
 public ImmediateMode(ExecutionContext parent)
     : base(parent)
 {
     StdOut("kOS Operating System");
     StdOut("KerboScript v" + Core.VersionInfo.ToString());
     StdOut("");
     StdOut("Proceed.");
 }
Пример #6
0
        public InterpreterBootup(ExecutionContext parent)
            : base(parent)
        {
            //ShowAnimationFrame(0);
            PrintAt("BOOTING UP...", 22, 20);

            State = ExecutionState.WAIT;
        }
Пример #7
0
        public Expression(String text, ExecutionContext context)
        {
            this.executionContext = context;

            text = text.Trim();
            Text = text;

            UnwrapFullBrackets(ref text);

            Process(text);
        }
Пример #8
0
        public InterpreterEdit(String fileName, ExecutionContext parent)
            : base(parent)
        {
            File = SelectedVolume.GetByName(fileName);

            if (File == null)
            {
                File = new File(fileName);
                File.Add("");
            }

            CursorX = 0;
            CursorY = 2;
        }
Пример #9
0
        public static Command Get(String input, ExecutionContext context, int line)
        {
            try
            {
                Command retCommand = Get(input, context);
                retCommand.Line = line;

                return retCommand;
            }
            catch (kOSException e)
            {
                e.LineNumber = line;
                throw e;
            }
        }
Пример #10
0
        public Expression(String text, ExecutionContext context)
        {
            this.executionContext = context;

            text = text.Trim();
            Text = text;

            if (!Utils.DelimterMatch (text))
            {
                throw new kOSException ("Error: mismatching delimiter.");
            }

            UnwrapFullBrackets(ref text);

            Process(text);
        }
Пример #11
0
        public Expression(String text, ExecutionContext context)
        {
            this.executionContext = context;

            text = text.Trim();
            Text = text;

            if (!CheckForBrackets(text))
            {
                throw new kOSException("Bracket matching error.");
            }

            UnwrapFullBrackets(ref text);

            Process(text);
        }
Пример #12
0
        public static Command Get(String input, ExecutionContext context)
        {
            input = input.Trim();//.Replace("\n", " ");

            foreach (var kvp in CommandRegistry.Bindings)
            {
                Match match = Regex.Match(input, kvp.Key, RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    var command = (Command)Activator.CreateInstance(kvp.Value, match, context);
                    return command;
                }
            }

            throw new kOSException("Syntax Error.", context);
        }
Пример #13
0
        public ImmediateMode(ExecutionContext parent)
            : base(parent)
        {
            //StdOut("kOS Operating System");
            //StdOut("KerboScript v" + Core.VersionInfo.ToString());

            for (var y = 13; y < 16; y++)
            {
                string output = "";
                for (var x = 11; x < 16; x++)
                {
                    output += ((char)((y*16) + x)).ToString();
                }

                if (y == 15) output += " v" + Core.VersionInfo.ToString();

                StdOut(output);
            }

            StdOut("");
            StdOut("");
            StdOut("Proceed.");
        }
Пример #14
0
        public Body(CelestialBody target, ExecutionContext context)
        {
            this.Context = context;
            this.BodyRef = target;

            AddSuffix("NAME", null, () => { return BodyRef.name; });
            AddSuffix("DESCRIPTION", null, () => { return BodyRef.bodyDescription; });
            AddSuffix("MASS", null, () => { return BodyRef.Mass; });
            AddSuffix("POSITION", null, () => { return new Vector(BodyRef.position); });
            AddSuffix("ALTITUDE", null, () => { return BodyRef.orbit.altitude; });
            AddSuffix("APOAPSIS", null, () => { return BodyRef.orbit.ApA; });
            AddSuffix("PERIAPSIS", null, () => { return BodyRef.orbit.PeA; });
            AddSuffix("VELOCITY", null, () => { return new Vector(BodyRef.orbit.GetVel()); });
            AddSuffix("DISTANCE", null, () => { return (float)GetDistance(); });
            AddSuffix("BODY", null, () => { return new Body(BodyRef.orbit.referenceBody, Context); });
            AddSuffix("MU", null, () => { return BodyRef.gravParameter; });
            AddSuffix("ROTATIONPERIOD", null, () => { return BodyRef.rotationPeriod; });
            AddSuffix("RADIUS", null, () => { return BodyRef.Radius; });
            AddSuffix("GRAVITY", null, () => { return BodyRef.gravParameter; });
            AddSuffix("OCEANIC", null, () => { return BodyRef.ocean; });
            AddSuffix("ATMOSPHERE", null, () => { return new Atmosphere(BodyRef, Context); });
            AddSuffix("ATM", null, () => { return new Atmosphere(BodyRef, Context); });
        }
Пример #15
0
 public CommandSetOff(Match regexMatch, ExecutionContext context) : base(regexMatch, context)
 {
 }
Пример #16
0
 public Command(String input, ExecutionContext context)
     : base(context)
 {
     this.Input = input;
 }
Пример #17
0
 public virtual void Push(ExecutionContext newChild)
 {
     ChildContext = newChild;
 }
Пример #18
0
 public CommandBreak(Match regexMatch, ExecutionContext context)
     : base(regexMatch, context)
 {
 }
Пример #19
0
 public CommandBlock(String directInput, ExecutionContext context)
     : base(Regex.Match(directInput, "^([\\S\\s]*)$"), context)
 {
 }
Пример #20
0
 public CommandToggle(Match regexMatch, ExecutionContext context) : base(regexMatch, context)
 {
 }
Пример #21
0
 public CommandVesselListings(Match regexMatch, ExecutionContext context)
     : base(regexMatch, context)
 {
 }
Пример #22
0
 public Command(String input, ExecutionContext context) : base(context)
 {
     this.Input = input;
 }
Пример #23
0
 public CommandShutdown(Match regexMatch, ExecutionContext context) : base(regexMatch, context)
 {
 }
Пример #24
0
 public CommandReboot(Match regexMatch, ExecutionContext context) : base(regexMatch, context)
 {
 }
Пример #25
0
 public VesselTarget(Vessel target, ExecutionContext context)
 {
     this.context = context;
     this.target  = target;
 }
Пример #26
0
 public ExecutionContext(ExecutionContext parent)
 {
     this.ParentContext = parent;
 }
Пример #27
0
 public CommandVesselStage(Match regexMatch, ExecutionContext context)
     : base(regexMatch, context)
 {
 }
Пример #28
0
 public CommandClearScreen(Match regexMatch, ExecutionContext context) : base(regexMatch, context)
 {
 }
Пример #29
0
 public BodyTarget(CelestialBody target, ExecutionContext context)
 {
     this.context = context;
     Target = target;
 }
Пример #30
0
 public static String Evaluate(String text, ExecutionContext context)
 {
     Expression e = new Expression(text, context);
     return e.GetValue().ToString();
 }
Пример #31
0
 public CommandOnEvent(Match regexMatch, ExecutionContext context)
     : base(regexMatch, context)
 {
 }
Пример #32
0
        public virtual void Update(float time)
        {
            // Process Command locks
            foreach (Command command in new List<Command>(CommandLocks))
            {
                command.Update(time);
            }

            if (ChildContext != null)
            {
                if (ChildContext.State == ExecutionState.DONE)
                {
                    ChildContext = null;
                }
                else
                {
                    ChildContext.Update(time);
                }
            }
        }
Пример #33
0
 public CommandUntilLoop(Match regexMatch, ExecutionContext context)
     : base(regexMatch, context)
 {
 }
Пример #34
0
 public VesselTarget(Vessel target, ExecutionContext context)
 {
     this.context = context;
     this.target = target;
 }
Пример #35
0
 public CommandDeclareVar(Match regexMatch, ExecutionContext context) : base(regexMatch, context)
 {
 }
Пример #36
0
 public CommandPrintAt(Match regexMatch, ExecutionContext context) : base(regexMatch, context)
 {
 }
Пример #37
0
 public virtual void Push(ExecutionContext newChild)
 {
     ChildContext = newChild;
 }
Пример #38
0
 public Body(String name, ExecutionContext context)
     : this(VesselUtils.GetBodyByName(name), context)
 {
 }
Пример #39
0
 public ExecutionContext(ExecutionContext parent)
 {
     this.ParentContext = parent;
 }
Пример #40
0
 public Command(Match regexMatch, ExecutionContext context) : base(context)
 {
     this.RegexMatch = regexMatch;
 }
Пример #41
0
 public Command(Match regexMatch, ExecutionContext context)
     : base(context)
 {
     Input = regexMatch.ToString();
     this.RegexMatch = regexMatch;
 }
Пример #42
0
 public CommandSetTerminator(Match regexMatch, ExecutionContext context) : base(regexMatch, context)
 {
 }
Пример #43
0
 public CommandDelete(Match regexMatch, ExecutionContext context)
     : base(regexMatch, context)
 {
 }
Пример #44
0
 public kOSException(String message, ExecutionContext context) : this (message)
 {
     this.LineNumber = context.Line;
     this.Context = context;
     this.Program = context.FindClosestParentOfType<ContextRunProgram>();
 }