QuickCopy & fix NoteEffects

This commit is contained in:
SoulliesOfficial
2025-02-21 14:08:32 -05:00
parent 70eddeb881
commit 187b2efdad
28 changed files with 277 additions and 60 deletions

View File

@@ -161,6 +161,26 @@ namespace Ichni.RhythmGame
submodule.SetUpInspector();
}
}
/// <summary>
/// 获取自身和所有子GameElement
/// </summary>
public List<GameElement> GetAllGameElementsFromThis()
{
void GetAllChildrenRecursively(GameElement parent, List<GameElement> elements)
{
foreach (var child in parent.childElementList)
{
elements.Add(child);
GetAllChildrenRecursively(child, elements);
}
}
List<GameElement> gameElements = new List<GameElement> { this };
GetAllChildrenRecursively(this, gameElements);
return gameElements;
}
}
namespace Beatmap

View File

@@ -64,7 +64,7 @@ namespace Ichni.RhythmGame
this.bloomPeak = bloomPeak;
}
public override EffectBase ConvertToGameType()
public override EffectBase ConvertToGameType(GameElement attachedGameElement)
{
return new BloomShake(bloomTime, bloomPeak);
}

View File

@@ -152,18 +152,16 @@ namespace Ichni.RhythmGame
var xField = qcWindow.GenerateGetterInputField(qcContainer, "X offset", "0");
var yField = qcWindow.GenerateGetterInputField(qcContainer, "Y offset", "0");
var zField = qcWindow.GenerateGetterInputField(qcContainer, "Z offset", "0");
var timeField = qcWindow.GenerateGetterInputField(qcContainer, "Time offset", "0");
var iterationField = qcWindow.GenerateGetterInputField(qcContainer, "Iteration", "0");
var includeAnimationToggle = qcWindow.GenerateToggle(null, qcContainer, "Include Animation", string.Empty);
qcWindow.GenerateButton(this, qcContainer, "Copy", () =>
{
CopyPasteDeleteModule cpd = EditorManager.instance.operationManager.CopyPasteDeleteModule;
cpd.CopyElement(this);
cpd.PasteElement(parentElement);
Track newTrack = cpd.pastedElementList[0] as Track;
newTrack.trackPathSubmodule.pathNodeList.ForEach(pn =>
{
Vector3 offset = new Vector3(xField.GetResult<float>(), yField.GetResult<float>(), zField.GetResult<float>());
pn.transformSubmodule.originalPosition += offset;
pn.transformSubmodule.Refresh();
});
Vector3 positionOffset = new Vector3(xField.GetResult<float>(), yField.GetResult<float>(), zField.GetResult<float>());
float timeOffset = timeField.GetResult<float>();
int iteration = iterationField.GetResult<int>();
bool includeAnimation = includeAnimationToggle.toggle.isOn;
QuickCopy(positionOffset, timeOffset, includeAnimation, iteration);
});
});

View File

@@ -0,0 +1,76 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Ichni.Editor;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class Track
{
/// <summary>
/// 快速复制粘贴Track
/// </summary>
/// <param name="unitPositionOffset">单位位置整体偏移</param>
/// <param name="unitTimeOffset">单位时间偏移</param>
/// <param name="iteration">迭代次数即产生几个粘贴的Track</param>
private void QuickCopy(Vector3 unitPositionOffset, float unitTimeOffset, bool includeAnimations = true, int iteration = 1)
{
if(iteration <= 0) return;
CopyPasteDeleteModule cpd = EditorManager.instance.operationManager.CopyPasteDeleteModule;
cpd.CopyElement(this);
for (int i = 1; i <= iteration; i++)
{
cpd.PasteElement(parentElement);
Track newTrack = cpd.pastedElementList[0] as Track;
Vector3 positionOffset = unitPositionOffset * i;
float timeOffset = unitTimeOffset * i;
//对Track的所有有效的Submodule和子GameElement进行偏移
if (newTrack.trackTimeSubmodule is TrackTimeSubmoduleMovable movable)
{
movable.trackStartTime += timeOffset;
movable.trackEndTime += timeOffset;
}
newTrack.trackPathSubmodule.pathNodeList.ForEach(pn =>
{
pn.transformSubmodule.originalPosition += positionOffset;
pn.transformSubmodule.Refresh();
});
List<GameElement> allNewGameElements = newTrack.GetAllGameElementsFromThis();
List<TrackPercentPoint> percentPoints = allNewGameElements
.FindAll(x => x is TrackPercentPoint).Cast<TrackPercentPoint>().ToList();
percentPoints.ForEach(pp =>
{
pp.trackPercent.animations.ForEach(anim => anim.ApplyTimeOffset(timeOffset));
});
List<NoteBase> notes = allNewGameElements.FindAll(x => x is NoteBase).Cast<NoteBase>().ToList();
notes.ForEach(note =>
{
note.exactJudgeTime += timeOffset;
note.Refresh();
});
if (includeAnimations)
{
List<AnimationBase> animations = allNewGameElements
.FindAll(x => x.GetType().IsSubclassOf(typeof(AnimationBase))).Cast<AnimationBase>().ToList();
animations.ForEach(anim =>
{
anim.ApplyTimeOffset(timeOffset);
});
}
}
cpd.pastedElementList.Clear();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 91eb99ad678b44efe90bd2699a9502f3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: