Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2011, 8:53:28 PM (13 years ago)
Author:
dafrick
Message:

Merging presentation branch back into trunk.
There are many new features and also a lot of other changes and bugfixes, if you want to know, digg through the svn log.
Not everything is yet working as it should, but it should be fairly stable. If you habe any bug reports, just send me an email.

Location:
code/trunk
Files:
4 deleted
66 edited
45 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/CMakeLists.txt

    r8457 r8706  
    2727
    2828ADD_SUBDIRECTORY(designtools)
     29ADD_SUBDIRECTORY(gametypes)
    2930ADD_SUBDIRECTORY(notifications)
    3031ADD_SUBDIRECTORY(objects)
     
    3435ADD_SUBDIRECTORY(portals)
    3536ADD_SUBDIRECTORY(questsystem)
     37ADD_SUBDIRECTORY(tetris)
    3638ADD_SUBDIRECTORY(weapons)
     39ADD_SUBDIRECTORY(docking)
  • code/trunk/src/modules/notifications/CMakeLists.txt

    r7403 r8706  
    11SET_SOURCE_FILES(NOTIFICATIONS_SRC_FILES
    2   Notification.cc
    32  NotificationDispatcher.cc
    43  NotificationManager.cc
    54  NotificationQueue.cc
     5  NotificationQueueCEGUI.cc
    66)
    77
     
    1313  TOLUA_FILES
    1414    NotificationManager.h
    15     NotificationQueue.h
     15    NotificationQueueCEGUI.h
    1616  PCH_FILE
    1717    NotificationsPrecompiledHeaders.h
  • code/trunk/src/modules/notifications/NotificationDispatcher.cc

    r7552 r8706  
    4141
    4242#include "infos/PlayerInfo.h"
     43#include "interfaces/NotificationListener.h"
    4344#include "interfaces/PlayerTrigger.h"
    4445#include "worldentities/pawns/Pawn.h"
    45 
    46 #include "NotificationManager.h"
    4746
    4847namespace orxonox
     
    6160        RegisterObject(NotificationDispatcher);
    6261
    63         this->sender_ = NotificationManager::NONE;
     62        this->sender_ = NotificationListener::NONE;
    6463        this->registerVariables();
    6564    }
     
    114113        {
    115114            const std::string message = this->createNotificationMessage();
    116             NotificationManager::sendNotification(message, clientId, this->getSender());
     115            // TODO: Make the type configurable.
     116            NotificationListener::sendNotification(message, this->getSender(), notificationMessageType::info, notificationSendMode::network, clientId);
    117117        }
    118118        else if(GameMode::isServer())
     
    140140
    141141        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    142         Pawn* pawn = NULL;
     142        PlayerInfo* player = NULL;
    143143
    144144        // If the trigger is a PlayerTrigger.
     
    148148                return false;
    149149            else
    150                 pawn = pTrigger->getTriggeringPlayer();
     150                player = pTrigger->getTriggeringPlayer();
    151151        }
    152152        else
    153153            return false;
    154154
    155         if(pawn == NULL)
     155        if(player == NULL)
    156156        {
    157157            COUT(4) << "The NotificationDispatcher was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    158             return false;
    159         }
    160 
    161         // Extract the PlayerInfo from the Pawn.
    162         PlayerInfo* player = pawn->getPlayer();
    163 
    164         if(player == NULL)
    165         {
    166             COUT(3) << "The PlayerInfo* is NULL." << std::endl;
    167158            return false;
    168159        }
  • code/trunk/src/modules/notifications/NotificationManager.cc

    r8079 r8706  
    3636#include "core/command/ConsoleCommand.h"
    3737#include "core/CoreIncludes.h"
    38 #include "core/GUIManager.h"
    3938#include "core/LuaState.h"
    40 #include "network/Host.h"
    41 #include "network/NetworkFunction.h"
    4239#include "util/ScopedSingletonManager.h"
    4340
    4441#include "interfaces/NotificationListener.h"
    4542
    46 #include "Notification.h"
    4743#include "NotificationQueue.h"
    48 
    49 #include "ToluaBindNotifications.h"
     44#include "NotificationQueueCEGUI.h"
    5045
    5146namespace orxonox
    5247{
    5348
    54     const std::string NotificationManager::ALL("all");
    55     const std::string NotificationManager::NONE("none");
    56 
    57     // Register tolua_open function when loading the library.
    58     DeclareToluaInterface(Notifications);
    59 
    6049    ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
    6150
    62     // Setting console command to enter the edit mode.
    63     SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode);
    64 
    65     registerStaticNetworkFunction(NotificationManager::sendNotification);
    66 
    6751    /**
    6852    @brief
     
    7357        RegisterRootObject(NotificationManager);
    7458
    75         this->highestIndex_ = 0;
    76 
    77         ModifyConsoleCommand("enterEditMode").setObject(this);
    78 
    7959        COUT(3) << "NotificatioManager created." << std::endl;
    8060    }
     
    8666    NotificationManager::~NotificationManager()
    8767    {
    88         ModifyConsoleCommand("enterEditMode").setObject(NULL);
    89 
    9068        // Destroys all Notifications.
    9169        for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it!= this->allNotificationsList_.end(); it++)
     
    10684        while(it != this->queues_.end())
    10785        {
    108             it->second->destroy(true);
     86            it->second->destroy();
    10987            it = this->queues_.begin();
    11088        }
     
    11593    /**
    11694    @brief
    117         Sends a Notification with the specified message to the specified client from the specified sender.
     95        Creates and registers a Notification with the input message from the input sender.
     96        This is called by the NotificationListener, whenever a new notification arrives.
    11897    @param message
    119         The message that should be sent.
    120     @param clientId
    121         The id of the client the notification should be sent to.
     98        The message of the new Notification.
    12299    @param sender
    123         The sender that sent the notification.
    124     @param isLocal
    125         If this is set to true (false is default), then the Notification is sent to the client where this function is executed, meaning the Notification is sent locally.
    126     */
    127     /*static*/ void NotificationManager::sendNotification(const std::string& message, unsigned int clientId, const std::string& sender, bool isLocal)
    128     {
    129         // If we're in standalone mode or we're already no the right client we create and send the Notification.
    130         if(GameMode::isStandalone() || isLocal || Host::getPlayerID() == clientId)
    131         {
    132             Notification* notification = new Notification(message, sender);
    133             if(NotificationManager::getInstance().registerNotification(notification))
    134                 COUT(3) << "Notification \"" << notification->getMessage() << "\" sent." << std::endl;
    135         }
    136         // If we're on the server (and the server is not the intended recipient of the Notification) we send it over the network.
    137         else if(GameMode::isServer())
    138         {
    139             callStaticNetworkFunction(NotificationManager::sendNotification, clientId, message, clientId, sender);
    140         }
    141     }
    142 
    143     /**
    144     @brief
    145         Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationListeners associated with its sender.
     100        The name of the entity (of the collective) that sent the new Notification.
     101    @param type
     102        The type of the new Notification.
     103    @return
     104        Returns true if successful.
     105    */
     106    bool NotificationManager::registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type)
     107    {
     108        // TODO: Do something with the type.
     109        Notification* notification = new Notification(message, sender, type);
     110        return this->registerNotification(notification);
     111    }
     112
     113    /**
     114    @brief
     115        Executes the input command from the input sender.
     116        This is called by the NotificationListener, whenever a new command arrives.
     117    @param command
     118        The command to be executed,
     119    @param sender
     120        The The name of the entity (of the collective) that sent the command.
     121    @return
     122        Returns true if the command was successfully executed.
     123    */
     124    bool NotificationManager::executeCommand(notificationCommand::Value command, const std::string& sender)
     125    {
     126        bool commandExecuted = false;
     127        if(command == notificationCommand::clear)
     128        {
     129            if(this->commandClear(sender))
     130                commandExecuted = true;
     131        }
     132
     133        if(commandExecuted)
     134            COUT(3) << "Notification command \"" << NotificationListener::command2Str(command) << "\" executed." << endl;
     135
     136        return commandExecuted;
     137    }
     138
     139    /**
     140    @brief
     141        The clear command. Clears all NotificationQueues that have its sender as a target.
     142    @param sender
     143        The sender of the clear command.
     144    @return
     145        Returns true if the command was successfully executed by at least one NotificationQueue, false if it was not executed.
     146    */
     147    bool NotificationManager::commandClear(const std::string& sender)
     148    {
     149        bool all = (sender == NotificationListener::ALL);
     150        bool executed = false;
     151        // Clear all NotificationQueues that have the input sender as target.
     152        for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues.
     153        {
     154            const std::set<std::string>& set = it->second->getTargetsSet();
     155            // If either the sender is 'all', the NotificationQueue has as target all or the NotificationQueue has the input sender as a target.
     156            if(all || set.find(NotificationListener::ALL) != set.end() || set.find(sender) != set.end())
     157                executed = it->second->tidy() || executed;
     158        }
     159
     160        return executed;
     161    }
     162   
     163    /**
     164    @brief
     165        Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationQueues associated with its sender.
    146166    @param notification
    147167        The Notification to be registered.
     
    158178        this->allNotificationsList_.insert(std::pair<std::time_t, Notification*>(time, notification));
    159179
    160         if(notification->getSender() == NotificationManager::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.
     180        if(notification->getSender() == NotificationListener::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.
    161181            return true;
    162182
    163         bool all = false;
    164         if(notification->getSender() == NotificationManager::ALL) // If all are the sender, then the Notifications is added to every NotificationListener.
    165             all = true;
    166 
    167         // Insert the Notification in all NotificationListeners that have its sender as target.
    168         for(std::map<NotificationListener*, unsigned int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) // Iterate through all NotificationListeners.
    169         {
    170             const std::set<std::string>& set = it->first->getTargetsSet();
    171             bool bAll = set.find(NotificationManager::ALL) != set.end();
    172             // If either the Notification has as sender 'all', the NotificationListener displays all Notifications or the NotificationListener has the sender of the Notification as target.
     183        // If all are the sender, then the Notifications is added to every NotificationQueue.
     184        bool all = (notification->getSender() == NotificationListener::ALL);
     185
     186        // Insert the Notification in all NotificationQueues that have its sender as target.
     187        for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues.
     188        {
     189            const std::set<std::string>& set = it->second->getTargetsSet();
     190            bool bAll = set.find(NotificationListener::ALL) != set.end();
     191            // If either the Notification has as sender 'all', the NotificationQueue displays all Notifications or the NotificationQueue has the sender of the Notification as target.
    173192            if(all || bAll || set.find(notification->getSender()) != set.end())
    174193            {
    175194                if(!bAll)
    176                     this->notificationLists_[it->second]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationListener.
    177                 it->first->update(notification, time); // Update the NotificationListener.
     195                    this->notificationLists_[it->second->getName()]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationQueue.
     196                it->second->update(notification, time); // Update the NotificationQueue.
    178197            }
    179198        }
     
    186205    /**
    187206    @brief
    188         Unregisters a Notification within the NotificationManager for a given NotificationListener.
     207        Unregisters a Notification within the NotificationManager for a given NotificationQueue.
    189208    @param notification
    190209        A pointer to the Notification to be unregistered.
    191     @param listener
    192         A pointer to the NotificationListener the Notification is unregistered for.
    193     */
    194     void NotificationManager::unregisterNotification(Notification* notification, NotificationListener* listener)
     210    @param queue
     211        A pointer to the NotificationQueue the Notification is unregistered for.
     212    */
     213    void NotificationManager::unregisterNotification(Notification* notification, NotificationQueue* queue)
    195214    {
    196215        assert(notification);
    197         assert(listener);
    198 
    199         // Remove the Notification from the list of Notifications of the input NotificationListener.
    200         this->removeNotification(notification, *(this->notificationLists_.find(this->listenerList_.find(listener)->second)->second));
    201 
    202         COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from listener (&" << listener << ")" << std::endl;
     216        assert(queue);
     217
     218        // Remove the Notification from the list of Notifications of the input NotificationQueue.
     219        this->removeNotification(notification, *(this->notificationLists_.find(queue->getName())->second));
     220
     221        COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from NotificationQueue " << queue->getName() << "." << std::endl;
    203222    }
    204223
     
    230249    /**
    231250    @brief
    232         Registers a NotificationListener within the NotificationManager.
    233     @param listener
    234         The NotificationListener to be registered.
    235     @return
    236         Returns true if successful.  Fales if the NotificationListener is already registered.
    237     */
    238     bool NotificationManager::registerListener(NotificationListener* listener)
    239     {
    240         assert(listener);
    241 
    242         // If the NotificationListener is already registered.
    243         if(this->listenerList_.find(listener) != this->listenerList_.end())
    244             return false;
    245 
    246         this->highestIndex_ += 1;
    247         unsigned int index = this->highestIndex_; // An identifier that identifies each registered NotificationListener uniquely.
    248 
    249         this->listenerList_[listener] = index; // Add the NotificationListener to the list of NotificationListeners.
    250 
    251         const std::set<std::string>& set = listener->getTargetsSet();
    252 
    253         // If all senders are the target of the NotificationListener, then the list of Notifications for that specific NotificationListener is the same as the list of all Notifications.
    254         bool bAll = set.find(NotificationManager::ALL) != set.end();
    255         std::multimap<std::time_t, Notification*>* map = NULL;
    256         if(bAll)
    257             this->notificationLists_[index] = &this->allNotificationsList_;
    258         // Else a new list (resp. multimap) is created and added to the list of Notification lists for NotificationListeners.
    259         else
    260         {
    261             this->notificationLists_[index] = new std::multimap<std::time_t, Notification*>;
    262             map = this->notificationLists_[index];
    263         }
    264 
    265         // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener.
    266         for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
    267         {
    268             if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target.
    269                 map->insert(std::pair<std::time_t, Notification*>(it->first, it->second));
    270         }
    271 
    272         listener->update(); // Update the listener.
    273 
    274         COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl;
    275 
    276         return true;
    277     }
    278 
    279     /**
    280     @brief
    281         Unregisters a NotificationListener within the NotificationManager.
    282     @param listener
    283         The NotificationListener to be unregistered.
    284     */
    285     void NotificationManager::unregisterListener(NotificationListener* listener)
    286     {
    287         assert(listener);
    288 
    289         unsigned int identifier = this->listenerList_.find(listener)->second;
    290         std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(identifier)->second;
    291 
    292         // If the map is not the map of all Notifications, make sure all Notifications are unregistered.
    293         std::multimap<std::time_t, Notification*>::iterator it = map->begin();
    294         if(map != &this->allNotificationsList_)
    295         {
    296             while(it != map->end())
    297             {
    298                 this->unregisterNotification(it->second, listener);
    299                 it = map->begin();
    300             }
    301             delete map;
    302         }
    303 
    304         COUT(4) << "NotificationListener '" << identifier << "' unregistered with the NotificationManager." << std::endl;
    305 
    306         // Remove the NotificationListener from the list of NotificationListeners.
    307         this->listenerList_.erase(listener);
    308         // Remove the Notifications list that was associated with the input NotificationListener.
    309         this->notificationLists_.erase(identifier);
    310     }
    311 
    312     /**
    313     @brief
    314         Fetches the Notifications for a specific NotificationListener in a specified timeframe and stores them in the input map.
    315     @param listener
    316         The NotificationListener the Notifications are fetched for.
     251        Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map.
     252    @param queue
     253        The NotificationQueue the Notifications are fetched for.
    317254    @param map
    318255        A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
     
    324261        Returns true if successful.
    325262    */
    326     void NotificationManager::getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
    327     {
    328         assert(listener);
     263    void NotificationManager::getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
     264    {
     265        assert(queue);
    329266        assert(map);
    330267
    331         std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; // All the Notifications for the input NotificationListener.
     268        std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue.
    332269
    333270        std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest;
     
    342279    /**
    343280    @brief
    344         Enters the edit mode of the NotificationLayer.
    345     */
    346     void NotificationManager::enterEditMode(void)
    347     {
    348         if(GameMode::showsGraphics())
    349         {
    350             GUIManager::getInstance().hideGUI("NotificationLayer");
    351             GUIManager::getInstance().showGUI("NotificationLayer", false, false);
    352             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.enterEditMode()");
     281        Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map.
     282    @param queue
     283        The NotificationQueue the Notifications are fetched for.
     284    @param map
     285        A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
     286    @param numberOfNotifications
     287        The number of newest Notifications to be got.
     288    @return
     289        Returns true if successful.
     290    */
     291    void NotificationManager::getNewestNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications)
     292    {
     293        assert(queue);
     294        assert(map);
     295
     296        std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue.
     297
     298        if(!notifications->empty()) // If the list of Notifications is not empty.
     299        {
     300            std::multimap<std::time_t,Notification*>::iterator it = notifications->end();
     301            for(int i = 0; i < numberOfNotifications; i++) // Iterate through the Notifications from the newest until we have the specified number of notifications.
     302            {
     303                it--;
     304                map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); // Add the found Notifications to the map.
     305                if(it == notifications->begin())
     306                    break;
     307            }
    353308        }
    354309    }
     
    357312    @brief
    358313        Registers a NotificationQueue.
    359         This makes sure that the NotificationQueue can be attained through lua by name. It also makes sure that the NotificationQueue is destroyed upon destruction of the NotificationManager.
     314        This makes sure that the NotificationQueue can be accessed through lua by name. It also makes sure that the NotificationQueue is destroyed upon destruction of the NotificationManager.
    360315    @param queue
    361316        A pointer to the NotificationQueue to be registered.
     
    365320    bool NotificationManager::registerQueue(NotificationQueue* queue)
    366321    {
     322        assert(queue);
     323
     324        // If the NotificationQueue is already registered.
     325        if(this->queues_.find(queue->getName()) != this->queues_.end())
     326            return false;
     327
     328        this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)); // Add the NotificationQueue to the list of NotificationQueues.
     329
     330        const std::set<std::string>& set = queue->getTargetsSet();
     331
     332        // If all senders are the target of the NotificationQueue, then the list of Notifications for that specific NotificationQueue is the same as the list of all Notifications.
     333        bool bAll = set.find(NotificationListener::ALL) != set.end();
     334        std::multimap<std::time_t, Notification*>* map = NULL;
     335        if(bAll)
     336            this->notificationLists_[queue->getName()] = &this->allNotificationsList_;
     337        // Else a new list (resp. multimap) is created and added to the list of Notification lists for NotificationQueues.
     338        else
     339        {
     340            this->notificationLists_[queue->getName()] = new std::multimap<std::time_t, Notification*>;
     341            map = this->notificationLists_[queue->getName()];
     342        }
     343
     344        // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationQueue.
     345        for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
     346        {
     347            if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target.
     348                map->insert(std::pair<std::time_t, Notification*>(it->first, it->second));
     349        }
     350
     351        queue->update(); // Update the queue.
     352       
    367353        COUT(4) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << std::endl;
    368         return this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)).second;
     354        return true;
    369355    }
    370356
     
    377363    void NotificationManager::unregisterQueue(NotificationQueue* queue)
    378364    {
     365        assert(queue);
     366
     367        std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(queue->getName())->second;
     368
     369        // If the map is not the map of all Notifications, make sure all Notifications are unregistered.
     370        std::multimap<std::time_t, Notification*>::iterator it = map->begin();
     371        if(map != &this->allNotificationsList_)
     372        {
     373            while(it != map->end())
     374            {
     375                this->unregisterNotification(it->second, queue);
     376                it = map->begin();
     377            }
     378            delete map;
     379        }
     380
     381        // Remove the NotificationQueue from the list of NotificationQueues.
     382        this->queues_.erase(queue->getName());
     383        // Remove the Notifications list that was associated with the input NotificationQueue.
     384        this->notificationLists_.erase(queue->getName());
     385       
    379386        COUT(4) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << std::endl;
    380         this->queues_.erase(queue->getName());
    381     }
    382 
    383     /**
    384     @brief
    385         Loads all the NotificationQueues that should exist.
    386     */
    387     void NotificationManager::loadQueues(void)
    388     {
    389         new NotificationQueue("all");
    390     }
    391 
    392     /**
    393     @brief
    394         Creates a new NotificationQueue.
    395         This is used in lua.
    396     @param name
    397         The name of the new NotificationQueue.
    398     */
    399     void NotificationManager::createQueue(const std::string& name)
    400     {
    401         new NotificationQueue(name);
    402387    }
    403388
     
    420405    }
    421406
     407    /**
     408    @brief
     409        Loads all the NotificationQueues that should exist.
     410    */
     411    void NotificationManager::loadQueues(void)
     412    {
     413        /*NotificationQueueCEGUI* allQueue = new NotificationQueueCEGUI("all");
     414        allQueue->setDisplaySize(Vector2(0.5, 0));
     415        allQueue->setPosition(Vector4(0.0, 10, 0.3, 0));
     416
     417        NotificationQueueCEGUI* infoQueue = new NotificationQueueCEGUI("info", "gameinfo", 1, -1);
     418        infoQueue->setPosition(Vector4(0.2, 0, 0.8, 0));
     419        infoQueue->setFontSize(24);
     420        infoQueue->setFontColor(Vector4(1.0, 1.0, 0.0, 0.8));
     421        infoQueue->setAlignment("HorzCentred");
     422        infoQueue->setDisplaySize(Vector2(0.6, 0.0));*/
     423    }
     424
     425    // Notification class
     426
     427    /**
     428    @brief
     429        Constructor. Creates a Notification with the input message and sender.
     430    @param message
     431        The message of the Notification.
     432    @param sender
     433        The sender of the Notification.
     434    @param type
     435
     436    */
     437    Notification::Notification(const std::string& message, const std::string& sender, notificationMessageType::Value type)
     438    {
     439        this->initialize();
     440        this->message_ = message;
     441        this->sender_ = sender;
     442        this->type_ = type;
     443    }
     444
     445    /**
     446    @brief
     447        Destructor.
     448    */
     449    Notification::~Notification()
     450    {
     451
     452    }
     453
     454    /**
     455    @brief
     456        Registers the object and sets some default values.
     457    */
     458    void Notification::initialize(void)
     459    {
     460        this->message_.clear();
     461        this->sender_ = NotificationListener::NONE;
     462    }
     463
    422464}
  • code/trunk/src/modules/notifications/NotificationManager.h

    r7552 r8706  
    4242#include <string>
    4343
     44#include "core/OrxonoxClass.h"
    4445#include "util/Singleton.h"
    45 #include "core/OrxonoxClass.h"
     46#include "interfaces/NotificationListener.h"
    4647
    4748namespace orxonox // tolua_export
     
    5051    /**
    5152    @brief
    52         The Singleton NotificationManager functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationListener "NotificationListeners".
    53         It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationListener "NotificationListeners".
    54         It also provides a static function to send @ref orxonox::Notification "Notifications" and works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer.
     53        A Notification represents a short message used to inform the player about something that just happened. With the @ref orxonox::NotificationManager "NotificationManager" a Notification can be sent from any part of orxonox and is then displayed by the proper @ref orxonox::NotificationQueue "NotificationQueue(s)" (depending on which senders the specific @ref orxonox::NotificationQueue "NotificationQueues" accepts).
     54
     55        A Notification is just a data structure that is used internally by the Notifications module.
     56
     57    @author
     58        Damian 'Mozork' Frick
     59
     60    @ingroup Notifications
     61    */
     62    class _NotificationsExport Notification
     63    {
     64        public:
     65            Notification(const std::string& message, const std::string& sender, notificationMessageType::Value type);
     66            virtual ~Notification();
     67
     68            /**
     69            @brief Destroys the Notification.
     70            */
     71            void destroy(void)
     72                { delete this; }
     73
     74            /**
     75            @brief Get the message of the Notification.
     76            @return Returns the message of the Notification.
     77            */
     78            inline const std::string & getMessage(void) const
     79                { return this->message_; }
     80
     81            /**
     82            @brief Get the sender of the Notification.
     83            @return Returns the sender of the Notification.
     84            */
     85            inline const std::string & getSender(void) const
     86                { return this->sender_; }
     87
     88            /**
     89            @brief Get the type of the Notification.
     90            @return Returns an enum with the type of the Notification.
     91            */
     92            inline notificationMessageType::Value getType(void) const
     93                { return this->type_; }
     94
     95        private:
     96            std::string message_; //!< The Notification message.
     97            std::string sender_; //!< The sender of the notification.
     98            notificationMessageType::Value type_; //!< The type of the notification.
     99
     100            void initialize(void); //!< Registers the object and sets some default values.
     101
     102    };
     103
     104    /**
     105    @brief
     106        The Singleton NotificationManager is a NotificationListener and functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationQueue "NotificationQueues".
     107        It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationQueue "NotificationQueues".
     108        It also works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer.
    55109
    56110    @author
     
    60114    */
    61115    class _NotificationsExport NotificationManager // tolua_export
    62         : public Singleton<NotificationManager>, public OrxonoxClass
     116        : public Singleton<NotificationManager>, public NotificationListener
    63117    { // tolua_export
    64118            friend class Singleton<NotificationManager>;
     
    67121            virtual ~NotificationManager();
    68122
    69             virtual void preDestroy(void); //!< Is called before the object is destroyed.
     123            virtual void preDestroy(void); // Is called before the object is destroyed.
    70124
    71125            /**
     
    75129            static NotificationManager& getInstance() { return Singleton<NotificationManager>::getInstance(); } // tolua_export
    76130
    77             static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners.
    78             static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener.
     131            virtual bool registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type);
     132            virtual bool executeCommand(notificationCommand::Value command, const std::string& sender);
    79133
    80             //! Sends a Notification with the specified message to the specified client from the specified sender.
    81             static void sendNotification(const std::string& message, unsigned int clientId, const std::string& sender = NotificationManager::NONE, bool isLocal = false);
     134            bool registerNotification(Notification* notification); // Registers a Notification within the NotificationManager.
     135            void unregisterNotification(Notification* notification, NotificationQueue* queue); // Unregisters a Notification within the NotificationManager for a given NotificationQueue.
    82136
    83             bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
    84             void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager for a given NotificationListener.
    85             bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager.
    86             void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager.
    87 
    88             void getNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Fetches the Notifications for a specific NotificationListener in a specified timeframe and stores them in the input map.
     137            void getNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); // Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map.
    89138
    90139            /**
    91             @brief Fetches the Notifications for a specific NotificationListener in a timeframe from now-timeDelay to now and stores them in the input map.
    92             @param listener The NotificationListener the Notifications are fetched for.
     140            @brief Fetches the Notifications for a specific NotificationQueue in a timeframe from (now-timeDelay) to now and stores them in the input map.
     141            @param queue The NotificationQueue the Notifications are fetched for.
    93142            @param map A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
    94143            @param timeDelay The timespan.
    95144            @return Returns true if successful.
    96145            */
    97             void getNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int timeDelay)
    98                 { this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
     146            void getNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int timeDelay)
     147                { this->getNotifications(queue, map, std::time(0)-timeDelay, std::time(0)); }
    99148
    100             void enterEditMode(void); //!< Enters the edit mode of the NotificationLayer.
     149            void getNewestNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications); // Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map.
    101150
    102             bool registerQueue(NotificationQueue* queue); //!< Registers a NotificationQueue.
    103             void unregisterQueue(NotificationQueue* queue); //!< Unregisters a NotificationQueue.
     151            bool registerQueue(NotificationQueue* queue); // Registers a NotificationQueue.
     152            void unregisterQueue(NotificationQueue* queue); // Unregisters a NotificationQueue.
    104153
    105             // tolua_begin
    106             void loadQueues(void); //!< Loads all the NotificationQueues that should exist.
    107             void createQueue(const std::string& name); //!< Creates a new NotificationQueue.
    108             orxonox::NotificationQueue* getQueue(const std::string & name); //!< Get the NotificationQueue with the input name.
    109             // tolua_end
     154            void loadQueues(void); // tolua_export // Loads all the NotificationQueues that should exist.
     155
     156            NotificationQueue* getQueue(const std::string & name); // Get the NotificationQueue with the input name.
    110157
    111158        private:
    112159            static NotificationManager* singletonPtr_s;
    113160
    114             unsigned int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
    115 
    116161            std::multimap<std::time_t, Notification*> allNotificationsList_; //!< Container where all Notifications are stored.
    117             std::map<NotificationListener*, unsigned int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
    118             std::map<int,std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
     162            std::map<const std::string, std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationQueue), are stored.
    119163
    120164            std::map<const std::string, NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager.
    121165
    122             bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input Notification form an input map.
     166            bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); // Helper method that removes an input Notification form an input map.
     167           
     168            // Commands
     169            bool commandClear(const std::string& sender); // The clear command. Clears all NotificationQueues that have its sender as a target.
    123170
    124171    }; // tolua_export
  • code/trunk/src/modules/notifications/NotificationQueue.cc

    r8079 r8706  
    3838
    3939#include "core/CoreIncludes.h"
    40 #include "core/GameMode.h"
    41 #include "core/GUIManager.h"
    42 #include "core/LuaState.h"
    43 #include "util/Convert.h"
     40#include "core/XMLPort.h"
    4441#include "util/SubString.h"
    45 
    46 #include "Notification.h"
    4742
    4843namespace orxonox
    4944{
    5045
    51     /**
    52     @brief
    53         Constructor. Creates and initializes the object.
     46    CreateFactory(NotificationQueue);
     47   
     48    /**
     49    @brief
     50        Default constructor. Registers and initializes the object.
     51    @param creator
     52        The creator of the NotificationQueue.
     53    */
     54    NotificationQueue::NotificationQueue(BaseObject* creator) : BaseObject(creator), Synchronisable(creator), registered_(false)
     55    {
     56        RegisterObject(NotificationQueue);
     57
     58        this->size_ = 0;
     59        this->tickTime_ = 0.0f;
     60        this->maxSize_ = NotificationQueue::DEFAULT_SIZE;
     61        this->displayTime_ = NotificationQueue::DEFAULT_DISPLAY_TIME;
     62
     63        this->creationTime_ = std::time(0);
     64       
     65        this->registerVariables();
     66    }
     67
     68    // TODO move to docu.
     69    /**
     70    @brief
     71        Constructor. Registers and initializes the object.
     72    @param creator
     73        The creator of the NotificationQueue
    5474    @param name
    5575        The name of the new NotificationQueue. It needs to be unique
     
    6282        The time during which a Notification is (at most) displayed.
    6383    */
    64     NotificationQueue::NotificationQueue(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime)
    65     {
    66         this->registered_ = false;
    67 
    68         RegisterRootObject(NotificationQueue);
    69 
    70         // Initialize.
    71         this->size_ = 0;
    72         this->tickTime_ = 0.0f;
    73 
    74         // Sets the input values.
    75         this->setTargets(senders);
    76         this->name_ = name;
    77         this->maxSize_ = size;
    78         this->setDisplayTime(displayTime);
    79 
     84
     85    /**
     86    @brief
     87        Destructor.
     88    */
     89    NotificationQueue::~NotificationQueue()
     90    {
     91        this->targets_.clear();
     92
     93        if(this->isRegistered()) // If the NotificationQueue is registered.
     94        {
     95            this->clear(true);
     96
     97            // Unregister with the NotificationManager.
     98            NotificationManager::getInstance().unregisterQueue(this);
     99        }
     100    }
     101
     102    /**
     103    @brief
     104        Is called when the name of the NotificationQueue has changed.
     105        Clears and re-creates the NotificationQueue.
     106    */
     107    void NotificationQueue::changedName(void)
     108    {
     109        SUPER(NotificationQueue, changedName);
     110
     111        if(this->isRegistered())
     112            this->clear();
     113           
     114        this->create();
     115
     116        this->targetsChanged();
     117        this->maxSizeChanged();
     118        this->displayTimeChanged();
     119    }
     120
     121    /**
     122    @brief
     123        Creates the NotificationQueue.
     124    */
     125    void NotificationQueue::create(void)
     126    {
    80127        // Register the NotificationQueue with the NotificationManager.
    81128        bool queueRegistered = NotificationManager::getInstance().registerQueue(this);
     
    88135        }
    89136
    90         this->create(); // Creates the NotificationQueue in lua.
    91 
    92         // Register the NotificationQueue as NotificationListener with the NotificationManager.
    93         bool listenerRegistered = NotificationManager::getInstance().registerListener(this);
    94         if(!listenerRegistered) // If the registration has failed.
    95         {
    96             this->registered_ = false;
    97             // Remove the NotificationQueue in lua.
    98             if(GameMode::showsGraphics())
    99                 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
    100             NotificationManager::getInstance().unregisterQueue(this);
    101             COUT(1) << "Error: NotificationQueue '" << this->getName() << "' could not be registered." << std::endl;
    102             return;
    103         }
    104 
    105137        COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
    106     }
    107 
    108     /**
    109     @brief
    110         Destructor.
    111     */
    112     NotificationQueue::~NotificationQueue()
    113     {
    114         this->targets_.clear();
    115 
    116         if(this->registered_) // If the NotificationQueue is registered.
    117         {
    118             this->clear(true);
    119 
    120             // Unregister with the NotificationManager.
    121             NotificationManager::getInstance().unregisterListener(this);
    122             NotificationManager::getInstance().unregisterQueue(this);
    123         }
    124     }
    125 
    126     /**
    127     @brief
    128         Destroys the NotificationQueue.
    129         Used in lua and NotificationManager.
    130     @param noGraphics
    131         If this is set to true (false is default), then the queue is not removed in lua. This is used to destroy the queue, after the GUIManager has been destroyed.
    132     */
    133     void NotificationQueue::destroy(bool noGraphics)
    134     {
    135         // Remove the NotificationQueue in lua.
    136         if(GameMode::showsGraphics() && !noGraphics)
    137             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
    138 
    139         COUT(3) << "NotificationQueue '" << this->getName() << "' destroyed." << std::endl;
    140 
    141         this->OrxonoxClass::destroy();
    142     }
    143 
    144     /**
    145     @brief
    146         Creates the NotificationQueue in lua.
    147     */
    148     void NotificationQueue::create(void)
    149     {
    150         if(GameMode::showsGraphics())
    151             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() +  "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
    152138    }
    153139
     
    161147    {
    162148        this->tickTime_ += dt; // Add the time interval that has passed to the time counter.
    163         if(this->tickTime_ >= 1.0) // If the time counter is greater than 1s all Notifications that have expired are removed, if it is smaller we wait to the next tick.
    164         {
    165             this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containig the current time.
     149        if(this->displayTime_ != INF && this->tickTime_ >= 1.0) // If the time counter is greater than 1 s all Notifications that have expired are removed, if it is smaller we wait to the next tick.
     150        {
     151            this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containing the current time.
    166152
    167153            std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator it = this->ordering_.begin();
     
    177163    }
    178164
     165    void NotificationQueue::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     166    {
     167        SUPER(NotificationQueue, XMLPort, xmlelement, mode);
     168
     169        XMLPortParam(NotificationQueue, "targets", setTargets, getTargets, xmlelement, mode).defaultValues(NotificationListener::ALL);
     170        XMLPortParam(NotificationQueue, "size", setMaxSize, getMaxSize, xmlelement, mode);
     171        XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlelement, mode);
     172    }
     173   
     174   
     175    /**
     176    @brief
     177        Registers Variables to be Synchronised.
     178        Registers Variables which have to be synchronised to the network system.
     179      */
     180    void NotificationQueue::registerVariables()
     181    {
     182        registerVariable( this->name_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::changedName));
     183        registerVariable( this->maxSize_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::maxSizeChanged));
     184        registerVariable( this->targets_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::targetsChanged));
     185        registerVariable( this->displayTime_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::displayTimeChanged));
     186    }
     187
    179188    /**
    180189    @brief
    181190        Updates the NotificationQueue.
    182191        Updates by clearing the queue and requesting all relevant Notifications from the NotificationManager and inserting them into the queue.
     192        This is called by the NotificationManager when the Notifications have changed so much, that the NotificationQueue may have to re-initialize his operations.
    183193    */
    184194    void NotificationQueue::update(void)
     
    188198        std::multimap<std::time_t, Notification*>* notifications = new std::multimap<std::time_t, Notification*>;
    189199        // Get the Notifications sent in the interval from now to now minus the display time.
    190         NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_);
     200        if(this->displayTime_ == INF)
     201            NotificationManager::getInstance().getNewestNotifications(this, notifications, this->getMaxSize());
     202        else
     203            NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_);
    191204
    192205        if(!notifications->empty())
    193206        {
    194             // Add all Notifications.
     207            // Add all Notifications that have been created after this NotificationQueue was created.
    195208            for(std::multimap<std::time_t, Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++)
    196                 this->push(it->second, it->first);
     209            {
     210                if(it->first >= this->creationTime_)
     211                    this->push(it->second, it->first);
     212            }
    197213        }
    198214
     
    222238    @brief
    223239        Adds (pushes) a Notification to the NotificationQueue.
    224         It inserts it into the storage containers, creates a corresponding container and pushes the Notification message to the GUI.
     240        It inserts it into the storage containers, creates a corresponding container and pushes the notification message to the GUI.
    225241    @param notification
    226242        The Notification to be pushed.
     
    246262        this->notifications_.insert(this->notifications_.begin(), container);
    247263
    248         // Push the Notification to the GUI.
    249         if(GameMode::showsGraphics())
    250             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
     264        // Inform that a Notification was pushed.
     265        this->notificationPushed(notification);
    251266
    252267        COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl;
     268        COUT(3) << "NotificationQueue \"" << this->getName() << "\": " << notification->getMessage() << endl;
    253269    }
    254270
     
    279295        delete container;
    280296
    281         // Pops the Notification from the GUI.
    282         if(GameMode::showsGraphics())
    283             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")");
     297        // Inform that a Notification was popped.
     298        this->notificationPopped();
    284299    }
    285300
     
    305320        delete *containerIterator;
    306321
    307         // Removes the Notification from the GUI.
    308         if(GameMode::showsGraphics())
    309             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");
     322        // TODO: index automatically cast?
     323        // Inform that a Notification was removed.
     324        this->notificationRemoved(index);
    310325    }
    311326
     
    314329        Clears the NotificationQueue by removing all NotificationContainers.
    315330    @param noGraphics
    316         If this is eset to true the GUI is not informed of the clearing of the NotificationQueue. This is needed only internally.
     331        If this is set to true the GUI is not informed of the clearing of the NotificationQueue. This is needed only internally.
    317332    */
    318333    void NotificationQueue::clear(bool noGraphics)
     
    326341        this->notifications_.clear();
    327342        this->size_ = 0;
    328 
    329         // Clear the NotificationQueue in the GUI.
    330         if(GameMode::showsGraphics() && !noGraphics)
    331             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");
    332343    }
    333344
     
    354365            return;
    355366
     367        if(size == 0)
     368        {
     369            COUT(2) << "Trying to set maximal size of NotificationQueue '" << this->getName() << "' to 0. Ignoring..." << endl;
     370            return;
     371        }
     372       
    356373        this->maxSize_ = size;
    357 
    358         if(this->registered_)
     374        this->maxSizeChanged();
     375    }
     376
     377    /**
     378    @brief
     379        Is called when the maximum number of displayed Notifications has changed.
     380    */
     381    void NotificationQueue::maxSizeChanged(void)
     382    {
     383        if(this->isRegistered())
    359384            this->update();
    360385    }
     
    364389        Sets the maximum number of seconds a Notification is displayed.
    365390    @param time
    366         The number of seconds the Notifications is displayed.
    367     @return
    368         Returns true if successful.
    369     */
    370     void NotificationQueue::setDisplayTime(unsigned int time)
     391        The number of seconds a Notification is displayed.
     392    */
     393    void NotificationQueue::setDisplayTime(int time)
    371394    {
    372395        if(this->displayTime_ == time)
    373396            return;
    374397
     398        if(time != NotificationQueue::INF && time <= 0)
     399        {
     400            COUT(2) << "Trying to set display time of NotificationQueue '" << this->getName() << "' to non-positive value. Ignoring..." << endl;
     401        }
     402           
    375403        this->displayTime_ = time;
    376 
    377         if(this->registered_)
     404        this->displayTimeChanged();
     405    }
     406
     407    /**
     408    @brief
     409        Is called when the maximum number of seconds a Notification is displayed has changed.
     410    */
     411    void NotificationQueue::displayTimeChanged(void)
     412    {
     413        if(this->isRegistered())
    378414            this->update();
    379415    }
     
    381417    /**
    382418    @brief
    383         Produces all targets of the NotificationQueue concatinated as string, with commas (',') as seperators.
     419        Produces all targets of the NotificationQueue concatenated as string, with commas (',') as separators.
    384420    @return
    385421        Returns the targets as a string.
     
    407443        The targets are the senders whose Notifications are displayed in this queue.
    408444    @param targets
    409         Accepts a string of targets, each seperated by commas (','), spaces are ignored.
     445        Accepts a string of targets, each separated by commas (','), spaces are ignored.
    410446    */
    411447    void NotificationQueue::setTargets(const std::string & targets)
     
    417453            this->targets_.insert(string[i]);
    418454
    419         if(this->registered_)
    420         {
    421             NotificationManager::getInstance().unregisterListener(this);
    422             NotificationManager::getInstance().registerListener(this);
    423         }
     455        this->targetsChanged();
     456    }
     457
     458    /**
     459    @brief
     460        Is called when the NotificationQueue's targets have changed.
     461    */
     462    void NotificationQueue::targetsChanged(void)
     463    {
     464        // TODO: Why?
     465        if(this->isRegistered())
     466        {
     467            NotificationManager::getInstance().unregisterQueue(this);
     468            NotificationManager::getInstance().registerQueue(this);
     469        }
     470    }
     471
     472    /**
     473    @brief
     474        Pops all Notifications from the NotificationQueue.
     475    @return
     476        Returns true if successful, false if not.
     477    */
     478    bool NotificationQueue::tidy(void)
     479    {
     480        while(this->size_ > 0)
     481            this->pop();
     482        return true;
    424483    }
    425484
  • code/trunk/src/modules/notifications/NotificationQueue.h

    r7552 r8706  
    4545#include "NotificationManager.h"
    4646
     47#include "core/BaseObject.h"
    4748#include "tools/interfaces/Tickable.h"
    48 #include "interfaces/NotificationListener.h"
    49 
    50 namespace orxonox // tolua_export
    51 { // tolua_export
     49#include "network/synchronisable/Synchronisable.h"
     50
     51namespace orxonox
     52{
    5253
    5354    /**
     
    7879        Displays @ref orxonox::Notification "Notifications" from specific senders.
    7980
    80         There are quite some parameters that influence the behaviour of the NotificationQueue:
     81        There are quite some parameters that influence the behavior of the NotificationQueue:
    8182        - @b name The name of the NotificationQueue. It needs to be unique.
    8283        - @b senders The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays.
     
    8990    @ingroup Notifications
    9091    */
    91     class _NotificationsExport NotificationQueue // tolua_export
    92         : public Tickable, public NotificationListener
    93     { // tolua_export
     92    class _NotificationsExport NotificationQueue : public BaseObject, public Tickable, public Synchronisable
     93    {
    9494
    9595        public:
    96             NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
     96            NotificationQueue(BaseObject* creator);
    9797            virtual ~NotificationQueue();
    9898
    99             //! Destroys the NotificationQueue.
    100             void destroy(bool noGraphics = false); // tolua_export
    101 
    102             virtual void tick(float dt); //!< To update from time to time.
    103 
    104             void update(void); //!< Updates the NotificationQueue.
    105             void update(Notification* notification, const std::time_t & time); //!< Updates the NotificationQueue by adding an new Notification.
     99            virtual void tick(float dt); // To update from time to time.
     100            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     101
     102            virtual void changedName(void);
     103           
     104            void update(void); // Updates the NotificationQueue.
     105            void update(Notification* notification, const std::time_t & time); // Updates the NotificationQueue by adding an new Notification.
    106106
    107107            // tolua_begin
     
    110110            @return Returns the name.
    111111            */
    112             inline const std::string& getName() const
    113                 { return this->name_; }
    114 
    115             void setMaxSize(unsigned int size); //!< Sets the maximum number of displayed Notifications.
     112            inline const std::string& getName(void) const
     113                { return this->BaseObject::getName(); }
     114
     115            void setMaxSize(unsigned int size); // Sets the maximum number of displayed Notifications.
    116116            /**
    117117            @brief Returns the maximum number of Notifications displayed.
    118118            @return Returns maximum size.
    119119            */
    120             inline unsigned int getMaxSize() const
     120            inline unsigned int getMaxSize(void) const
    121121                { return this->maxSize_; }
    122122
    123             void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed.
     123            void setDisplayTime(int time); // Sets the maximum number of seconds a Notification is displayed.
    124124            /**
    125125            @brief Returns the time interval the Notification is displayed.
    126126            @return Returns the display time.
    127127            */
    128             inline unsigned int getDisplayTime() const
     128            inline int getDisplayTime(void) const
    129129                { return this->displayTime_; }
    130130            // tolua_end
     131            void maxSizeChanged(void); // Is called when the maximum number of displayed Notifications has changed.
     132            void displayTimeChanged(void);
    131133
    132134            /**
     
    134136            @return Returns the size of the NotificationQueue.
    135137            */
    136             inline unsigned int getSize() const
     138            inline unsigned int getSize(void) const
    137139                { return this->size_; }
    138140
     
    141143            @return Returns a set of strings holding the different targets.
    142144            */
    143             inline const std::set<std::string> & getTargetsSet()
     145            inline const std::set<std::string> & getTargetsSet(void)
    144146                { return this->targets_; }
    145147
    146             // tolua_begin
    147             void setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
    148             const std::string& getTargets(void) const; //!< Returns a string consisting of the concatination of the targets.
    149             // tolua_end
    150 
    151         private:
     148            void setTargets(const std::string & targets); // Set the targets of this NotificationQueue.
     149            const std::string& getTargets(void) const; // Returns a string consisting of the concatenation of the targets.
     150            void targetsChanged(void); // Is called when the NotificationQueue's targets have changed.
     151
     152            /**
     153            @brief Check whether the NotificationQueue is registered with the NotificationManager.
     154            @return Returns true if it is registered, false if not.
     155            */
     156            inline bool isRegistered(void)
     157                { return this->registered_; }
     158
     159            bool tidy(void); // Pops all Notifications from the NotificationQueue.
     160           
     161        protected:
     162            void registerVariables();
     163           
     164            /**
     165            @brief Is called when a notification was pushed.
     166            @param notification The Notification that was pushed.
     167            */
     168            virtual void notificationPushed(Notification* notification) {}
     169            /**
     170            @brief Is called when a notification was popped.
     171            */
     172            virtual void notificationPopped(void) {}
     173            /**
     174            @brief Is called when a notification was removed.
     175            @param index The index the removed notification was at.
     176            */
     177            virtual void notificationRemoved(unsigned int index) {}
     178           
     179            virtual void clear(bool noGraphics = false); // Clears the NotificationQueue by removing all NotificationContainers.
     180
     181        protected:
    152182            static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
    153183            static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
    154 
    155             std::string name_; //!< The name of the NotificationQueue.
    156 
     184            static const int INF = -1; //!< Constant denoting infinity.
     185
     186            virtual void create(void); // Creates the NotificationQueue.
     187
     188        private:
     189            time_t creationTime_; //!< The time this NotificationQueue was created.
     190           
    157191            unsigned int maxSize_; //!< The maximal number of Notifications displayed.
    158192            unsigned int size_; //!< The number of Notifications displayed.
    159             unsigned int displayTime_; //!< The time a Notification is displayed.
     193            int displayTime_; //!< The time a Notification is displayed.
    160194
    161195            bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already.
     
    169203            NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
    170204
    171             void create(void); //!< Creates the NotificationQueue in lua.
    172 
    173205            void setName(const std::string& name); //!< Sets the name of the NotificationQueue.
    174206
    175             void push(Notification* notification, const std::time_t & time); //!< Adds (pushes) a Notification to the NotificationQueue.
    176             void pop(void); //!< Removes (pops) the least recently added Notification form the NotificationQueue.
    177             void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); //!< Removes the Notification that is stored in the input NotificationContainer.
    178 
    179             void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers.
    180 
    181     }; // tolua_export
    182 
    183 } // tolua_export
    184 
    185 #endif /* _NotificationOverlay_H__ */
     207            void push(Notification* notification, const std::time_t & time); // Adds (pushes) a Notification to the NotificationQueue.
     208            void pop(void); // Removes (pops) the least recently added Notification form the NotificationQueue.
     209            void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); // Removes the Notification that is stored in the input NotificationContainer.
     210
     211    };
     212
     213}
     214
     215#endif /* _NotificationQueue_H__ */
  • code/trunk/src/modules/notifications/dispatchers/SimpleNotification.cc

    r7474 r8706  
    5151        this->setSender("simpleNotification");
    5252
    53         this->setSyncMode(0x0);
     53        this->setSyncMode(ObjectDirection::None);
    5454    }
    5555
  • code/trunk/src/modules/objects/CMakeLists.txt

    r7163 r8706  
    44  Planet.cc
    55  Script.cc
     6  SpaceBoundaries.cc
    67)
    78
  • code/trunk/src/modules/objects/ObjectsPrereqs.h

    r8351 r8706  
    7272    class Planet;
    7373    class Script;
     74    class SpaceBoundaries;
    7475
    7576    // collisionshapes
  • code/trunk/src/modules/objects/Script.cc

    r7493 r8706  
    140140
    141141        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    142         Pawn* pawn = NULL;
     142        PlayerInfo* player = NULL;
    143143
    144144        // If the trigger is a PlayerTrigger.
     
    148148                return false;
    149149            else
    150                 pawn = pTrigger->getTriggeringPlayer();
     150                player = pTrigger->getTriggeringPlayer();
    151151        }
    152152        else
    153153            return false;
    154154
    155         if(pawn == NULL)  //TODO: Will this ever happen? If not, change in NotificationDispatcher as well.
     155        if(player == NULL)  //TODO: Will this ever happen? If not, change in NotificationDispatcher as well.
    156156        {
    157157            COUT(4) << "The Script was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    158             return false;
    159         }
    160 
    161         // Extract the PlayerInfo from the Pawn.
    162         PlayerInfo* player = pawn->getPlayer();
    163 
    164         if(player == NULL)
    165         {
    166             COUT(3) << "The PlayerInfo* is NULL." << std::endl;
    167158            return false;
    168159        }
  • code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc

    r6417 r8706  
    2727 */
    2828
     29/**
     30    @file BoxCollisionShape.cc
     31    @brief Implementation of the BoxCollisionShape class.
     32*/
     33
    2934#include "BoxCollisionShape.h"
    3035
     
    3944    CreateFactory(BoxCollisionShape);
    4045
     46    /**
     47    @brief
     48        Constructor. Registers and initializes the object.
     49    */
    4150    BoxCollisionShape::BoxCollisionShape(BaseObject* creator) : CollisionShape(creator)
    4251    {
     
    4453
    4554        this->halfExtents_ = Vector3(1, 1, 1);
    46         updateShape();
     55        this->updateShape();
    4756
    4857        this->registerVariables();
     
    5160    BoxCollisionShape::~BoxCollisionShape()
    5261    {
     62        // TODO: Move to CollisionShape?
    5363        if (this->isInitialized())
    5464            delete this->collisionShape_;
     
    7080    }
    7181
     82    /**
     83    @brief
     84        Is called when the scale of the BoxCollisionShape has changed.
     85    */
     86    void BoxCollisionShape::changedScale()
     87    {
     88        CollisionShape::changedScale();
     89
     90        // Resize the internal collision shape
     91        // TODO: Assuming setLocalScaling works.
     92        // this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
     93        if(!this->hasUniformScaling())
     94        {
     95            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
     96            return;
     97        }
     98
     99        this->setHalfExtents(this->halfExtents_ * this->getScale());
     100    }
     101
     102    /**
     103    @brief
     104        Creates a new internal collision shape for the BoxCollisionShape.
     105    @return
     106        Returns a pointer to the newly created btBoxShape.
     107    */
    72108    btCollisionShape* BoxCollisionShape::createNewShape() const
    73109    {
  • code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h

    r7601 r8706  
    4343namespace orxonox
    4444{
     45
     46    /**
     47    @brief
     48        Wrapper for the bullet box collision shape class btBoxShape.
     49
     50    @author
     51        Reto Grieder
     52
     53    @see btBoxShape
     54    @ingroup Collisionshapes
     55    */
    4556    class _ObjectsExport BoxCollisionShape : public CollisionShape
    4657    {
     
    5162            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5263
    53             inline void setHalfExtents(const Vector3& extents)
    54                 { this->halfExtents_ = extents; updateShape(); }
     64            /**
     65            @brief Set the half extents of the BoxCollisionShape.
     66                   If the half extent changes, this causes the internal collision shape to be recreated.
     67            @param extents A vector with the half extents.
     68                   The x-component is half the length, the y-component is half the height and the z-component is half the width.
     69            @return Returns true if the half extent has changed, false if not.
     70            */
     71            inline bool setHalfExtents(const Vector3& extents)
     72                { if(this->halfExtents_ == extents) return false; this->halfExtents_ = extents; updateShape(); return true; }
     73            /**
     74            @brief Get the half extents of the BoxCollisionShape.
     75            @return Returns a vector containing the half extents.
     76            */
    5577            inline const Vector3& getHalfExtents() const
    5678                { return halfExtents_;}
    5779
    58             inline void setWidth(float value)
    59                 { this->halfExtents_.z = value / 2; updateShape(); }
     80            /**
     81            @brief Set the width of the BoxCollisionShape.
     82                   If the width changes, this causes the internal collision shape to be recreated.
     83            @param value The width to be set.
     84            @return Returns true if the width has changed, false if not.
     85            */
     86            inline bool setWidth(float value)
     87                { if(this->halfExtents_.z == value/2.0f) return false; this->halfExtents_.z = value / 2.0f; updateShape(); return true; }
     88            /**
     89            @brief Get the width of the BoxCollisionShape.
     90            @return Returns the width of the BoxCollisionShape.
     91            */
    6092            inline float getWidth() const
    61                 { return this->halfExtents_.z * 2; }
     93                { return this->halfExtents_.z * 2.0f; }
    6294
    63             inline void setHeight(float value)
    64                 { this->halfExtents_.y = value / 2; updateShape(); }
     95            /**
     96            @brief Set the height of the BoxCollisionShape.
     97                   If the height changes, this causes the internal collision shape to be recreated.
     98            @param value The height to be set.
     99            @return Returns true if the height has changed, false if not.
     100            */
     101            inline bool setHeight(float value)
     102                { if(this->halfExtents_.y == value/2.0f) return false; this->halfExtents_.y = value / 2.0f; updateShape(); return true; }
     103            /**
     104            @brief Get the height of the BoxCollisionShape.
     105            @return Returns the height of the BoxCollisionShape.
     106            */
    65107            inline float getHeight() const
    66                 { return this->halfExtents_.y * 2; }
     108                { return this->halfExtents_.y * 2.0f; }
    67109
    68             inline void setLength(float value)
    69                 { this->halfExtents_.x = value / 2; updateShape(); }
     110            /**
     111            @brief Set the length of the BoxCollisionShape.
     112                   If the length changes, this causes the internal collision shape to be recreated.
     113            @param value The length to be set.
     114            @return Returns true if the length has changed, false if not.
     115            */
     116            inline bool setLength(float value)
     117                { if(this->halfExtents_.x == value/2.0f) return false; this->halfExtents_.x = value / 2.0f; updateShape(); return true; }
     118            /**
     119            @brief Get the length of the BoxCollisionShape.
     120            @return Returns the length of the BoxCollisionShape.
     121            */
    70122            inline float getLength() const
    71                 { return this->halfExtents_.x * 2; }
     123                { return this->halfExtents_.x * 2.0f; }
     124
     125            virtual void changedScale(); // Is called when the scale of the BoxCollisionShape has changed.
    72126
    73127        private:
    74128            void registerVariables();
    75129
    76             btCollisionShape* createNewShape() const;
     130            btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the BoxCollisionShape.
    77131
    78             Vector3 halfExtents_;
     132            Vector3 halfExtents_; //!< The half extents of the BoxCollisionShape. The x-component is half the length, the y-component is half the height and the z-component is half the width.
    79133     };
    80134}
  • code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc

    r6417 r8706  
    2727 */
    2828
     29/**
     30    @file ConeCollisionShape.cc
     31    @brief Implementation of the ConeCollisionShape class.
     32*/
     33
    2934#include "ConeCollisionShape.h"
    3035
     
    3338#include "core/CoreIncludes.h"
    3439#include "core/XMLPort.h"
     40#include "tools/BulletConversions.h"
    3541
    3642namespace orxonox
     
    3844    CreateFactory(ConeCollisionShape);
    3945
     46    /**
     47    @brief
     48        Constructor. Registers and initializes the object.
     49    */
    4050    ConeCollisionShape::ConeCollisionShape(BaseObject* creator) : CollisionShape(creator)
    4151    {
     
    6979    }
    7080
     81    /**
     82    @brief
     83        Is called when the scale of the ConeCollisionShape has changed.
     84    */
     85    void ConeCollisionShape::changedScale()
     86    {
     87        CollisionShape::changedScale();
     88
     89        // Resize the internal collision shape
     90        // TODO: Assuming setLocalScaling works.
     91        //this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
     92        if(!this->hasUniformScaling())
     93        {
     94            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
     95            return;
     96        }
     97
     98        this->radius_ *= this->getScale();
     99        this->height_ *= this->getScale();
     100        this->updateShape();
     101    }
     102
     103    /**
     104    @brief
     105        Creates a new internal collision shape for the ConeCollisionShape.
     106    @return
     107        Returns a pointer to the newly created btConeShape.
     108    */
    71109    btCollisionShape* ConeCollisionShape::createNewShape() const
    72110    {
  • code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h

    r7601 r8706  
    4141namespace orxonox
    4242{
     43
     44    /**
     45    @brief
     46        Wrapper for the bullet cone collision shape class btConeShape.
     47
     48    @author
     49        Reto Grieder
     50
     51    @see btConeShape
     52    @ingroup Collisionshapes
     53    */
    4354    class _ObjectsExport ConeCollisionShape : public CollisionShape
    4455    {
     
    4960            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5061
    51             inline void setRadius(float value)
    52                 { this->radius_ = value; updateShape(); }
     62            /**
     63            @brief Set the radius of the ConeCollisionShape.
     64                   If the radius changes, this causes the internal collision shape to be recreated.
     65            @param value The radius to be set.
     66            @return Returns true if the radius has changed, false if not.
     67            */
     68            inline bool setRadius(float value)
     69                { if(this->radius_ == value) return false; this->radius_ = value; updateShape(); return true; }
     70            /**
     71            @brief Get the radius of the ConeCollisionShape.
     72            @return Returns the radius of the ConeCollisionShape.
     73            */
    5374            inline float getRadius() const
    5475                { return radius_; }
    5576
    56             inline void setHeight(float value)
    57                 { this->height_ = value; updateShape(); }
     77            /**
     78            @brief Set the height of the ConeCollisionShape.
     79                   If the height changes, this causes the internal collision shape to be recreated.
     80            @param value The height to be set.
     81            @return Returns true if the height has changed, false if not.
     82            */
     83            inline bool setHeight(float value)
     84                { if(this->height_ == value) return false; this->height_ = value; updateShape(); return true; }
     85            /**
     86            @brief Get the height of the ConeCollisionShape.
     87            @return Returns the height of the ConeCollisionShape.
     88            */
    5889            inline float getHeight() const
    5990                { return this->height_; }
     91
     92            virtual void changedScale(); // Is called when the scale of the ConeCollisionShape has changed.
    6093
    6194        private:
    6295            void registerVariables();
    6396
    64             btCollisionShape* createNewShape() const;
     97            btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the ConeCollisionShape.
    6598
    66             float radius_;
    67             float height_;
     99            float radius_; //!< The radius of the ConeCollisionShape.
     100            float height_; //!< The height of the ConeCollisionShape.
    68101     };
    69102}
  • code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc

    r6417 r8706  
    2727 */
    2828
     29/**
     30    @file PlaneCollisionShape.cc
     31    @brief Implementation of the PlaneCollisionShape class.
     32*/
     33
    2934#include "PlaneCollisionShape.h"
    3035
     
    3944    CreateFactory(PlaneCollisionShape);
    4045
     46    /**
     47    @brief
     48        Constructor. Registers and initializes the object.
     49    */
    4150    PlaneCollisionShape::PlaneCollisionShape(BaseObject* creator) : CollisionShape(creator)
    4251    {
     
    7079    }
    7180
     81    /**
     82    @brief
     83        Is called when the scale of the PlaneCollisionShape has changed.
     84    */
     85    void PlaneCollisionShape::changedScale()
     86    {
     87        CollisionShape::changedScale();
     88
     89        // Resize the internal collision shape
     90        // TODO: Assuming setLocalScaling works.
     91        //this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
     92        if(!this->hasUniformScaling())
     93        {
     94            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
     95            return;
     96        }
     97
     98        this->setOffset(this->offset_*this->getScale());
     99    }
     100
     101    /**
     102    @brief
     103        Creates a new internal collision shape for the PlaneCollisionShape.
     104    @return
     105        Returns a pointer to the newly created btStaticPlaneShape.
     106    */
    72107    btCollisionShape* PlaneCollisionShape::createNewShape() const
    73108    {
  • code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h

    r7601 r8706  
    4343namespace orxonox
    4444{
     45
     46    /**
     47    @brief
     48        Wrapper for the bullet plane collision shape class btStaticPlaneShape.
     49
     50    @author
     51        Martin Stypinski
     52
     53    @see btStaticPlaneShape
     54    @ingroup Collisionshapes
     55    */
    4556    class _ObjectsExport PlaneCollisionShape : public CollisionShape
    4657    {
     
    5162            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5263
    53             inline void setNormal(const Vector3& normal)
    54                 { this->normal_ = normal; updateShape(); }
    55             inline const Vector3& getNormal()
     64            /**
     65            @brief Set the normal of the PlaneCollisionShape.
     66                   If the normal changes, this causes the internal collision shape to be recreated.
     67            @param normal The normal vector to be set.
     68            @return Returns true if the normal has changed, false if not.
     69            */
     70            inline bool setNormal(const Vector3& normal)
     71                { if(this->normal_ == normal) return false; this->normal_ = normal; updateShape(); return true; }
     72            /**
     73            @brief Get the normal of the PlaneCollisionShape.
     74            @return Returns the normal vector of the PlaneCollisionShape.
     75            */
     76            inline const Vector3& getNormal() const
    5677                { return normal_;}
    5778
    58             inline void setOffset(float offset)
    59                 { this->offset_ = offset; updateShape(); }
    60             inline float getOffset()
     79            /**
     80            @brief Set the offset of the PlaneCollisionShape.
     81                   If the offset changes, this causes the internal collision shape to be recreated.
     82            @param offset The offset to be set.
     83            @return Returns true if the offset has changed, false if not.
     84            */
     85            inline bool setOffset(float offset)
     86                { if(this->offset_ == offset) return false; this->offset_ = offset; updateShape(); return true; }
     87            /**
     88            @brief Get the offset of the PlaneCollisionShape.
     89            @return Returns the offset of the PlaneCollisionShape.
     90            */
     91            inline float getOffset() const
    6192                { return this->offset_;}
     93
     94            virtual void changedScale(); // Is called when the scale of the PlaneCollisionShape has changed.
    6295
    6396        private:
    6497            void registerVariables();
    6598
    66             btCollisionShape* createNewShape()const;
     99            btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the PlaneCollisionShape.
    67100
    68             Vector3 normal_;
    69             float   offset_;
     101            Vector3 normal_; //!< The normal vector of the PlaneCollisionShape.
     102            float   offset_; //!< The offset of the PlaneCollisionShape.
    70103     };
    71104}
  • code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc

    r5781 r8706  
    2727 */
    2828
     29/**
     30    @file SphereCollisionShape.cc
     31    @brief Implementation of the SphereCollisionShape class.
     32*/
     33
    2934#include "SphereCollisionShape.h"
    3035
     
    3338#include "core/CoreIncludes.h"
    3439#include "core/XMLPort.h"
     40#include "tools/BulletConversions.h"
    3541
    3642namespace orxonox
     
    3844    CreateFactory(SphereCollisionShape);
    3945
     46    /**
     47    @brief
     48        Constructor. registers and initializes the object.
     49    */
    4050    SphereCollisionShape::SphereCollisionShape(BaseObject* creator) : CollisionShape(creator)
    4151    {
     
    6676    }
    6777
     78    /**
     79    @brief
     80        Is called when the scale of the SphereCollisionShape has changed.
     81    */
     82    void SphereCollisionShape::changedScale()
     83    {
     84        CollisionShape::changedScale();
     85
     86        // Resize the internal collision shape
     87        // TODO: Assuming setLocalScaling works.
     88        //this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
     89        if(!this->hasUniformScaling())
     90        {
     91            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
     92            return;
     93        }
     94
     95        this->setRadius(this->radius_*this->getScale());
     96    }
     97
     98    /**
     99    @brief
     100        Creates a new internal collision shape for the SphereCollisionShape.
     101    @return
     102        Returns a pointer to the newly created btSphereShape.
     103    */
    68104    btCollisionShape* SphereCollisionShape::createNewShape() const
    69105    {
  • code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h

    r7601 r8706  
    4141namespace orxonox
    4242{
     43
     44    /**
     45    @brief
     46        Wrapper for the bullet sphere collision shape class btSphereShape.
     47
     48    @author
     49        Reto Grieder
     50
     51    @see btSphereShape
     52    @ingroup Collisionshapes
     53    */
    4354    class _ObjectsExport SphereCollisionShape : public CollisionShape
    4455    {
     
    4960            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5061
    51             inline void setRadius(float radius)
    52                 { this->radius_ = radius; updateShape(); }
     62            /**
     63            @brief Set the radius of the SphereCollisionShape.
     64                   If the radius changes, this causes the internal collision shape to be recreated.
     65            @param radius The radius to be set.
     66            @return Returns true if the radius has changed, false if not.
     67            */
     68            inline bool setRadius(float radius)
     69                { if(this->radius_ == radius) return false; this->radius_ = radius; updateShape(); return true; }
     70            /**
     71            @brief Get the radius of the SphereCollisionShape.
     72            @return Returns the radius of the SphereCollisionShape.
     73            */
    5374            inline float getRadius() const
    5475                { return this->radius_; }
     76
     77            virtual void changedScale(); // Is called when the scale of the SphereCollisionShape has changed.
    5578
    5679        private:
     
    5982            btCollisionShape* createNewShape() const;
    6083
    61             float radius_;
     84            float radius_; //!< The radius of the SphereCollisionShape.
    6285    };
    6386}
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc

    r8213 r8706  
    5353        Default Constructor. Registers the object and initializes default values.
    5454    */
    55     DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator), beaconMask_(NULL)
     55    DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator)
    5656    {
    5757        RegisterObject(DistanceMultiTrigger);
     
    6060        this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::off);
    6161        this->targetName_ = "";
     62        this->beaconMask_.exclude(Class(BaseObject));
     63        this->beaconMask_.include(Class(DistanceTriggerBeacon));
    6264    }
    6365
     
    6870    DistanceMultiTrigger::~DistanceMultiTrigger()
    6971    {
    70         if(this->beaconMask_ != NULL)
    71             delete this->beaconMask_;
     72
    7273    }
    7374
     
    135136        // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons.
    136137        if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify)
    137             targetMask = *this->beaconMask_;
     138            targetMask = this->beaconMask_;
    138139
    139140        // Iterate through all objects that are targets of the DistanceMultiTrigger.
     
    207208    {
    208209        this->beaconMode_ = mode;
    209         if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify && this->beaconMask_ == NULL)
    210         {
    211             this->beaconMask_ = new ClassTreeMask();
    212             this->beaconMask_->exclude(Class(BaseObject));
    213             this->beaconMask_->include(Class(DistanceTriggerBeacon));
    214         }
    215210    }
    216211   
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h

    r8213 r8706  
    152152            distanceMultiTriggerBeaconMode::Value beaconMode_; //!< The beacon mode, the DistanceMultiTrigger is in.
    153153            std::string targetName_; //!< The target name, used in <em>single-target</em> mode.
    154             ClassTreeMask* beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
     154            ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
    155155
    156156            std::map<WorldEntity*, WeakPtr<WorldEntity>* > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.cc

    r8213 r8706  
    5757        The creator of this trigger.
    5858    */
    59     DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator), beaconMask_(NULL)
     59    DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator)
    6060    {
    6161        RegisterObject(DistanceTrigger);
     
    6464        this->targetMask_.exclude(Class(BaseObject));
    6565        this->targetName_ = "";
     66        this->beaconMask_.exclude(Class(BaseObject));
     67        this->beaconMask_.include(Class(DistanceTriggerBeacon));
    6668    }
    6769
     
    7274    DistanceTrigger::~DistanceTrigger()
    7375    {
    74         // Delete the beacon mask if it exists.
    75         if(this->beaconMask_ != NULL)
    76             delete this->beaconMask_;
     76
    7777    }
    7878
     
    159159        // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons.
    160160        if(this->beaconMode_ == distanceTriggerBeaconMode::identify)
    161             targetMask = *this->beaconMask_;
     161            targetMask = this->beaconMask_;
    162162
    163163        // Iterate through all objects that are targets of the DistanceTrigger.
     
    205205                        entity = entity->getParent();
    206206
    207                     Pawn* player = orxonox_cast<Pawn*>(entity);
    208                     this->setTriggeringPlayer(player);
     207                    Pawn* pawn = orxonox_cast<Pawn*>(entity);
     208                    if(pawn != NULL)
     209                        this->setTriggeringPawn(pawn);
     210                    else
     211                        CCOUT(2) << "Pawn was NULL." << endl;
    209212                }
    210213               
     
    228231    {
    229232        this->beaconMode_ = mode;
    230         if(this->beaconMode_ == distanceTriggerBeaconMode::identify && this->beaconMask_ == NULL)
    231         {
    232             this->beaconMask_ = new ClassTreeMask();
    233             this->beaconMask_->exclude(Class(BaseObject));
    234             this->beaconMask_->include(Class(DistanceTriggerBeacon));
    235         }
    236233    }
    237234
     
    280277        Check whether the DistanceTrigger is triggered.
    281278        It is triggered if it is triggered according only to its mode (i.e. its sub-triggers) and if a target is in range.
    282     @param
     279    @param mode
     280        The mode for which it is tested, whether the DistanceTrigger is triggered.
     281    @return
    283282        Returns true if it is triggered ,false if not.
    284283    */
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.h

    r8213 r8706  
    7171        - @b target Which specifies the class of objects that can trigger the DistanceTrigger. Default is <code>"Pawn"</code>.
    7272        - @b beaconMode Which specifies, whether the DistanceTrigger operates on @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacons" or not. If <em>off</em> the DistanceMultiTrigger works as usual. If set to <em>identify</em> the DistanceTrigger is only triggered by objects that have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon", with the same name as specified in <em>targetname</em>, attached to them. If set to <em>exclude</em> the DistanceTrigger is only triggered by objects that don't have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon", with the same name as specified in <em>targetname</em>, attached to them. Default is <em>off</em>.
    73         - @b targetname Which specifies the name @ref oroxnox::DistanceTriggerBeacon "DistanceTriggerBeacons" need to have to make the DistanceTrigger react to them if it is in <em>beacon-mode</em> (the beaconMode is not <em>off</em>).
     73        - @b targetname Which specifies the name @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacons" need to have to make the DistanceTrigger react to them if it is in <em>beacon-mode</em> (the beaconMode is not <em>off</em>).
    7474
    7575        A simple DistanceTrigger could look like this:
     
    162162            distanceTriggerBeaconMode::Value beaconMode_; //!< The beacon mode.
    163163            std::string targetName_; //!< The name a DistanceTriggerBeacon needs to have to make the DistanceTrigger react to it if in beacon-mode.
    164             ClassTreeMask* beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
     164            ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
    165165           
    166166            WeakPtr<WorldEntity> cache_; //!< Caches the entity that triggered the DistanceTrigger last.
  • code/trunk/src/modules/objects/triggers/EventTrigger.h

    r8213 r8706  
    6060
    6161    @see Trigger
    62         For more information on @ref oroxnox::Trigger "Triggers".
     62        For more information on @ref orxonox::Trigger "Triggers".
    6363
    6464    @author
  • code/trunk/src/modules/objects/triggers/MultiTrigger.cc

    r8213 r8706  
    6363        this->bMultiTrigger_ = true;
    6464
    65         this->setSyncMode(0x0);
     65        this->setSyncMode(ObjectDirection::None);
    6666    }
    6767
     
    198198                        if(bActive ^ this->isActive(state->originator))
    199199                        {
    200 
    201200                            bool bFire = true;
    202201
     
    312311
    313312        // We only want WorldEntities
    314         //TODO: Really?
    315313        ClassTreeMask WEMask;
    316314        WEMask.include(Class(WorldEntity));
  • code/trunk/src/modules/objects/triggers/MultiTriggerContainer.cc

    r7601 r8706  
    7373        {
    7474            this->setForPlayer(true);
    75             this->setTriggeringPlayer(pawn);
     75            this->setTriggeringPawn(pawn);
    7676        }
    7777    }
  • code/trunk/src/modules/objects/triggers/Trigger.cc

    r8213 r8706  
    7676        }
    7777
    78         this->setSyncMode(0x0);
     78        this->setSyncMode(ObjectDirection::None);
    7979    }
    8080
  • code/trunk/src/modules/objects/triggers/TriggerBase.cc

    r7652 r8706  
    7171        this->bMultiTrigger_ = false;
    7272
    73         this->setSyncMode(0x0);
     73        this->setSyncMode(ObjectDirection::None);
    7474    }
    7575
  • code/trunk/src/modules/objects/triggers/TriggerBase.h

    r8213 r8706  
    133133            inline int getActivations(void) const
    134134                { return this->remainingActivations_; }
     135            /**
     136            @brief Check whether the trigger has still at least one remaining activation.
     137            @return Returns true if the trigger has remaining activations (i.e. the number of remaining activations is not zero).
     138            */
     139            inline bool hasRemainingActivations(void) const
     140                { return this->remainingActivations_ > 0 || this->remainingActivations_ == INF_s; }
    135141
    136142            /**
  • code/trunk/src/modules/overlays/OverlaysPrereqs.h

    r8351 r8706  
    8989    class HUDRadar;
    9090    class HUDSpeedBar;
     91    class HUDBoostBar;
    9192    class HUDTimer;
    9293    class KillMessage;
  • code/trunk/src/modules/overlays/hud/CMakeLists.txt

    r8178 r8706  
    44  HUDRadar.cc
    55  HUDSpeedBar.cc
     6  HUDBoostBar.cc
    67  HUDHealthBar.cc
    78  HUDTimer.cc
    89  ChatOverlay.cc
    9   GametypeStatus.cc
    1010  AnnounceMessage.cc
    1111  KillMessage.cc
  • code/trunk/src/modules/overlays/hud/HUDBar.cc

    r7801 r8706  
    2626 *      Fabian 'x3n' Landau
    2727 *      Reto Grieder
     28 *      Benjamin Knecht
    2829 *
    2930 */
  • code/trunk/src/modules/overlays/hud/HUDBar.h

    r7401 r8706  
    2626 *      Fabian 'x3n' Landau
    2727 *      Reto Grieder
     28 *      Benjamin Knecht
    2829 *
    2930 */
  • code/trunk/src/modules/overlays/hud/HUDNavigation.cc

    r7801 r8706  
    342342    text->hide();
    343343
    344     ObjectInfo tempStruct = {panel, text, false};
     344    ObjectInfo tempStruct = {panel, text, false /*, TODO: initialize wasOutOfView_ */};
    345345    activeObjectList_[object] = tempStruct;
    346346
  • code/trunk/src/modules/overlays/hud/HUDSpeedBar.cc

    r5781 r8706  
    5454        SUPER(HUDSpeedBar, tick, dt);
    5555
    56         if (this->owner_ && this->owner_->getEngine())
     56        if (this->owner_)
    5757        {
    58             float value = this->owner_->getVelocity().length() / (this->owner_->getEngine()->getMaxSpeedFront() * this->owner_->getEngine()->getSpeedFactor() * this->owner_->getEngine()->getBoostFactor());
     58            float value = this->owner_->getVelocity().length() / (this->owner_->getMaxSpeedFront() * this->owner_->getSpeedFactor() * this->owner_->getBoostFactor());
    5959            this->setValue(value);
    6060        }
  • code/trunk/src/modules/pickup/PickupManager.h

    r7547 r8706  
    148148            @return Returns true if the input Pickupable is still valid, false if not.
    149149            */
    150             const bool isValidPickup(uint32_t pickup) const
     150            bool isValidPickup(uint32_t pickup) const
    151151                { return this->pickups_.find(pickup) != this->pickups_.end(); }
    152152            // tolua_end
  • code/trunk/src/modules/pickup/PickupPrereqs.h

    r8351 r8706  
    8585    class SpeedPickup;
    8686    class ShieldPickup;
     87    class ShrinkPickup;
    8788
    8889}
  • code/trunk/src/modules/pickup/PickupRepresentation.cc

    r8079 r8706  
    5757
    5858        this->initialize();
    59         this->setSyncMode(0x0); // The default PickupRperesentation created by each PickupManager is not synchronised, since it only exists locally.
     59        this->setSyncMode(ObjectDirection::None); // The default PickupRperesentation created by each PickupManager is not synchronised, since it only exists locally.
    6060    }
    6161
  • code/trunk/src/modules/pickup/items/CMakeLists.txt

    r7163 r8706  
    66  SpeedPickup.cc
    77  ShieldPickup.cc
     8  ShrinkPickup.cc
    89)
  • code/trunk/src/modules/pong/PongBat.h

    r8108 r8706  
    100100                { this->length_ = length; }
    101101            /**
    102             @brief get the length of the bat.
     102            @brief Get the length of the bat.
    103103            @return Returns the length of the bat (in z-direction) as percentage of the height of the playing field.
    104104            */
  • code/trunk/src/modules/portals/CMakeLists.txt

    • Property svn:eol-style set to native
  • code/trunk/src/modules/portals/PortalEndPoint.cc

    • Property svn:executable deleted
    • Property svn:eol-style set to native
    r8471 r8706  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Andreas Büchel
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
    129#include "PortalEndPoint.h"
    230#include "core/XMLPort.h"
     
    432#include "portals/PortalLink.h"
    533#include "worldentities/MobileEntity.h"
    6 
     34#include <ctime>
    735
    836namespace orxonox
     
    1442    std::map<unsigned int, PortalEndPoint *> PortalEndPoint::idMap_s;
    1543
    16     PortalEndPoint::PortalEndPoint(BaseObject* creator) : StaticEntity(creator), id_(0), trigger_(NULL)
     44    PortalEndPoint::PortalEndPoint(BaseObject* creator) : StaticEntity(creator), RadarViewable(creator, static_cast<WorldEntity*>(this)), id_(0), trigger_(NULL), reenterDelay_(0)
    1745    {
    1846        RegisterObject(PortalEndPoint);
     47       
    1948        this->trigger_ = new DistanceMultiTrigger(this);
    2049        this->trigger_->setName("portal");
    2150        this->attach(trigger_);
     51
     52        this->setRadarObjectColour(ColourValue::White);
     53        this->setRadarObjectShape(RadarViewable::Dot);
     54        this->setRadarVisibility(true);
    2255    }
    2356   
    2457    PortalEndPoint::~PortalEndPoint()
    2558    {
    26         delete this->trigger_;
     59        if(this->isInitialized() && this->trigger_ != NULL)
     60            delete this->trigger_;
    2761    }
    2862
     
    3367        XMLPortParam(PortalEndPoint, "id", setID, getID, xmlelement, mode);
    3468        XMLPortParam(PortalEndPoint, "design", setTemplate, getTemplate, xmlelement, mode);
     69        XMLPortParam(PortalEndPoint, "reenterDelay", setReenterDelay, getReenterDelay, xmlelement, mode);
    3570        XMLPortParamExtern(PortalEndPoint, DistanceMultiTrigger, this->trigger_, "distance", setDistance, getDistance, xmlelement, mode);
    3671        XMLPortParamLoadOnly(PortalEndPoint, "target", setTarget, xmlelement, mode).defaultValues("Pawn");
     
    6499        if(originatingTrigger == 0)
    65100        {
    66             COUT(1) << "originator no DistanceMultiTrigger\n" << std::endl;
    67101            return true;
    68102        }
     
    74108        if(bTriggered)
    75109        {
    76             if(this->recentlyJumpedOut_.find(entity) == this->recentlyJumpedOut_.end())  // only enter the portal if not just jumped out of it
     110            if(this->letsEnter(entity))  // only enter the portal if not just (this very moment) jumped out of it, or if the reenterDelay expired
    77111            {
    78112                PortalLink::use(entity, this);
     
    87121    }
    88122
     123    void PortalEndPoint::changedActivity(void)
     124    {
     125        SUPER(PortalEndPoint, changedActivity);
     126       
     127        this->setRadarVisibility(this->isActive());
     128    }
     129
     130    bool PortalEndPoint::letsEnter(MobileEntity* entity)
     131    {
     132        // not allowed to enter if reenterDelay hasn't expired yet
     133        std::map<MobileEntity *, time_t>::const_iterator time = this->jumpOutTimes_.find(entity);
     134        if(time != this->jumpOutTimes_.end() && std::difftime(std::time(0),time->second) < this->reenterDelay_)
     135            return false;
     136
     137        // not allowed to enter if jumped out of this portal and not left its activation radius yet
     138        std::set<MobileEntity *>::const_iterator recent = this->recentlyJumpedOut_.find(entity);
     139        if(recent != this->recentlyJumpedOut_.end())
     140            return false;
     141       
     142        return true;
     143    }
     144
    89145    void PortalEndPoint::jumpOut(MobileEntity* entity)
    90146    {
     147        this->jumpOutTimes_[entity] = std::time(0);
    91148        this->recentlyJumpedOut_.insert(entity);
    92        
     149
     150        // adjust
    93151        entity->setPosition(this->getWorldPosition());
    94152        entity->rotate(this->getWorldOrientation());
    95153        entity->setVelocity(this->getWorldOrientation() * entity->getVelocity());
    96         entity->setVelocity(entity->getVelocity() * 1.5);
    97154    }
    98155
  • code/trunk/src/modules/portals/PortalEndPoint.h

    • Property svn:executable deleted
    • Property svn:eol-style set to native
    r8457 r8706  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Andreas Büchel
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
     29/**
     30 *  @file PortalEndPoint.h
     31 *  @brief Declaration of the PortalEndPoint class.
     32 *  @ingroup Portals
     33 */
     34
    135#ifndef _PortalEndPoint_H__
    236#define _PortalEndPoint_H__
     
    943
    1044#include "worldentities/StaticEntity.h"
     45#include "interfaces/RadarViewable.h"
    1146#include "graphics/Billboard.h"
    1247#include "objects/triggers/DistanceMultiTrigger.h"
    1348#include "core/EventIncludes.h"
     49#include <ctime>
    1450
    1551namespace orxonox
    1652{
    17     class _PortalsExport PortalEndPoint : public StaticEntity
     53    /**
     54     @brief
     55     A PortalEndPoint serves as portal entrance and/or exit.
     56     
     57     @ingroup Portals
     58     */
     59   
     60    class _PortalsExport PortalEndPoint : public StaticEntity, public RadarViewable
    1861    {
    1962        public:
    2063            PortalEndPoint(BaseObject* creator);
    2164            virtual ~PortalEndPoint();
     65           
    2266            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     67            virtual void changedActivity(void);
     68           
    2369            inline void setTarget(const std::string & target)                 //!< add types which are allowed to activate the PortalEndPoint
    24             {
    25                 this->trigger_->addTarget(target);
    26             }
     70                { this->trigger_->addTarget(target); }
    2771           
    2872            void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    2973            static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint
     74            inline void setReenterDelay(unsigned int seconds)
     75                { this->reenterDelay_ = seconds; }
     76            inline unsigned int getReenterDelay()
     77                { return this->reenterDelay_; }
    3078            inline void setID(unsigned int id)
    31             {
    32                 this->id_ = id;
    33             }
     79                { this->id_ = id; }
    3480           
    3581            inline unsigned int getID() const
    36             {
    37                 return this->id_;
    38             }
     82                { return this->id_; }
    3983           
    4084            /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object
    4185            inline void setTemplate(const std::string & name)
    42             {
    43                 this->templateName_ = name;
    44                 this->addTemplate(name);
    45             }
     86                { this->templateName_ = name; this->addTemplate(name); }
    4687
    4788            /// \brief Get the name of the attached design template
    4889            inline const std::string & getTemplate()
    49             {
    50                 return this->templateName_;
    51             }
     90                { return this->templateName_; }
    5291
    5392            /*! \brief This function is called each time the DistanceMultiTrigger of this PortalEndPoint changed
    54              * \param bTriggered true if the trigger was triggered on, false if the trigger has switched to off
    55              * \param trigger the MultiTriggerContainer containing the triggering BaseObject (and trigger_ the portal's MultiDistanceTrigger which we already know)
    56              *
    57              * if bTriggered is \c true the triggering entity enters this portal (if it is an entrance)
    58              * otherwise the triggering entity is removed from the set of entities who recently jumped out of this portal */
     93                \param bTriggered true if the trigger was triggered on, false if the trigger has switched to off
     94                \param trigger the MultiTriggerContainer containing the triggering BaseObject (and trigger_ the portal's MultiDistanceTrigger which we already know)
     95            */
    5996            bool execute(bool bTriggered, BaseObject* trigger);
    6097
     
    6299             * \param entity The Entity which should jump out of this portal */
    63100            void jumpOut(MobileEntity * entity);
     101           
     102            /** \brief Tells wether a certain Entity is allowed to enter the PortalEndPoint?
     103                @return @c true if the entity not just came out of this portal and the reenterDelay has expired for it, @c false otherwise
     104            */
     105            bool letsEnter(MobileEntity* entity);
    64106        protected:
    65107           
     
    71113            std::string templateName_;            //!< The name of the design template used for this endpoint
    72114
    73             std::set<MobileEntity *> recentlyJumpedOut_; //!< Entities which recently jumped out of this EndPoint, hence they shouldn't be pulled in again if the endpoint is the beginning of a link
     115            int reenterDelay_;
     116            std::map<MobileEntity *, time_t> jumpOutTimes_;   //!< Stores the time at which a certain MobileEntity @ref jumpOut "jumped out" of this PortalEndPoint
     117            std::set<MobileEntity *> recentlyJumpedOut_;   //!< Stores the entities witch recently jumped out of this PortalEndPoint and haven't left the activation radius yet. This is needed in order to prevent them from beeing pulled into the PortalEndPoint they have just come out of.
    74118    };
    75119
  • code/trunk/src/modules/portals/PortalLink.cc

    • Property svn:executable deleted
    • Property svn:eol-style set to native
    r8457 r8706  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Andreas Büchel
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
    129#include "PortalLink.h"
    230#include "core/XMLPort.h"
     
    1745    PortalLink::~PortalLink()
    1846    {
     47       
    1948    }
    2049   
     
    3766        if(entrance == 0)
    3867        {
    39             // TODO COUT
    4068            return;
    4169        }
    4270       
    43         std::map<PortalEndPoint *, PortalEndPoint *>::iterator endpoint = PortalLink::links_s.find(entrance);
     71        std::map<PortalEndPoint *, PortalEndPoint *>::iterator endpoints = PortalLink::links_s.find(entrance);
    4472       
    45         if(endpoint == PortalLink::links_s.end())  // entrance has no corresponding exit
     73        if(endpoints == PortalLink::links_s.end())  // entrance has no corresponding exit
    4674            return;
    47        
    48         endpoint->second->jumpOut(entity);
     75
     76        endpoints->second->jumpOut(entity);
    4977    }
    50 
    51 
    5278}
  • code/trunk/src/modules/portals/PortalLink.h

    • Property svn:executable deleted
    • Property svn:eol-style set to native
    r8457 r8706  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Andreas Büchel
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
     29/**
     30    @file PortalLink.h
     31    @brief Declaration of the PortalLink class
     32    @ingroup Portals
     33 */
     34
    135#ifndef _PortalLink_H__
    236#define _PortalLink_H__
     
    1246namespace orxonox
    1347{
     48    /**
     49        @brief
     50            A PortalLink represents the connection between two @ref orxonox::PortalEndPoint "PortalEndPoints"
     51        @ingroup Portals
     52     */
    1453    class _PortalsExport PortalLink : public BaseObject
    1554    {
     
    3473                return this->toID_;
    3574            }
    36             static void use(MobileEntity * entity, PortalEndPoint * entrance);   //
     75            /*! \brief Let an entity enter a certain PortalEndPoint
     76                \param entity pointer to the entity which is entering a PortalEndPoint
     77                \param entrance pointer to the PortalEndPoint to enter
     78             */
     79            static void use(MobileEntity * entity, PortalEndPoint * entrance);   //!< let entity enter the PortalEndPoint pointed to by entrance
    3780        protected:
    3881        private:
    39             static std::map<PortalEndPoint *, PortalEndPoint *> links_s;
    40             unsigned int fromID_;
    41             unsigned int toID_;
    42             PortalEndPoint* from_;
    43             PortalEndPoint* to_;
    44             float activationRadius_;
    45             bool isNowPortable(WorldEntity * ent);
     82            static std::map<PortalEndPoint *, PortalEndPoint *> links_s;   //!< maps entrances to exits
     83            unsigned int fromID_;   //!< id of the entrance of this Link
     84            unsigned int toID_;   //!< id of the exit of this Link
     85            PortalEndPoint* from_;   //!< pointer to this Link's entrance
     86            PortalEndPoint* to_;   //!< pointer to this Link's exit
    4687    };
    47 
    4888}
    4989
  • code/trunk/src/modules/portals/PortalsPrecompiledHeaders.h

    • Property svn:eol-style set to native
  • code/trunk/src/modules/portals/PortalsPrereqs.h

    • Property svn:eol-style set to native
  • code/trunk/src/modules/questsystem/QuestDescription.cc

    r7474 r8706  
    4040#include "infos/PlayerInfo.h"
    4141
    42 #include "notifications/NotificationManager.h"
     42#include "interfaces/NotificationListener.h"
    4343
    4444namespace orxonox
     
    119119        }
    120120
    121         NotificationManager::sendNotification(message, player->getClientID(), QuestDescription::SENDER);
     121        NotificationListener::sendNotification(message, QuestDescription::SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());
    122122        return true;
    123123    }
  • code/trunk/src/modules/questsystem/QuestEffectBeacon.cc

    r8351 r8706  
    113113
    114114        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    115         Pawn* pawn = NULL;
     115        PlayerInfo* player = NULL;
    116116
    117117        // If the trigger is a PlayerTrigger.
     
    121121                return false;
    122122            else
    123                 pawn = pTrigger->getTriggeringPlayer();
     123                player = pTrigger->getTriggeringPlayer();
    124124        }
    125125        else
    126126            return false;
    127127
    128         if(pawn == NULL)
     128        if(player == NULL)
    129129        {
    130130            COUT(4) << "The QuestEffectBeacon was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    131             return false;
    132         }
    133 
    134         // Extract the PlayerInfo from the Pawn.
    135         PlayerInfo* player = pawn->getPlayer();
    136 
    137         if(player == NULL)
    138         {
    139             COUT(3) << "The PlayerInfo* is NULL." << std::endl;
    140131            return false;
    141132        }
  • code/trunk/src/modules/questsystem/QuestManager.cc

    r8079 r8706  
    274274    int QuestManager::getNumSubQuests(Quest* quest, PlayerInfo* player)
    275275    {
     276        if(quest == NULL)
     277            return this->getNumRootQuests(player);
     278
    276279        std::list<Quest*> quests = quest->getSubQuestList();
    277280        int numQuests = 0;
     
    296299    Quest* QuestManager::getSubQuest(Quest* quest, PlayerInfo* player, int index)
    297300    {
     301        if(quest == NULL)
     302            return this->getRootQuest(player, index);
     303
    298304        std::list<Quest*> quests = quest->getSubQuestList();
    299305        for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
     
    312318    @param player
    313319        The player.
    314     @return Returns the number of QuestHints of the input Quest for the input player.
     320    @return
     321        Returns the number of QuestHints of the input Quest for the input player.
    315322    */
    316323    int QuestManager::getNumHints(Quest* quest, PlayerInfo* player)
     
    335342    @param index
    336343        The index of the QuestHint.
     344    @return
     345        Returns a pointer to the index-th QuestHint of the input Quest for the input player.
    337346    */
    338347    QuestHint* QuestManager::getHints(Quest* quest, PlayerInfo* player, int index)
     
    345354        }
    346355        return NULL;
     356    }
     357
     358    /**
     359    @brief
     360        Get the parent-quest of the input Quest.
     361    @param quest
     362        The Quest to get the parent-quest of.
     363    @return
     364        Returns a pointer to the parent-quest of the input Quest.
     365    */
     366    Quest* QuestManager::getParentQuest(Quest* quest)
     367    {
     368        return quest->getParentQuest();
    347369    }
    348370
     
    375397    /**
    376398    @brief
     399        Get the id of the input Quest.
     400    @param item
     401        The Quest to get the id of.
     402    @return
     403        Returns the id of the input Quest.
     404    */
     405    const std::string QuestManager::getId(Quest* item) const
     406    {
     407        return item->getId();
     408    }
     409
     410    /**
     411    @brief
     412        Get the id of the input QuestHint.
     413    @param item
     414        The QuestHint to get the id of.
     415    @return
     416        Returns the id of the input QuestHint.
     417    */
     418    const std::string QuestManager::getId(QuestHint* item) const
     419    {
     420        return item->getId();
     421    }
     422
     423    /**
     424    @brief
    377425        Retrieve the player for a certain GUI.
    378426    @param guiName
  • code/trunk/src/modules/questsystem/QuestManager.h

    r7552 r8706  
    8181            QuestHint* getHints(Quest* quest, orxonox::PlayerInfo* player, int index); //!< Get the index-th QuestHint of the input Quest for the input player.
    8282
    83             QuestDescription* getDescription(Quest* item);
    84             QuestDescription* getDescription(QuestHint* item);
     83            Quest* getParentQuest(Quest* quest); //!< Get the parent-quest of the input Quest.
     84
     85            QuestDescription* getDescription(Quest* item); //!< Get the QuestDescription of the input Quest.
     86            QuestDescription* getDescription(QuestHint* item); //!< Get the QuestDescription of the input QuestHint.
     87
     88            const std::string getId(Quest* item) const; //!< Get the id of the input Quest.
     89            const std::string getId(QuestHint* item) const; //!< Get the id of the input QuestHint.
    8590            // tolua_end
    8691
  • code/trunk/src/modules/weapons/projectiles/CMakeLists.txt

    r7163 r8706  
    66  Rocket.cc
    77  SimpleRocket.cc
     8  BasicProjectile.cc
    89)
  • code/trunk/src/modules/weapons/projectiles/Projectile.cc

    r7284 r8706  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4141    CreateFactory(Projectile);
    4242
    43     Projectile::Projectile(BaseObject* creator) : MovableEntity(creator)
     43    Projectile::Projectile(BaseObject* creator) : MovableEntity(creator), BasicProjectile()
    4444    {
    4545        RegisterObject(Projectile);
    4646
    4747        this->setConfigValues();
    48         this->bDestroy_ = false;
    4948        this->owner_ = 0;
    50         this->damage_ = 15;
    5149
    5250        // Get notification about collisions
    53 
    5451        if (GameMode::isMaster())
    5552        {
     
    8481            return;
    8582
    86         if (this->bDestroy_)
     83        if (this->getBDestroy())
    8784            this->destroy(); // TODO: use a scheduler instead of deleting the object right here in tick()
    8885    }
     
    9491    }
    9592
     93    /* Calls the collidesAgainst function of BasicProjectile
     94     */
    9695    bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    9796    {
    98         if (!this->bDestroy_ && GameMode::isMaster())
    99         {
    100             if (otherObject == this->owner_)
    101                 return false;
    102 
    103             this->bDestroy_ = true;
    104 
    105             if (this->owner_)
    106             {
    107                 {
    108                     ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
    109                     effect->setPosition(this->getPosition());
    110                     effect->setOrientation(this->getOrientation());
    111                     effect->setDestroyAfterLife(true);
    112                     effect->setSource("Orxonox/explosion3");
    113                     effect->setLifetime(2.0f);
    114                 }
    115                 {
    116                     ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
    117                     effect->setPosition(this->getPosition());
    118                     effect->setOrientation(this->getOrientation());
    119                     effect->setDestroyAfterLife(true);
    120                     effect->setSource("Orxonox/smoke4");
    121                     effect->setLifetime(3.0f);
    122                 }
    123             }
    124 
    125             Pawn* victim = orxonox_cast<Pawn*>(otherObject);
    126             if (victim)
    127                 victim->hit(this->owner_, contactPoint, this->damage_);
    128         }
    129         return false;
     97        return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this);
    13098    }
    13199
  • code/trunk/src/modules/weapons/projectiles/Projectile.h

    r5929 r8706  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    3535#include "worldentities/MovableEntity.h"
    3636
     37#include "BasicProjectile.h"
     38
    3739namespace orxonox
    3840{
    39     class _WeaponsExport Projectile : public MovableEntity
     41    class _WeaponsExport Projectile : public MovableEntity, public BasicProjectile
    4042    {
    4143        public:
     
    4951            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    5052
    51             inline void setDamage(float damage)
    52                 { this->damage_ = damage; }
    53             inline float getDamage() const
    54                 { return this->damage_; }
    55 
    5653            void setOwner(Pawn* owner);
    5754            inline Pawn* getOwner() const
    5855                { return this->owner_; }
    5956
     57
    6058        private:
    6159            WeakPtr<Pawn> owner_;
    6260            float lifetime_;
    63             float damage_;
    64             bool bDestroy_;
    6561            Timer destroyTimer_;
    6662    };
  • code/trunk/src/modules/weapons/projectiles/Rocket.cc

    r7848 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    5252        Constructor. Registers the object and initializes some default values.
    5353    */
    54     Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator)
     54    Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator), BasicProjectile()
    5555    {
    5656        RegisterObject(Rocket);// - register the Rocket class to the core
    5757
    5858        this->localAngularVelocity_ = 0;
    59         this->bDestroy_ = false;
    6059        this->lifetime_ = 100;
    6160
     
    146145    {
    147146        this->owner_ = owner;
    148         this->player_ = this->owner_->getPlayer();
    149         this->owner_->getPlayer()->startTemporaryControl(this);
     147        this->player_ = this->getOwner()->getPlayer();
     148        this->getOwner()->getPlayer()->startTemporaryControl(this);
    150149
    151150        if( GameMode::isMaster() )
     
    175174        if( GameMode::isMaster() )
    176175        {
    177             if( this->bDestroy_ )
     176            if( this->getBDestroy() )
    178177                this->destroy();
    179178
     
    181180    }
    182181
     182    /* Calls the collidesAgainst function of BasicProjectile
     183     */
    183184    bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    184185    {
    185         if (!this->bDestroy_ && GameMode::isMaster())
    186         {
    187             if (otherObject == this->owner_)
    188                 return false;
    189 
    190             this->bDestroy_ = true;
    191 
    192             if (this->owner_)
    193             {
    194                 {
    195                     ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
    196                     effect->setPosition(this->getPosition());
    197                     effect->setOrientation(this->getOrientation());
    198                     effect->setDestroyAfterLife(true);
    199                     effect->setSource("Orxonox/explosion4");
    200                     effect->setLifetime(2.0f);
    201                 }
    202 
    203                 {
    204                     ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
    205                     effect->setPosition(this->getPosition());
    206                     effect->setOrientation(this->getOrientation());
    207                     effect->setDestroyAfterLife(true);
    208                     effect->setSource("Orxonox/smoke4");
    209                     effect->setLifetime(3.0f);
    210                 }
    211             }
    212 
    213             Pawn* victim = orxonox_cast<Pawn*>(otherObject);
    214             if (victim)
    215                 victim->hit(this->owner_, contactPoint, this->damage_);
    216 //             this->destroy();
    217         }
    218         return false;
     186        return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this);
    219187    }
    220188
     
    233201    void Rocket::fired(unsigned int firemode)
    234202    {
    235 //         if (this->owner_)
    236 //         {
    237             this->destroy();
    238 //         }
     203        this->destroy();
    239204    }
    240205
     
    242207    {
    243208        ParticleSpawner *effect1, *effect2;
    244         if( this->owner_ )
    245         {
    246             effect1 = new ParticleSpawner(this->owner_->getCreator());
    247             effect2 = new ParticleSpawner(this->owner_->getCreator());
     209        if( this->getOwner() )
     210        {
     211            effect1 = new ParticleSpawner(this->getOwner()->getCreator());
     212            effect2 = new ParticleSpawner(this->getOwner()->getCreator());
    248213        }
    249214        else
  • code/trunk/src/modules/weapons/projectiles/Rocket.h

    r7163 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    3434#include "tools/Timer.h"
    3535#include "worldentities/ControllableEntity.h"
     36
     37#include "BasicProjectile.h"
    3638
    3739namespace orxonox
     
    4648        Oli Scheuss
    4749    */
    48     class _WeaponsExport Rocket : public ControllableEntity
     50    class _WeaponsExport Rocket : public ControllableEntity, public BasicProjectile
    4951    {
    5052        public:
     
    109111                { return this->owner_; }
    110112
    111             inline void setDamage(float damage)
    112                 { this->damage_ = damage; }
    113             inline float getDamage() const
    114                 { return this->damage_; }
    115113            virtual void fired(unsigned int firemode);
    116114
     
    118116            WeakPtr<Pawn> owner_;
    119117            Vector3 localAngularVelocity_;
    120             float damage_;
    121             bool bDestroy_;
    122118
    123119            WeakPtr<PlayerInfo> player_;
  • code/trunk/src/modules/weapons/projectiles/SimpleRocket.cc

    r7163 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4848    CreateFactory(SimpleRocket);
    4949
    50     SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator)
     50    SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator), BasicProjectile()
    5151    {
    5252        RegisterObject(SimpleRocket);// - register the SimpleRocket class to the core
    5353
    5454        this->localAngularVelocity_ = 0;
    55         this->bDestroy_ = false;
    5655        this->lifetime_ = 120;
    5756
    5857        this->setMass(15);
    59         COUT(4) << "simplerocket constructed\n";
     58//        COUT(4) << "simplerocket constructed\n";
    6059
    6160        if (GameMode::isMaster())
     
    115114                this->disableFire();
    116115
    117             if( this->bDestroy_ )
     116            if( this->getBDestroy() )
    118117                this->destroy();
    119118        }
     
    159158    {
    160159        this->owner_ = owner;
    161         this->player_ = this->owner_->getPlayer();
    162     }
    163 
    164 
    165 
    166 
     160        this->player_ = this->getOwner()->getPlayer();
     161    }
     162
     163
     164    /* Calls the collidesAgainst function of BasicProjectile
     165     */
    167166    bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    168167    {
    169         if (!this->bDestroy_ && GameMode::isMaster())
    170         {
    171             if (otherObject == this->owner_)
    172                 return false;
    173 
    174             this->bDestroy_ = true;
    175 
    176             if (this->owner_)
    177             {
    178                 {
    179                     ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
    180                     effect->setPosition(this->getPosition());
    181                     effect->setOrientation(this->getOrientation());
    182                     effect->setDestroyAfterLife(true);
    183                     effect->setSource("Orxonox/explosion4");
    184                     effect->setLifetime(2.0f);
    185                 }
    186 
    187                 {
    188                     ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
    189                     effect->setPosition(this->getPosition());
    190                     effect->setOrientation(this->getOrientation());
    191                     effect->setDestroyAfterLife(true);
    192                     effect->setSource("Orxonox/smoke4");
    193                     effect->setLifetime(3.0f);
    194                 }
    195             }
    196 
    197             float dmg = this->damage_;
    198 //             if (this->owner_)
    199 //                 dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
    200 
    201             Pawn* victim = orxonox_cast<Pawn*>(otherObject);
    202             if (victim)
    203                 victim->hit(this->owner_, contactPoint, dmg);
    204         }
    205         return false;
     168        return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this);
    206169    }
    207170
  • code/trunk/src/modules/weapons/projectiles/SimpleRocket.h

    r7163 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    3636#include "graphics/ParticleSpawner.h"
    3737
     38#include "BasicProjectile.h"
     39
    3840namespace orxonox
    3941{
     
    4648       Gabriel Nadler (Original file: Oli Scheuss)
    4749    */
    48     class _WeaponsExport SimpleRocket : public ControllableEntity
     50    class _WeaponsExport SimpleRocket : public ControllableEntity, public BasicProjectile
    4951    {
    5052        public:
     
    111113            inline Pawn* getOwner() const
    112114                { return this->owner_; }
     115
    113116            inline bool hasFuel() const
    114117            { return this->fuel_; }
    115 
    116             inline void setDamage(float damage)
    117                 { this->damage_ = damage; }
    118             inline float getDamage() const
    119                 { return this->damage_; }
    120118
    121119
     
    123121            WeakPtr<Pawn> owner_;
    124122            Vector3 localAngularVelocity_;
    125             float damage_;
    126             bool bDestroy_;
    127123            bool fuel_; //!< Bool is true while the rocket "has fuel"
    128124
  • code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc

    r7284 r8706  
    2323 *      Hagen Seifert
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    5050
    5151        this->reloadTime_ = 0.25;
    52         this->damage_ = 15;
     52        this->damage_ = 0; //default 15
    5353        this->speed_ = 2500;
    5454        this->delay_ = 0;
     
    9797    }
    9898
     99    /* Creates the projectile object, sets its properties to the EnergyDrink properties, calls muendungsfeuer()
     100     */
    99101    void EnergyDrink::shot()
    100102    {
     
    112114        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    113115        projectile->setDamage(this->getDamage());
     116        projectile->setShieldDamage(this->getShieldDamage());
     117        projectile->setHealthDamage(this->getHealthDamage());
    114118
    115119        EnergyDrink::muendungsfeuer();
  • code/trunk/src/modules/weapons/weaponmodes/FusionFire.cc

    r6732 r8706  
    2323 *      Martin Polak
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4848        this->reloadTime_ = 1.0;
    4949        this->bParallelReload_ = false;
    50         this->damage_ = 40;
     50        this->damage_ = 0; //default 40
    5151        this->speed_ = 1250;
    5252
     
    5454    }
    5555
     56    /* Creates the projectile (BillboardProjectile) object, sets its properties to the FusionFire properties
     57     */
    5658    void FusionFire::fire()
    5759    {
     
    6567        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    6668        projectile->setDamage(this->getDamage());
     69        projectile->setShieldDamage(this->getShieldDamage());
     70        projectile->setHealthDamage(this->getHealthDamage());
     71
    6772        projectile->setColour(ColourValue(1.0f, 0.7f, 0.3f, 1.0f));
    6873    }
  • code/trunk/src/modules/weapons/weaponmodes/HsW01.cc

    r7284 r8706  
    2323 *      Hagen Seifert
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    5151
    5252        this->reloadTime_ = 0.25;
    53         this->damage_ = 15;
     53        this->damage_ = 0; //default 15
    5454        this->speed_ = 2500;
    5555        this->delay_ = 0;
     
    109109    }
    110110
     111    /* Creates the projectile object, sets its properties to the HsW01 properties, calls muendungsfeuer()
     112     */
    111113    void HsW01::shot()
    112114    {
     
    126128        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    127129        projectile->setDamage(this->getDamage());
     130        projectile->setShieldDamage(this->getShieldDamage());
     131        projectile->setHealthDamage(this->getHealthDamage());
    128132
    129133        HsW01::muendungsfeuer();
  • code/trunk/src/modules/weapons/weaponmodes/LaserFire.cc

    r6732 r8706  
    2323 *      Martin Polak
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4545
    4646        this->reloadTime_ = 0.25;
    47         this->damage_ = 15;
     47        this->damage_ = 0; //default 15
    4848        this->speed_ = 1250;
    4949
     
    5151    }
    5252
     53    /* Creates the projectile object, sets its properties to the LaserFire properties
     54     */
    5355    void LaserFire::fire()
    5456    {
     
    6163        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    6264        projectile->setDamage(this->getDamage());
     65        projectile->setShieldDamage(this->getShieldDamage());
     66        projectile->setHealthDamage(this->getHealthDamage());
    6367    }
    6468}
  • code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc

    r6732 r8706  
    2323 *      Joel Smely
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4545
    4646        this->reloadTime_ = 1;
    47         this->damage_ = 100;
     47        this->damage_ = 0; //default 100
    4848        this->speed_ = 150;
    4949
     
    5656    }
    5757
     58    /* Creates the projectile (LightningGunProjectile) object, sets its properties to the LightningGun properties
     59     */
    5860    void LightningGun::fire()
    5961    {
     
    6971        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    7072        projectile->setDamage(this->getDamage());
     73        projectile->setShieldDamage(this->getShieldDamage());
     74        projectile->setHealthDamage(this->getHealthDamage());
    7175    }
    7276}
  • code/trunk/src/modules/weapons/weaponmodes/RocketFire.cc

    r7846 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4848        this->reloadTime_ = 0.20f;
    4949        this->bParallelReload_ = false;
    50         this->damage_ = 100;
     50        this->damage_ = 0;
    5151        this->speed_ = 500;
    5252
     
    5959    }
    6060
     61    /* Creates the Rocket object, sets its properties to the RocketFire properties
     62     */
    6163    void RocketFire::fire()
    6264    {
     
    7173        rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    7274        rocket->setDamage(this->getDamage());
     75        rocket->setShieldDamage(this->getShieldDamage());
     76        rocket->setHealthDamage(this->getHealthDamage());
    7377    }
    7478}
  • code/trunk/src/modules/weapons/weaponmodes/SimpleRocketFire.cc

    r7846 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    5050        this->reloadTime_ = 1;
    5151        this->bParallelReload_ = false;
    52         this->damage_ = 100;
     52        this->damage_ = 0;
    5353        this->speed_ = 500;
    5454
     
    6262    }
    6363
     64    /* Creates the Rocket (RocketController) object, sets its properties to the SimpleRocketFire properties, sets target
     65     */
    6466    void SimpleRocketFire::fire()
    6567    {
     
    7173        rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
    7274        rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
     75
    7376        rocket->setDamage(this->damage_);
     77        rocket->setShieldDamage(this->getShieldDamage());
     78        rocket->setHealthDamage(this->getHealthDamage());
     79
    7480        WorldEntity* pawnn=static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget();
    7581        if (pawnn) con->setTarget(pawnn);
Note: See TracChangeset for help on using the changeset viewer.