Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ICmpUnitMotion.h
Go to the documentation of this file.
1 /* Copyright (C) 2011 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_ICMPUNITMOTION
19 #define INCLUDED_ICMPUNITMOTION
20 
22 
23 #include "simulation2/components/ICmpPathfinder.h" // for pass_class_t
24 #include "simulation2/components/ICmpPosition.h" // for entity_pos_t
25 
26 /**
27  * Motion interface for entities with complex movement capabilities.
28  * (Simpler motion is handled by ICmpMotion instead.)
29  *
30  * Currently this is limited to telling the entity to walk to a point.
31  * Eventually it should support different movement speeds, moving to areas
32  * instead of points, moving as part of a group, moving as part of a formation,
33  * etc.
34  */
35 class ICmpUnitMotion : public IComponent
36 {
37 public:
38 
39  /**
40  * Attempt to walk into range of a to a given point, or as close as possible.
41  * If the unit is already in range, or cannot move anywhere at all, or if there is
42  * some other error, then returns false.
43  * Otherwise, returns true and sends a MotionChanged message after starting to move,
44  * and sends another MotionChanged after finishing moving.
45  * If maxRange is negative, then the maximum range is treated as infinity.
46  */
47  virtual bool MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange) = 0;
48 
49  /**
50  * Determine wether the givven point is within the given range, using the same measurement
51  * as MoveToPointRange.
52  */
53  virtual bool IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange) = 0;
54 
55  /**
56  * Determine whether the target is within the given range, using the same measurement
57  * as MoveToTargetRange.
58  */
59  virtual bool IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) = 0;
60 
61  /**
62  * Attempt to walk into range of a given target entity, or as close as possible.
63  * If the unit is already in range, or cannot move anywhere at all, or if there is
64  * some other error, then returns false.
65  * Otherwise, returns true and sends a MotionChanged message after starting to move,
66  * and sends another MotionChanged after finishing moving.
67  * If maxRange is negative, then the maximum range is treated as infinity.
68  */
69  virtual bool MoveToTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) = 0;
70 
71  /**
72  * Join a formation, and move towards a given offset relative to the formation controller entity.
73  * Continues following the formation until given a different command.
74  */
75  virtual void MoveToFormationOffset(entity_id_t target, entity_pos_t x, entity_pos_t z) = 0;
76 
77  /**
78  * Turn to look towards the given point.
79  */
80  virtual void FaceTowardsPoint(entity_pos_t x, entity_pos_t z) = 0;
81 
82  /**
83  * Stop moving immediately.
84  */
85  virtual void StopMoving() = 0;
86 
87  /**
88  * Get the current movement speed.
89  */
90  virtual fixed GetCurrentSpeed() = 0;
91 
92  /**
93  * Set the current movement speed.
94  */
95  virtual void SetSpeed(fixed speed) = 0;
96 
97  /**
98  * Get whether the unit is moving.
99  */
100  virtual bool IsMoving() = 0;
101 
102  /**
103  * Get the default speed that this unit will have when walking, in metres per second.
104  */
105  virtual fixed GetWalkSpeed() = 0;
106 
107  /**
108  * Get the default speed that this unit will have when running, in metres per second.
109  */
110  virtual fixed GetRunSpeed() = 0;
111 
112  /**
113  * Set whether the unit will turn to face the target point after finishing moving.
114  */
115  virtual void SetFacePointAfterMove(bool facePointAfterMove) = 0;
116 
117  /**
118  * Get the unit's passability class.
119  */
121 
122  /**
123  * Override the default obstruction radius, used for planning paths and checking for collisions.
124  * Bad things may happen if this entity has an active Obstruction component with a larger
125  * radius. (This is intended primarily for formation controllers.)
126  */
127  virtual void SetUnitRadius(fixed radius) = 0;
128 
129  /**
130  * Toggle the rendering of debug info.
131  */
132  virtual void SetDebugOverlay(bool enabled) = 0;
133 
134  DECLARE_INTERFACE_TYPE(UnitMotion)
135 };
136 
137 #endif // INCLUDED_ICMPUNITMOTION
A simple fixed-point number class.
Definition: Fixed.h:115
virtual void StopMoving()=0
Stop moving immediately.
virtual bool MoveToTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)=0
Attempt to walk into range of a given target entity, or as close as possible.
virtual void SetFacePointAfterMove(bool facePointAfterMove)=0
Set whether the unit will turn to face the target point after finishing moving.
virtual fixed GetRunSpeed()=0
Get the default speed that this unit will have when running, in metres per second.
virtual bool MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange)=0
Attempt to walk into range of a to a given point, or as close as possible.
virtual bool IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)=0
Determine whether the target is within the given range, using the same measurement as MoveToTargetRan...
Motion interface for entities with complex movement capabilities.
virtual void MoveToFormationOffset(entity_id_t target, entity_pos_t x, entity_pos_t z)=0
Join a formation, and move towards a given offset relative to the formation controller entity...
virtual void SetUnitRadius(fixed radius)=0
Override the default obstruction radius, used for planning paths and checking for collisions...
virtual void SetSpeed(fixed speed)=0
Set the current movement speed.
virtual fixed GetWalkSpeed()=0
Get the default speed that this unit will have when walking, in metres per second.
#define DECLARE_INTERFACE_TYPE(iname)
Definition: Interface.h:23
virtual void SetDebugOverlay(bool enabled)=0
Toggle the rendering of debug info.
virtual ICmpPathfinder::pass_class_t GetPassabilityClass()=0
Get the unit&#39;s passability class.
virtual bool IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange)=0
Determine wether the givven point is within the given range, using the same measurement as MoveToPoin...
virtual fixed GetCurrentSpeed()=0
Get the current movement speed.
virtual bool IsMoving()=0
Get whether the unit is moving.
virtual void FaceTowardsPoint(entity_pos_t x, entity_pos_t z)=0
Turn to look towards the given point.
u32 entity_id_t
Entity ID type.
Definition: Entity.h:24