-
Notifications
You must be signed in to change notification settings - Fork 4
/
TimeLine.cs
43 lines (42 loc) · 1.11 KB
/
TimeLine.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using UnityEngine;
using clojure.lang;
using System.Collections;
public class TimeLine : IEnumerator{
public object[] fns;
public bool loop = false;
int idx = -1;
public IFn predicate = null;
public TimeLine(object[] list){
fns = list;}
public bool MoveNext(){
try{
if (idx == fns.Length) {
return false;}
else if (!(predicate == null) && RT.booleanCast(predicate.invoke())){
return true;}
else if (idx + 1 < fns.Length) {
idx++;
try{
predicate = (clojure.lang.IFn)fns[idx];}
catch (System.InvalidCastException){
predicate = null;}
return true;}
else {
this.Reset();
if (loop){
return true;}
return false;} }
catch (System.Exception){
return false;
}}
public void Reset(){
idx = -1;
predicate = null;}
public object Current{
get{
try{
return fns[idx];}
catch (System.IndexOutOfRangeException) {
//throw new System.InvalidOperationException();
return false;
}}}}