Skip to content

Commit

Permalink
UPD optimized delayer with 0 timings
Browse files Browse the repository at this point in the history
  • Loading branch information
deepnight committed Jul 2, 2024
1 parent 2ff2968 commit 817ec15
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/dn/Delayer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,30 @@ class Delayer {
}

public function addMs(?id:String, cb:Void->Void, ms:Float) {
delays.push( new Task( id, ms / 1000 * fps, cb) );
haxe.ds.ArraySort.sort(delays, cmp);
if( ms<=0 )
cb();
else {
delays.push( new Task( id, ms / 1000 * fps, cb) );
haxe.ds.ArraySort.sort(delays, cmp);
}
}

public function addS(?id:String, cb:Void->Void, sec:Float) {
delays.push( new Task( id, sec*fps, cb) );
haxe.ds.ArraySort.sort(delays, cmp);
if( sec<=0 )
cb();
else {
delays.push( new Task( id, sec*fps, cb) );
haxe.ds.ArraySort.sort(delays, cmp);
}
}

public function addF(?id:String, cb:Void->Void, frames:Float) {
delays.push( new Task( id, frames, cb ) );
haxe.ds.ArraySort.sort(delays, cmp);
if( frames<=0 )
cb();
else {
delays.push( new Task( id, frames, cb ) );
haxe.ds.ArraySort.sort(delays, cmp);
}
}

public inline function hasAny() return !isDestroyed() && delays.length>0;
Expand Down

0 comments on commit 817ec15

Please sign in to comment.