Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Scripger
- {
- GameResource m_gameResource;
- List<Script> m_runningScripts = new List<Script>();
- List<Script> m_toAdd = new List<Script>();
- public void run(float dt)
- {
- List<Script> toRemove = new List<Script>();
- foreach (Script s in m_toAdd)
- {
- m_runningScripts.Add(s);
- }
- m_toAdd.Clear();
- foreach (Script s in m_runningScripts)
- {
- if (s.shouldDelete())
- {
- toRemove.Add(s);
- }
- else if (!s.run(dt))
- {
- toRemove.Add(s);
- }
- }
- foreach (Script s in m_toAdd)
- {
- m_runningScripts.Add(s);
- }
- m_toAdd.Clear();
- foreach (Script s in toRemove)
- {
- m_runningScripts.Remove(s);
- }
- }
- public Script queueScript(String scriptName, String caller)
- {
- Script s = new Script(scriptName, m_gameResource, caller);
- m_toAdd.Add(s);
- return s;
- }
- public void clear()
- {
- m_toAdd.Clear();
- m_runningScripts.Clear();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement