Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ICmpCommandQueue.h
Go to the documentation of this file.
1/* Copyright (C) 2020 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_ICMPCOMMANDQUEUE
19#define INCLUDED_ICMPCOMMANDQUEUE
20
22
24
25#include <vector>
26
27/**
28 * Command queue, for sending orders to entities.
29 * Each command is associated with a player ID (who triggered the command, in some sense)
30 * and an arbitrary script value.
31 *
32 * Commands can be added to the local queue at any time, and will all be executed at the start
33 * of the next turn. (This will typically be used by AI scripts.)
34 *
35 * Alternatively, commands can be sent to the networking system, and they will be executed
36 * at the start of some later turn by all players simultaneously. (This will typically be
37 * used for user inputs.)
38 */
40{
41public:
42 /**
43 * Pushes a new command onto the local queue. @p cmd does not need to be rooted.
44 */
45 virtual void PushLocalCommand(player_id_t player, JS::HandleValue cmd) = 0;
46
47 /**
48 * Send a command associated with the current player to the networking system.
49 */
50 virtual void PostNetworkCommand(JS::HandleValue cmd) = 0;
51
52 /**
53 * Calls the ProcessCommand(player, cmd) global script function for each command in the
54 * local queue and in @p commands, and empties the local queue.
55 */
56 virtual void FlushTurn(const std::vector<SimulationCommand>& commands) = 0;
57
58 DECLARE_INTERFACE_TYPE(CommandQueue)
59};
60
61#endif // INCLUDED_ICMPCOMMANDQUEUE
#define DECLARE_INTERFACE_TYPE(iname)
Definition: Interface.h:23
int32_t player_id_t
valid player IDs are non-negative (see ICmpOwnership)
Definition: Player.h:24
Command queue, for sending orders to entities.
Definition: ICmpCommandQueue.h:40
virtual void FlushTurn(const std::vector< SimulationCommand > &commands)=0
Calls the ProcessCommand(player, cmd) global script function for each command in the local queue and ...
virtual void PushLocalCommand(player_id_t player, JS::HandleValue cmd)=0
Pushes a new command onto the local queue.
virtual void PostNetworkCommand(JS::HandleValue cmd)=0
Send a command associated with the current player to the networking system.
Definition: IComponent.h:33