コード例 #1
0
        public override void CheckConstructorSyntax()
        {
            base.CheckConstructorSyntax();

            //parse static types
            switch (Definition.ObjectType)
            {
            default:
                throw new ArgumentException("Unknown filter type '" + Definition.ObjectType + "'");

            case "NONE":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 1 && Definition.ObjectParameters[0] == "");
                if (Task == null)
                {
                    throw new InvalidOperationException("Filter NONE is valid only inside tasks");
                }
                break;

            case "INSIDE":
            case "OUTSIDE":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 1);
                area = ResolveOrDie <ScriptingArea>(0);
                break;

            case "BEFORETIME":
            case "AFTERTIME":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 1);
                time = Engine.Settings.Date.Date + ParseOrDie <TimeSpan>(0, Parsers.ParseTimeSpan);
                break;

            case "BEFOREPOINT":
            case "AFTERPOINT":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 1);
                point = ResolveOrDie <ScriptingPoint>(0);
                break;

            case "ABOVE":
            case "BELOW":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 1);
                altitude = ParseOrDie <double>(0, Parsers.ParseLength);
                break;
            }
        }
コード例 #2
0
ファイル: ScriptingPenalty.cs プロジェクト: Maasik/ax-toolbox
        public override void CheckConstructorSyntax()
        {
            base.CheckConstructorSyntax();

            if (Task == null)
            {
                throw new ArgumentException(Definition.ObjectName + ": no previous task defined");
            }

            //check syntax and resolve static values (well defined at constructor time, not pilot dependent)
            switch (Definition.ObjectType)
            {
            default:
                throw new ArgumentException("Unknown penalty type '" + Definition.ObjectType + "'");

            case "BPZ":
                //BPZ: blue PZ
                //BPZ(<area>,<description>)
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 2);
                area        = ResolveOrDie <ScriptingArea>(0);
                description = ParseOrDie <string>(1, Parsers.ParseString);
                break;

            case "RPZ":
                //BPZ: blue PZ
                //BPZ(<area>,<description>)
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 2);
                area        = ResolveOrDie <ScriptingArea>(0);
                description = ParseOrDie <string>(1, Parsers.ParseString);
                break;

            case "VSMAX":
                //VSMAX: maximum vertical speed
                //VSMAX(<verticalSpeed>,<sensitivity>)
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 2);
                maxSpeed    = ParseOrDie <double>(0, Parsers.ParseDouble) * Physics.FEET2METERS / 60;
                sensitivity = ParseOrDie <double>(1, Parsers.ParseDouble);
                break;
            }
        }
コード例 #3
0
        public override void CheckConstructorSyntax()
        {
            base.CheckConstructorSyntax();

            if (Task == null)
            {
                throw new ArgumentException(Definition.ObjectName + ": no previous task defined");
            }

            //check syntax and resolve static values (well defined at constructor time, not pilot dependent)
            switch (Definition.ObjectType)
            {
            default:
                throw new ArgumentException("Unknown restriction type '" + Definition.ObjectType + "'");

            //DMAX: maximum distance
            //DMAX(<pointNameA>, <pointNameB>, <distance>, <description>)
            case "DMAX":
            //DMIN: minimum distance
            //DMIN(<pointNameA>, <pointNameB>, <distance>, <description>)
            case "DMIN":
            //DVMAX: maximum vertical distance
            //DVMAX(<pointNameA>, <pointNameB>, <altitude>, <description>)
            case "DVMAX":
            //DVMIN: minimum vertical distance
            //DVMIN(<pointNameA>, <pointNameB>, <altitude>, <description>)
            case "DVMIN":
            {
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 4);
                pointA      = ResolveOrDie <ScriptingPoint>(0);
                pointB      = ResolveOrDie <ScriptingPoint>(1);
                distance    = ParseOrDie <double>(2, Parsers.ParseLength);
                description = ParseOrDie <string>(3, Parsers.ParseString);
            }
            break;

            //TMAX: maximum time
            //TMAX(<pointNameA>, <pointNameB>, <time>, <description>)
            case "TMAX":
            //TMIN: minimum time
            //TMIN(<pointNameA>, <pointNameB>, <time>, <description>)
            case "TMIN":
            {
                {
                    AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 4);
                    pointA      = ResolveOrDie <ScriptingPoint>(0);
                    pointB      = ResolveOrDie <ScriptingPoint>(1);
                    time        = ParseOrDie <int>(2, Parsers.ParseInt);
                    description = ParseOrDie <string>(3, Parsers.ParseString);
                }
            }
            break;

            //TBTOD: before time of day
            //TBTOD(<pointNameA>, <time>, <description>)
            case "TBTOD":
            //TATOD: after time of day
            //TATOD(<pointNameA>, <time>, <description>)
            case "TATOD":
            {
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 3);
                pointA      = ResolveOrDie <ScriptingPoint>(0);
                timeOfDay   = ParseOrDie <TimeSpan>(1, Parsers.ParseTimeSpan);
                description = ParseOrDie <string>(2, Parsers.ParseString);
            }
            break;

            //PINSIDE: point inside area
            //PINSIDE(<pointNameA>, <area>, <description>)
            case "PINSIDE":
            {
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 3);
                pointA = ResolveOrDie <ScriptingPoint>(0);
                var areaName = ParseOrDie <string>(1, Parsers.ParseString);
                area = Engine.Heap.Values.FirstOrDefault(o => o is ScriptingArea && o.Definition.ObjectName == areaName) as ScriptingArea;
                if (area == null)
                {
                    throw new ArgumentException("undeclaread area " + areaName);
                }
                description = ParseOrDie <string>(2, Parsers.ParseString);
            }
            break;
            }
        }