116 lines
3.7 KiB
C#
116 lines
3.7 KiB
C#
using System;
|
|
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 : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule, IHaveColorSubmodule
|
|
{
|
|
public Track track;
|
|
|
|
public int index => track.trackPathSubmodule.pathNodeList.IndexOf(this);
|
|
|
|
public SplinePoint node;
|
|
|
|
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, isFirstGenerated, track);
|
|
|
|
pathNode.track = track;
|
|
track.trackPathSubmodule.pathNodeList.Add(pathNode);
|
|
|
|
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)
|
|
{
|
|
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 as GameElement_BM);
|
|
}
|
|
}
|
|
|
|
namespace Beatmap
|
|
{
|
|
public class PathNode_BM : GameElement_BM
|
|
{
|
|
public PathNode_BM()
|
|
{
|
|
|
|
}
|
|
|
|
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, false,
|
|
GetElement(attachedElementGuid) as Track);
|
|
}
|
|
|
|
public override GameElement DuplicateBM(GameElement parent)
|
|
{
|
|
return PathNode.GenerateElement(elementName, elementGuid, tags, false, parent as Track);
|
|
}
|
|
}
|
|
}
|
|
} |