Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10634 in orxonox.OLD for branches/inputdevice


Ignore:
Timestamp:
Apr 19, 2007, 11:45:56 AM (18 years ago)
Author:
snellen
Message:

Got nothing to do during the MTU lecture… so I finished the ActionTrigger

Location:
branches/inputdevice/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/inputdevice/src/lib/script_engine/script.cc

    r10622 r10634  
    409409    this->registerClass("TickTrigger");
    410410    this->registerClass("TimeTrigger");
     411    this->registerClass("ActionTrigger");
     412
    411413
    412414   return success;
  • branches/inputdevice/src/world_entities/player.cc

    r10632 r10634  
    1717#include "playable.h"
    1818#include "space_ships/space_ship.h"
    19 #include "script_triggers/action_trigger.h"
    2019
    2120#include "event_handler.h"
     
    4140
    4241  this->subscribeEvent(ES_GAME, KeyMapper::PEV_CHANGE_SHIP);
    43   this->subscribeEvent(ES_GAME, KeyMapper::PEV_ACTION);
    4442}
    4543
     
    134132    this->enterNewPlayable();
    135133  }
    136   else if(event.type == KeyMapper::PEV_ACTION && event.bPressed)
    137   {
    138    for (ObjectList<ActionTrigger>::const_iterator it = ActionTrigger::objectList().begin();
    139        it != ActionTrigger::objectList().end();
    140        ++it)
    141       (*it)->executeAction();
    142   }
    143134
    144135  if (likely(this->playable != NULL))
  • branches/inputdevice/src/world_entities/script_triggers/action_trigger.cc

    r10632 r10634  
    1717#include "action_trigger.h"
    1818#include "debug.h"
     19#include "event_handler.h"
    1920
    2021ObjectListDefinition(ActionTrigger);
     
    4849{
    4950  this->registerObject(this, ActionTrigger::_objectList);
     51  this->subscribeEvent(ES_GAME, KeyMapper::PEV_ACTION);
    5052
    5153  radius = 10;
     
    117119}
    118120
     121void ActionTrigger::process( const Event &event)
     122{
     123 if (event.type == KeyMapper::PEV_ACTION && event.bPressed)
     124  actionScheduled = true;
     125}
    119126
    120127void ActionTrigger::tick( float timestep )
     
    128135      executeScriptFunction(timestep);
    129136      scriptCalled = true;
    130       return;
    131137    }
    132138    else if( invert && this->distance(target) > radius  && actionScheduled)
     
    134140      executeScriptFunction(timestep);
    135141      scriptCalled = true;
    136       return;
    137142    }
    138143  }
  • branches/inputdevice/src/world_entities/script_triggers/action_trigger.h

    r10631 r10634  
    1212#include "script_class.h"
    1313#include "script_trigger.h"
     14#include "event_listener.h"
    1415
    15 class ActionTrigger : public ScriptTrigger
     16class ActionTrigger : public ScriptTrigger, public EventListener
    1617{
    1718  ObjectListDeclaration(ActionTrigger);
     
    2627
    2728    /// DO WORK
    28     virtual void executeAction(){actionScheduled = true;}
     29    virtual void process( const Event &event);
    2930    virtual void tick(float timestep);
    3031
  • branches/inputdevice/src/world_entities/script_triggers/script_trigger.h

    r10631 r10634  
    2929    virtual void tick(float timestep){}
    3030    virtual void executeScriptFunction(float timestep);
    31     void testScriptingFramework();
    3231
    3332    /// SET MEMBER
Note: See TracChangeset for help on using the changeset viewer.