rokojori_action_library/Runtime/Time/Timeline.cs

81 lines
1.5 KiB
C#

using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System;
using Godot;
using Rokojori.Extensions;
namespace Rokojori
{
[RokojoriActionCoreExport]
[Tool][GlobalClass]
public partial class Timeline:Resource
{
[Export]
public bool executesInPause = false;
[Export]
public bool isModulatedByTimeScale = false;
[ExportGroup("Start")]
[Export]
public bool autoStart = true;
[Export]
public float startSpeed = 1;
[ExportGroup("Looping")]
[Export]
public bool isLooping = false;
[Export]
public float loopStart = 0;
[Export]
public float loopEnd = 100000;
public static float osTime => (float)(Godot.Time.GetTicksMsec() / 1000.0 );
public TimelineRunner runner
{
get
{
var tm = TimelineManager.Get();
if ( tm == null )
{
return null;
}
return tm.GetRunnerByTimeline( this );
}
}
public float delta => runner == null ? ( (float)( (SceneTree)Engine.GetMainLoop()).Root.GetProcessDeltaTime() ): runner.currentDelta;
public float position => runner == null ? Godot.Time.GetTicksMsec() / 1000f : 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 );
}
}
}