2019-04-19 03:04:50 -07:00
|
|
|
/* Copyright (C) 2019 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.
|
2019-05-28 04:38:18 -07:00
|
|
|
* If cannot move anywhere at all, or if there is some other error, then returns false.
|
|
|
|
|
* Otherwise, returns true.
|
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
|
|
|
|
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.
|
2019-05-28 04:38:18 -07:00
|
|
|
* If the unit cannot move anywhere at all, or if there is some other error, then returns false.
|
|
|
|
|
* Otherwise, returns true.
|
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
|
|
|
/**
|
2019-05-13 09:47:51 -07:00
|
|
|
* Get the distance travelled over the last turn.
|
2012-12-06 11:46:13 -08:00
|
|
|
*/
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual fixed GetCurrentSpeed() const = 0;
|
2012-12-06 11:46:13 -08:00
|
|
|
|
2010-07-18 08:19:49 -07:00
|
|
|
/**
|
2019-06-09 10:04:18 -07:00
|
|
|
* @returns true if the unit has a destination.
|
2010-07-18 08:19:49 -07:00
|
|
|
*/
|
2019-07-28 03:51:12 -07:00
|
|
|
virtual bool IsMoveRequested() const = 0;
|
2010-07-18 08:19:49 -07:00
|
|
|
|
2012-08-31 01:20:36 -07:00
|
|
|
/**
|
2019-05-13 09:47:51 -07:00
|
|
|
* Get the unit template walk speed after modifications.
|
2012-08-31 01:20:36 -07:00
|
|
|
*/
|
2019-05-13 09:47:51 -07:00
|
|
|
virtual fixed GetWalkSpeed() const = 0;
|
2012-08-31 01:20:36 -07:00
|
|
|
|
2010-04-29 16:36:05 -07:00
|
|
|
/**
|
2019-05-13 09:47:51 -07:00
|
|
|
* Get the unit template running (i.e. max) speed after modifications.
|
2010-04-29 16:36:05 -07:00
|
|
|
*/
|
2019-05-13 09:47:51 -07:00
|
|
|
virtual fixed GetRunMultiplier() const = 0;
|
2010-02-07 12:06:16 -08:00
|
|
|
|
2010-06-04 17:49:14 -07:00
|
|
|
/**
|
2019-05-13 09:47:51 -07:00
|
|
|
* Returns the ratio of GetSpeed() / GetWalkSpeed().
|
2010-06-04 17:49:14 -07:00
|
|
|
*/
|
2019-05-13 09:47:51 -07:00
|
|
|
virtual fixed GetSpeedMultiplier() const = 0;
|
2010-06-04 17:49:14 -07:00
|
|
|
|
2019-04-19 03:04:50 -07:00
|
|
|
/**
|
2019-05-13 09:47:51 -07:00
|
|
|
* Set the current movement speed.
|
|
|
|
|
* @param speed A multiplier of GetWalkSpeed().
|
2019-04-19 03:04:50 -07:00
|
|
|
*/
|
2019-05-13 09:47:51 -07:00
|
|
|
virtual void SetSpeedMultiplier(fixed multiplier) = 0;
|
2019-04-19 03:04:50 -07:00
|
|
|
|
|
|
|
|
/**
|
2019-05-13 09:47:51 -07:00
|
|
|
* Get the speed at which the unit intends to move.
|
|
|
|
|
* (regardless of whether the unit is moving or not right now).
|
2019-04-19 03:04:50 -07:00
|
|
|
*/
|
2019-05-13 09:47:51 -07:00
|
|
|
virtual fixed GetSpeed() const = 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.
|
|
|
|
|
*/
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual pass_class_t GetPassabilityClass() const = 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)
|
|
|
|
|
*/
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual std::string GetPassabilityClassName() const = 0;
|
2014-05-18 00:59:43 -07:00
|
|
|
|
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
|
|
|
*/
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual entity_pos_t GetUnitClearance() const = 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
|