Signed-off-by: TRAfoer <lhf190@outlook.com>
This commit is contained in:
2025-09-21 13:34:59 +08:00
parent 7f7324bdb8
commit 4966ba353a
29 changed files with 1528 additions and 1981 deletions

View File

@@ -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*$"))