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/cell.h"
25 %}
26 
27 namespace FIFE {
28 
29 	class Instance;
30 	class Layer;
31 	class Cell;
32 
33 	enum CellType {
34 		CTYPE_NO_BLOCKER = 0,
35 		CTYPE_STATIC_BLOCKER = 1,
36 		CTYPE_DYNAMIC_BLOCKER = 2,
37 		CTYPE_CELL_NO_BLOCKER = 3,
38 		CTYPE_CELL_BLOCKER = 4
39 	};
40 	typedef uint8_t CellTypeInfo;
41 
42 	%feature("director") CellChangeListener;
43 	class CellChangeListener {
44 	public:
~CellChangeListener()45 		virtual ~CellChangeListener() {};
46 		virtual void onInstanceEnteredCell(Cell* cell, Instance* instance) = 0;
47 		virtual void onInstanceExitedCell(Cell* cell, Instance* instance) = 0;
48 		virtual void onBlockingChangedCell(Cell* cell, CellTypeInfo type, bool blocks) = 0;
49 	};
50 
51 	%feature("director") CellDeleteListener;
52 	class CellDeleteListener {
53 	public:
~CellDeleteListener()54 		virtual ~CellDeleteListener() {};
55 		virtual void onCellDeleted(Cell* cell) = 0;
56 	};
57 
58 	class Cell : public FifeClass {
59 		public:
60 			Cell(int32_t coordint, ModelCoordinate coordinate, Layer* layer);
61 			~Cell();
62 
63 			void addInstances(const std::list<Instance*>& instances);
64 			void addInstance(Instance* instance);
65 			void changeInstance(Instance* instance);
66 			void removeInstance(Instance* instance);
67 
68 			bool isNeighbor(Cell* cell);
69 			std::vector<Cell*> getNeighbors();
70 			void updateCellInfo();
71 			int32_t getCellId();
72 			const ModelCoordinate getLayerCoordinates() const;
73 			bool defaultCost();
74 			void setCostMultiplier(double multi);
75 			double getCostMultiplier();
76 			void resetCostMultiplier();
77 			bool defaultSpeed();
78 			void setSpeedMultiplier(double multi);
79 			double getSpeedMultiplier();
80 			void resetSpeedMultiplier();
81 
82 			const std::set<Instance*>& getInstances();
83 			void setCellType(CellTypeInfo type);
84 			CellTypeInfo getCellType();
85 			Layer* getLayer();
86 			void createTransition(Layer* layer, const ModelCoordinate& mc);
87 			void deleteTransition();
88 
89 			void addChangeListener(CellChangeListener* listener);
90 			void removeChangeListener(CellChangeListener* listener);
91 			void addDeleteListener(CellDeleteListener* listener);
92 			void removeDeleteListener(CellDeleteListener* listener);
93 	};
94 }
95 
96 namespace std {
97 	%template(InstanceSet) set<FIFE::Instance*>;
98 	%template(CellSet) set<FIFE::Cell*>;
99 	%template(CellVector) vector<FIFE::Cell*>;
100 }
101