Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 11, 2010, 8:55:13 AM (14 years ago)
Author:
dafrick
Message:

Merged presentation3 branch into trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/interfaces/Pickupable.h

    • Property svn:eol-style set to native
    r6901 r7163  
    4141
    4242#include "core/OrxonoxClass.h"
     43#include "Rewardable.h"
    4344
    44 namespace orxonox
    45 {
    46    
     45namespace orxonox // tolua_export
     46{ // tolua_export
     47
    4748    /**
    4849    @brief
     
    5152        Damian 'Mozork' Frick
    5253    */
    53     class _OrxonoxExport Pickupable : virtual public OrxonoxClass
    54     {
     54    class _OrxonoxExport Pickupable  // tolua_export
     55        : virtual public OrxonoxClass, public Rewardable
     56    {  // tolua_export
    5557        protected:
    5658            Pickupable(); //!< Default constructor.
    57        
     59
    5860        public:
    5961            virtual ~Pickupable(); //!< Default destructor.
    60            
     62
    6163            /**
    6264            @brief Get whether the pickup is currently in use or not.
    6365            @return Returns true if the pickup is currently in use.
    6466            */
    65             inline bool isUsed(void)
    66                 { return this->used_; }
     67            inline bool isUsed(void) { return this->used_; }  // tolua_export
    6768            /**
    6869            @brief  Should be called when the pickup has transited from used to unused or the other way around.
     
    7071            */
    7172            virtual void changedUsed(void) {}
    72            
     73
    7374            /**
    7475            @brief Get the carrier of the pickup.
     
    8283            */
    8384            virtual void changedCarrier(void) {}
    84            
     85
    8586            /**
    8687            @brief Returns whether the Pickupable is currently picked up.
    8788            @return Returns true if the Pickupable is currently picked up, false if not.
    8889            */
    89             inline bool isPickedUp(void)
    90                 { return this->pickedUp_; }
     90            inline bool isPickedUp(void) { return this->pickedUp_; }  // tolua_export
    9191            /**
    9292            @brief  Should be called when the pickup has transited from picked up to dropped or the other way around.
     
    9494            */
    9595            virtual void changedPickedUp(void) {}
     96
     97            /**
     98            @brief Returns whether the Pickupable can be used.
     99            @return Returns true if it can be used.
     100            */
     101            inline bool isUsable(void) { return this->enabled_; } // tolua_export
    96102           
    97             bool pickedUp(PickupCarrier* carrier); //!< Sets the Pickupable to picked up.
    98             bool dropped(void); //!< Sets the Pickupable to not picked up or dropped.
    99            
     103            /**
     104            @brief Returns whether the Pickupable can be unused.
     105            @return Returns true if it can be unused.
     106            */
     107            inline bool isUnusable(void) { return this->enabled_; } // tolua_export
     108
     109            /**
     110            @brief Returns whether the Pickupable is enabled.
     111                   Once a Pickupable is disabled it cannot be enabled again. A Pickupable that is disabled can neither be used nor unused.
     112            @return Returns true if the Pickupable is enabled.
     113            */
     114            inline bool isEnabled(void)
     115                { return this->enabled_; }
     116
     117            bool pickup(PickupCarrier* carrier); //!< Can be called to pick up a Pickupable.
     118            bool drop(bool createSpawner = true); //!< Can be called to drop a Pickupable.
     119
    100120            virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether the given PickupCarrier is a target of this pickup.
    101121            bool isTarget(const Identifier* identifier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this Pickupable.
    102122            bool addTarget(PickupCarrier* target); //!< Add a PickupCarrier as target of this pickup.
    103123            bool addTarget(Identifier* identifier); //!< Add a class, representetd by the input Identifier, as target of this pickup.
    104            
     124
    105125            Pickupable* clone(void); //!< Creates a duplicate of the Pickupable.
    106126            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    107            
     127
    108128            /**
    109129            @brief Get the PickupIdentifier of this Pickupable.
     
    112132            virtual const PickupIdentifier* getPickupIdentifier(void)
    113133                { return this->pickupIdentifier_; }
    114                
     134
    115135            bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input.
    116136            bool setPickedUp(bool pickedUp); //!< Helper method to set the Pickupable to either picked up or not picked up.
    117             bool setCarrier(PickupCarrier* carrier); //!< Sets the carrier of the pickup.
    118            
     137            //TODO: private?
     138            bool setCarrier(PickupCarrier* carrier, bool tell = true); //!< Sets the carrier of the pickup.
     139
     140            //TODO: private?
     141            virtual void carrierDestroyed(void); //!< Is called by the PickupCarrier when it is being destroyed.
     142
     143            void destroy(void); //!< Is called internally within the pickup module to destroy pickups.
     144
    119145        protected:
    120146            /**
     
    122148            */
    123149            void initializeIdentifier(void) {}
    124            
     150
     151            virtual void preDestroy(void); //!< A method that is called by OrxonoxClass::destroy() before the object is actually destroyed.
     152            virtual void destroyPickup(void); //!< Destroys a Pickupable.
     153
     154            /**
     155            @brief Sets the Pickuapble to disabled.
     156            */
     157            inline void setDisabled(void)
     158                { this->enabled_ = false; }
     159
    125160            /**
    126161            @brief Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
     
    131166            */
    132167            virtual bool createSpawner(void) = 0;
    133            
     168
    134169            PickupIdentifier* pickupIdentifier_; //!< The PickupIdentifier of this Pickupable.
    135            
     170
    136171        private:
    137            
    138             bool used_; //!< Whether the pickup is currently in use or not.
    139             bool pickedUp_; //!< Whether the pickup is currently picked up or not.
    140            
    141             PickupCarrier* carrier_; //!< The carrier of the pickup.
    142             std::list<Identifier*> targets_; //!< The possible targets of this pickup.
    143172
    144     };
    145    
     173            bool used_; //!< Whether the Pickupable is currently in use or not.
     174            bool pickedUp_; //!< Whether the Pickupable is currently picked up or not.
     175
     176            bool enabled_; //!< Whether the Pickupable is enabled or not.
     177
     178            PickupCarrier* carrier_; //!< The PickupCarrier of the Pickupable.
     179            std::list<Identifier*> targets_; //!< The possible targets of this Pickupable.
     180
     181            bool beingDestroyed_; //!< Is true if the Pickupable is in the process of being destroyed.
     182
     183        // For implementing the Rewardable interface:
     184        public:
     185            virtual bool reward(PlayerInfo* player); //!< Method to transcribe a Pickupable as a Rewardable to the player.
     186
     187    };  // tolua_export
     188
    146189    SUPER_FUNCTION(10, Pickupable, changedUsed, false);
    147190    SUPER_FUNCTION(12, Pickupable, changedCarrier, false);
    148191    SUPER_FUNCTION(13, Pickupable, changedPickedUp, false);
    149 }
     192}  // tolua_export
    150193
    151194#endif /* _Pickupable_H__ */
Note: See TracChangeset for help on using the changeset viewer.