public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 0) { return(VariableValue.Create(new VariableStore())); } else if (parameters.Count == 1) { var schemaName = parameters[0].Evaluate(variables); if (!schemaName.HasString) { throw CommandEvaluationException.WrongParameterType(name, 0, schemaName.Type, VariableType.String); } var schema = Resources.Load <VariableSchema>(schemaName.String); if (!schema) { Debug.LogWarningFormat(_invalidSchemaWarning, schemaName.String); } return(VariableValue.Create(schema ? new ConstrainedStore(schema) : new VariableStore())); } throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 0, 1); }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 3) { var xValue = parameters[0].Evaluate(variables); var yValue = parameters[1].Evaluate(variables); var zValue = parameters[2].Evaluate(variables); if (!xValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 0, xValue.Type, VariableType.Float); } if (!yValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 1, yValue.Type, VariableType.Float); } if (!zValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 2, zValue.Type, VariableType.Float); } return(VariableValue.Create(new Vector3(xValue.Number, yValue.Number, zValue.Number))); } throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 3); }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 3) { var rValue = parameters[0].Evaluate(variables); var gValue = parameters[1].Evaluate(variables); var bValue = parameters[2].Evaluate(variables); if (!rValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 0, rValue.Type, VariableType.Float); } if (!gValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 1, gValue.Type, VariableType.Float); } if (!bValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 2, bValue.Type, VariableType.Float); } return(VariableValue.Create(new Color(rValue.Number, gValue.Number, bValue.Number))); } else if (parameters.Count == 4) { var rValue = parameters[0].Evaluate(variables); var gValue = parameters[1].Evaluate(variables); var bValue = parameters[2].Evaluate(variables); var aValue = parameters[3].Evaluate(variables); if (!rValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 0, rValue.Type, VariableType.Float); } if (!gValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 1, bValue.Type, VariableType.Float); } if (!bValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 2, gValue.Type, VariableType.Float); } if (!aValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 3, aValue.Type, VariableType.Float); } return(VariableValue.Create(new Vector4(rValue.Number, gValue.Number, bValue.Number, aValue.Number))); } throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 3, 4); }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 0) { return(VariableValue.Create(Time.time)); } else { throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 0); } }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 3) { var a = parameters[0].Evaluate(variables); var b = parameters[1].Evaluate(variables); var t = parameters[2].Evaluate(variables); if (!t.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 2, t.Type, VariableType.Float); } if (a.HasNumber && b.HasNumber) { return(VariableValue.Create(Mathf.Lerp(a.Number, b.Number, t.Number))); } else if (a.HasNumber2 && b.HasNumber2) { return(VariableValue.Create(Vector2.Lerp(a.Number2, b.Number2, t.Number))); } else if (a.HasNumber3 && b.HasNumber3) { return(VariableValue.Create(Vector3.Lerp(a.Number3, b.Number3, t.Number))); } else if (a.HasNumber4 && b.HasNumber4) { return(VariableValue.Create(Vector4.Lerp(a.Number4, b.Number4, t.Number))); } else if (a.Type == VariableType.Quaternion && b.Type == VariableType.Quaternion) { return(VariableValue.Create(Quaternion.Lerp(a.Quaternion, b.Quaternion, t.Number))); } else if (a.Type == VariableType.Color && b.Type == VariableType.Color) { return(VariableValue.Create(Color.Lerp(a.Color, b.Color, t.Number))); } if (a.HasNumber || a.HasNumber4 || a.Type == VariableType.Quaternion || a.Type == VariableType.Color) { throw CommandEvaluationException.WrongParameterType(name, 1, b.Type, a.Type); } else { throw CommandEvaluationException.WrongParameterType(name, 0, a.Type, VariableType.Float, VariableType.Vector2, VariableType.Vector3, VariableType.Vector4, VariableType.Quaternion, VariableType.Color); } } else { throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 3); } }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 2) { var positionValue = parameters[0].Evaluate(variables); var sizeValue = parameters[1].Evaluate(variables); if (!positionValue.HasNumber2) { throw CommandEvaluationException.WrongParameterType(name, 0, positionValue.Type, VariableType.Vector2); } if (!sizeValue.HasNumber2) { throw CommandEvaluationException.WrongParameterType(name, 1, sizeValue.Type, VariableType.Vector2); } return(VariableValue.Create(new Rect(positionValue.Number2, sizeValue.Number2))); } else if (parameters.Count == 4) { var xValue = parameters[0].Evaluate(variables); var yValue = parameters[1].Evaluate(variables); var widthValue = parameters[2].Evaluate(variables); var heightValue = parameters[3].Evaluate(variables); if (xValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 0, xValue.Type, VariableType.Float); } if (yValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 1, yValue.Type, VariableType.Float); } if (widthValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 2, widthValue.Type, VariableType.Float); } if (heightValue.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 3, heightValue.Type, VariableType.Float); } return(VariableValue.Create(new Rect(xValue.Number, yValue.Number, widthValue.Number, heightValue.Number))); } throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 2, 4); }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { switch (parameters.Count) { case 1: { var value = parameters[0].Evaluate(variables); if (value.TryGetFloat(out var number)) { return(VariableValue.Create(Mathf.Atan(number))); } else if (value.TryGetVector2(out var vector)) { return(VariableValue.Create(Mathf.Atan2(vector.y, vector.x))); } else { throw CommandEvaluationException.WrongParameterType(name, 0, value.Type, VariableType.Float, VariableType.Vector2); } } case 2: { var y = parameters[0].Evaluate(variables); var x = parameters[1].Evaluate(variables); if (!y.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 0, y.Type, VariableType.Float); } if (!x.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 1, x.Type, VariableType.Float); } return(VariableValue.Create(Mathf.Atan2(y.Number, x.Number))); } default: { throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 1, 2); } } }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { switch (parameters.Count) { case 1: { var value = parameters[0].Evaluate(variables); if (value.TryGetFloat(out var number)) { return(VariableValue.Create(Mathf.Log(number, 10.0f))); } else { throw CommandEvaluationException.WrongParameterType(name, 0, value.Type, VariableType.Float); } } case 2: { var value = parameters[0].Evaluate(variables); var power = parameters[1].Evaluate(variables); if (!value.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 0, value.Type, VariableType.Float); } if (!power.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 1, power.Type, VariableType.Int, VariableType.Float); } return(VariableValue.Create(Mathf.Log(value.Number, power.Number))); } default: { throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 1, 2); } } }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 1) { var result = parameters[0].Evaluate(variables); switch (result.Type) { case VariableType.Int: return(VariableValue.Create(Math.Abs(result.Int))); case VariableType.Float: return(VariableValue.Create(Math.Abs(result.Float))); } throw CommandEvaluationException.WrongParameterType(name, 0, result.Type, VariableType.Int, VariableType.Float); } else { throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 1); } }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 0) { return(VariableValue.Create(new VariableList())); } else if (parameters.Count == 1) { var count = parameters[0].Evaluate(variables); if (count.Type != VariableType.Int) { throw CommandEvaluationException.WrongParameterType(name, 0, count.Type, VariableType.Int); } return(VariableValue.Create(new VariableList(count.Int))); } throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 0, 1); }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 1) { var result = parameters[0].Evaluate(variables); if (result.Type == VariableType.Float) { return(VariableValue.Create(Mathf.CeilToInt(result.Float))); } else { throw CommandEvaluationException.WrongParameterType(name, 0, result.Type, VariableType.Float); } } else { throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 1); } }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 2) { var xValue = parameters[0].Evaluate(variables); var yValue = parameters[1].Evaluate(variables); if (xValue.Type != VariableType.Int) { throw CommandEvaluationException.WrongParameterType(name, 0, xValue.Type, VariableType.Int); } if (yValue.Type != VariableType.Int) { throw CommandEvaluationException.WrongParameterType(name, 1, yValue.Type, VariableType.Int); } return(VariableValue.Create(new Vector2Int(xValue.Int, yValue.Int))); } throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 2); }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 2) { var positionValue = parameters[0].Evaluate(variables); var sizeValue = parameters[1].Evaluate(variables); if (!positionValue.HasNumber3) { throw CommandEvaluationException.WrongParameterType(name, 0, positionValue.Type, VariableType.Vector3); } if (!sizeValue.HasNumber3) { throw CommandEvaluationException.WrongParameterType(name, 1, sizeValue.Type, VariableType.Vector3); } return(VariableValue.Create(new Bounds(positionValue.Number3, sizeValue.Number3))); } throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 2); }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 3) { var value = parameters[0].Evaluate(variables); var min = parameters[1].Evaluate(variables); var max = parameters[2].Evaluate(variables); if (!value.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 0, value.Type, VariableType.Int, VariableType.Float); } if (!min.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 1, min.Type, VariableType.Int, VariableType.Float); } if (!max.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 2, max.Type, VariableType.Int, VariableType.Float); } if (value.Type == VariableType.Int && min.Type == VariableType.Int && max.Type == VariableType.Int) { return(VariableValue.Create(Mathf.Clamp(value.Int, min.Int, max.Int))); } else { return(VariableValue.Create(Mathf.Clamp(value.Number, min.Number, max.Number))); } } else { throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 3); } }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 2) { var value = parameters[0].Evaluate(variables); var power = parameters[1].Evaluate(variables); if (!value.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 0, value.Type, VariableType.Int, VariableType.Float); } if (!power.HasNumber) { throw CommandEvaluationException.WrongParameterType(name, 1, power.Type, VariableType.Int, VariableType.Float); } return(VariableValue.Create(Mathf.Pow(value.Number, power.Number))); } else { throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 2); } }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 1) { var result = parameters[0].Evaluate(variables); switch (result.Type) { case VariableType.Int: return(result); case VariableType.Int2: return(result); case VariableType.Int3: return(result); case VariableType.IntRect: return(result); case VariableType.IntBounds: return(result); case VariableType.Float: return(VariableValue.Create((int)result.Float)); case VariableType.Vector2: return(VariableValue.Create(new Vector2Int((int)result.Vector2.x, (int)result.Vector2.y))); case VariableType.Vector3: return(VariableValue.Create(new Vector3Int((int)result.Vector3.x, (int)result.Vector3.y, (int)result.Vector3.z))); case VariableType.Rect: return(VariableValue.Create(new RectInt((int)result.Rect.x, (int)result.Rect.y, (int)result.Rect.width, (int)result.Rect.height))); case VariableType.Bounds: return(VariableValue.Create(new BoundsInt((int)result.Bounds.min.x, (int)result.Bounds.min.y, (int)result.Bounds.min.z, (int)result.Bounds.size.x, (int)result.Bounds.size.y, (int)result.Bounds.size.z))); } throw CommandEvaluationException.WrongParameterType(name, 0, result.Type, VariableType.Float, VariableType.Vector2, VariableType.Vector3, VariableType.Rect, VariableType.Bounds); } else { throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 1); } }
public VariableValue Evaluate(IVariableStore variables, string name, List <Operation> parameters) { if (parameters.Count == 2) { var positionValue = parameters[0].Evaluate(variables); var sizeValue = parameters[1].Evaluate(variables); if (positionValue.Type != VariableType.Int3) { throw CommandEvaluationException.WrongParameterType(name, 0, positionValue.Type, VariableType.Int3); } if (sizeValue.Type != VariableType.Int3) { throw CommandEvaluationException.WrongParameterType(name, 1, sizeValue.Type, VariableType.Int3); } return(VariableValue.Create(new BoundsInt(positionValue.Int3, sizeValue.Int3))); } else if (parameters.Count == 6) { var xValue = parameters[0].Evaluate(variables); var yValue = parameters[1].Evaluate(variables); var zValue = parameters[2].Evaluate(variables); var widthValue = parameters[3].Evaluate(variables); var heightValue = parameters[4].Evaluate(variables); var depthValue = parameters[4].Evaluate(variables); if (xValue.Type != VariableType.Int) { throw CommandEvaluationException.WrongParameterType(name, 0, xValue.Type, VariableType.Int); } if (yValue.Type != VariableType.Int) { throw CommandEvaluationException.WrongParameterType(name, 1, yValue.Type, VariableType.Int); } if (zValue.Type != VariableType.Int) { throw CommandEvaluationException.WrongParameterType(name, 2, zValue.Type, VariableType.Int); } if (widthValue.Type != VariableType.Int) { throw CommandEvaluationException.WrongParameterType(name, 3, widthValue.Type, VariableType.Int); } if (heightValue.Type != VariableType.Int) { throw CommandEvaluationException.WrongParameterType(name, 4, heightValue.Type, VariableType.Int); } if (depthValue.Type != VariableType.Int) { throw CommandEvaluationException.WrongParameterType(name, 5, depthValue.Type, VariableType.Int); } return(VariableValue.Create(new BoundsInt(xValue.Int, yValue.Int, zValue.Int, widthValue.Int, heightValue.Int, depthValue.Int))); } throw CommandEvaluationException.WrongParameterCount(name, parameters.Count, 2, 6); }