using System; using System.Collections; using System.Collections.Generic; using Dreamteck.Splines; using Ichni.RhythmGame.Beatmap; using UnityEngine; namespace Ichni.RhythmGame { public partial class PathNode : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule, IHaveColorSubmodule { public Track track; public SplinePoint node; public int index => track.trackPathSubmodule.pathNodeList.IndexOf(this); public TransformSubmodule transformSubmodule { get; set; } public TimeDurationSubmodule timeDurationSubmodule { get; set; } public ColorSubmodule colorSubmodule { get; set; } public bool haveEmission => false; public override int HierarchyPriority => -100; public bool isShowingSphere; public static PathNode GenerateElement(string elementName, Guid id, List tags, bool isFirstGenerated, Track track, bool isShowingSphere) { PathNode pathNode = Instantiate(GameManager.instance.basePrefabs.pathNode, track.transform).GetComponent(); pathNode.Initialize(elementName, id, tags, isFirstGenerated, track); pathNode.track = track; pathNode.isShowingSphere = isShowingSphere; track.trackPathSubmodule.pathNodeList.Add(pathNode); track.trackPathSubmodule.SetPathNode(pathNode); return pathNode; } public override void SetDefaultSubmodules() { transformSubmodule = new TransformSubmodule(this); timeDurationSubmodule = new TimeDurationSubmodule(this); colorSubmodule = new ColorSubmodule(this); } } public partial class PathNode { public override void Refresh() { base.Refresh(); Vector3 position = transformSubmodule.currentPosition; Vector3 normal = Quaternion.Euler(transformSubmodule.currentEulerAngles) * Vector3.up; float size = transformSubmodule.currentScale.x; Color color = colorSubmodule.currentBaseColor; transform.localPosition = position; transform.localRotation = 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 PathNode_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM, isShowingSphere); } } namespace Beatmap { public class PathNode_BM : GameElement_BM { public bool isShowingSphere; public PathNode_BM() { } public PathNode_BM(string elementName, Guid elementGuid, List tags, GameElement_BM attachedElement, bool isShowingSphere) : base(elementName, elementGuid, tags, attachedElement) { this.isShowingSphere = isShowingSphere; } public override void ExecuteBM() { matchedElement = PathNode.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid) as Track, isShowingSphere); } public override GameElement DuplicateBM(GameElement parent) { return PathNode.GenerateElement(elementName, Guid.NewGuid(), tags, false, parent as Track, isShowingSphere); } } } }