author | truelight |
Thu, 19 Jul 2007 22:39:43 +0000 | |
branch | noai |
changeset 9682 | d031eb183733 |
child 9741 | 53c1c5850e01 |
permissions | -rw-r--r-- |
9682
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
1 |
#include "ai_event.hpp" |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
2 |
|
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
3 |
namespace SQConvert { |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
4 |
/* Allow enums to be used as Squirrel parameters */ |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
5 |
template <> AIEvent::AIEventType GetParam(ForceType<AIEvent::AIEventType>, HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIEvent::AIEventType)tmp; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
6 |
template <> int Return<AIEvent::AIEventType>(HSQUIRRELVM vm, AIEvent::AIEventType res) { sq_pushinteger(vm, (int32)res); return 1; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
7 |
|
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
8 |
/* Allow AIEvent to be used as Squirrel parameter */ |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
9 |
template <> AIEvent *GetParam(ForceType<AIEvent *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIEvent *)instance; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
10 |
template <> AIEvent &GetParam(ForceType<AIEvent &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEvent *)instance; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
11 |
template <> const AIEvent *GetParam(ForceType<const AIEvent *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIEvent *)instance; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
12 |
template <> const AIEvent &GetParam(ForceType<const AIEvent &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEvent *)instance; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
13 |
template <> int Return<AIEvent *>(HSQUIRRELVM vm, AIEvent *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIEvent", res, NULL, DefSQDestructorCallback<AIEvent>); return 1; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
14 |
}; // namespace SQConvert |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
15 |
|
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
16 |
void SQAIEventRegister(Squirrel *engine) { |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
17 |
DefSQClass <AIEvent> SQAIEvent("AIEvent"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
18 |
SQAIEvent.PreRegister(engine); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
19 |
SQAIEvent.AddConstructor<void (AIEvent::*)(AIEvent::AIEventType type), 2>(engine, "xi"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
20 |
|
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
21 |
SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_INVALID, "AI_ET_INVALID"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
22 |
SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_TEST, "AI_ET_TEST"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
23 |
SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_CRASHED_VEHICLE, "AI_ET_CRASHED_VEHICLE"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
24 |
|
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
25 |
SQAIEvent.DefSQStaticMethod(engine, &AIEvent::GetClassName, "GetClassName", 1, "x"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
26 |
|
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
27 |
SQAIEvent.DefSQMethod(engine, &AIEvent::GetEventType, "GetEventType", 1, "x"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
28 |
|
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
29 |
SQAIEvent.PostRegister(engine); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
30 |
} |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
31 |
|
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
32 |
namespace SQConvert { |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
33 |
/* Allow AIEventController to be used as Squirrel parameter */ |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
34 |
template <> AIEventController *GetParam(ForceType<AIEventController *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIEventController *)instance; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
35 |
template <> AIEventController &GetParam(ForceType<AIEventController &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventController *)instance; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
36 |
template <> const AIEventController *GetParam(ForceType<const AIEventController *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIEventController *)instance; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
37 |
template <> const AIEventController &GetParam(ForceType<const AIEventController &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventController *)instance; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
38 |
template <> int Return<AIEventController *>(HSQUIRRELVM vm, AIEventController *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIEventController", res, NULL, DefSQDestructorCallback<AIEventController>); return 1; } |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
39 |
}; // namespace SQConvert |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
40 |
|
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
41 |
void SQAIEventControllerRegister(Squirrel *engine) { |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
42 |
DefSQClass <AIEventController> SQAIEventController("AIEventController"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
43 |
SQAIEventController.PreRegister(engine); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
44 |
SQAIEventController.AddConstructor<void (AIEventController::*)(), 1>(engine, "x"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
45 |
|
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
46 |
SQAIEventController.DefSQStaticMethod(engine, &AIEventController::GetClassName, "GetClassName", 1, "x"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
47 |
SQAIEventController.DefSQStaticMethod(engine, &AIEventController::IsEventWaiting, "IsEventWaiting", 1, "x"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
48 |
SQAIEventController.DefSQStaticMethod(engine, &AIEventController::GetNextEvent, "GetNextEvent", 1, "x"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
49 |
SQAIEventController.DefSQStaticMethod(engine, &AIEventController::DisableEvent, "DisableEvent", 2, "xi"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
50 |
SQAIEventController.DefSQStaticMethod(engine, &AIEventController::EnableEvent, "EnableEvent", 2, "xi"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
51 |
SQAIEventController.DefSQStaticMethod(engine, &AIEventController::DisableAllEvents, "DisableAllEvents", 1, "x"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
52 |
SQAIEventController.DefSQStaticMethod(engine, &AIEventController::EnableAllEvents, "EnableAllEvents", 1, "x"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
53 |
SQAIEventController.DefSQStaticMethod(engine, &AIEventController::InsertEvent, "InsertEvent", 2, "xx"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
54 |
SQAIEventController.DefSQStaticMethod(engine, &AIEventController::Test, "Test", 1, "x"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
55 |
SQAIEventController.DefSQStaticMethod(engine, &AIEventController::FreeEventPointer, "FreeEventPointer", 1, "x"); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
56 |
|
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
57 |
SQAIEventController.PostRegister(engine); |
d031eb183733
(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff
changeset
|
58 |
} |