@@ -178,6 +178,10 @@ namespace Ichni.Editor
|
||||
}
|
||||
private string TransformCommand(string input)
|
||||
{
|
||||
string getFloatorInt(string a)
|
||||
{
|
||||
return a.Contains(".") ? $"float.Parse({a})" : a;
|
||||
}
|
||||
// 处理命令格式,适配 DynamicExpresso
|
||||
string trimmed = input.Trim();
|
||||
|
||||
@@ -212,9 +216,9 @@ namespace Ichni.Editor
|
||||
string content = a.Substring(1, a.Length - 2).Trim();
|
||||
var nums = content.Split(',').Select(s => s.Trim()).ToArray();
|
||||
if (nums.Length == 2)
|
||||
processedArgs.Add($"new Vector2({nums[0]},{nums[1]})");
|
||||
processedArgs.Add($"new Vector2({getFloatorInt(nums[0])},{getFloatorInt(nums[1])})");
|
||||
else if (nums.Length == 3)
|
||||
processedArgs.Add($"new Vector3({nums[0]},{nums[1]},{nums[2]})");
|
||||
processedArgs.Add($"new Vector3({getFloatorInt(nums[0])},{getFloatorInt(nums[1])},{getFloatorInt(nums[2])})");
|
||||
else
|
||||
processedArgs.Add(a); // 不是2或3维,原样返回
|
||||
}
|
||||
@@ -226,7 +230,7 @@ namespace Ichni.Editor
|
||||
// 数字
|
||||
else if (Regex.IsMatch(a, @"^-?\d+(\.\d+)?([eE][+-]?\d+)?$"))
|
||||
{
|
||||
processedArgs.Add(a);
|
||||
processedArgs.Add(getFloatorInt(a));
|
||||
}
|
||||
// 变量名(字母开头,允许字母数字下划线)
|
||||
else if (Regex.IsMatch(a, @"^[a-zA-Z_]\w*$"))
|
||||
|
||||
Reference in New Issue
Block a user