public void Flow(FlowInit init, FlowLogic logic, Act endLogic = null) { FlowInfo flow = new FlowInfo { Init = init, Logic = logic, EndLogic = endLogic }; Flows.Add(flow); }
public void InternalUpdate( ) { upmut.WaitOne( ); List <IfInfo> iil = new List <IfInfo> ( ); foreach (IfInfo ci in Ifs) { if (ci.If( )) { ci.Action( ); } else { if (ci.Else != null) { ci.Else( ); } } if (ci.Until != null) { if (ci.Until( )) { iil.Add(ci); } } } foreach (IfInfo ci in iil) { Ifs.Remove(ci); } List <DoInfo> rd = new List <DoInfo> ( ); List <DoInfo> dt = new List <DoInfo> ( ); foreach (DoInfo Do in Dos) { Do.Do( ); if (Do.Until != null) { if (Do.Until( )) { if (Do.Then != null) { dt.Add(Do); } rd.Add(Do); } } } foreach (DoInfo dd in dt) { dd.Then( ); } foreach (DoInfo Do in rd) { Dos.Remove(Do); } List <WhenInfo> rw = new List <WhenInfo> ( ); foreach (WhenInfo w in Whens) { if (w.When( )) { if (w.Unless != null) { if (w.Unless( )) { //rw.Add(w); } else { w.Action( ); rw.Add(w); } } else { w.Action( ); rw.Add(w); } } } foreach (WhenInfo w in rw) { Whens.Remove(w); } if (Flows.Count > 0) { FlowInfo ff = Flows[0]; if (ff.Begun == false) { if (ff.Init != null) { ff.Init( ); } ff.Begun = true; } if (ff.Logic( )) { if (ff.EndLogic != null) { ff.EndLogic( ); } Flows.Remove(ff); } } List <ActInfo> rem = new List <ActInfo>(); int ms = Environment.TickCount; foreach (ActInfo a in Acts) { if (a.NoTime) { a.Action( ); if (a.Until( )) { rem.Add(a); continue; } } if (a.Until != null) { if (ms > (a.When)) { a.Action( ); if (a.Until( )) { rem.Add(a); continue; } } } if (a.Running) { if (ms > (a.When + a.For)) { Console.WriteLine("Done"); rem.Add(a); continue; } } else { if (ms > a.When) { a.Action( ); if (a.Once) { rem.Add(a); } else { a.Running = true; } } } } foreach (ActInfo a in rem) { Acts.Remove(a); } upmut.ReleaseMutex( ); }