using Facepunch.ActionGraphs; using System.Threading; namespace Sandbox.ActionGraphs; internal static class TimeNodes { /// /// A task that does nothing for a given amount of time in seconds. This will continue even if the /// object containing this graph is destroyed, you probably want → Time → Delay instead. /// /// Time to wait in seconds. /// Token for cancelling the delay. [ActionGraphNode( "time.delay" ), Title( "Scene Delay" ), Category( "Time" ), Icon( "schedule" ), Tags( "common" )] public static Task Delay( float seconds, CancellationToken? ct = null ) { return ct is null ? GameTask.DelaySeconds( seconds ) : GameTask.DelaySeconds( seconds, ct.Value ); } /// /// A task that does nothing for a given amount of time in seconds, and cancels automatically if the target /// is destroyed. /// /// Cancel the delay if this object is destroyed. /// Time to wait in seconds. /// Token for cancelling the delay. [ActionGraphNode( "time.delayobj" ), Category( "Time" ), Icon( "schedule" ), Tags( "common" )] public static Task Delay( [Target] GameObject target, float seconds, CancellationToken? ct = null ) { return ct is null ? target.Task.DelaySeconds( seconds ) : target.Task.DelaySeconds( seconds, ct.Value ); } /// [ActionGraphNode( "time.delta" ), Pure, Category( "Time" ), Icon( "Δ" ), Tags( "common" )] public static float Delta() { return Time.Delta; } /// [ActionGraphNode( "time.now" ), Pure, Category( "Time" ), Icon( "Δ" ), Tags( "common" )] public static float Now() { return Time.Now; } }