00001
00002
00003
00004
00005
00006 #ifndef __BS_CONTROLLER_H__
00007 #define __BS_CONTROLLER_H__
00008
00009 #include "bsPrerequisites.h"
00010 #include "bsCore.h"
00011 #include "bsControllerDefinition.h"
00012 #include "bsEmitter.h"
00013
00014 namespace BS_NMSP
00015 {
00016 class ScriptMachine;
00017
00025 class _BSAPI Controller : public DeepMemoryPoolObject
00026 {
00027
00028 struct MemberController
00029 {
00030 float time;
00031 bstype speed;
00032 };
00033
00034
00035 struct EmitterInstance
00036 {
00037 Emitter* emitter;
00038 bstype special[NUM_SPECIAL_MEMBERS];
00039
00040 MemberController controllers[NUM_SPECIAL_MEMBERS];
00041 uint32 activeControllers;
00042 };
00043
00044
00045
00046 struct Event
00047 {
00048 String name;
00049 int numArguments;
00050 CodeRecord* code;
00051 };
00052
00053 bool mEnabled;
00054
00055 ScriptMachine* mScriptMachine;
00056
00057
00058 float mDirX, mDirY;
00059
00060
00061 EmitterInstance* mEmitters;
00062
00063 int mNumEmitters;
00064
00065
00066 Event* mEvents;
00067
00068 int mNumEvents;
00069
00070
00071 std::list<bstype> mBlocks;
00072
00073
00074 ScriptState mEventState;
00075
00076 ScriptRecord* mRecord;
00077
00078
00079 void* mUserObject;
00080
00081 private:
00082
00083 void runScript(float frameTime);
00084
00085 public:
00086
00090 explicit Controller(ScriptMachine* machine);
00091
00098 void onRelease();
00099
00100 #ifndef BS_Z_DIMENSION
00101
00112 void setDefinition(ControllerDefinition* def, bstype x, bstype y, bstype angle);
00113 #else
00114
00126 void setDefinition(ControllerDefinition* def, bstype x, bstype y, bstype z, bstype angle);
00127 #endif
00128
00133 void enable(bool enable);
00134
00139 bool isEnabled() const;
00140
00145 void setX(bstype x);
00146
00151 void setY(bstype y);
00152
00153 #ifdef BS_Z_DIMENSION
00154
00158 void setZ(bstype z);
00159 #endif
00160
00161 #ifndef BS_Z_DIMENSION
00162
00167 void setPosition(bstype x, bstype y);
00168 #else
00169
00175 void setPosition(bstype x, bstype y, bstype z);
00176 #endif
00177
00183 void setAngle(bstype facing, bstype orbit);
00184
00193 void setMember(int member, bstype value);
00194
00200 void setUserObject(void* userObject);
00201
00211 void* getUserObject() const;
00212
00220 void setState(int state);
00221
00232 void setEmitterMember(int emitter, int member, bstype value);
00233
00245 void setEmitterMember(int emitter, int member, bstype value, float time);
00246
00256 bstype getEmitterMember(int emitter, int member) const;
00257
00266 void setEmitterMemberState(int emitter, int state);
00267
00277 int raiseEvent(const String& evt, const bstype* args);
00278
00287 bool _raiseEvent(int index, const bstype* args);
00288
00297 void addBlock(bstype block);
00298
00306 void signal(bstype block);
00307
00313 void resume();
00314
00323 void enableEmitter(int index, bool enable);
00324
00331 void update(float frameTime);
00332
00333 };
00334
00335 }
00336
00337 #endif