Pyrogenesis  trunk
ICmpObstruction.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_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  /**
51  * Same as the method above, but returns an obstruction shape for the previous turn
52  */
54 
55  virtual entity_pos_t GetSize() const = 0;
56 
57  virtual entity_pos_t GetUnitRadius() const = 0;
58 
59  virtual void SetUnitClearance(const entity_pos_t& clearance) = 0;
60 
61  virtual bool IsControlPersistent() const = 0;
62 
63  /**
64  * Test whether this entity is colliding with any obstruction that are set to
65  * block the creation of foundations.
66  * @param ignoredEntities List of entities to ignore during the test.
67  * @return FOUNDATION_CHECK_SUCCESS if check passes, else an EFoundationCheck
68  * value describing the type of failure.
69  */
70  virtual EFoundationCheck CheckFoundation(const std::string& className) const = 0;
71  virtual EFoundationCheck CheckFoundation(const std::string& className, bool onlyCenterPoint) const = 0;
72 
73  /**
74  * CheckFoundation wrapper for script calls, to return friendly strings instead of an EFoundationCheck.
75  * @return "success" if check passes, else a string describing the type of failure.
76  */
77  virtual std::string CheckFoundation_wrapper(const std::string& className, bool onlyCenterPoint) const;
78 
79  /**
80  * Test whether this entity is colliding with any obstructions that share its
81  * control groups and block the creation of foundations.
82  * @return true if foundation is valid (not obstructed)
83  */
84  virtual bool CheckDuplicateFoundation() const = 0;
85 
86  /**
87  * Returns a list of units that are colliding with this entity,
88  * @return vector of blocking units
89  */
90  virtual std::vector<entity_id_t> GetUnitCollisions() const = 0;
91 
92  /**
93  * Detects collisions between foundation-blocking entities and
94  * tries to fix them by setting control groups, if appropriate.
95  */
96  virtual void ResolveFoundationCollisions() const = 0;
97 
98  virtual void SetActive(bool active) = 0;
99 
100  virtual void SetMovingFlag(bool enabled) = 0;
101 
102  virtual void SetDisableBlockMovementPathfinding(bool movementDisabled, bool pathfindingDisabled, int32_t shape) = 0;
103 
104  virtual bool GetBlockMovementFlag() const = 0;
105 
106  /**
107  * Change the control group that the entity belongs to.
108  * Control groups are used to let units ignore collisions with other units from
109  * the same group. Default is the entity's own ID.
110  */
111  virtual void SetControlGroup(entity_id_t group) = 0;
112 
113  /// See SetControlGroup.
114  virtual entity_id_t GetControlGroup() const = 0;
115 
116  virtual void SetControlGroup2(entity_id_t group2) = 0;
117  virtual entity_id_t GetControlGroup2() const = 0;
118 
119  DECLARE_INTERFACE_TYPE(Obstruction)
120 };
121 
122 #endif // INCLUDED_ICMPOBSTRUCTION
Definition: IComponent.h:33
A simple fixed-point number class.
Definition: Fixed.h:115
virtual void ResolveFoundationCollisions() const =0
Detects collisions between foundation-blocking entities and tries to fix them by setting control grou...
virtual bool GetBlockMovementFlag() const =0
virtual void SetControlGroup2(entity_id_t group2)=0
static void out(const wchar_t *fmt,...)
Definition: wdbg_sym.cpp:419
EFoundationCheck
Definition: ICmpObstruction.h:33
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...
Definition: ICmpObstruction.h:29
virtual void SetMovingFlag(bool enabled)=0
virtual std::string CheckFoundation_wrapper(const std::string &className, bool onlyCenterPoint) const
CheckFoundation wrapper for script calls, to return friendly strings instead of an EFoundationCheck...
Definition: ICmpObstruction.cpp:26
virtual ICmpObstructionManager::tag_t GetObstruction() const =0
virtual entity_pos_t GetUnitRadius() const =0
#define DECLARE_INTERFACE_TYPE(iname)
Definition: Interface.h:23
virtual bool GetPreviousObstructionSquare(ICmpObstructionManager::ObstructionSquare &out) const =0
Same as the method above, but returns an obstruction shape for the previous turn. ...
virtual void SetActive(bool active)=0
Definition: ICmpObstruction.h:34
virtual entity_id_t GetControlGroup2() const =0
virtual entity_id_t GetControlGroup() const =0
See SetControlGroup.
virtual bool GetObstructionSquare(ICmpObstructionManager::ObstructionSquare &out) const =0
Gets the square corresponding to this obstruction shape.
virtual EFoundationCheck CheckFoundation(const std::string &className) const =0
Test whether this entity is colliding with any obstruction that are set to block the creation of foun...
virtual bool CheckDuplicateFoundation() const =0
Test whether this entity is colliding with any obstructions that share its control groups and block t...
Definition: ICmpObstruction.h:35
virtual void SetUnitClearance(const entity_pos_t &clearance)=0
virtual entity_pos_t GetSize() const =0
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:23
virtual bool IsControlPersistent() const =0
Standard representation for all types of shapes, for use with geometry processing code...
Definition: ICmpObstructionManager.h:224
virtual std::vector< entity_id_t > GetUnitCollisions() const =0
Returns a list of units that are colliding with this entity,.
External identifiers for shapes.
Definition: ICmpObstructionManager.h:60