2019-09-20 00:45:55 -07:00
|
|
|
/* Copyright (C) 2019 Wildfire Games.
|
2010-01-29 13:13:18 -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_ICMPOBSTRUCTION
|
|
|
|
|
#define INCLUDED_ICMPOBSTRUCTION
|
|
|
|
|
|
|
|
|
|
#include "simulation2/system/Interface.h"
|
|
|
|
|
|
2010-04-29 16:36:05 -07:00
|
|
|
#include "simulation2/components/ICmpObstructionManager.h"
|
2010-01-29 13:13:18 -08:00
|
|
|
|
|
|
|
|
/**
|
2010-03-17 16:01:12 -07:00
|
|
|
* Flags an entity as obstructing movement for other units,
|
|
|
|
|
* and handles the processing of collision queries.
|
2010-01-29 13:13:18 -08:00
|
|
|
*/
|
|
|
|
|
class ICmpObstruction : public IComponent
|
|
|
|
|
{
|
|
|
|
|
public:
|
2010-04-29 16:36:05 -07:00
|
|
|
|
2013-02-23 16:12:41 -08:00
|
|
|
enum EFoundationCheck {
|
|
|
|
|
FOUNDATION_CHECK_SUCCESS,
|
|
|
|
|
FOUNDATION_CHECK_FAIL_ERROR,
|
|
|
|
|
FOUNDATION_CHECK_FAIL_NO_OBSTRUCTION,
|
|
|
|
|
FOUNDATION_CHECK_FAIL_OBSTRUCTS_FOUNDATION,
|
|
|
|
|
FOUNDATION_CHECK_FAIL_TERRAIN_CLASS
|
|
|
|
|
};
|
|
|
|
|
|
2019-09-20 00:45:55 -07:00
|
|
|
enum EObstructionType {
|
|
|
|
|
STATIC,
|
|
|
|
|
UNIT,
|
|
|
|
|
CLUSTER
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual ICmpObstructionManager::tag_t GetObstruction() const = 0;
|
2010-04-29 16:36:05 -07:00
|
|
|
|
2011-07-20 12:48:06 -07:00
|
|
|
/**
|
|
|
|
|
* Gets the square corresponding to this obstruction shape.
|
|
|
|
|
* @return true and updates @p out on success;
|
|
|
|
|
* false on failure (e.g. object not in the world).
|
|
|
|
|
*/
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual bool GetObstructionSquare(ICmpObstructionManager::ObstructionSquare& out) const = 0;
|
2011-02-10 08:06:28 -08:00
|
|
|
|
2013-12-30 08:07:19 -08:00
|
|
|
/**
|
|
|
|
|
* Same as the method above, but returns an obstruction shape for the previous turn
|
|
|
|
|
*/
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual bool GetPreviousObstructionSquare(ICmpObstructionManager::ObstructionSquare& out) const = 0;
|
2013-12-30 08:07:19 -08:00
|
|
|
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual entity_pos_t GetSize() const = 0;
|
2015-04-14 14:33:43 -07:00
|
|
|
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual entity_pos_t GetUnitRadius() const = 0;
|
2010-04-29 16:36:05 -07:00
|
|
|
|
2019-09-20 00:45:55 -07:00
|
|
|
virtual EObstructionType GetObstructionType() const = 0;
|
|
|
|
|
|
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 void SetUnitClearance(const entity_pos_t& clearance) = 0;
|
|
|
|
|
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual bool IsControlPersistent() const = 0;
|
2012-08-01 14:38:13 -07:00
|
|
|
|
2018-01-21 18:34:46 -08:00
|
|
|
/**
|
|
|
|
|
* Test whether the front of the obstruction square is in the water and the back is on the shore.
|
|
|
|
|
*/
|
|
|
|
|
virtual bool CheckShorePlacement() const = 0;
|
|
|
|
|
|
2010-03-17 16:01:12 -07:00
|
|
|
/**
|
2011-02-10 08:06:28 -08:00
|
|
|
* Test whether this entity is colliding with any obstruction that are set to
|
|
|
|
|
* block the creation of foundations.
|
2012-05-05 12:22:22 -07:00
|
|
|
* @param ignoredEntities List of entities to ignore during the test.
|
2013-02-23 16:12:41 -08:00
|
|
|
* @return FOUNDATION_CHECK_SUCCESS if check passes, else an EFoundationCheck
|
|
|
|
|
* value describing the type of failure.
|
|
|
|
|
*/
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual EFoundationCheck CheckFoundation(const std::string& className) const = 0;
|
|
|
|
|
virtual EFoundationCheck CheckFoundation(const std::string& className, bool onlyCenterPoint) const = 0;
|
2013-02-23 16:12:41 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* CheckFoundation wrapper for script calls, to return friendly strings instead of an EFoundationCheck.
|
|
|
|
|
* @return "success" if check passes, else a string describing the type of failure.
|
2011-02-10 08:06:28 -08:00
|
|
|
*/
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual std::string CheckFoundation_wrapper(const std::string& className, bool onlyCenterPoint) const;
|
2011-02-10 08:06:28 -08:00
|
|
|
|
2012-08-03 09:36:40 -07:00
|
|
|
/**
|
|
|
|
|
* Test whether this entity is colliding with any obstructions that share its
|
|
|
|
|
* control groups and block the creation of foundations.
|
|
|
|
|
* @return true if foundation is valid (not obstructed)
|
|
|
|
|
*/
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual bool CheckDuplicateFoundation() const = 0;
|
2012-08-03 09:36:40 -07:00
|
|
|
|
2011-02-10 08:06:28 -08:00
|
|
|
/**
|
2018-03-26 08:18:53 -07:00
|
|
|
* Returns a list of entities that have an obstruction matching the given flag and intersect the current obstruction.
|
|
|
|
|
* @return vector of blocking entities
|
2010-03-17 16:01:12 -07:00
|
|
|
*/
|
2018-03-26 08:18:53 -07:00
|
|
|
virtual std::vector<entity_id_t> GetEntitiesByFlags(ICmpObstructionManager::flags_t flags) const = 0;
|
2011-02-10 08:06:28 -08:00
|
|
|
|
2018-03-20 18:44:15 -07:00
|
|
|
/**
|
2018-03-26 08:18:53 -07:00
|
|
|
* Returns a list of entities that are blocking construction of a foundation.
|
|
|
|
|
* @return vector of blocking entities
|
2018-03-20 18:44:15 -07:00
|
|
|
*/
|
2018-03-26 08:18:53 -07:00
|
|
|
virtual std::vector<entity_id_t> GetEntitiesBlockingConstruction() const = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a list of entities that shall be deleted when a construction on this obstruction starts,
|
|
|
|
|
* for example sheep carcasses.
|
|
|
|
|
*/
|
|
|
|
|
virtual std::vector<entity_id_t> GetEntitiesDeletedUponConstruction() const = 0;
|
2018-03-20 18:44:15 -07:00
|
|
|
|
2012-08-01 14:38:13 -07:00
|
|
|
/**
|
|
|
|
|
* Detects collisions between foundation-blocking entities and
|
|
|
|
|
* tries to fix them by setting control groups, if appropriate.
|
|
|
|
|
*/
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual void ResolveFoundationCollisions() const = 0;
|
2012-08-01 14:38:13 -07:00
|
|
|
|
2011-02-10 08:06:28 -08:00
|
|
|
virtual void SetActive(bool active) = 0;
|
2010-03-17 16:01:12 -07:00
|
|
|
|
2010-09-03 02:55:14 -07:00
|
|
|
virtual void SetMovingFlag(bool enabled) = 0;
|
|
|
|
|
|
2012-07-08 09:25:33 -07:00
|
|
|
virtual void SetDisableBlockMovementPathfinding(bool movementDisabled, bool pathfindingDisabled, int32_t shape) = 0;
|
2011-02-24 13:49:24 -08:00
|
|
|
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual bool GetBlockMovementFlag() const = 0;
|
2011-05-13 13:32:41 -07:00
|
|
|
|
2010-09-03 02:55:14 -07:00
|
|
|
/**
|
|
|
|
|
* Change the control group that the entity belongs to.
|
|
|
|
|
* Control groups are used to let units ignore collisions with other units from
|
|
|
|
|
* the same group. Default is the entity's own ID.
|
|
|
|
|
*/
|
|
|
|
|
virtual void SetControlGroup(entity_id_t group) = 0;
|
|
|
|
|
|
2012-05-05 12:22:22 -07:00
|
|
|
/// See SetControlGroup.
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual entity_id_t GetControlGroup() const = 0;
|
2012-05-05 12:22:22 -07:00
|
|
|
|
|
|
|
|
virtual void SetControlGroup2(entity_id_t group2) = 0;
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual entity_id_t GetControlGroup2() const = 0;
|
2012-05-05 12:22:22 -07:00
|
|
|
|
2010-01-29 13:13:18 -08:00
|
|
|
DECLARE_INTERFACE_TYPE(Obstruction)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // INCLUDED_ICMPOBSTRUCTION
|