public void UpdateCommandQueue()
{
bool imm = true;
while (imm)
{
if (_commandQueue.Count == 0)
break;
PersonCommand c = _commandQueue.Dequeue();
Commands command = (Commands)c.command;
imm = c.immediate;
if (c.script != null) {
PersonManager.CurrentPerson = Name;
c.script.Execute();
continue;
}
bool update = ((command == Commands.Animate || (int)command > 9) && !imm);
Vector2f move = new Vector2f();
switch (command)
{
case Commands.FaceNorth:
Direction = "north";
break;
case Commands.FaceEast:
Direction = "east";
break;
case Commands.FaceSouth:
Direction = "south";
break;
case Commands.FaceWest:
Direction = "west";
break;
case Commands.MoveNorth:
move.Y = -Speed.Y;
break;
case Commands.MoveEast:
move.X = Speed.X;
break;
case Commands.MoveSouth:
move.Y = Speed.Y;
break;
case Commands.MoveWest:
move.X = -Speed.X;
break;
}
Position += move;
if (IsObstructedAt(Position))
{
Position -= move;
}
_revert = 0;
_toNextDelay += (update ? 1 : 0);
if (_toNextDelay >= _delay)
{
Frame = Frame + 1;
_toNextDelay = 0;
}
}
if (FrameRevert > 0) {
_revert++;
if (_revert >= FrameRevert) {
Frame = 0;
_revert = 0;
}
}
}