架构重新设计

基本重做了所有物体和次级模块代码
This commit is contained in:
SoulliesOfficial
2025-02-08 02:31:39 -05:00
parent 752c9b73e3
commit 7ab738cb68
44 changed files with 1320 additions and 847 deletions

View File

@@ -3,45 +3,58 @@ using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class PathNode : BaseElement
public partial class PathNode : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule,
IHaveColorSubmodule
{
public ColorSubmodule colorSubmodule;
public Track track;
public int index => track.trackPathSubmodule.pathNodeList.IndexOf(this);
public SplinePoint node;
public static PathNode GenerateElement(string elementName, Guid id, List<string> tags, Track track)
public TransformSubmodule transformSubmodule { get; set; }
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
public ColorSubmodule colorSubmodule { get; set; }
public static PathNode GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
Track track)
{
PathNode pathNode = Instantiate(EditorManager.instance.basePrefabs.pathNode, track.transform)
.GetComponent<PathNode>();
pathNode.Initialize(elementName, id, tags);
pathNode.Initialize(elementName, id, tags, isFirstGenerated);
pathNode.track = track;
//pathNode.index = index;
pathNode.transformSubmodule = new TransformSubmodule(pathNode);
pathNode.timeDurationSubmodule = new TimeDurationSubmodule(pathNode);
pathNode.colorSubmodule = new ColorSubmodule(pathNode);
track.trackPathSubmodule.pathNodeList.Add(pathNode);
pathNode.SetParent(track);
return pathNode;
}
protected override void SetDefaultSubmodules()
{
transformSubmodule = new TransformSubmodule(this);
timeDurationSubmodule = new TimeDurationSubmodule(this);
colorSubmodule = new ColorSubmodule(this);
submoduleList.Add(transformSubmodule);
submoduleList.Add(timeDurationSubmodule);
submoduleList.Add(colorSubmodule);
}
public override void AfterInitialize()
{
base.AfterInitialize();
Refresh();
if (track.trackPathSubmodule.pathNodeList.Count > 3)
{
@@ -58,7 +71,7 @@ namespace Ichni.RhythmGame
Vector3 normal = Quaternion.Euler(transformSubmodule.currentEulerAngles) * Vector3.up;
float size = transformSubmodule.currentScale.x;
Color color = colorSubmodule.currentBaseColor;
transform.position = position;
transform.rotation = Quaternion.LookRotation(normal);
transform.localScale = Vector3.one * size;
@@ -72,34 +85,34 @@ namespace Ichni.RhythmGame
{
public override void SaveBM()
{
matchedBM = new Beatmap.PathNode_BM(elementName, elementGuid, tags, parentElement.matchedBM);
matchedBM = new Beatmap.PathNode_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM);
}
}
namespace Beatmap
{
public class PathNode_BM : BaseElement_BM
public class PathNode_BM : GameElement_BM
{
public PathNode_BM()
{
}
public PathNode_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement)
public PathNode_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement)
: base(elementName, elementGuid, tags, attachedElement)
{
}
public override void ExecuteBM()
{
matchedElement = PathNode.GenerateElement(elementName, elementGuid, tags,
matchedElement = PathNode.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid) as Track);
}
public override BaseElement DuplicateBM(BaseElement parent)
public override GameElement DuplicateBM(GameElement parent)
{
return PathNode.GenerateElement(elementName, elementGuid, tags, parent as Track);
return PathNode.GenerateElement(elementName, elementGuid, tags, false, parent as Track);
}
}
}

View File

