| 1 |
/*************************************************************************** |
| 2 |
* Copyright (C) 2005-2019 by the FIFE team * |
| 3 |
* http://www.fifengine.net * |
| 4 |
* This file is part of FIFE. * |
| 5 |
* * |
| 6 |
* FIFE is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Lesser General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2.1 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 14 |
* Lesser General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Lesser General Public * |
| 17 |
* License along with this library; if not, write to the * |
| 18 |
* Free Software Foundation, Inc., * |
| 19 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
| 20 |
***************************************************************************/ |
| 21 |
|
| 22 |
%module fife |
| 23 |
%{ |
| 24 |
#include "model/structures/layer.h" |
| 25 |
%} |
| 26 |
|
| 27 |
%include "model/metamodel/modelcoords.i" |
| 28 |
%include "model/metamodel/grids/cellgrids.i" |
| 29 |
%include "util/structures/utilstructures.i" |
| 30 |
%include "util/base/utilbase.i" |
| 31 |
|
| 32 |
namespace FIFE { |
| 33 |
|
| 34 |
class Map; |
| 35 |
class Instance; |
| 36 |
class Object; |
| 37 |
class CellGrid; |
| 38 |
class CellCache; |
| 39 |
|
| 40 |
enum PathingStrategy { |
| 41 |
CELL_EDGES_ONLY, |
| 42 |
CELL_EDGES_AND_DIAGONALS |
| 43 |
}; |
| 44 |
|
| 45 |
enum SortingStrategy { |
| 46 |
SORTING_CAMERA, |
| 47 |
SORTING_LOCATION, |
| 48 |
SORTING_CAMERA_AND_LOCATION |
| 49 |
}; |
| 50 |
|
| 51 |
%feature("director") LayerChangeListener; |
| 52 |
class LayerChangeListener { |
| 53 |
public: |
| 54 |
virtual ~LayerChangeListener() {}; |
| 55 |
virtual void onLayerChanged(Layer* layer, std::vector<Instance*>& changedInstances) = 0; |
| 56 |
virtual void onInstanceCreate(Layer* layer, Instance* instance) = 0; |
| 57 |
virtual void onInstanceDelete(Layer* layer, Instance* instance) = 0; |
| 58 |
}; |
| 59 |
|
| 60 |
|
| 61 |
class Layer : public FifeClass { |
| 62 |
public: |
| 63 |
Layer(const std::string& identifier, Map* map, CellGrid* geometry); |
| 64 |
~Layer(); |
| 65 |
|
| 66 |
const std::string& getId() const; |
| 67 |
void setId(const std::string& id); |
| 68 |
|
| 69 |
CellGrid* getCellGrid() const; |
| 70 |
void setCellGrid(CellGrid* grid); |
| 71 |
|
| 72 |
Map* getMap(); |
| 73 |
bool hasInstances() const; |
| 74 |
Instance* createInstance(Object* object, const ModelCoordinate& p, const std::string& id=""); |
| 75 |
Instance* createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id=""); |
| 76 |
bool addInstance(Instance* instance, const ExactModelCoordinate& p); |
| 77 |
void deleteInstance(Instance* object); |
| 78 |
void removeInstance(Instance* object); |
| 79 |
|
| 80 |
const std::vector<Instance*>& getInstances() const; |
| 81 |
std::vector<Instance*> getInstances(const std::string& identifier); |
| 82 |
std::vector<Instance*> getInstancesAt(Location& loc, bool use_exactcoordinates=false); |
| 83 |
std::list<Instance*> getInstancesIn(Rect& rec); |
| 84 |
std::vector<Instance*> getInstancesInLine(const ModelCoordinate& pt1, const ModelCoordinate& pt2); |
| 85 |
std::vector<Instance*> getInstancesInCircle(const ModelCoordinate& center, uint16_t radius); |
| 86 |
std::vector<Instance*> getInstancesInCircleSegment(const ModelCoordinate& center, uint16_t radius, int32_t sangle, int32_t eangle); |
| 87 |
Instance* getInstance(const std::string& id); |
| 88 |
|
| 89 |
void setInstancesVisible(bool vis); |
| 90 |
void setLayerTransparency(uint8_t transparency); |
| 91 |
uint8_t getLayerTransparency(); |
| 92 |
void getMinMaxCoordinates(ModelCoordinate& min, ModelCoordinate& max, const Layer* layer = 0) const; |
| 93 |
bool cellContainsBlockingInstance(const ModelCoordinate& cellCoordinate); |
| 94 |
std::vector<Instance*> getBlockingInstances(const ModelCoordinate& cellCoordinate); |
| 95 |
void toggleInstancesVisible(); |
| 96 |
bool areInstancesVisible() const; |
| 97 |
|
| 98 |
void setPathingStrategy(PathingStrategy strategy); |
| 99 |
PathingStrategy getPathingStrategy(); |
| 100 |
|
| 101 |
void setSortingStrategy(SortingStrategy strategy); |
| 102 |
SortingStrategy getSortingStrategy() const; |
| 103 |
|
| 104 |
void setWalkable(bool walkable); |
| 105 |
bool isWalkable(); |
| 106 |
|
| 107 |
void setInteract(bool interact, const std::string& id); |
| 108 |
bool isInteract(); |
| 109 |
const std::string& getWalkableId(); |
| 110 |
|
| 111 |
void addInteractLayer(Layer* layer); |
| 112 |
const std::vector<Layer*>& getInteractLayers(); |
| 113 |
void removeInteractLayer(Layer* layer); |
| 114 |
|
| 115 |
void createCellCache(); |
| 116 |
CellCache* getCellCache(); |
| 117 |
void destroyCellCache(); |
| 118 |
|
| 119 |
void addChangeListener(LayerChangeListener* listener); |
| 120 |
void removeChangeListener(LayerChangeListener* listener); |
| 121 |
bool isChanged(); |
| 122 |
std::vector<Instance*>& getChangedInstances(); |
| 123 |
|
| 124 |
void setStatic(bool stati); |
| 125 |
bool isStatic(); |
| 126 |
}; |
| 127 |
} |