Beispiel #1
0
        public Expression GetFunctionExpression(string funcname, Expression argexp, Expression argParams, ParameterExpression inputParams, Expression inputContextParam, List <InputVar> compiledInputVarsList)
        {
            switch (funcname)
            {
            case "f:random":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("RandomDouble",
                                                                                                  new[] { typeof(double), typeof(double), typeof(IRandomProvider) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetRandomArg(inputContextParam)));

            case "f:randomint":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("RandomInt",
                                                                                                  new[] { typeof(int), typeof(int), typeof(IRandomProvider) }),
                                       ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetRandomArg(inputContextParam)));

            case "f:roll":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Roll",
                                                                                                  new[] { typeof(int), typeof(int), typeof(IRandomProvider) }),
                                       ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetRandomArg(inputContextParam)));

            default:
                throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'");
            }
        }
Beispiel #2
0
    /// <summary>
    /// Verifies whether the given GameObject is a weapon, and applies it to all slots in the array if it is.
    /// Returns the weapon if it was valid, and returns null otherwise.
    /// </summary>
    private GameObject ValidateWeapon(GameObject weapon)
    {
        // Remove pre-existing weapons so we can spawn new ones.
        FunctionDelegator.ExecuteWhenSafe(RemoveAllWeapons);

        // Check if a weapon prefab was specified.
        if (weapon == null)
        {
            // No prefab specified.
            return(null);
        }
        else
        {
            // Prefab specified, make sure it is actually a weapon, and if it is, whether the array supports it.
            ProjectileWeapon weaponScript = weapon.GetComponent <ProjectileWeapon>();
            if (weaponScript == null)
            {
                Debug.LogWarning("Speficied prefab does not contain a ProjectileWeapon script.", this);
                return(null);
            }
            else if (!CanEquipWeapon(weaponScript.Category))
            {
                Debug.LogWarning("Speficied weapon is not supported by this array.", this);
                return(null);
            }

            // Weapon specified, so fill the array with instances of that weapon.
            if (_weaponSlots.Count > 0)
            {
                foreach (Transform weaponSlot in _weaponSlots)
                {
                    if (weaponSlot != null)
                    {
                        // Make sure we only spawn weapon instances if this is a ship in the scene during play mode.
                        if (Application.isPlaying && !ExFuncs.IsPrefab(this))
                        {
                            FunctionDelegator.ExecuteWhenSafe(() =>
                            {
                                GameObject weaponInstance = Instantiate(weapon, weaponSlot.position, weaponSlot.rotation, weaponSlot);
                                _weapons.Add(weaponInstance.GetComponent <ProjectileWeapon>());
                            });
                        }
                    }
                    else
                    {
                        Debug.LogError("One of the weapon slot transforms in " + gameObject.name + " is null.", this);
                    }
                }
            }
        }

        // If we reached this point, the given prefab was a valid weapon, so we can return it.
        return(weapon);
    }
Beispiel #3
0
        public Expression GetFunctionExpression(string funcname, Expression argexp, Expression argParams, ParameterExpression inputParams, Expression inputContextParam, List <InputVar> compiledInputVarsList)
        {
            switch (funcname)
            {
            case "f:substring":
                if (argexp is NewArrayExpression)
                {
                    if ((argexp as NewArrayExpression).Expressions.Count > 2)
                    {
                        return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Substring",
                                                                                                          new[] { typeof(string), typeof(int), typeof(int) }),
                                               ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 0)),
                                               ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1)),
                                               ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 2))));
                    }
                    return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Substring",
                                                                                                      new[] { typeof(string), typeof(int) }),
                                           ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 0)),
                                           ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1))));
                }
                // otherwise we need to inspect the number of args at runtime
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("SubstringRuntime",
                                                                                                  new[] { typeof(object[]) }),
                                       ExCasts.WrapArguments(argexp)));

            case "f:length":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Length",
                                                                                                  new[] { typeof(string) }),
                                       ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:comma":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Comma",
                                                                                                  new[] { typeof(string[]) }),
                                       Expression.Call(typeof(ExCasts).GetTypeInfo().GetDeclaredMethod("UnwrapStringArray"),
                                                       ExCasts.WrapArguments(argexp))));

            case "f:commaand":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("CommaAnd",
                                                                                                  new[] { typeof(string[]) }),
                                       Expression.Call(typeof(ExCasts).GetTypeInfo().GetDeclaredMethod("UnwrapStringArray"),
                                                       ExCasts.WrapArguments(argexp))));

            case "f:replace":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Replace",
                                                                                                  new[] { typeof(string), typeof(string), typeof(string) }),
                                       ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 2))));

            default:
                throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'");
            }
        }
