104 lines
3.3 KiB
C#
104 lines
3.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Dreamteck.Splines;
|
|
using Ichni;
|
|
using Lean.Pool;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace Ichni.RhythmGame
|
|
{
|
|
public partial class PathNode : BaseElement
|
|
{
|
|
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)
|
|
{
|
|
PathNode pathNode = Instantiate(EditorManager.instance.basePrefabs.pathNode, track.transform)
|
|
.GetComponent<PathNode>();
|
|
|
|
pathNode.Initialize(elementName, id, tags);
|
|
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;
|
|
}
|
|
|
|
public override void AfterInitialize()
|
|
{
|
|
Refresh();
|
|
if (track.trackPathSubmodule.pathNodeList.Count > 3)
|
|
{
|
|
track.trackPathSubmodule.ClosePath(track.trackPathSubmodule.isClosed);
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class PathNode
|
|
{
|
|
public override void Refresh()
|
|
{
|
|
Vector3 position = transformSubmodule.currentPosition;
|
|
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;
|
|
|
|
node = new SplinePoint(position, Vector3.up, normal, size, color);
|
|
track.trackPathSubmodule.SetPathNode(this);
|
|
}
|
|
}
|
|
|
|
public partial class PathNode
|
|
{
|
|
public override void SaveBM()
|
|
{
|
|
matchedBM = new Beatmap.PathNode_BM(elementName, elementGuid, tags, parentElement.matchedBM);
|
|
}
|
|
}
|
|
|
|
namespace Beatmap
|
|
{
|
|
public class PathNode_BM : BaseElement_BM
|
|
{
|
|
public PathNode_BM()
|
|
{
|
|
|
|
}
|
|
|
|
public PathNode_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement)
|
|
: base(elementName, elementGuid, tags, attachedElement)
|
|
{
|
|
|
|
}
|
|
|
|
public override void ExecuteBM()
|
|
{
|
|
matchedElement = PathNode.GenerateElement(elementName, elementGuid, tags,
|
|
GetElement(attachedElementGuid) as Track);
|
|
}
|
|
|
|
public override BaseElement DuplicateBM(BaseElement parent)
|
|
{
|
|
return PathNode.GenerateElement(elementName, elementGuid, tags, parent as Track);
|
|
}
|
|
}
|
|
}
|
|
} |