Signed-off-by: TRAfoer <lhf190@outlook.com>
This commit is contained in:
@@ -229,26 +229,26 @@ namespace Ichni.Editor
|
||||
switch (action)
|
||||
{
|
||||
case "Tap":
|
||||
Tap a = Tap.GenerateElement("New Tap", Guid.NewGuid(), new List<string>(), false, findTrack(id), timestamp);
|
||||
Tap a = Tap.GenerateElement("New Tap", Guid.NewGuid(), new List<string>(), true, findTrack(id), timestamp);
|
||||
((TransformSubmodule)a.noteVisual.submoduleList.Where(i => i is TransformSubmodule)?.First()).originalPosition = new Vector3(value, 0, 0);
|
||||
a.noteVisual.SetEditorSubmodules(); // 设置selset
|
||||
a.Refresh();
|
||||
break;
|
||||
case "Stay":
|
||||
|
||||
Stay b = Stay.GenerateElement("New Stay", Guid.NewGuid(), new List<string>(), false, findTrack(id), timestamp);
|
||||
Stay b = Stay.GenerateElement("New Stay", Guid.NewGuid(), new List<string>(), true, findTrack(id), timestamp);
|
||||
((TransformSubmodule)b.noteVisual.submoduleList.Where(i => i is TransformSubmodule)?.First()).originalPosition = new Vector3(value, 0, 0);
|
||||
b.noteVisual.SetEditorSubmodules(); // 设置selset
|
||||
b.Refresh();
|
||||
break;
|
||||
case "Hold":
|
||||
Hold c = Hold.GenerateElement("New Hold", Guid.NewGuid(), new List<string>(), false, findTrack(id), timestamp, timestamp + holdDuration);
|
||||
Hold c = Hold.GenerateElement("New Hold", Guid.NewGuid(), new List<string>(), true, findTrack(id), timestamp, timestamp + holdDuration);
|
||||
((TransformSubmodule)c.noteVisual.submoduleList.Where(i => i is TransformSubmodule)?.First()).originalPosition = new Vector3(value, 0, 0);
|
||||
c.noteVisual.SetEditorSubmodules(); // 设置selset
|
||||
c.Refresh();
|
||||
break;
|
||||
case "Flick":
|
||||
Flick d = Flick.GenerateElement("New Flick", Guid.NewGuid(), new List<string>(), false, findTrack(id), timestamp, new List<Vector2>());
|
||||
Flick d = Flick.GenerateElement("New Flick", Guid.NewGuid(), new List<string>(), true, findTrack(id), timestamp, new List<Vector2>());
|
||||
((TransformSubmodule)d.noteVisual.submoduleList.Where(i => i is TransformSubmodule)?.First()).originalPosition = new Vector3(value, 0, 0);
|
||||
d.noteVisual.SetEditorSubmodules(); // 设置selset
|
||||
d.Refresh();
|
||||
@@ -398,5 +398,61 @@ namespace Ichni.Editor
|
||||
anim.startValue = -anim.startValue;
|
||||
}
|
||||
}
|
||||
public static void AttachNoteInNearestTrail()
|
||||
{
|
||||
Track track = inspector.connectedGameElement as Track;
|
||||
if (track == null)
|
||||
{
|
||||
LogWindow.Log("Please select a Track first!", Color.red);
|
||||
return;
|
||||
}
|
||||
List<NoteBase> noteBases = track.childElementList.OfType<NoteBase>().ToList();
|
||||
List<IHaveTrail> trails = track.GetAllGameElementsFromThis().OfType<IHaveTrail>().ToList();
|
||||
if (trails.Count == 0)
|
||||
{
|
||||
LogWindow.Log("The Track has no Trail!", Color.red);
|
||||
return;
|
||||
}
|
||||
foreach (var note in noteBases)
|
||||
{
|
||||
IHaveTrail nearestTrail = null;
|
||||
Vector3 FinalPos = Vector3.positiveInfinity;
|
||||
foreach (var trail in trails)
|
||||
{
|
||||
if (trail is IHaveTransformSubmodule haveTransform && trail is GameElement gameElement)
|
||||
{
|
||||
Vector3 pos = haveTransform.transformSubmodule.originalPosition;
|
||||
GameElement gameElement1 = gameElement;
|
||||
while (gameElement1 != track)
|
||||
{
|
||||
if (gameElement1 is not IHaveTransformSubmodule)
|
||||
{
|
||||
gameElement1 = gameElement1.parentElement;
|
||||
continue;
|
||||
}
|
||||
List<Displacement> animationBases = gameElement1.childElementList.OfType<Displacement>().ToList();
|
||||
|
||||
foreach (var displacement in animationBases)
|
||||
{
|
||||
pos += displacement.getValue(note.exactJudgeTime);
|
||||
}
|
||||
gameElement1 = gameElement1.parentElement;
|
||||
}
|
||||
if (Vector3.Distance(pos, (note.noteVisual.submoduleList.First(i => i is TransformSubmodule) as TransformSubmodule).originalPosition) <=
|
||||
Vector3.Distance(FinalPos, (note.noteVisual.submoduleList.First(i => i is TransformSubmodule) as TransformSubmodule).originalPosition))
|
||||
{
|
||||
nearestTrail = trail;
|
||||
FinalPos = pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nearestTrail != null)
|
||||
{
|
||||
(note.noteVisual.submoduleList.First(i => i is TransformSubmodule) as TransformSubmodule).originalPosition = FinalPos;
|
||||
note.Refresh();
|
||||
(note.noteVisual.submoduleList.First(i => i is TransformSubmodule) as TransformSubmodule).Refresh();//捏妈妈滴为什么notevisual的TransformSubmodule不刷新
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user