Beispiel #4
0
        public Expression GetFunctionExpression(string funcname, Expression argexp, Expression argParams, ParameterExpression inputParams, Expression inputContextParam, List <InputVar> compiledInputVarsList)
        {
            switch (funcname)
            {
            case "f:subset":
                if (argexp is NewArrayExpression)
                {
                    if ((argexp as NewArrayExpression).Expressions.Count > 2)
                    {
                        return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Subset",
                                                                                                          new[] { typeof(object[]), typeof(int), typeof(int) }),
                                               ExCasts.WrapArguments(ExFuncs.GetArgIndex(argexp, 0)),
                                               ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1)),
                                               ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 2))));
                    }
                    return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Subset",
                                                                                                      new[] { typeof(object[]), typeof(int) }),
                                           ExCasts.WrapArguments(ExFuncs.GetArgIndex(argexp, 0)),
                                           ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1))));
                }
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("SubsetRuntime",
                                                                                                  new[] { typeof(object[]) }),
                                       ExCasts.WrapArguments(argexp)));

            case "f:length":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Length",
                                                                                                  new[] { typeof(object[]) }),
                                       ExCasts.WrapArguments(argexp)));

            case "f:append":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Append",
                                                                                                  new[] { typeof(object[]), typeof(object) }),
                                       ExCasts.WrapArguments(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsObject(ExFuncs.GetArgIndex(argexp, 1))));

            case "f:insert":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Insert",
                                                                                                  new[] { typeof(object[]), typeof(object), typeof(int) }),
                                       ExCasts.WrapArguments(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsObject(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 2))));

            case "f:remove":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Remove",
                                                                                                  new[] { typeof(object[]), typeof(int) }),
                                       ExCasts.WrapArguments(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1))));

            default:
                throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'");
            }
        }
Beispiel #5
0
    /// <summary>
    /// Processes input for the editor script.
    /// Only call from OnSceneGUI.
    /// </summary>
    private void ProcessInput()
    {
        if (GetKeyDown(KeyCode.F))
        {
            // Make sure that the scene window is in focus.
            if (SceneView.focusedWindow == SceneView.lastActiveSceneView)
            {
                // Cache existing selection.
                var previousSelection = Selection.objects;

                // Create temporary object at center of all selected waypoints.
                GameObject     tempSelectionObject  = new GameObject();
                List <Vector3> allWaypointPositions = new List <Vector3>();
                foreach (Waypoint w in targets)
                {
                    allWaypointPositions.Add(w.WorldPosition);
                }
                tempSelectionObject.transform.position = ExFuncs.Centroid(allWaypointPositions);

                // Set selection to temporary object and adjust camera to view it.
                Selection.activeGameObject = tempSelectionObject;
                if (targets.Length == 1)
                {
                    // Focus on single selected waypoint.
                    SceneView.lastActiveSceneView.FrameSelected();
                }
                else
                {
                    Vector3    centroidPosition  = tempSelectionObject.transform.position;
                    Quaternion sceneViewRotation = SceneView.lastActiveSceneView.rotation;
                    float      largestDistanceBetweenWaypoints = ExFuncs.LargestDistance(allWaypointPositions);

                    // Turn scene camera towards centroid of all selected waypoints, and zoom out to fit all waypoints in the view.
                    SceneView.lastActiveSceneView.LookAt(centroidPosition, sceneViewRotation, largestDistanceBetweenWaypoints);
                }

                // Destroy temporary selection object and reset previous selection.
                DestroyImmediate(tempSelectionObject);
                Selection.objects = previousSelection;
            }
        }
    }
 /// <summary>
 /// Updates the turning slowdown time based on max velocity and friction.
 /// </summary>
 private void UpdateTurningSlowdownTime()
 {
     _turningSlowdownTime = ExFuncs.RoundToDecimal(MaxRotationalVelocity / TurningFriction, 2);
 }
 /// <summary>
 /// Updates the sailing slowdown time based on max velocity and friction.
 /// </summary>
 private void UpdateSailingSlowdownTime()
 {
     _sailingSlowdownTime = ExFuncs.RoundToDecimal(MaxSailVelocity / SailingFriction, 2);
 }
 /// <summary>
 /// Updates the driving slowdown time based on max velocity and friction.
 /// </summary>
 private void UpdateDrivingSlowdownTime()
 {
     _drivingSlowdownTime = ExFuncs.RoundToDecimal(MaxDrivingVelocity / DrivingFriction, 2);
 }
