Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 6, 2010, 8:00:40 AM (14 years ago)
Author:
dafrick
Message:

Pickups module is now (from what I can tell after some basic testing) fully functional over the network.
However it's still a little messy, needs some cleanup and documentation.
I introduced a new class, the PickupListener, which allows reacting to pickups becoming used, unused, picked up or dropped.

Location:
code/trunk/src/orxonox/interfaces
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/interfaces/CMakeLists.txt

    r7494 r7504  
    33  Pickupable.cc
    44  PickupCarrier.cc
     5  PickupListener.cc
    56  RadarViewable.cc
    67)
  • code/trunk/src/orxonox/interfaces/Pickupable.cc

    r7494 r7504  
    3434#include "Pickupable.h"
    3535
    36 #include "core/LuaState.h"
    37 #include "core/GUIManager.h"
    3836#include "core/Identifier.h"
    3937#include "core/CoreIncludes.h"
     
    4543
    4644#include "PickupCarrier.h"
     45#include "PickupListener.h"
    4746
    4847namespace orxonox
     
    130129
    131130        this->used_ = used;
     131
     132        // Notify all the PickupListeners of the change.
     133        PickupListener::broadcastPickupChangedUsed(this, used);
     134
    132135        this->changedUsed();
    133136
    134         //TODO: Synchronize & make safe for dedicated server.
    135         GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()");
     137
    136138        return true;
    137139    }
     
    222224            return false;
    223225        }
    224        
     226
    225227        this->setPickedUp(true);
    226228        COUT(4) << "Pickupable (&" << this << ") got picked up by a PickupCarrier (&" << carrier << ")." << std::endl;
     
    277279
    278280        this->pickedUp_ = pickedUp;
     281
     282        // Notify all the PickupListeners of the change.
     283        PickupListener::broadcastPickupChangedPickedUp(this, pickedUp);
     284
    279285        if(!pickedUp) // if the Pickupable has been dropped it unregisters itself with its PickupCarrier.
    280286            this->getCarrier()->removePickup(this);
    281287        this->changedPickedUp();
    282288
    283         //TODO: Synchronize & make safe for dedicated server.
    284         GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()");
    285289        return true;
    286290    }
  • code/trunk/src/orxonox/interfaces/Pickupable.h

    r7494 r7504  
    4444#include "Rewardable.h"
    4545
    46 namespace orxonox // tolua_export
    47 { // tolua_export
     46namespace orxonox
     47{
    4848
    4949    /**
     
    5858        Damian 'Mozork' Frick
    5959    */
    60     class _OrxonoxExport Pickupable  // tolua_export
    61         : virtual public OrxonoxClass, public Rewardable
    62     {  // tolua_export
     60    class _OrxonoxExport Pickupable : virtual public OrxonoxClass, public Rewardable
     61    {
    6362        protected:
    6463            Pickupable(); //!< Default constructor.
     
    7170            @return Returns true if the Pickupable is currently in use.
    7271            */
    73             inline bool isUsed(void) { return this->used_; }  // tolua_export
     72            inline bool isUsed(void)
     73                { return this->used_; }
    7474            /**
    7575            @brief  Should be called when the Pickupable has transited from used to unused or the other way around.
     
    9494            @return Returns true if the Pickupable is currently picked up, false if not.
    9595            */
    96             inline bool isPickedUp(void) { return this->pickedUp_; }  // tolua_export
     96            inline bool isPickedUp(void)
     97                { return this->pickedUp_; }
    9798            /**
    9899            @brief  Should be called when the Pickupable has transited from picked up to dropped or the other way around.
     
    105106            @return Returns true if it can be used.
    106107            */
    107             inline bool isUsable(void) { return this->enabled_; } // tolua_export
    108            
     108            inline bool isUsable(void)
     109                { return this->enabled_; }
     110
    109111            /**
    110112            @brief Returns whether the Pickupable can be unused.
    111113            @return Returns true if it can be unused.
    112114            */
    113             inline bool isUnusable(void) { return this->enabled_; } // tolua_export
     115            inline bool isUnusable(void)
     116                { return this->enabled_; }
    114117
    115118            /**
     
    190193            virtual bool reward(PlayerInfo* player); //!< Method to transcribe a Pickupable as a Rewardable to the player.
    191194
    192     };  // tolua_export
     195    };
    193196
    194197    //! SUPER functions.
     
    196199    SUPER_FUNCTION(12, Pickupable, changedCarrier, false);
    197200    SUPER_FUNCTION(13, Pickupable, changedPickedUp, false);
    198 }  // tolua_export
     201}
    199202
    200203#endif /* _Pickupable_H__ */
Note: See TracChangeset for help on using the changeset viewer.