Add exception description for invalid child index.

This commit is contained in:
2023-05-25 15:02:03 +08:00
parent 5b510fa5da
commit 5f4d35b3b3
2 changed files with 9 additions and 4 deletions

View File

@@ -24,7 +24,10 @@ namespace Cryville.Crtr.Event {
= new Dictionary<Type, List<ContainerState>>();
public ContainerState GetChild(int index, Type handlerType) {
return TypedChildren[handlerType][index];
var list = TypedChildren[handlerType];
if (index < 0 || index >= list.Count)
throw new ArgumentOutOfRangeException("index", string.Format("{0}#{1} does not exist.", list[0].Handler.TypeName, index));
return list[index];
}
private bool m_active;

View File

@@ -144,9 +144,11 @@ namespace Cryville.Crtr {
Vector3 GetFrame(ContainerState state, float track, Func<ContainerState, Vector3> func) {
// TODO
int id = Mathf.FloorToInt(track);
var ts0 = state.GetChild(id, typeof(Chart.Track));
var p1 = func(ts0);
if (track == id) return p1;
if (track == id) {
var ts0 = state.GetChild(id, typeof(Chart.Track));
var p1 = func(ts0);
return p1;
}
return gh.GetCurrentFrame(func, track);
}