diff --git a/.DS_Store b/.DS_Store index 0ebab392..681b92dc 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Assets/.DS_Store b/Assets/.DS_Store index 1dc2194e..a5894ecd 100644 Binary files a/Assets/.DS_Store and b/Assets/.DS_Store differ diff --git a/Assets/Prefabs/.DS_Store b/Assets/Prefabs/.DS_Store new file mode 100644 index 00000000..406d18b3 Binary files /dev/null and b/Assets/Prefabs/.DS_Store differ diff --git a/Assets/Scripts/.DS_Store b/Assets/Scripts/.DS_Store index aff4f18f..1dfcc813 100644 Binary files a/Assets/Scripts/.DS_Store and b/Assets/Scripts/.DS_Store differ diff --git a/Assets/Scripts/Base/GeneralSubmodules/ColorSubmodule.cs b/Assets/Scripts/Base/GeneralSubmodules/ColorSubmodule.cs index b92de51a..fc0ec107 100644 --- a/Assets/Scripts/Base/GeneralSubmodules/ColorSubmodule.cs +++ b/Assets/Scripts/Base/GeneralSubmodules/ColorSubmodule.cs @@ -67,5 +67,49 @@ namespace Ichni.RhythmGame this.baseColorDirtyMark = false; this.emissionColorDirtyMark = false; } + + public override void SaveBM() + { + matchedBM = new Beatmap.ColorSubmodule_BM(attachedElement, originalBaseColor, emissionEnabled, + originalEmissionColor, originalEmissionIntensity); + } + } + + namespace Beatmap + { + public class ColorSubmodule_BM : Submodule_BM + { + public Color originalBaseColor; + public bool emissionEnabled; + public Color originalEmissionColor; + public float originalEmissionIntensity; + + public ColorSubmodule_BM() + { + + } + + public ColorSubmodule_BM(BaseElement attachedElement, Color originalBaseColor, bool emissionEnabled, + Color originalEmissionColor, float originalEmissionIntensity) : base(attachedElement) + { + this.originalBaseColor = originalBaseColor; + this.emissionEnabled = emissionEnabled; + this.originalEmissionColor = originalEmissionColor; + this.originalEmissionIntensity = originalEmissionIntensity; + } + + public override void ExecuteBM() + { + attachedElement = GetElement(attachedElementGuid); + attachedElement.colorSubmodule = new ColorSubmodule(attachedElement, originalBaseColor, emissionEnabled, + originalEmissionColor, originalEmissionIntensity); + } + + public override void DuplicateBM(BaseElement attached) + { + attached.colorSubmodule = new ColorSubmodule(attached, originalBaseColor, emissionEnabled, + originalEmissionColor, originalEmissionIntensity); + } + } } } \ No newline at end of file diff --git a/Assets/Scripts/Base/GeneralSubmodules/EffectSubmodule.cs b/Assets/Scripts/Base/GeneralSubmodules/EffectSubmodule.cs index 1ee96325..63cdd663 100644 --- a/Assets/Scripts/Base/GeneralSubmodules/EffectSubmodule.cs +++ b/Assets/Scripts/Base/GeneralSubmodules/EffectSubmodule.cs @@ -12,6 +12,45 @@ namespace Ichni.RhythmGame { effectList = new List(); } + + public override void SaveBM() + { + matchedBM = new Beatmap.EffectSubmodule_BM(attachedElement); + } + } + + public interface IHaveEffect + { + public EffectSubmodule effectSubmodule { get; set; } + } + + namespace Beatmap + { + public class EffectSubmodule_BM : Submodule_BM + { + public List effectList; + + public EffectSubmodule_BM() + { + + } + + public EffectSubmodule_BM(BaseElement attachedElement) : base(attachedElement) + { + effectList = new List(); + } + + public override void ExecuteBM() + { + attachedElement = GetElement(attachedElementGuid); + (attachedElement as IHaveEffect).effectSubmodule = new EffectSubmodule(attachedElement); + } + + public override void DuplicateBM(BaseElement attached) + { + (attached as IHaveEffect).effectSubmodule = new EffectSubmodule(attached); + } + } } public abstract class EffectBase diff --git a/Assets/Scripts/Base/GeneralSubmodules/SubmoduleBase.cs b/Assets/Scripts/Base/GeneralSubmodules/SubmoduleBase.cs index 8bf8042c..f051ed34 100644 --- a/Assets/Scripts/Base/GeneralSubmodules/SubmoduleBase.cs +++ b/Assets/Scripts/Base/GeneralSubmodules/SubmoduleBase.cs @@ -1,5 +1,7 @@ +using System; using System.Collections; using System.Collections.Generic; +using Ichni.RhythmGame.Beatmap; using UnityEngine; namespace Ichni.RhythmGame @@ -7,15 +9,58 @@ namespace Ichni.RhythmGame public abstract class SubmoduleBase { public BaseElement attachedElement; - + + public Submodule_BM matchedBM; + public SubmoduleBase(BaseElement attachedElement) { this.attachedElement = attachedElement; } - + public virtual void InitialRefresh() { - + + } + + public abstract void SaveBM(); + } + + namespace Beatmap + { + public abstract class Submodule_BM + { + [System.NonSerialized] public BaseElement attachedElement; //存档类对应的游戏物体 + public Guid attachedElementGuid; + + public Submodule_BM() + { + + } + + public Submodule_BM(BaseElement attachedElement) + { + this.attachedElement = attachedElement; + attachedElementGuid = attachedElement.elementGuid; + } + + public static BaseElement_BM GetElementBM(Guid id) + { + if (BaseElement_BM.identifier.TryGetValue(id, out BaseElement_BM element_BM)) + { + return element_BM; + } + + Debug.LogAssertion("Element not found or do not have id"); + return null; + } + + public static BaseElement GetElement(Guid id) + { + return GetElementBM(id)?.matchedElement; + } + + public abstract void ExecuteBM(); + public abstract void DuplicateBM(BaseElement attached); } } } \ No newline at end of file diff --git a/Assets/Scripts/Base/GeneralSubmodules/TimeDurationSubmodule.cs b/Assets/Scripts/Base/GeneralSubmodules/TimeDurationSubmodule.cs index 7864f3e6..a8bfb58f 100644 --- a/Assets/Scripts/Base/GeneralSubmodules/TimeDurationSubmodule.cs +++ b/Assets/Scripts/Base/GeneralSubmodules/TimeDurationSubmodule.cs @@ -18,9 +18,9 @@ namespace Ichni.RhythmGame endTime = 999;//TODO: 换为songLength } - public TimeDurationSubmodule(BaseElement attachedElement, float startTime, float endTime) : base(attachedElement) + public TimeDurationSubmodule(BaseElement attachedElement, bool isOverridingDuration, float startTime, float endTime) : base(attachedElement) { - this.isOverridingDuration = false; + this.isOverridingDuration = isOverridingDuration; this.startTime = startTime; this.endTime = endTime; } @@ -73,5 +73,42 @@ namespace Ichni.RhythmGame startTime = durations.Min(duration => duration.x); endTime = durations.Max(duration => duration.y); } + + public override void SaveBM() + { + matchedBM = new Beatmap.TimeDurationSubmodule_BM(attachedElement, this); + } + } + + namespace Beatmap + { + public class TimeDurationSubmodule_BM : Submodule_BM + { + public bool isOverridingDuration; + public float startTime, endTime; + + public TimeDurationSubmodule_BM() + { + + } + + public TimeDurationSubmodule_BM(BaseElement attachedElement, TimeDurationSubmodule timeDurationSubmodule) : base(attachedElement) + { + isOverridingDuration = timeDurationSubmodule.isOverridingDuration; + startTime = timeDurationSubmodule.startTime; + endTime = timeDurationSubmodule.endTime; + } + + public override void ExecuteBM() + { + attachedElement = GetElement(attachedElementGuid); + attachedElement.timeDurationSubmodule = new TimeDurationSubmodule(attachedElement, isOverridingDuration, startTime, endTime); + } + + public override void DuplicateBM(BaseElement attached) + { + attached.timeDurationSubmodule = new TimeDurationSubmodule(attached, isOverridingDuration, startTime, endTime); + } + } } } \ No newline at end of file diff --git a/Assets/Scripts/Base/GeneralSubmodules/TransformSubmodule.cs b/Assets/Scripts/Base/GeneralSubmodules/TransformSubmodule.cs index c1aac24a..74aa4e57 100644 --- a/Assets/Scripts/Base/GeneralSubmodules/TransformSubmodule.cs +++ b/Assets/Scripts/Base/GeneralSubmodules/TransformSubmodule.cs @@ -28,10 +28,7 @@ namespace Ichni.RhythmGame public bool scaleDirtyMark; public bool eulerAnglesOffsetLock; - - public UnityAction OnPositionChanged; - public UnityAction OnEulerAnglesChanged; - public UnityAction OnScaleChanged; + public TransformSubmodule(BaseElement attachedElement) : base(attachedElement) { @@ -79,5 +76,45 @@ namespace Ichni.RhythmGame attachedElement.SetTransformObserver(); } + + public override void SaveBM() + { + matchedBM = new Beatmap.TransformSubmodule_BM(attachedElement, originalPosition, originalEulerAngles, originalScale); + } + } + + namespace Beatmap + { + public class TransformSubmodule_BM : Submodule_BM + { + public Vector3 originalPosition; + public Vector3 originalEulerAngles; + public Vector3 originalScale; + + public TransformSubmodule_BM() + { + + } + + public TransformSubmodule_BM(BaseElement attachedElement, Vector3 originalPosition, + Vector3 originalEulerAngles, Vector3 originalScale) : + base(attachedElement) + { + this.originalPosition = originalPosition; + this.originalEulerAngles = originalEulerAngles; + this.originalScale = originalScale; + } + + public override void ExecuteBM() + { + attachedElement = GetElement(attachedElementGuid); + attachedElement.transformSubmodule = new TransformSubmodule(attachedElement, originalPosition, originalEulerAngles, originalScale); + } + + public override void DuplicateBM(BaseElement attached) + { + attached.transformSubmodule = new TransformSubmodule(attached, originalPosition, originalEulerAngles, originalScale); + } + } } } \ No newline at end of file diff --git a/Assets/Scripts/GameElements/Notes/JudgeSubmodules/NoteJudgeSubmodule.cs b/Assets/Scripts/GameElements/Notes/JudgeSubmodules/NoteJudgeSubmodule.cs index 581ba12b..b53e8a7d 100644 --- a/Assets/Scripts/GameElements/Notes/JudgeSubmodules/NoteJudgeSubmodule.cs +++ b/Assets/Scripts/GameElements/Notes/JudgeSubmodules/NoteJudgeSubmodule.cs @@ -6,10 +6,47 @@ namespace Ichni.RhythmGame { public class NoteJudgeSubmodule : SubmoduleBase { + public List judgeUnitList; + public NoteJudgeSubmodule(BaseElement attachedElement) : base(attachedElement) { } + + public override void SaveBM() + { + matchedBM = new Beatmap.NoteJudgeSubmodule_BM(attachedElement); + } + } + + namespace Beatmap + { + public class NoteJudgeSubmodule_BM : Submodule_BM + { + public List judgeUnitList; + + public NoteJudgeSubmodule_BM() + { + + } + + public NoteJudgeSubmodule_BM(BaseElement attachedElement) : base(attachedElement) + { + judgeUnitList = new List(); + } + + public override void ExecuteBM() + { + attachedElement = GetElement(attachedElementGuid); + //(attachedElement as NoteElement).noteJudgeSubmodule = new NoteJudgeSubmodule(attachedElement); + } + + public override void DuplicateBM(BaseElement attached) + { + //(attached as NoteElement).noteJudgeSubmodule = new NoteJudgeSubmodule(attached); + } + } + } public class NoteJudgeUnit diff --git a/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackPathSubmodule.cs b/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackPathSubmodule.cs index 34edf9e7..99105895 100644 --- a/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackPathSubmodule.cs +++ b/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackPathSubmodule.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using Dreamteck.Splines; +using Ichni.RhythmGame.Beatmap; using Unity.VisualScripting; using UnityEngine; @@ -63,4 +64,48 @@ namespace Ichni.RhythmGame path.SetPoint(point.index, point.node, SplineComputer.Space.Local); } } + + public partial class TrackPathSubmodule + { + override public void SaveBM() + { + matchedBM = new TrackPathSubmodule_BM(attachedElement, this); + } + } + + namespace Beatmap + { + public class TrackPathSubmodule_BM : Submodule_BM + { + public Track.TrackSpaceType trackSpaceType; + public Track.TrackSamplingType trackSamplingType; + public bool isClosed; + + public TrackPathSubmodule_BM() + { + + } + + + public TrackPathSubmodule_BM(BaseElement attachedElement, TrackPathSubmodule trackPathSubmodule) : base( + attachedElement) + { + this.trackSpaceType = trackPathSubmodule.trackSpaceType; + this.trackSamplingType = trackPathSubmodule.trackSamplingType; + this.isClosed = trackPathSubmodule.isClosed; + } + + public override void ExecuteBM() + { + attachedElement = GetElement(attachedElementGuid); + (attachedElement as Track).trackPathSubmodule = new TrackPathSubmodule(attachedElement as Track, trackSpaceType, trackSamplingType, isClosed); + } + + public override void DuplicateBM(BaseElement attached) + { + (attached as Track).trackPathSubmodule = new TrackPathSubmodule(attached as Track, trackSpaceType, trackSamplingType, isClosed); + } + } + + } } \ No newline at end of file diff --git a/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackRendererSubmodule.cs b/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackRendererSubmodule.cs index afe4ec7a..1e4431fd 100644 --- a/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackRendererSubmodule.cs +++ b/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackRendererSubmodule.cs @@ -11,12 +11,17 @@ namespace Ichni.RhythmGame public MeshGenerator meshGenerator; public MeshRenderer meshRenderer; public Material renderMaterial; - + public TrackRendererSubmodule(Track track) : base(track) { this.track = track; this.track.trackRendererSubmodule = this; } + + public override void SaveBM() + { + throw new System.NotImplementedException(); + } } public class TrackRendererSubmoduleAutoOrient : TrackRendererSubmodule @@ -44,5 +49,41 @@ namespace Ichni.RhythmGame splineRenderer.clipTo = 0; } } + + public override void SaveBM() + { + matchedBM = new Beatmap.TrackRendererSubmoduleAutoOrient_BM(attachedElement, this); + } + } + + namespace Beatmap + { + public class TrackRendererSubmoduleAutoOrient_BM : Submodule_BM + { + public string renderMaterialName; + + public TrackRendererSubmoduleAutoOrient_BM() + { + + } + + public TrackRendererSubmoduleAutoOrient_BM(BaseElement attachedElement, + TrackRendererSubmodule trackRendererSubmodule) : base(attachedElement) + { + renderMaterialName = trackRendererSubmodule.renderMaterial.name; + } + + public override void ExecuteBM() + { + attachedElement = GetElement(attachedElementGuid); + (attachedElement as Track).trackRendererSubmodule = + new TrackRendererSubmodule(attachedElement as Track); + } + + public override void DuplicateBM(BaseElement attached) + { + (attached as Track).trackRendererSubmodule = new TrackRendererSubmodule(attached as Track); + } + } } } \ No newline at end of file diff --git a/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackTimeSubmodule.cs b/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackTimeSubmodule.cs index bb9efbb1..81a0786b 100644 --- a/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackTimeSubmodule.cs +++ b/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackTimeSubmodule.cs @@ -7,14 +7,21 @@ namespace Ichni.RhythmGame public class TrackTimeSubmodule : TrackSubmodule { public float headPercent, tailPercent; - + public TrackTimeSubmodule(Track track) : base(track) { this.track = track; this.track.trackTimeSubmodule = this; } + + public override void SaveBM() + { + throw new System.NotImplementedException(); + } } - + + #region Movable + public class TrackTimeSubmoduleMovable : TrackTimeSubmodule { public float trackStartTime; @@ -40,40 +47,125 @@ namespace Ichni.RhythmGame public void UpdateTrackPart() { float songTime = EditorManager.instance.songModule.songTime; - + headPercent = GetTrackPercent(songTime); tailPercent = GetTrackPercent(songTime - visibleTrackTimeLength); - + if (track.trackRendererSubmodule != null) { track.trackRendererSubmodule.meshGenerator.clipFrom = tailPercent; track.trackRendererSubmodule.meshGenerator.clipTo = headPercent; } } - + public float GetTrackPercent(float songTimeInTime) { - float per = AnimationCurveEvaluator.Evaluate(animationCurveType, (songTimeInTime - trackStartTime) / trackTotalTime); + float per = AnimationCurveEvaluator.Evaluate(animationCurveType, + (songTimeInTime - trackStartTime) / trackTotalTime); return Mathf.Clamp01(per); } + + public override void SaveBM() + { + matchedBM = new Beatmap.TrackTimeSubmoduleMovable_BM(attachedElement, this); + } } - + + namespace Beatmap + { + public class TrackTimeSubmoduleMovable_BM : Submodule_BM + { + public float trackStartTime; + public float trackEndTime; + public float visibleTrackTimeLength; + public AnimationCurveType animationCurveType; + + public TrackTimeSubmoduleMovable_BM() + { + + } + + public TrackTimeSubmoduleMovable_BM(BaseElement attachedElement, TrackTimeSubmoduleMovable trackTimeSubmoduleMovable) : base(attachedElement) + { + trackStartTime = trackTimeSubmoduleMovable.trackStartTime; + trackEndTime = trackTimeSubmoduleMovable.trackEndTime; + visibleTrackTimeLength = trackTimeSubmoduleMovable.visibleTrackTimeLength; + animationCurveType = trackTimeSubmoduleMovable.animationCurveType; + } + + public override void ExecuteBM() + { + attachedElement = GetElement(attachedElementGuid); + Track track = attachedElement as Track; + track.trackTimeSubmodule = new TrackTimeSubmoduleMovable(track, trackStartTime, trackEndTime, visibleTrackTimeLength, animationCurveType); + } + + public override void DuplicateBM(BaseElement attached) + { + Track track = attached as Track; + track.trackTimeSubmodule = new TrackTimeSubmoduleMovable(track, trackStartTime, trackEndTime, visibleTrackTimeLength, animationCurveType); + } + } + } + + #endregion + + #region Static public class TrackTimeSubmoduleStatic : TrackTimeSubmodule { public float trackTotalTime; public AnimationCurveType animationCurveType; - public TrackTimeSubmoduleStatic(Track track, float trackTotalTime, AnimationCurveType animationCurveType) : base(track) + public TrackTimeSubmoduleStatic(Track track, float trackTotalTime, AnimationCurveType animationCurveType) : + base(track) { this.trackTotalTime = trackTotalTime; this.animationCurveType = animationCurveType; this.headPercent = 0; this.tailPercent = 1; - + track.timeDurationSubmodule.startTime = -999; track.timeDurationSubmodule.endTime = 999; //timeDurationSubmodule 根据下辖Note的时间来设置 } + + public override void SaveBM() + { + matchedBM = new Beatmap.TrackTimeSubmoduleStatic_BM(attachedElement, this); + } } + namespace Beatmap + { + public class TrackTimeSubmoduleStatic_BM : Submodule_BM + { + public float trackTotalTime; + public AnimationCurveType animationCurveType; + + public TrackTimeSubmoduleStatic_BM() + { + + } + + public TrackTimeSubmoduleStatic_BM(BaseElement attachedElement, TrackTimeSubmoduleStatic trackTimeSubmoduleStatic) : base(attachedElement) + { + trackTotalTime = trackTimeSubmoduleStatic.trackTotalTime; + animationCurveType = trackTimeSubmoduleStatic.animationCurveType; + } + + public override void ExecuteBM() + { + attachedElement = GetElement(attachedElementGuid); + Track track = attachedElement as Track; + track.trackTimeSubmodule = new TrackTimeSubmoduleStatic(track, trackTotalTime, animationCurveType); + } + + public override void DuplicateBM(BaseElement attached) + { + Track track = attached as Track; + track.trackTimeSubmodule = new TrackTimeSubmoduleStatic(track, trackTotalTime, animationCurveType); + } + } + } + #endregion } \ No newline at end of file diff --git a/Assets/StreamingAssets/.DS_Store b/Assets/StreamingAssets/.DS_Store index a9d8656d..9a6292d9 100644 Binary files a/Assets/StreamingAssets/.DS_Store and b/Assets/StreamingAssets/.DS_Store differ