2015-07-18 01:37:49 -07:00
|
|
|
/* Copyright (C) 2015 Wildfire Games.
|
2010-01-09 11:20:14 -08:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef INCLUDED_ICMPUNITMOTION
|
|
|
|
|
#define INCLUDED_ICMPUNITMOTION
|
|
|
|
|
|
|
|
|
|
#include "simulation2/system/Interface.h"
|
|
|
|
|
|
2011-08-06 01:11:05 -07:00
|
|
|
#include "simulation2/components/ICmpPathfinder.h" // for pass_class_t
|
|
|
|
|
#include "simulation2/components/ICmpPosition.h" // for entity_pos_t
|
2010-01-09 11:20:14 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Motion interface for entities with complex movement capabilities.
|
|
|
|
|
* (Simpler motion is handled by ICmpMotion instead.)
|
|
|
|
|
*
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 11:58:24 -07:00
|
|
|
* It should eventually support different movement speeds, moving to areas
|
2010-01-09 11:20:14 -08:00
|
|
|
* instead of points, moving as part of a group, moving as part of a formation,
|
|
|
|
|
* etc.
|
|
|
|
|
*/
|
|
|
|
|
class ICmpUnitMotion : public IComponent
|
|
|
|
|
{
|
|
|
|
|
public:
|
2010-11-30 04:31:54 -08:00
|
|
|
|
2010-04-29 16:36:05 -07:00
|
|
|
/**
|
2010-11-30 04:31:54 -08:00
|
|
|
* Attempt to walk into range of a to a given point, or as close as possible.
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 11:58:24 -07:00
|
|
|
* The range is measured from the center of the unit.
|
2010-12-08 08:12:04 -08:00
|
|
|
* If the unit is already in range, or cannot move anywhere at all, or if there is
|
|
|
|
|
* some other error, then returns false.
|
2010-11-30 04:31:54 -08:00
|
|
|
* Otherwise, returns true and sends a MotionChanged message after starting to move,
|
|
|
|
|
* and sends another MotionChanged after finishing moving.
|
2011-03-04 06:36:41 -08:00
|
|
|
* If maxRange is negative, then the maximum range is treated as infinity.
|
2010-04-29 16:36:05 -07:00
|
|
|
*/
|
2010-11-30 04:31:54 -08:00
|
|
|
virtual bool MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange) = 0;
|
2010-01-09 11:20:14 -08:00
|
|
|
|
2012-12-02 09:25:23 -08:00
|
|
|
/**
|
|
|
|
|
* Determine wether the givven point is within the given range, using the same measurement
|
|
|
|
|
* as MoveToPointRange.
|
|
|
|
|
*/
|
|
|
|
|
virtual bool IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange) = 0;
|
|
|
|
|
|
2010-04-29 16:36:05 -07:00
|
|
|
/**
|
|
|
|
|
* Determine whether the target is within the given range, using the same measurement
|
2010-11-30 04:31:54 -08:00
|
|
|
* as MoveToTargetRange.
|
2010-04-29 16:36:05 -07:00
|
|
|
*/
|
2010-11-30 04:31:54 -08:00
|
|
|
virtual bool IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) = 0;
|
2010-04-29 16:36:05 -07:00
|
|
|
|
|
|
|
|
/**
|
2010-07-18 08:19:49 -07:00
|
|
|
* Attempt to walk into range of a given target entity, or as close as possible.
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 11:58:24 -07:00
|
|
|
* The range is measured between approximately the edges of the unit and the target, so that
|
|
|
|
|
* maxRange=0 is not unreachably close to the target.
|
2010-04-29 16:36:05 -07:00
|
|
|
* If the unit is already in range, or cannot move anywhere at all, or if there is
|
|
|
|
|
* some other error, then returns false.
|
2010-11-30 04:31:54 -08:00
|
|
|
* Otherwise, returns true and sends a MotionChanged message after starting to move,
|
|
|
|
|
* and sends another MotionChanged after finishing moving.
|
2011-03-04 06:36:41 -08:00
|
|
|
* If maxRange is negative, then the maximum range is treated as infinity.
|
2010-07-18 08:19:49 -07:00
|
|
|
*/
|
2010-11-30 04:31:54 -08:00
|
|
|
virtual bool MoveToTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) = 0;
|
2010-07-18 08:19:49 -07:00
|
|
|
|
2010-09-03 02:55:14 -07:00
|
|
|
/**
|
|
|
|
|
* Join a formation, and move towards a given offset relative to the formation controller entity.
|
|
|
|
|
* Continues following the formation until given a different command.
|
|
|
|
|
*/
|
|
|
|
|
virtual void MoveToFormationOffset(entity_id_t target, entity_pos_t x, entity_pos_t z) = 0;
|
|
|
|
|
|
2011-06-09 12:44:40 -07:00
|
|
|
/**
|
|
|
|
|
* Turn to look towards the given point.
|
|
|
|
|
*/
|
|
|
|
|
virtual void FaceTowardsPoint(entity_pos_t x, entity_pos_t z) = 0;
|
|
|
|
|
|
2010-07-18 08:19:49 -07:00
|
|
|
/**
|
|
|
|
|
* Stop moving immediately.
|
|
|
|
|
*/
|
|
|
|
|
virtual void StopMoving() = 0;
|
|
|
|
|
|
2012-12-06 11:46:13 -08:00
|
|
|
/**
|
|
|
|
|
* Get the current movement speed.
|
|
|
|
|
*/
|
|
|
|
|
virtual fixed GetCurrentSpeed() = 0;
|
|
|
|
|
|
2010-07-18 08:19:49 -07:00
|
|
|
/**
|
2010-07-20 01:45:09 -07:00
|
|
|
* Set the current movement speed.
|
2010-07-18 08:19:49 -07:00
|
|
|
*/
|
2010-07-20 01:45:09 -07:00
|
|
|
virtual void SetSpeed(fixed speed) = 0;
|
2010-07-18 08:19:49 -07:00
|
|
|
|
2012-08-31 01:20:36 -07:00
|
|
|
/**
|
|
|
|
|
* Get whether the unit is moving.
|
|
|
|
|
*/
|
|
|
|
|
virtual bool IsMoving() = 0;
|
|
|
|
|
|
2010-04-29 16:36:05 -07:00
|
|
|
/**
|
2010-05-02 13:32:37 -07:00
|
|
|
* Get the default speed that this unit will have when walking, in metres per second.
|
2010-04-29 16:36:05 -07:00
|
|
|
*/
|
2010-07-18 08:19:49 -07:00
|
|
|
virtual fixed GetWalkSpeed() = 0;
|
2010-02-07 12:06:16 -08:00
|
|
|
|
2010-06-04 17:49:14 -07:00
|
|
|
/**
|
|
|
|
|
* Get the default speed that this unit will have when running, in metres per second.
|
|
|
|
|
*/
|
|
|
|
|
virtual fixed GetRunSpeed() = 0;
|
|
|
|
|
|
2013-09-30 16:52:22 -07:00
|
|
|
/**
|
|
|
|
|
* Set whether the unit will turn to face the target point after finishing moving.
|
|
|
|
|
*/
|
|
|
|
|
virtual void SetFacePointAfterMove(bool facePointAfterMove) = 0;
|
|
|
|
|
|
2011-08-06 01:11:05 -07:00
|
|
|
/**
|
|
|
|
|
* Get the unit's passability class.
|
|
|
|
|
*/
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 11:58:24 -07:00
|
|
|
virtual pass_class_t GetPassabilityClass() = 0;
|
2011-08-06 01:11:05 -07:00
|
|
|
|
2014-05-18 00:59:43 -07:00
|
|
|
/**
|
|
|
|
|
* Get the passability class name (as defined in pathfinder.xml)
|
|
|
|
|
*/
|
|
|
|
|
virtual std::string GetPassabilityClassName() = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the passability class
|
|
|
|
|
*/
|
|
|
|
|
virtual void SetPassabilityClassName(std::string passClassName) = 0;
|
|
|
|
|
|
2010-09-03 02:55:14 -07:00
|
|
|
/**
|
2015-07-18 01:37:49 -07:00
|
|
|
* Get the unit clearance (used by the Obstruction component)
|
2010-09-03 02:55:14 -07:00
|
|
|
*/
|
2015-07-18 01:37:49 -07:00
|
|
|
virtual entity_pos_t GetUnitClearance() = 0;
|
2010-09-03 02:55:14 -07:00
|
|
|
|
2010-04-29 16:36:05 -07:00
|
|
|
/**
|
|
|
|
|
* Toggle the rendering of debug info.
|
|
|
|
|
*/
|
|
|
|
|
virtual void SetDebugOverlay(bool enabled) = 0;
|
|
|
|
|
|
2010-01-09 11:20:14 -08:00
|
|
|
DECLARE_INTERFACE_TYPE(UnitMotion)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // INCLUDED_ICMPUNITMOTION
|