Files
ichni_Creator_Studio/Assets/Scripts/GameElements/Track/PathNode.cs
SoulliesOfficial bc1c5d65ef 基础内容-8
添加BM存档类
2025-02-02 21:59:43 -05:00

115 lines
3.9 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, Vector3 nodePosition, Vector3 nodeNormal, float nodeSize, Color nodeColor)
{
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, nodePosition,
Quaternion.LookRotation(nodeNormal, Vector3.up).eulerAngles, Vector3.one * nodeSize);
pathNode.timeDurationSubmodule = new TimeDurationSubmodule(pathNode);
pathNode.colorSubmodule = new ColorSubmodule(pathNode, nodeColor);
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;
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, index,
node.position, node.normal, node.size, node.color);
}
}
namespace Beatmap
{
public class PathNode_BM : BaseElement_BM
{
public int index;
public Vector3 position;
public Vector3 normal;
public float size;
public Color color;
public PathNode_BM()
{
}
public PathNode_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement,
int index, Vector3 position, Vector3 normal, float size, Color color)
: base(elementName, elementGuid, tags, attachedElement)
{
this.index = index;
this.position = position;
this.normal = normal;
this.size = size;
this.color = color;
}
public override void ExecuteBM()
{
matchedElement = PathNode.GenerateElement(elementName, elementGuid, tags,
GetElement(attachedElementGuid) as Track, position, normal, size, color);
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return PathNode.GenerateElement(elementName, elementGuid, tags, parent as Track,
position, normal, size, color);
}
}
}
}