Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8831 in orxonox.OLD for branches/single_player_map/src/lib/util


Ignore:
Timestamp:
Jun 27, 2006, 3:51:33 PM (18 years ago)
Author:
snellen
Message:

Implemented executor without ret and 4 parameters, added setAbsDir and setAbsCoor to GenericNPC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/lib/util/executor/executor_lua.h

    r8830 r8831  
    233233
    234234
     235///////////
     236//// 4 ////
     237///////////
     238//! Executes a Function with a lua_State* parameter.
     239template<class T, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4 : public Executor
     240{
     241  public:
     242    /**
     243   * @brief Constructor of a ExecutorXML
     244   * @param function a Function to call
     245     */
     246    ExecutorLua4(void(T::*function)(type0, type1, type2, type3))
     247  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())
     248    {
     249      this->functionPointer = function;
     250      this->functorType = Executor_Objective | Executor_NoLoadString;
     251    }
     252
     253    /**
     254     * @brief executes the Command on BaseObject
     255     * @param object the BaseObject to execute this Executor on
     256     * @param loadString ignored in this case
     257     */
     258    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     259    {
     260      PRINTF(1)("no usefull executor\n");
     261    }
     262
     263    virtual void operator()(BaseObject* object, int& count, void* values) const
     264    {
     265      lua_State* state = (lua_State*)values;
     266      count = 0;
     267
     268      (dynamic_cast<T*>(object)->*(functionPointer))(
     269          fromLua<type0>(state, 1),
     270          fromLua<type1>(state, 2),
     271          fromLua<type2>(state, 3),
     272          fromLua<type3>(state, 4) );
     273    }
     274
     275    /**
     276     * @returns a _new_ Copy of this Executor
     277     */
     278    virtual Executor* clone () const
     279    {
     280      return new ExecutorLua4<T, type0, type1, type2, type3>(this->functionPointer);
     281    }
     282  private:
     283    void          (T::*functionPointer)(type0, type1, type2, type3);
     284};
    235285
    236286
Note: See TracChangeset for help on using the changeset viewer.