@@ -1,43 +1,40 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class Track : BaseElement
public partial class Track : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule
{
public TrackPathSubmodule trackPathSubmodule;
public TrackTimeSubmodule trackTimeSubmodule;
public TrackRendererSubmodule trackRendererSubmodule;
public static Track GenerateElement(string elementName, Guid id, List<string> tags,
BaseElement parent, Vector3 position)
public TransformSubmodule transformSubmodule { get; set; }
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
public TrackPathSubmodule trackPathSubmodule { get; set; }
public TrackTimeSubmodule trackTimeSubmodule { get; set; }
public TrackRendererSubmodule trackRendererSubmodule { get; set; }
public static Track GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated, GameElement parent)
{
Track track = Instantiate(EditorManager.instance.basePrefabs.track, parent.transform).GetComponent<Track>();
track.Initialize(elementName, id, tags);
track.Initialize(elementName, id, tags, isFirstGenerated);
track.SetParent(parent);
track.transformSubmodule = new TransformSubmodule(track, position, Vector3.zero, Vector3.one);
track.timeDurationSubmodule = new TimeDurationSubmodule(track);
track.trackPathSubmodule = null;
track.trackTimeSubmodule = null;
track.trackRendererSubmodule = null;
track.SetTransformObserver();
return track;
}
public override void AfterInitialize()
protected override void SetDefaultSubmodules()
{
base.AfterInitialize();
submoduleList.Add(trackPathSubmodule);
submoduleList.Add(trackTimeSubmodule);
submoduleList.Add(trackRendererSubmodule);
transformSubmodule = new TransformSubmodule(this);
timeDurationSubmodule = new TimeDurationSubmodule(this);
trackPathSubmodule = null;
trackTimeSubmodule = null;
trackRendererSubmodule = null;
submoduleList.Add(transformSubmodule);
submoduleList.Add(timeDurationSubmodule);
}
private void Update()
@@ -53,7 +50,7 @@ namespace Ichni.RhythmGame
{
public override void SaveBM()
{
matchedBM = new Beatmap.Track_BM(elementName, elementGuid, tags, parentElement.matchedBM);
matchedBM = new Beatmap.Track_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM);
}
}
@@ -75,14 +72,14 @@ namespace Ichni.RhythmGame
namespace Beatmap
{
public class Track_BM : BaseElement_BM
public class Track_BM : GameElement_BM
{
public Track_BM()
{
}
public Track_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement)
public Track_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement)
: base(elementName, elementGuid, tags, attachedElement)
{
@@ -90,12 +87,12 @@ namespace Ichni.RhythmGame
public override void ExecuteBM()
{
matchedElement = Track.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid), Vector3.zero);
matchedElement = Track.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid));
}
public override BaseElement DuplicateBM(BaseElement parent)
public override GameElement DuplicateBM(GameElement parent)
{
return Track.GenerateElement(elementName, elementGuid, tags, parent, Vector3.zero);
return Track.GenerateElement(elementName, elementGuid, tags, false, parent);
}
}
}

View File

@@ -3,11 +3,12 @@ using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni.RhythmGame;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class CrossTrackPoint : BaseElement
public partial class CrossTrackPoint : GameElement, IHaveTimeDurationSubmodule
{
public ElementFolder trackListFolder;
public Track nowAttachedTrack;
@@ -16,24 +17,32 @@ namespace Ichni.RhythmGame
public FlexibleInt trackSwitch;
public FlexibleFloat trackPercent;
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
public static CrossTrackPoint GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated,
ElementFolder elementFolder, FlexibleInt trackSwitch, FlexibleFloat trackPercent)
{
CrossTrackPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, elementFolder.transform).AddComponent<CrossTrackPoint>();
point.Initialize(elementName, id, tags);
CrossTrackPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, elementFolder.transform)
.AddComponent<CrossTrackPoint>();
point.Initialize(elementName, id, tags, isFirstGenerated);
point.trackPositioner = point.gameObject.AddComponent<SplinePositioner>();
point.nowAttachedTrackIndex = -1;
point.trackListFolder = elementFolder;
point.trackSwitch = trackSwitch;
point.trackPercent = trackPercent;
point.transformSubmodule = new TransformSubmodule(point);
point.timeDurationSubmodule = new TimeDurationSubmodule(point);
point.SetParent(elementFolder);
return point;
}
protected override void SetDefaultSubmodules()
{
timeDurationSubmodule = new TimeDurationSubmodule(this);
submoduleList.Add(timeDurationSubmodule);
}
private void Update()
{
if (trackPercent.animations.Count > 0)
@@ -46,7 +55,8 @@ namespace Ichni.RhythmGame
private void SetPoint()
{
if (nowAttachedTrackIndex != trackSwitch.value && trackSwitch.value >= 0 && trackSwitch.value < trackListFolder.trackList.Count)
if (nowAttachedTrackIndex != trackSwitch.value && trackSwitch.value >= 0 &&
trackSwitch.value < trackListFolder.trackList.Count)
{
nowAttachedTrack = trackListFolder.trackList[trackSwitch.value];
nowAttachedTrackIndex = trackSwitch.value;
@@ -56,28 +66,30 @@ namespace Ichni.RhythmGame
trackPositioner.SetPercent(trackPercent.value);
}
}
public partial class CrossTrackPoint
{
public override void SaveBM()
{
matchedBM = new Beatmap.CrossTrackPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM, trackSwitch, trackPercent);
matchedBM = new CrossTrackPoint_BM(elementName, elementGuid, tags,
parentElement.matchedBM as GameElement_BM, trackSwitch, trackPercent);
}
}
namespace Beatmap
{
public class CrossTrackPoint_BM : BaseElement_BM
public class CrossTrackPoint_BM : GameElement_BM
{
public FlexibleInt trackSwitch;
public FlexibleFloat trackPercent;
public CrossTrackPoint_BM()
{
}
public CrossTrackPoint_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, FlexibleInt trackSwitch, FlexibleFloat trackPercent)
GameElement_BM attachedElement, FlexibleInt trackSwitch, FlexibleFloat trackPercent)
: base(elementName, elementGuid, tags, attachedElement)
{
this.trackSwitch = trackSwitch;
@@ -86,14 +98,14 @@ namespace Ichni.RhythmGame
public override void ExecuteBM()
{
CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid) as ElementFolder,
trackSwitch, trackPercent);
CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid) as ElementFolder, trackSwitch, trackPercent);
}
public override BaseElement DuplicateBM(BaseElement parent)
public override GameElement DuplicateBM(GameElement parent)
{
return CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, parent as ElementFolder,
trackSwitch, trackPercent);
return CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, false,
parent as ElementFolder, trackSwitch, trackPercent);
}
}
}

