1.修改以进行可选Interaction支持\n2.并修复Parse函数中正则表达式的bug\n3.新增对序列{S,B,C}解析为小节节点的Parse, 这将会使得DDT与Parse函数能够通过bpm动态工作
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0667b42895d3e8d49899aabe3006d732
|
||||
guid: 2b3ed32090a476b46b21bd207b4d2d34
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -16,30 +16,34 @@ namespace Demo.Game
|
||||
public List<float> Datas = new();
|
||||
|
||||
[ScriptableCall(@"
|
||||
添加float数据, 随后可以用对象路径+索引获取变量值,
|
||||
添加float数据(允许使用除本以外的表达式), 随后可以用对象路径+索引获取变量值,
|
||||
e.g: CameraObject/DDT[3], 获取CameraObject/DDT对象路径下DDT数据中的第四个值
|
||||
")]
|
||||
public void Add(string value)
|
||||
{
|
||||
Datas.Add(float.Parse(value));
|
||||
Datas.Add(Parse(value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从特定的json中读取数据
|
||||
/// 从特定的json中读取数据, 并调用<see cref="Add(string)"/>
|
||||
/// </summary>
|
||||
[ScriptableCall(@"从特定的json中读取数据")]
|
||||
[ScriptableCall(@"从特定的json中读取数据, 并调用Add函数")]
|
||||
public void Load()
|
||||
{
|
||||
var file = new ToolFile(BindingDataJson);
|
||||
if (file.Exists() == false)
|
||||
{
|
||||
file.MustExistsPath()
|
||||
.SaveAsJson<List<float>>(new());
|
||||
.SaveAsJson<List<string>>(new());
|
||||
Datas.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
Datas = file.LoadAsJson<List<float>>();
|
||||
Datas.Clear();
|
||||
foreach (var item in file.LoadAsJson<List<string>>())
|
||||
{
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,11 @@ namespace Demo.Game
|
||||
{
|
||||
IEnumerator Run()
|
||||
{
|
||||
#if ENABLE_CLASS_Interaction
|
||||
var clipFile = new Interaction(clipPath);
|
||||
#else
|
||||
var clipFile = new ToolFile(clipPath);
|
||||
#endif
|
||||
if (clipFile.Exists() == false)
|
||||
clipFile = new(MainConfig.GetFile(clipPath).GetFullPath());
|
||||
if (clipFile.Exists() == false)
|
||||
@@ -109,6 +113,7 @@ namespace Demo.Game
|
||||
{
|
||||
ScriptableObject.FastScriptableObjectTypen = content.ScriptableObjectTypen;
|
||||
ScriptableObject.IsAutoPlay = content.IsAutoPlay;
|
||||
ScriptableObject.OneBarTime = (float)MainConfig.FindItem(nameof(Editor.EditorController.BPM), Editor.EditorController.instance.BPM);
|
||||
SetupSongDuration = GameContent.instance.SetupSongDuration;
|
||||
SetSongCurrentTime = GameContent.instance.SetSongCurrentTime;
|
||||
SongOffset = GameContent.instance.SongOffset;
|
||||
|
||||
@@ -269,6 +269,7 @@ namespace Demo
|
||||
// 数值解析工具
|
||||
|
||||
private readonly Dictionary<string, DDT> DDTCache = new();
|
||||
public static float OneBarTime = 1;
|
||||
|
||||
/// <summary>
|
||||
/// <list type="bullet">从时间点列表<see cref="TimePoints"/>中获取</list>
|
||||
@@ -287,15 +288,34 @@ namespace Demo
|
||||
return result;
|
||||
if(value.EndsWith(']'))
|
||||
{
|
||||
Regex regex = new(@"^(.*)\[(\d)\]$");
|
||||
var match = regex.Match(value);
|
||||
if (match.Success)
|
||||
{
|
||||
if (FindWithPath(match.Groups[1].Value) is DDT ddt)
|
||||
Regex regex = new(@"^(.+)\[(\d+)\]$");
|
||||
var match = regex.Match(value);
|
||||
if (match.Success)
|
||||
{
|
||||
return ddt.Datas[int.Parse(match.Groups[2].Value)];
|
||||
if (FindWithPath(match.Groups[1].Value) is DDT ddt)
|
||||
{
|
||||
DDTCache[match.Groups[1].Value] = ddt;
|
||||
}
|
||||
return DDTCache[match.Groups[1].Value].Datas[int.Parse(match.Groups[2].Value)];
|
||||
}
|
||||
}
|
||||
throw new ArgumentException("value is end by ']' but not match on any invlid parse");
|
||||
}
|
||||
if (value.EndsWith('}'))
|
||||
{
|
||||
{
|
||||
Regex regex = new(@"^\{\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\}$");
|
||||
var match = regex.Match(value);
|
||||
if (match.Success)
|
||||
{
|
||||
int barSplitTimes = int.Parse(match.Groups[1].Value);
|
||||
int barCount = int.Parse(match.Groups[2].Value);
|
||||
int tickCount = int.Parse(match.Groups[3].Value);
|
||||
return (barCount + tickCount / (float)barSplitTimes) * OneBarTime;
|
||||
}
|
||||
}
|
||||
throw new ArgumentException("value is end by '}' but not match on any invlid parse");
|
||||
}
|
||||
return float.Parse(value);
|
||||
}
|
||||
@@ -871,7 +891,11 @@ namespace Demo
|
||||
file = file | "Windows";
|
||||
#endif
|
||||
file = file | ab;
|
||||
#if ENABLE_CLASS_Interaction
|
||||
var downloader = new Interaction(file.GetFullPath());
|
||||
#else
|
||||
var downloader = new ToolFile(file.GetFullPath());
|
||||
#endif
|
||||
if (AssetBundlesItemEntry == null)
|
||||
{
|
||||
var hierarchy = HierarchyWindow.instance;
|
||||
|
||||
Reference in New Issue
Block a user