Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 21, 2010, 11:15:44 PM (14 years ago)
Author:
dafrick
Message:

Synchronizing Notifications.
In the course of that, notifications are not longer sent by creating a Notification and the calling notification.send() bur by letting the NotificationManager handle all this: NotificationManager::getInstance().sendNotification(message)
This made QuestNotification obsolete, thus it was removde.

Also did some work on synchronizing the Script class. It should work properly most of the time, but the current solution is unreliable and unsatisfactory. So this will change as soon as I know how.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/objects/Script.h

    r7463 r7474  
    3333
    3434#include <string>
     35#include <vector>
     36
    3537#include "core/BaseObject.h"
     38#include "tools/interfaces/Tickable.h"
     39#include "network/synchronisable/Synchronisable.h"
     40#include "network/ClientConnectionListener.h"
    3641
    3742namespace orxonox
     
    5459        'code': The code that should be executed.
    5560        'mode': The mode, specifying whether the set code should be executed the normal way ('normal') or in lua ('lua'). Default is 'normal'.
    56         'onLoad': Whether the code is executed upon loading (creation) of this object. Default is true.
     61        'onLoad': Whether the code is executed upon loading (creation) of this object. If this is set the code is executed ofr all players, regardless of the value of parameter 'forAll'. Default is true.
    5762        'needsGraphics': Whether the code needs graphics to be executed or not. Default is false.
     63        'forAll': Whether the code is executed for all players each time the Script is triggered or jut for the player triggering the Script. If forAll is false, which is default, the event that triggers the Script must come from a PlayerTrigger.
    5864
    5965        Here are two examples illustrating the usage:
     
    7783        Damian 'Mozork' Frick
    7884    */
    79     class _ObjectsExport Script : public BaseObject
     85    class _ObjectsExport Script : public BaseObject, public Synchronisable, public ClientConnectionListener, public Tickable
    8086    {
    8187        public:
     
    8692            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a port that can be used to channel events and react to them.
    8793
    88             void trigger(bool triggered); //!< Is called when an event comes in trough the event port.
    89             void execute(); //!< Executes the Scripts code, depending on the mode.
     94            virtual void tick(float dt);
     95
     96            bool trigger(bool triggered, BaseObject* trigger); //!< Is called when an event comes in trough the event port.
     97            void execute(unsigned int clientId, bool fromCallback = false); //!< Executes the Scripts code for the input client, depending on the mode.
    9098
    9199            /**
     
    139147                { return this->needsGraphics_; }
    140148
     149            /**
     150            @brief Set whether the code is executed for all players or just for the player triggering the Script.
     151            @param forAll If true the code is executed for all players.
     152            */
     153            void setForAll(bool forAll)
     154                { this->forAll_ = forAll; }
     155            /**
     156            @brief Get whether the Script executes its code for all players or just for the player triggering the Script.
     157            @return Returns true if the code is executed for all players, false if not.
     158            */
     159            bool isForAll(void)
     160                { return this->forAll_; }
     161
     162            virtual void clientConnected(unsigned int clientId);
     163            virtual void clientDisconnected(unsigned int clientid) {}
     164
    141165        private:
    142166            //! Static variables to avoid magic strings.
     
    150174            int times_; //!< The number of times the Scripts code is executed at the most. -1 denotes infinity.
    151175            bool needsGraphics_; //!< Whether the code to be executed needs graphics.
     176            bool forAll_; //!< Whether the code is executed for all players (in a multiplayer setup) or just for the one triggering the Script.
     177
     178            std::string modeStr_;
     179
     180            std::vector<unsigned int> clientCallbacks_;
     181            float counter_;
    152182
    153183            LuaState* luaState_; //!< The LuaState to execute the code in lua.
    154184            int remainingExecutions_; //!< The number of remainign executions. -1 denotes infinity.
     185
     186            void registerVariables(void);
     187            void modeChanged();
    155188
    156189            /**
Note: See TracChangeset for help on using the changeset viewer.