[10609] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Silvan Nellen |
---|
| 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
[10616] | 16 | #include "util/loading/factory.h" |
---|
[10620] | 17 | #include "script_class.h" |
---|
[10609] | 18 | #include "tick_trigger.h" |
---|
| 19 | #include "debug.h" |
---|
| 20 | |
---|
| 21 | ObjectListDefinition(TickTrigger); |
---|
[10611] | 22 | CREATE_FACTORY(TickTrigger); |
---|
[10609] | 23 | |
---|
[10610] | 24 | CREATE_SCRIPTABLE_CLASS(TickTrigger, |
---|
| 25 | // Coordinates |
---|
| 26 | addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) |
---|
| 27 | ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) |
---|
| 28 | ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) |
---|
| 29 | ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) |
---|
| 30 | //Properties |
---|
| 31 | ->addMethod("setName", Executor1<BaseObject, lua_State*, const std::string&>(&BaseObject::setName)) |
---|
| 32 | ->addMethod("setScript", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setScript)) |
---|
| 33 | ->addMethod("setFunction", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setFunction)) |
---|
| 34 | ->addMethod("setDebugDraw", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setDebugDraw)) |
---|
| 35 | ); |
---|
[10609] | 36 | |
---|
| 37 | |
---|
| 38 | /** |
---|
| 39 | * Constructs a new TickTrigger. |
---|
| 40 | * @param root the xml element to load the parameters from. |
---|
| 41 | * |
---|
| 42 | */ |
---|
| 43 | TickTrigger::TickTrigger(const TiXmlElement* root) |
---|
| 44 | { |
---|
| 45 | this->registerObject(this, TickTrigger::_objectList); |
---|
| 46 | |
---|
[10614] | 47 | if(root != NULL) |
---|
| 48 | { |
---|
| 49 | loadParams(root); |
---|
| 50 | |
---|
| 51 | if(addToScript && scriptIsOk) |
---|
| 52 | { |
---|
| 53 | script->addObject( "TickTrigger", this->getName()); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | } |
---|
| 57 | |
---|
[10609] | 58 | } |
---|
| 59 | |
---|
| 60 | /** |
---|
| 61 | * Deletes the TickTrigger. |
---|
| 62 | * |
---|
| 63 | */ |
---|
| 64 | TickTrigger::~TickTrigger() |
---|
| 65 | { |
---|
| 66 | |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | void TickTrigger::tick(float timestep) |
---|
| 71 | { |
---|
| 72 | if( scriptFinished ) return; |
---|
| 73 | |
---|
[10638] | 74 | this->executeScriptFunction(timestep); |
---|
[10609] | 75 | |
---|
| 76 | } |
---|