Command
CommandQueues
CommandQueues is a referenced type container that stores queues of different command types. Usually one game should only have one CommandQueues instance, which is passed to any system that needs to produce or consume commands.
CommandQueue
CommandQueue is a generic container that stores a queue of commands of a specific type.
How to add a new command
-
create a struct that conforms to
Command. -
create a producer that construct the command and add it to the
commandQueuesviacommandQueues.push(NewCommand(id: CommandId())) -
register that commandQueue into the
CommandQueuesinstance, e.g.commandQueues.register(NewCommand.self) -
update the consume logic in
InputSystemto consume the command, e.g.while commandQueues.pop(NewCommand.self) != nil {
// Consume the command
}