| 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/instance.h" |
| 25 |
%} |
| 26 |
|
| 27 |
%include "model/metamodel/modelcoords.i" |
| 28 |
%include "model/metamodel/ivisual.i" |
| 29 |
%include "util/structures/utilstructures.i" |
| 30 |
%include "util/base/utilbase.i" |
| 31 |
%include "location.i" |
| 32 |
|
| 33 |
namespace FIFE { |
| 34 |
|
| 35 |
class Layer; |
| 36 |
class Action; |
| 37 |
class Object; |
| 38 |
class Instance; |
| 39 |
class Route; |
| 40 |
class OverlayColors; |
| 41 |
class AnimationPtr; |
| 42 |
|
| 43 |
%feature("director") InstanceActionListener; |
| 44 |
class InstanceActionListener { |
| 45 |
public: |
| 46 |
virtual ~InstanceActionListener() {}; |
| 47 |
virtual void onInstanceActionFinished(Instance* instance, Action* action) = 0; |
| 48 |
virtual void onInstanceActionCancelled(Instance* instance, Action* action) = 0; |
| 49 |
virtual void onInstanceActionFrame(Instance* instance, Action* action, int32_t frame) = 0; |
| 50 |
}; |
| 51 |
|
| 52 |
enum InstanceChangeType { |
| 53 |
ICHANGE_NO_CHANGES = 0x0000, |
| 54 |
ICHANGE_LOC = 0x0001, |
| 55 |
ICHANGE_ROTATION = 0x0002, |
| 56 |
ICHANGE_SPEED = 0x0004, |
| 57 |
ICHANGE_ACTION = 0x0008, |
| 58 |
ICHANGE_TIME_MULTIPLIER = 0x0010, |
| 59 |
ICHANGE_SAYTEXT = 0x0020, |
| 60 |
ICHANGE_BLOCK = 0x0040, |
| 61 |
ICHANGE_CELL = 0x0080, |
| 62 |
ICHANGE_TRANSPARENCY = 0x0100, |
| 63 |
ICHANGE_VISIBLE = 0x0200, |
| 64 |
ICHANGE_STACKPOS = 0x0400 |
| 65 |
}; |
| 66 |
typedef uint32_t InstanceChangeInfo; |
| 67 |
|
| 68 |
%feature("director") InstanceChangeListener; |
| 69 |
class InstanceChangeListener { |
| 70 |
public: |
| 71 |
virtual ~InstanceChangeListener() {}; |
| 72 |
virtual void onInstanceChanged(Instance* instance, InstanceChangeInfo info) = 0; |
| 73 |
}; |
| 74 |
|
| 75 |
%feature("director") InstanceDeleteListener; |
| 76 |
class InstanceDeleteListener { |
| 77 |
public: |
| 78 |
virtual ~InstanceDeleteListener() {}; |
| 79 |
virtual void onInstanceDeleted(Instance* instance) = 0; |
| 80 |
}; |
| 81 |
|
| 82 |
class Instance : public FifeClass { |
| 83 |
public: |
| 84 |
Instance(Object* object, const Location& location, const std::string& identifier=""); |
| 85 |
virtual ~Instance(); |
| 86 |
const std::string& getId(); |
| 87 |
void setId(const std::string& identifier=""); |
| 88 |
Object* getObject(); |
| 89 |
void setLocation(const Location& loc); |
| 90 |
Location getLocation() const; |
| 91 |
Location& getLocationRef(); |
| 92 |
Location getTargetLocation() const; |
| 93 |
void setRotation(int32_t); |
| 94 |
int32_t getRotation() const; |
| 95 |
int32_t getOldRotation() const; |
| 96 |
void setBlocking(bool blocking); |
| 97 |
bool isBlocking() const; |
| 98 |
void setOverrideBlocking(bool overblock); |
| 99 |
bool isOverrideBlocking() const; |
| 100 |
void addActionListener(InstanceActionListener* listener); |
| 101 |
void removeActionListener(InstanceActionListener* listener); |
| 102 |
void addChangeListener(InstanceChangeListener* listener); |
| 103 |
void removeChangeListener(InstanceChangeListener* listener); |
| 104 |
void addDeleteListener(InstanceDeleteListener* listener); |
| 105 |
void removeDeleteListener(InstanceDeleteListener* listener); |
| 106 |
Action* getCurrentAction() const; |
| 107 |
double getMovementSpeed() const; |
| 108 |
void setFacingLocation(const Location& loc); |
| 109 |
Location getFacingLocation(); |
| 110 |
uint32_t getActionRuntime(); |
| 111 |
void setActionRuntime(uint32_t time_offset); |
| 112 |
void move(const std::string& actionName, const Location& target, const double speed, const std::string& costId = ""); |
| 113 |
void actOnce(const std::string& actionName, const Location& direction); |
| 114 |
void actOnce(const std::string& actionName, int32_t rotation); |
| 115 |
void actOnce(const std::string& actionName); |
| 116 |
void actRepeat(const std::string& actionName, const Location& direction); |
| 117 |
void actRepeat(const std::string& actionName, int32_t rotation); |
| 118 |
void actRepeat(const std::string& actionName); |
| 119 |
void follow(const std::string& actionName, Instance* leader, const double speed); |
| 120 |
void follow(const std::string& actionName, Route* route, const double speed); |
| 121 |
void cancelMovement(uint32_t length = 1); |
| 122 |
void say(const std::string& text, uint32_t duration=0); |
| 123 |
void setTimeMultiplier(float multip); |
| 124 |
float getTimeMultiplier(); |
| 125 |
uint32_t getRuntime(); |
| 126 |
void refresh(); |
| 127 |
InstanceChangeInfo getChangeInfo(); |
| 128 |
|
| 129 |
void setVisual(IVisual* visual); |
| 130 |
template<typename T> T* getVisual() const; |
| 131 |
|
| 132 |
Route* getRoute(); |
| 133 |
void setCellStackPosition(uint8_t stack); |
| 134 |
uint8_t getCellStackPosition(); |
| 135 |
bool isSpecialCost(); |
| 136 |
void setCost(const std::string& id, double cost); |
| 137 |
void resetCost(); |
| 138 |
double getCost(); |
| 139 |
std::string getCostId(); |
| 140 |
double getSpeed(); |
| 141 |
bool isSpecialSpeed(); |
| 142 |
|
| 143 |
bool isMultiCell(); |
| 144 |
bool isMultiObject(); |
| 145 |
const std::vector<Instance*>& getMultiInstances(); |
| 146 |
Instance* getMainMultiInstance(); |
| 147 |
|
| 148 |
void addStaticColorOverlay(uint32_t angle, const OverlayColors& colors); |
| 149 |
OverlayColors* getStaticColorOverlay(int32_t angle); |
| 150 |
void removeStaticColorOverlay(int32_t angle); |
| 151 |
bool isStaticColorOverlay(); |
| 152 |
|
| 153 |
void addColorOverlay(const std::string& actionName, uint32_t angle, const OverlayColors& colors); |
| 154 |
OverlayColors* getColorOverlay(const std::string& actionName, uint32_t angle); |
| 155 |
void removeColorOverlay(const std::string& actionName, int32_t angle); |
| 156 |
|
| 157 |
void addAnimationOverlay(const std::string& actionName, uint32_t angle, int32_t order, const AnimationPtr& animationptr); |
| 158 |
std::map<int32_t, AnimationPtr> getAnimationOverlay(const std::string& actionName, int32_t angle); |
| 159 |
void removeAnimationOverlay(const std::string& actionName, uint32_t angle, int32_t order); |
| 160 |
|
| 161 |
void addColorOverlay(const std::string& actionName, uint32_t angle, int32_t order, const OverlayColors& colors); |
| 162 |
OverlayColors* getColorOverlay(const std::string& actionName, uint32_t angle, int32_t order); |
| 163 |
void removeColorOverlay(const std::string& actionName, int32_t angle, int32_t order); |
| 164 |
|
| 165 |
void convertToOverlays(const std::string& actionName, bool color); |
| 166 |
bool isAnimationOverlay(const std::string& actionName); |
| 167 |
bool isColorOverlay(const std::string& actionName); |
| 168 |
}; |
| 169 |
} |
| 170 |
|
| 171 |
namespace std { |
| 172 |
%template(InstanceVector) vector<FIFE::Instance*>; |
| 173 |
%template(InstanceList) list<FIFE::Instance*>; |
| 174 |
%template(AnimationOverlayMap) map<int32_t, FIFE::AnimationPtr>; |
| 175 |
} |
| 176 |
|