Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ICmpObstruction.h
Go to the documentation of this file.
1 /* Copyright (C) 2013 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_ICMPOBSTRUCTION
19 #define INCLUDED_ICMPOBSTRUCTION
20 
22 
24 
25 /**
26  * Flags an entity as obstructing movement for other units,
27  * and handles the processing of collision queries.
28  */
30 {
31 public:
32 
39  };
40 
42 
43  /**
44  * Gets the square corresponding to this obstruction shape.
45  * @return true and updates @p out on success;
46  * false on failure (e.g. object not in the world).
47  */
49 
50  virtual entity_pos_t GetUnitRadius() = 0;
51 
52  virtual bool IsControlPersistent() = 0;
53 
54  /**
55  * Test whether this entity is colliding with any obstruction that are set to
56  * block the creation of foundations.
57  * @param ignoredEntities List of entities to ignore during the test.
58  * @return FOUNDATION_CHECK_SUCCESS if check passes, else an EFoundationCheck
59  * value describing the type of failure.
60  */
61  virtual EFoundationCheck CheckFoundation(std::string className) = 0;
62  virtual EFoundationCheck CheckFoundation(std::string className, bool onlyCenterPoint) = 0;
63 
64  /**
65  * CheckFoundation wrapper for script calls, to return friendly strings instead of an EFoundationCheck.
66  * @return "success" if check passes, else a string describing the type of failure.
67  */
68  virtual std::string CheckFoundation_wrapper(std::string className, bool onlyCenterPoint);
69 
70  /**
71  * Test whether this entity is colliding with any obstructions that share its
72  * control groups and block the creation of foundations.
73  * @return true if foundation is valid (not obstructed)
74  */
75  virtual bool CheckDuplicateFoundation() = 0;
76 
77  /**
78  * Returns a list of entities that are colliding with this entity,
79  * filtered depending on type of entities that are requested.
80  * @return vector of blocking entities
81  */
82  virtual std::vector<entity_id_t> GetEntityCollisions(bool checkStructures, bool checkUnits) = 0;
83 
84  /**
85  * Detects collisions between foundation-blocking entities and
86  * tries to fix them by setting control groups, if appropriate.
87  */
88  virtual void ResolveFoundationCollisions() = 0;
89 
90  virtual void SetActive(bool active) = 0;
91 
92  virtual void SetMovingFlag(bool enabled) = 0;
93 
94  virtual void SetDisableBlockMovementPathfinding(bool movementDisabled, bool pathfindingDisabled, int32_t shape) = 0;
95 
96  virtual bool GetBlockMovementFlag() = 0;
97 
98  /**
99  * Change the control group that the entity belongs to.
100  * Control groups are used to let units ignore collisions with other units from
101  * the same group. Default is the entity's own ID.
102  */
103  virtual void SetControlGroup(entity_id_t group) = 0;
104 
105  /// See SetControlGroup.
106  virtual entity_id_t GetControlGroup() = 0;
107 
108  virtual void SetControlGroup2(entity_id_t group2) = 0;
109  virtual entity_id_t GetControlGroup2() = 0;
110 
111  DECLARE_INTERFACE_TYPE(Obstruction)
112 };
113 
114 #endif // INCLUDED_ICMPOBSTRUCTION
A simple fixed-point number class.
Definition: Fixed.h:115
virtual void SetControlGroup2(entity_id_t group2)=0
static void out(const wchar_t *fmt,...)
Definition: wdbg_sym.cpp:419
virtual bool GetObstructionSquare(ICmpObstructionManager::ObstructionSquare &out)=0
Gets the square corresponding to this obstruction shape.
virtual void ResolveFoundationCollisions()=0
Detects collisions between foundation-blocking entities and tries to fix them by setting control grou...
virtual bool IsControlPersistent()=0
virtual void SetDisableBlockMovementPathfinding(bool movementDisabled, bool pathfindingDisabled, int32_t shape)=0
Flags an entity as obstructing movement for other units, and handles the processing of collision quer...
virtual void SetMovingFlag(bool enabled)=0
virtual entity_id_t GetControlGroup2()=0
#define DECLARE_INTERFACE_TYPE(iname)
Definition: Interface.h:23
virtual std::vector< entity_id_t > GetEntityCollisions(bool checkStructures, bool checkUnits)=0
Returns a list of entities that are colliding with this entity, filtered depending on type of entitie...
virtual void SetActive(bool active)=0
virtual bool CheckDuplicateFoundation()=0
Test whether this entity is colliding with any obstructions that share its control groups and block t...
virtual entity_pos_t GetUnitRadius()=0
virtual bool GetBlockMovementFlag()=0
virtual EFoundationCheck CheckFoundation(std::string className)=0
Test whether this entity is colliding with any obstruction that are set to block the creation of foun...
virtual entity_id_t GetControlGroup()=0
See SetControlGroup.
virtual void SetControlGroup(entity_id_t group)=0
Change the control group that the entity belongs to.
u32 entity_id_t
Entity ID type.
Definition: Entity.h:24
Standard representation for all types of shapes, for use with geometry processing code...
virtual std::string CheckFoundation_wrapper(std::string className, bool onlyCenterPoint)
CheckFoundation wrapper for script calls, to return friendly strings instead of an EFoundationCheck...
virtual ICmpObstructionManager::tag_t GetObstruction()=0
External identifiers for shapes.