using Godot; using System.Collections.Generic; namespace Rokojori; public abstract class LineVFXData { public abstract int GetUpdateID(); public abstract IEnumerable GetPointData(); public abstract int GetNumSegments(); public abstract void SetSegmentData( MeshInstance3D mi, int segmentIndex ); public virtual int GetNumPoints() { return GetNumSegments() + 1; } public abstract Vector3 GetPositionAt( int index ); public Vector3 LerpPositionAt( float normalizedIndex ) { if ( GetNumPoints() == 0 ) { return Vector3.Zero; } if ( GetNumPoints() == 1 ) { return GetPositionAt( 0 ); } var pointIndex = normalizedIndex * GetNumPoints(); if ( pointIndex <= 0 ) { return GetPositionAt( 0 ); } if ( pointIndex >= GetNumPoints() - 1 ) { return GetPositionAt( GetNumPoints() - 1 ); } var lowerIndex = Mathf.FloorToInt( pointIndex ); var higherIndex = Mathf.CeilToInt( pointIndex ); var p0 = GetPositionAt( lowerIndex ); var p1 = GetPositionAt( higherIndex ); return p0.Lerp( p1, pointIndex - lowerIndex ); } }