public void InterpretMessage(string message, Character.Iactor actor) { Character.NPC npc = actor as Character.NPC; MessageParser parser = new MessageParser(message, actor, npc.Triggers); parser.FindTrigger(); //Here's the rub. This call is a sequential call up to this point, maybe we want to //kick off a separate thread so that then it won't hold up the players actions and //then we can even execute states that operate on a delay. if (parser.TriggerToExecute != null) { IState state = GetStateFromName(parser.TriggerToExecute.StateToExecute); if (state != null) { ChangeState(state, npc); npc.NextAiAction = DateTime.Now.ToUniversalTime().AddSeconds(-1); //this state will execute next now state.Execute(npc, parser.TriggerToExecute); } } }
public void InterpretMessage(IMessage message, IActor actor) { NPC npc = actor as NPC; List<ITrigger> triggers = new List<ITrigger>(); npc.Triggers.ForEach((t) => triggers.Add(t)); MessageParser parser = new MessageParser(message, actor, triggers); parser.FindTrigger(); //Here's the rub. This call is a sequential call up to this point, maybe we want to //kick off a separate thread so that then it won't hold up the players actions and //then we can even execute states that operate on a delay. if (parser.TriggersToExecute.Count > 0) { foreach (ITrigger trigger in parser.TriggersToExecute) { IState state = GetStateFromName(trigger.StateToExecute); if (state != null) { ChangeState(state, npc); npc.NextAiAction = DateTime.Now.ToUniversalTime().AddSeconds(-1); //this state will execute next now state.Execute(npc, trigger); } } } }