View File

@@ -2,23 +2,27 @@ using System;
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class TrackHeadPoint : BaseElement
public partial class TrackHeadPoint : GameElement, IHaveTimeDurationSubmodule
{
public Track track;
public TrackTimeSubmoduleMovable trackTimeSubmoduleMovable;
public SplinePositioner trackPositioner;
public static TrackHeadPoint GenerateElement(string elementName, Guid id, List<string> tags, Track track)
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
public static TrackHeadPoint GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, Track track)
{
TrackHeadPoint head = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform)
.AddComponent<TrackHeadPoint>();
head.Initialize(elementName, id, tags);
head.Initialize(elementName, id, tags, isFirstGenerated);
head.track = track;
head.trackPositioner = head.gameObject.AddComponent<SplinePositioner>();
head.trackPositioner.spline = track.trackPathSubmodule.path;
@@ -27,6 +31,12 @@ namespace Ichni.RhythmGame
return head;
}
protected override void SetDefaultSubmodules()
{
timeDurationSubmodule = new TimeDurationSubmodule(this);
submoduleList.Add(timeDurationSubmodule);
}
public void Update()
{
if (track.timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songModule.songTime))
@@ -40,13 +50,13 @@ namespace Ichni.RhythmGame
{
public override void SaveBM()
{
matchedBM = new Beatmap.TrackHeadPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM);
matchedBM = new TrackHeadPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM);
}
}
namespace Beatmap
{
public class TrackHeadPoint_BM : BaseElement_BM
public class TrackHeadPoint_BM : GameElement_BM
{
public TrackHeadPoint_BM()
{
@@ -54,20 +64,20 @@ namespace Ichni.RhythmGame
}
public TrackHeadPoint_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement)
GameElement_BM attachedElement)
: base(elementName, elementGuid, tags, attachedElement)
{
}
public override void ExecuteBM()
{
TrackHeadPoint.GenerateElement(elementName, elementGuid, tags,
TrackHeadPoint.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid) as Track);
}
public override BaseElement DuplicateBM(BaseElement parent)
public override GameElement DuplicateBM(GameElement parent)
{
return TrackHeadPoint.GenerateElement(elementName, elementGuid, tags, parent as Track);
return TrackHeadPoint.GenerateElement(elementName, elementGuid, tags, false, parent as Track);
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Dreamteck.Splines;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UniRx;
using UnityEngine;
@@ -12,31 +13,41 @@ namespace Ichni.RhythmGame
/// <summary>
/// 在轨道上根据百分比进行运动的点
/// </summary>
public partial class TrackPercentPoint : BaseElement
public partial class TrackPercentPoint : GameElement, IHaveTimeDurationSubmodule
{
public Track track;
public SplinePositioner trackPositioner;
public FlexibleFloat trackPercent;
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
private bool isBeyond1 = false;
public static TrackPercentPoint GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated,
Track track, FlexibleFloat trackPercent)
{
TrackPercentPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackPercentPoint>();
TrackPercentPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform)
.AddComponent<TrackPercentPoint>();
point.Initialize(elementName, id, tags);
point.Initialize(elementName, id, tags, isFirstGenerated);
point.track = track;
point.trackPositioner = point.gameObject.AddComponent<SplinePositioner>();
point.trackPositioner.spline = track.trackPathSubmodule.path;
point.trackPercent = trackPercent;
point.SetParent(track);
point.isBeyond1 = trackPercent.animations.Any(animation => animation.endValue > 1);//判断是否有超过1的动画超过1将会循环
point.isBeyond1 = trackPercent.animations.Any(animation => animation.endValue > 1); //判断是否有超过1的动画超过1将会循环
return point;
}
protected override void SetDefaultSubmodules()
{
timeDurationSubmodule = new TimeDurationSubmodule(this);
submoduleList.Add(timeDurationSubmodule);
}
public void Update()
{
if (trackPercent.animations.Count > 0)
@@ -45,38 +56,41 @@ namespace Ichni.RhythmGame
if (trackPercent.returnType == FlexibleReturnType.MiddleExecuting)
{
float finalValue = trackPercent.value;
if (isBeyond1)
{
finalValue -= Mathf.Floor(finalValue);
}
trackPositioner.SetPercent(finalValue);
}
}
}
}
public partial class TrackPercentPoint
{
public override void SaveBM()
{
matchedBM = new Beatmap.TrackPercentPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM, trackPercent.ConvertToBM());
matchedBM = new TrackPercentPoint_BM(elementName, elementGuid, tags,
parentElement.matchedBM as GameElement_BM,
trackPercent.ConvertToBM());
}
}
namespace Beatmap
{
public class TrackPercentPoint_BM : BaseElement_BM
public class TrackPercentPoint_BM : GameElement_BM
{
public FlexibleFloat_BM trackPercent;
public TrackPercentPoint_BM()
{
}
public TrackPercentPoint_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, FlexibleFloat_BM trackPercent)
GameElement_BM attachedElement, FlexibleFloat_BM trackPercent)
: base(elementName, elementGuid, tags, attachedElement)
{
this.trackPercent = trackPercent;
@@ -84,12 +98,14 @@ namespace Ichni.RhythmGame
public override void ExecuteBM()
{
TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid) as Track, trackPercent.ConvertToGameType());
TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid) as Track, trackPercent.ConvertToGameType());
}
public override BaseElement DuplicateBM(BaseElement parent)
public override GameElement DuplicateBM(GameElement parent)
{
return TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, parent as Track, trackPercent.ConvertToGameType());
return TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, false, parent as Track,
trackPercent.ConvertToGameType());
}
}
}

