Changeset 10620 in orxonox.OLD for branches/scriptimprovements/src/world_entities/script_triggers/time_trigger.cc
- Timestamp:
- Apr 5, 2007, 6:11:02 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/scriptimprovements/src/world_entities/script_triggers/time_trigger.cc
r10607 r10620 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 16 #include "util/loading/factory.h" 17 #include "time_trigger.h" 18 #include "debug.h" 19 #include "script_class.h" 20 21 ObjectListDefinition(TimeTrigger); 22 CREATE_FACTORY(TimeTrigger); 23 24 CREATE_SCRIPTABLE_CLASS(TimeTrigger, 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 ->addMethod("start", Executor0<TimeTrigger, lua_State*>(&TimeTrigger::start)) 36 ->addMethod("stop", Executor0<TimeTrigger, lua_State*>(&TimeTrigger::stop)) 37 ->addMethod("reset", Executor0<TimeTrigger, lua_State*>(&TimeTrigger::reset)) 38 ->addMethod("setDelay", Executor1<TimeTrigger, lua_State*, float>(&TimeTrigger::setDelay)) 39 40 ); 41 42 43 /** 44 * Constructs a new TimeTrigger. 45 * @param root the xml element to load the parameters from. 46 * 47 */ 48 TimeTrigger::TimeTrigger(const TiXmlElement* root) 49 { 50 this->registerObject(this, TimeTrigger::_objectList); 51 52 this->delay = 1; 53 this->currentTime = delay; 54 this->isStopped = true; 55 56 if(root != NULL) 57 { 58 loadParams(root); 59 60 if(addToScript && scriptIsOk) 61 { 62 script->addObject( "TimeTrigger", this->getName()); 63 } 64 65 } 66 67 } 68 69 /** 70 * Deletes the TimeTrigger. 71 * 72 */ 73 TimeTrigger::~TimeTrigger() 74 { 75 76 } 77 78 79 void TimeTrigger::tick(float timestep) 80 { 81 if( scriptFinished ) return; 82 83 if( !isStopped ) 84 { 85 currentTime -= timestep; 86 87 if(currentTime < 0) 88 { 89 this->executeAction(timestep); 90 this->stop(); 91 } 92 93 } 94 95 96 }
Note: See TracChangeset
for help on using the changeset viewer.