65 lines
1.1 KiB
C#
65 lines
1.1 KiB
C#
|
|
using System.Diagnostics;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
using Godot;
|
|
|
|
|
|
namespace Rokojori
|
|
{
|
|
[Tool]
|
|
[GlobalClass]
|
|
public partial class TimeLine:Resource
|
|
{
|
|
[Export]
|
|
public bool isLooping = false;
|
|
|
|
[Export]
|
|
public float loopStart = 0;
|
|
|
|
[Export]
|
|
public float loopEnd = 100000;
|
|
|
|
[Export]
|
|
public float startSpeed = 1;
|
|
|
|
[Export]
|
|
public bool autoStart = true;
|
|
|
|
|
|
public TimeLineRunner runner
|
|
{
|
|
get
|
|
{
|
|
|
|
var tm = TimeLineManager.Get();
|
|
|
|
if ( tm == null )
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return tm.GetRunner( this );
|
|
}
|
|
}
|
|
|
|
public float delta => runner == null ? 1/60f : runner.currentDelta;
|
|
|
|
public float position => runner.position;
|
|
|
|
public float ComputePhase( float duration, float offset = 0 )
|
|
{
|
|
var time = position + offset;
|
|
|
|
return ( time % duration ) / duration;
|
|
}
|
|
|
|
public float ComputeRange( float start, float end )
|
|
{
|
|
return MathX.Normalize( position, start, end );
|
|
}
|
|
|
|
|
|
}
|
|
} |