Beispiel #9
0
        public Expression GetFunctionExpression(string funcname, Expression argexp, Expression argParams, ParameterExpression inputParams, Expression inputContextParam, List <InputVar> compiledInputVarsList)
        {
            switch (funcname)
            {
            case "f:sin":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Sin",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:cos":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Cos",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:tan":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Tan",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:abs":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Abs",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:min":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Min",
                                                                                                  new[] { typeof(double[]) }),
                                       ExFuncs.GetArgsAsDouble(argexp)));

            case "f:max":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Max",
                                                                                                  new[] { typeof(double[]) }),
                                       ExFuncs.GetArgsAsDouble(argexp)));

            case "f:avg":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Avg",
                                                                                                  new[] { typeof(double[]) }),
                                       ExFuncs.GetArgsAsDouble(argexp)));

            case "f:sign":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Sign",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:pow":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Pow",
                                                                                                  new[] { typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1))));

            case "f:sqrt":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Sqrt",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:ln":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Ln",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:log10":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Log10",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:log":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Log",
                                                                                                  new[] { typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1))));

            case "f:round":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Round",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:floor":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Floor",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:ceiling":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Ceiling",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:acos":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Acos",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:asin":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Asin",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:atan":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Atan",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:atan2":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Atan2",
                                                                                                  new[] { typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1))));

            case "f:cosh":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Cosh",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:sinh":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Sinh",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:tanh":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Tanh",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:exp":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Exp",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:clamp":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Clamp",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2))));

            case "f:blend":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Blend",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2))));

            // trigonometric
            case "f:cot":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Cot",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:sec":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Sec",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:csc":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Csc",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:cas":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Cas",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:sinc":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Sinc",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            // hyperbolic
            case "f:asinh":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Asinh",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:acosh":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Acosh",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:atanh":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Atanh",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:acoth":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Acoth",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:asech":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Asech",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:acsch":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Acsch",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:dasinh":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Dasinh",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:dacosh":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Dacosh",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:datanh":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Datanh",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:dacoth":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Dacoth",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:dasech":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Dasech",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:dacsch":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Dacsch",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            // periodics
            case "f:clausen":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Clausen",
                                                                                                  new[] { typeof(double[]) }),
                                       ExFuncs.GetArgsAsDouble(argexp)));

            case "f:cycloid":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Cycloid",
                                                                                                  new[] { typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1))));

            case "f:squarewave":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("SquareWave",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:trianglewave":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("TriangleWave",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            case "f:sawtoothwave":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("SawtoothWave",
                                                                                                  new[] { typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0))));

            // parametric
            case "f:trochoid":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Trochoid",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2))));

            case "f:trochoidx":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("TrochoidX",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2))));

            case "f:trochoidy":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("TrochoidY",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2))));

            case "f:hypotrochoid":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Hypotrochoid",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 3))));

            case "f:hypotrochoidx":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("HypotrochoidX",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 3))));

            case "f:hypotrochoidy":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("HypotrochoidY",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 3))));

            case "f:epitrochoid":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Epitrochoid",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 3))));

            case "f:epitrochoidx":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("EpitrochoidX",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 3))));

            case "f:epitrochoidy":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("EpitrochoidY",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 3))));

            case "f:epicycloid":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Epicycloid",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2))));

            case "f:epicycloidx":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("EpicycloidX",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2))));

            case "f:epicycloidy":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("EpicycloidY",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2))));

            case "f:hypocycloid":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Hypocycloid",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2))));

            case "f:hypocycloidx":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("HypocycloidX",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2))));

            case "f:hypocycloidy":
                return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("HypocycloidY",
                                                                                                  new[] { typeof(double), typeof(double), typeof(double) }),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 0)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 1)),
                                       ExFuncs.GetArgAsDouble(ExFuncs.GetArgIndex(argexp, 2))));

            default:
                throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'");
            }
        }