- Home /
Question by
Megaboy · Jan 22, 2015 at 10:03 AM ·
fixedupdatesequence
Approach to the command sequence execution
Perhaps the title of this topic is quite intricate. Let me explain. I have a list of commands like: "move forward 10 m turn left 20 degree" The idea is to perform them in a right order by script in a FixedUpdate() section. I guess it makes sense to use some pattern or approach without reinventing the wheel but I can't find one. I would be glad of any help, please forward me on the way.
Comment
Best Answer
Answer by cdrandin · Jan 22, 2015 at 10:10 AM
Well you would need to be able to create a system that is familiar with the language. Then knowing the language decipher what tasks are needed and in what order they were received. Then you will have a list of actions that need to be performed and just Invoke each one as you go along the list.
General idea:
public static class EventManager
{
public static current_task_completed;
public static List<System.Action> actions;
}
// Assume all stuff init... and actions have already been recorded
// Reminder this is sudo code stuff
IENumerator PerformActions()
{
foreach(System.Action a in EventManager.actions)
{
a.Invoke();
while(true)
{
if(isDone(a)) break;
yield return null;
}
}
}