Advertisement
Guest User

Untitled

a guest
Feb 7th, 2011
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. class ScriptManager
  2.     {
  3.         GameResource m_gameResource;
  4.         List<Script> m_runningScripts = new List<Script>();
  5.         List<Script> m_toAdd = new List<Script>();      
  6.         public void run(float dt)
  7.         {
  8.             List<Script> toRemove = new List<Script>();
  9.             foreach (Script s in m_toAdd)
  10.             {
  11.                 m_runningScripts.Add(s);
  12.             }
  13.             m_toAdd.Clear();
  14.             foreach (Script s in m_runningScripts)
  15.             {
  16.                 if (s.shouldDelete())
  17.                 {
  18.                     toRemove.Add(s);
  19.                 }
  20.                 else if (!s.run(dt))
  21.                 {
  22.                     toRemove.Add(s);
  23.                 }
  24.             }
  25.             foreach (Script s in m_toAdd)
  26.             {
  27.                 m_runningScripts.Add(s);
  28.             }
  29.             m_toAdd.Clear();
  30.             foreach (Script s in toRemove)
  31.             {
  32.                 m_runningScripts.Remove(s);
  33.             }
  34.  
  35.         }        
  36.         public Script queueScript(String scriptName, String caller)
  37.         {
  38.             Script s = new Script(scriptName, m_gameResource, caller);
  39.             m_toAdd.Add(s);
  40.             return s;
  41.         }
  42.         public void clear()
  43.         {
  44.             m_toAdd.Clear();
  45.             m_runningScripts.Clear();
  46.         }
  47.        
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement