Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ICmpCommandQueue.h
Go to the documentation of this file.
1/* Copyright (C) 2025 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
24
25#include <js/TypeDecls.h>
26#include <js/Value.h>
27#include <vector>
28
30
31/**
32 * Command queue, for sending orders to entities.
33 * Each command is associated with a player ID (who triggered the command, in some sense)
34 * and an arbitrary script value.
35 *
36 * Commands can be added to the local queue at any time, and will all be executed at the start
37 * of the next turn. (This will typically be used by AI scripts.)
38 *
39 * Alternatively, commands can be sent to the networking system, and they will be executed
40 * at the start of some later turn by all players simultaneously. (This will typically be
41 * used for user inputs.)
42 */
44{
45public:
46 /**
47 * Pushes a new command onto the local queue. @p cmd does not need to be rooted.
48 */
49 virtual void PushLocalCommand(player_id_t player, JS::HandleValue cmd) = 0;
50
51 /**
52 * Send a command associated with the current player to the networking system.
53 */
54 virtual void PostNetworkCommand(JS::HandleValue cmd) = 0;
55
56 /**
57 * Calls the ProcessCommand(player, cmd) global script function for each command in the
58 * local queue and in @p commands, and empties the local queue.
59 */
60 virtual void FlushTurn(const std::vector<SimulationCommand>& commands) = 0;
61
62 DECLARE_INTERFACE_TYPE(CommandQueue)
63};
64
65#endif // INCLUDED_ICMPCOMMANDQUEUE
int32_t player_id_t
valid player IDs are non-negative (see ICmpOwnership)
Definition: Player.h:26
Command queue, for sending orders to entities.
Definition: ICmpCommandQueue.h:44
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
#define DECLARE_INTERFACE_TYPE(iname)
Definition: Interface.h:23
Simulation command, typically received over the network in multiplayer games.
Definition: SimulationCommand.h:39