1 /*
2 Copyright (C) 2007, 2010 - Bit-Blot
3 
4 This file is part of Aquaria.
5 
6 Aquaria is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10 
11 This program 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.
14 
15 See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 */
21 #ifndef AQ_PATH_H
22 #define AQ_PATH_H
23 
24 #include "../BBGE/Base.h"
25 #include "../BBGE/Particles.h"
26 #include "../BBGE/ScriptObject.h"
27 #include "ScriptInterface.h"
28 
29 #undef PATH_MAX  // May be set by a system header.
30 
31 class PathNode
32 {
33 public:
PathNode()34 	PathNode() { maxSpeed = -1;}
35 	Vector position;
36 	int maxSpeed;
37 };
38 
39 enum PathType
40 {
41 	PATH_NONE			= 0,
42 	PATH_CURRENT		= 1,
43 	PATH_STEAM			= 2,
44 	PATH_LI				= 3,
45 	PATH_SAVEPOINT		= 4,
46 	PATH_WARP			= 5,
47 	PATH_SPIRITPORTAL	= 6,
48 	PATH_BGSFXLOOP		= 7,
49 	PATH_RADARHIDE		= 8,
50 	PATH_COOK			= 9,
51 	PATH_WATERBUBBLE	= 10,
52 	PATH_GEM			= 11,
53 	PATH_SETING			= 12,
54 	PATH_SETENT			= 13,
55 	PATH_ZOOM			= 14,
56 	PATH_MAX
57 };
58 
59 enum LocalWarpType
60 {
61 	LOCALWARP_NONE		= 0,
62 	LOCALWARP_IN		= 1,
63 	LOCALWARP_OUT		= 2
64 };
65 
66 enum PathShape
67 {
68 	PATHSHAPE_RECT		= 0,
69 	PATHSHAPE_CIRCLE	= 1
70 };
71 
72 class Path : public ScriptObject
73 {
74 public:
75 	Path();
76 	~Path();
77 	void destroy();
78 	void init();
79 	void clampPosition(Vector *pos, float rad=0);
80 	void song(SongType song);
81 	void songNote(int note);
82 	void songNoteDone(int note, float len);
83 	bool hasScript();
84 	std::string name; // full node string
85 	std::string label; // first part only (the actual node name)
86 	std::vector<PathNode>nodes;
87 	void removeNode(int idx);
88 	void addNode(int idx);
89 	void update(float dt);
90 	void setActive(bool v);
91 	bool action(int id, int state);
92 	void setEmitter(const std::string& name);
93 
94 	PathNode *getPathNode(int idx);
95 	bool isCoordinateInside(const Vector &pos, int rad=0);
96 
97 	void reverseNodes();
98 
99 	int getLeft();
100 	int getRight();
101 	int getUp();
102 	int getDown();
103 
104 	Vector getBackPos(const Vector &position);
105 	Vector getEnterPosition(int outAmount=1);
106 	Vector getEnterNormal();
107 
108 	void activate(Entity *e=0);
109 	void refreshScript();
110 	Script *script;
111 	bool updateFunction;
112 	bool activateFunction;
113 	bool cursorActivation;
114 	int replayVox;
115 
116 	std::string warpMap, warpNode, vox, spawnEnemyName, content;
117 	float amount, time;
118 	Entity *spawnedEntity;
119 	int spawnEnemyNumber, spawnEnemyDistance;
120 	char warpType;
121 	RectShape rect;
122 	bool active, naijaIn;
123 
124 	float animOffset;
125 
126 	PathType pathType;
127 	Path *nextOfType;
128 
129 	int toFlip;
130 
131 	LocalWarpType localWarpType;
132 
133 	bool naijaHome;
134 	bool catchActions;
135 	bool songFunc, songNoteFunc, songNoteDoneFunc;
136 	bool neverSpawned;
137 	ParticleEffect *emitter;
138 
139 	float currentMod;
140 	bool addEmitter;
141 
142 	std::string gem;
143 
144 	bool spiritFreeze;
145 	bool pauseFreeze;
146 
147 	PathShape pathShape;
148 	float activationRange;
149 
150 
151 	void parseWarpNodeData(const std::string &dataString);
152 
153 	int messageVariadic(lua_State *L, int nparams);
154 	void luaDebugMsg(const std::string &func, const std::string &msg);
155 };
156 
157 #endif
158