2009-05-08 13:28:41 +00:00
|
|
|
/*
|
|
|
|
* OpenClonk, http://www.openclonk.org
|
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* Copyright (c) 1998-2000, Matthes Bender
|
|
|
|
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
|
2016-04-03 18:18:29 +00:00
|
|
|
* Copyright (c) 2009-2016, The OpenClonk Team and contributors
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* Distributed under the terms of the ISC license; see accompanying file
|
|
|
|
* "COPYING" for details.
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* "Clonk" is a registered trademark of Matthes Bender, used with permission.
|
|
|
|
* See accompanying file "TRADEMARK" for details.
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* To redistribute this file separately, substitute the full license texts
|
|
|
|
* for the above references.
|
2009-05-08 13:28:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Finds the way through the Clonk landscape */
|
|
|
|
|
|
|
|
#ifndef INC_C4PathFinder
|
|
|
|
#define INC_C4PathFinder
|
|
|
|
|
2015-03-31 15:12:43 +00:00
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
class C4Object;
|
2015-03-31 15:22:58 +00:00
|
|
|
class C4PathFinderRay;
|
2009-05-08 13:28:41 +00:00
|
|
|
class C4PathFinder
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
friend class C4PathFinderRay;
|
2010-03-28 17:58:21 +00:00
|
|
|
public:
|
|
|
|
C4PathFinder();
|
|
|
|
~C4PathFinder();
|
2015-03-31 15:12:43 +00:00
|
|
|
|
|
|
|
typedef std::function<bool(int32_t x, int32_t y)> PointFreeFn;
|
|
|
|
typedef std::function<bool(int32_t x, int32_t y, C4Object *transfer_object)> SetWaypointFn;
|
|
|
|
|
2010-03-28 17:58:21 +00:00
|
|
|
void Draw(C4TargetFacet &cgo);
|
|
|
|
void Clear();
|
|
|
|
void Default();
|
2016-11-02 23:58:02 +00:00
|
|
|
void Init(PointFreeFn fnPointFree, C4TransferZones* pTransferZones=nullptr);
|
2015-03-31 15:12:43 +00:00
|
|
|
bool Find(int32_t iFromX, int32_t iFromY, int32_t iToX, int32_t iToY, SetWaypointFn fnSetWaypoint);
|
2010-03-28 17:58:21 +00:00
|
|
|
void EnableTransferZones(bool fEnabled);
|
|
|
|
void SetLevel(int iLevel);
|
2015-03-31 15:12:43 +00:00
|
|
|
|
|
|
|
private:
|
2010-03-28 17:58:21 +00:00
|
|
|
void Run();
|
2016-11-02 23:58:02 +00:00
|
|
|
bool AddRay(int32_t iFromX, int32_t iFromY, int32_t iToX, int32_t iToY, int32_t iDepth, int32_t iDirection, C4PathFinderRay *pFrom, C4TransferZone *pUseZone=nullptr);
|
2010-03-28 17:58:21 +00:00
|
|
|
bool SplitRay(C4PathFinderRay *pRay, int32_t iAtX, int32_t iAtY);
|
|
|
|
bool Execute();
|
2015-03-31 15:12:43 +00:00
|
|
|
|
|
|
|
PointFreeFn PointFree;
|
|
|
|
SetWaypointFn SetWaypoint;
|
|
|
|
C4PathFinderRay *FirstRay;
|
|
|
|
bool Success;
|
|
|
|
C4TransferZones *TransferZones;
|
|
|
|
bool TransferZonesEnabled;
|
|
|
|
int Level;
|
2010-03-28 17:58:21 +00:00
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|