Game Development Reference
In-Depth Information
The command queue
The structure that holds all the commands issued from the agent is called the command
queue. Typically, this structure acts as a First In First Out ( FIFO ) data structure, which is
also known as a queue. The agent is able to communicate with the controller by queuing
commands or by issuing an immediate command that the controller prioritizes:
SoldierController.lua :
function SoldierController.QueueCommand(self, agent, command)
-- Add the new command to the back of the queue.
table.insert(self.commands, command);
end
function SoldierController.ClearCommands(self, agent)
self.commands = {};
end
function SoldierController.CurrentCommand(self)
return self.executingCommand;
end
function SoldierController.ImmediateCommand(
self, agent, command)
-- Adds the command to the beginning of the queue.
table.insert(self.commands, 1, command);
end
Search WWH ::




Custom Search