View File

@@ -69,7 +69,7 @@ namespace Ichni.RhythmGame
{
override public void SaveBM()
{
matchedBM = new TrackPathSubmodule_BM(attachedElement, this);
matchedBM = new TrackPathSubmodule_BM(attachedGameElement, this);
}
}
@@ -87,7 +87,7 @@ namespace Ichni.RhythmGame
}
public TrackPathSubmodule_BM(BaseElement attachedElement, TrackPathSubmodule trackPathSubmodule) : base(
public TrackPathSubmodule_BM(GameElement attachedElement, TrackPathSubmodule trackPathSubmodule) : base(
attachedElement)
{
this.trackSpaceType = trackPathSubmodule.trackSpaceType;
@@ -97,13 +97,15 @@ namespace Ichni.RhythmGame
public override void ExecuteBM()
{
attachedElement = GetElement(attachedElementGuid);
(attachedElement as Track).trackPathSubmodule = new TrackPathSubmodule(attachedElement as Track, trackSpaceType, trackSamplingType, isClosed);
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
Track track = attachedElement as Track;
track.trackPathSubmodule = new TrackPathSubmodule(track, trackSpaceType, trackSamplingType, isClosed);
}
public override void DuplicateBM(BaseElement attached)
public override void DuplicateBM(GameElement attached)
{
(attached as Track).trackPathSubmodule = new TrackPathSubmodule(attached as Track, trackSpaceType, trackSamplingType, isClosed);
Track track = attachedElement as Track;
track.trackPathSubmodule = new TrackPathSubmodule(track, trackSpaceType, trackSamplingType, isClosed);
}
}

View File

@@ -52,7 +52,7 @@ namespace Ichni.RhythmGame
public override void SaveBM()
{
matchedBM = new Beatmap.TrackRendererSubmoduleAutoOrient_BM(attachedElement, this);
matchedBM = new Beatmap.TrackRendererSubmoduleAutoOrient_BM(attachedGameElement, this);
}
}
@@ -67,7 +67,7 @@ namespace Ichni.RhythmGame
}
public TrackRendererSubmoduleAutoOrient_BM(BaseElement attachedElement,
public TrackRendererSubmoduleAutoOrient_BM(GameElement attachedElement,
TrackRendererSubmodule trackRendererSubmodule) : base(attachedElement)
{
renderMaterialName = trackRendererSubmodule.renderMaterial.name;
@@ -75,14 +75,15 @@ namespace Ichni.RhythmGame
public override void ExecuteBM()
{
attachedElement = GetElement(attachedElementGuid);
(attachedElement as Track).trackRendererSubmodule =
new TrackRendererSubmodule(attachedElement as Track);
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
Track track = attachedElement as Track;
track.trackRendererSubmodule = new TrackRendererSubmodule(track);//TODO: Implement Material
}
public override void DuplicateBM(BaseElement attached)
public override void DuplicateBM(GameElement attached)
{
(attached as Track).trackRendererSubmodule = new TrackRendererSubmodule(attached as Track);
Track track = attached as Track;
track.trackRendererSubmodule = new TrackRendererSubmodule(track);//TODO: Implement Material
}
}
}

