Pyrogenesis  trunk
Selection.h
Go to the documentation of this file.
1 /* Copyright (C) 2017 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_SELECTION
19 #define INCLUDED_SELECTION
20 
21 /**
22  * @file
23  * Helper functions related to entity selection
24  */
25 
27 #include "Player.h"
28 
29 #include <vector>
30 
31 class CSimulation2;
32 class CCamera;
33 
34 namespace EntitySelection
35 {
36 
37 /**
38  * Finds all selectable entities under the given screen coordinates.
39  *
40  * @param camera use this view to convert screen to world coordinates.
41  * @param screenX,screenY 2D screen coordinates.
42  * @param player player whose LOS will be used when selecting entities. In Atlas
43  * this value is ignored as the whole map is revealed.
44  * @param allowEditorSelectables if true, all entities with the ICmpSelectable interface
45  * will be selected (including decorative actors), else only those selectable ingame.
46  * @param range Approximate range to check for entity in.
47  *
48  * @return ordered list of selected entities with the closest first.
49  */
50 entity_id_t PickEntityAtPoint(CSimulation2& simulation, const CCamera& camera, int screenX, int screenY, player_id_t player, bool allowEditorSelectables);
51 
52 /**
53  * Finds all selectable entities within the given screen coordinate rectangle,
54  * belonging to the given player. Used for bandboxing.
55  *
56  * @param camera use this view to convert screen to world coordinates.
57  * @param sx0,sy0,sx1,sy1 diagonally opposite corners of the rectangle in 2D screen coordinates.
58  * @param owner player whose entities we are selecting. Ownership is ignored if
59  * INVALID_PLAYER is used.
60  * @param allowEditorSelectables if true, all entities with the ICmpSelectable interface
61  * will be selected (including decorative actors), else only those selectable ingame.
62  *
63  * @return unordered list of selected entities.
64  */
65 std::vector<entity_id_t> PickEntitiesInRect(CSimulation2& simulation, const CCamera& camera, int sx0, int sy0, int sx1, int sy1, player_id_t owner, bool allowEditorSelectables);
66 
67 /**
68  * Finds all selectable entities within the given screen coordinate rectangle,
69  * belonging to any given player (excluding Gaia). Used for status bars.
70  */
71 std::vector<entity_id_t> PickNonGaiaEntitiesInRect(CSimulation2& simulation, const CCamera& camera, int sx0, int sy0, int sx1, int sy1, bool allowEditorSelectables);
72 
73 /**
74  * Finds all entities with the given entity template name, belonging to the given player.
75  *
76  * @param camera use this view to convert screen to world coordinates.
77  * @param templateName the name of the template to match, or the selection group name
78  * for similar matching.
79  * @param owner player whose entities we are selecting. Ownership is ignored if
80  * INVALID_PLAYER is used.
81  * @param includeOffScreen if true, then all entities visible in the world will be selected,
82  * else only entities visible to the camera will be selected.
83  * @param matchRank if true, only entities that exactly match templateName will be selected,
84  * else entities with matching SelectionGroupName will be selected.
85  * @param allowEditorSelectables if true, all entities with the ICmpSelectable interface
86  * will be selected (including decorative actors), else only those selectable in-game.
87  * @param allowFoundations if true, foundations are also included in the results. Only takes
88  * effect when matchRank = true.
89  *
90  * @return unordered list of selected entities.
91  * @see ICmpIdentity
92  */
93 std::vector<entity_id_t> PickSimilarEntities(CSimulation2& simulation, const CCamera& camera, const std::string& templateName,
94  player_id_t owner, bool includeOffScreen, bool matchRank, bool allowEditorSelectables, bool allowFoundations);
95 
96 } // namespace
97 
98 #endif // INCLUDED_SELECTION
std::vector< entity_id_t > PickSimilarEntities(CSimulation2 &simulation, const CCamera &camera, const std::string &templateName, player_id_t owner, bool includeOffScreen, bool matchRank, bool allowEditorSelectables, bool allowFoundations)
Finds all entities with the given entity template name, belonging to the given player.
Definition: Selection.cpp:196
entity_id_t PickEntityAtPoint(CSimulation2 &simulation, const CCamera &camera, int screenX, int screenY, player_id_t player, bool allowEditorSelectables)
Finds all selectable entities under the given screen coordinates.
Definition: Selection.cpp:35
std::vector< entity_id_t > PickNonGaiaEntitiesInRect(CSimulation2 &simulation, const CCamera &camera, int sx0, int sy0, int sx1, int sy1, bool allowEditorSelectables)
Finds all selectable entities within the given screen coordinate rectangle, belonging to any given pl...
Definition: Selection.cpp:173
Public API for simulation system.
Definition: Simulation2.h:47
int32_t player_id_t
valid player IDs are non-negative (see ICmpOwnership)
Definition: Player.h:24
Definition: Camera.h:39
u32 entity_id_t
Entity ID type.
Definition: Entity.h:23
Definition: Selection.h:34
std::vector< entity_id_t > PickEntitiesInRect(CSimulation2 &simulation, const CCamera &camera, int sx0, int sy0, int sx1, int sy1, player_id_t owner, bool allowEditorSelectables)
Finds all selectable entities within the given screen coordinate rectangle, belonging to the given pl...
Definition: Selection.cpp:136