View File

@@ -7,12 +7,10 @@ namespace Ichni.RhythmGame
public abstract class TrackSubmodule : SubmoduleBase
{
public Track track;
public bool isUpdating;
public TrackSubmodule(Track track) : base(track)
{
this.track = track;
isUpdating = false;
}
}
}

View File

@@ -67,7 +67,7 @@ namespace Ichni.RhythmGame
public override void SaveBM()
{
matchedBM = new Beatmap.TrackTimeSubmoduleMovable_BM(attachedElement, this);
matchedBM = new Beatmap.TrackTimeSubmoduleMovable_BM(attachedGameElement, this);
}
}
@@ -85,7 +85,7 @@ namespace Ichni.RhythmGame
}
public TrackTimeSubmoduleMovable_BM(BaseElement attachedElement, TrackTimeSubmoduleMovable trackTimeSubmoduleMovable) : base(attachedElement)
public TrackTimeSubmoduleMovable_BM(GameElement attachedElement, TrackTimeSubmoduleMovable trackTimeSubmoduleMovable) : base(attachedElement)
{
trackStartTime = trackTimeSubmoduleMovable.trackStartTime;
trackEndTime = trackTimeSubmoduleMovable.trackEndTime;
@@ -95,12 +95,12 @@ namespace Ichni.RhythmGame
public override void ExecuteBM()
{
attachedElement = GetElement(attachedElementGuid);
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
Track track = attachedElement as Track;
track.trackTimeSubmodule = new TrackTimeSubmoduleMovable(track, trackStartTime, trackEndTime, visibleTrackTimeLength, animationCurveType);
}
public override void DuplicateBM(BaseElement attached)
public override void DuplicateBM(GameElement attached)
{
Track track = attached as Track;
track.trackTimeSubmodule = new TrackTimeSubmoduleMovable(track, trackStartTime, trackEndTime, visibleTrackTimeLength, animationCurveType);
@@ -131,7 +131,7 @@ namespace Ichni.RhythmGame
public override void SaveBM()
{
matchedBM = new Beatmap.TrackTimeSubmoduleStatic_BM(attachedElement, this);
matchedBM = new Beatmap.TrackTimeSubmoduleStatic_BM(attachedGameElement, this);
}
}
@@ -147,7 +147,7 @@ namespace Ichni.RhythmGame
}
public TrackTimeSubmoduleStatic_BM(BaseElement attachedElement, TrackTimeSubmoduleStatic trackTimeSubmoduleStatic) : base(attachedElement)
public TrackTimeSubmoduleStatic_BM(GameElement attachedElement, TrackTimeSubmoduleStatic trackTimeSubmoduleStatic) : base(attachedElement)
{
trackTotalTime = trackTimeSubmoduleStatic.trackTotalTime;
animationCurveType = trackTimeSubmoduleStatic.animationCurveType;
@@ -155,12 +155,12 @@ namespace Ichni.RhythmGame
public override void ExecuteBM()
{
attachedElement = GetElement(attachedElementGuid);
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
Track track = attachedElement as Track;
track.trackTimeSubmodule = new TrackTimeSubmoduleStatic(track, trackTotalTime, animationCurveType);
}
public override void DuplicateBM(BaseElement attached)
public override void DuplicateBM(GameElement attached)
{
Track track = attached as Track;
track.trackTimeSubmodule = new TrackTimeSubmoduleStatic(track, trackTotalTime, animationCurveType);

View File

@@ -1,74 +1,83 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class Trail : BaseElement
public partial class Trail : GameElement, IHaveTransformSubmodule
{
public TrailRenderer trailRenderer;
public Material renderMaterial;
public float visibleTimeLength;
public static Trail GenerateElement(string name, Guid id, List<string> tags,
BaseElement parentElement, float visibleTimeLength, Material material = null)
public TransformSubmodule transformSubmodule { get; set; }
public static Trail GenerateElement(string name, Guid id, List<string> tags, bool isFirstGenerated,
GameElement parentElement, float visibleTimeLength, Material material = null)
{
Trail trail = Instantiate(EditorManager.instance.basePrefabs.trail).GetComponent<Trail>();
trail.trailRenderer = trail.GetComponent<TrailRenderer>();
trail.Initialize(name, id, tags);
trail.Initialize(name, id, tags, isFirstGenerated);
trail.renderMaterial =
material == null ? EditorManager.instance.basePrefabs.defaultTrailMaterial : material;
trail.trailRenderer.material = trail.renderMaterial;
trail.visibleTimeLength = visibleTimeLength;
trail.SetParent(parentElement);
trail.transformSubmodule = new TransformSubmodule(trail);
return trail;
}
protected override void SetDefaultSubmodules()
{
transformSubmodule = new TransformSubmodule(this);
submoduleList.Add(transformSubmodule);
}
}
public partial class Trail
{
public override void SaveBM()
{
matchedBM = new Beatmap.Trail_BM(elementName, elementGuid, tags, parentElement.matchedBM, visibleTimeLength,
renderMaterial);
matchedBM = new Trail_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
visibleTimeLength, renderMaterial);
}
}
namespace Beatmap
{
public class Trail_BM : BaseElement_BM
public class Trail_BM : GameElement_BM
{
public float visibleTimeLength;
public Material renderMaterial;
public string renderMaterialName;
public Trail_BM()
{
}
public Trail_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement,
float visibleTimeLength, Material renderMaterial)
: base(elementName, elementGuid, tags, attachedElement)
public Trail_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
float visibleTimeLength, Material renderMaterial) : base(elementName, elementGuid, tags,
attachedElement)
{
this.visibleTimeLength = visibleTimeLength;
this.renderMaterial = renderMaterial;
this.renderMaterialName = renderMaterial.name;
}
public override void ExecuteBM()
{
matchedElement = Trail.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid),
visibleTimeLength, renderMaterial);
matchedElement = Trail.GenerateElement(elementName, elementGuid, tags,
false, GetElement(attachedElementGuid),
visibleTimeLength); //TODO: Implement Material
}
public override BaseElement DuplicateBM(BaseElement parent)
public override GameElement DuplicateBM(GameElement parent)
{
return Trail.GenerateElement(elementName, elementGuid, tags, parent, visibleTimeLength, renderMaterial);
return Trail.GenerateElement(elementName, elementGuid, tags,
false, parent, visibleTimeLength); //TODO: Implement Material
}
}
}