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:
11 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r5781 r7163  
    4444            virtual void killmessage(const GametypeInfo* gtinfo, const std::string& message) {}
    4545            virtual void deathmessage(const GametypeInfo* gtinfo, const std::string& message) {}
     46            virtual void staticmessage(const GametypeInfo* gtinfo, const std::string& message, const ColourValue& colour) {}
     47            virtual void fadingmessage(const GametypeInfo* gtinfo, const std::string& message) {}
    4648    };
    4749}
  • code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc

    r6711 r7163  
    5252        RegisterRootObject(GametypeMessageListener);
    5353    }
    54    
     54
    5555    //----------------------------
    5656    // PickupCarrier
     
    5959    {
    6060        RegisterRootObject(PickupCarrier);
    61        
    62         this->setCarrierName("PickupCarrier");
    6361    }
    64    
     62
    6563    PickupCarrier::~PickupCarrier()
    6664    {
     65
     66    }
     67
     68    void PickupCarrier::preDestroy(void)
     69    {
    6770        std::set<Pickupable*>::iterator it = this->pickups_.begin();
     71        std::set<Pickupable*>::iterator temp;
    6872        while(it != this->pickups_.end())
    6973        {
    70             (*(it++))->destroy();
     74            (*it)->carrierDestroyed();
     75            temp = it;
     76            it = this->pickups_.begin();
     77            if(it == temp) // Infinite loop avoidance, in case the pickup wasn't removed from the carrier somewhere in the carrierDestroy() procedure.
     78            {
     79                COUT(2) << "Oops. In a PickupCarrier, while cleaning up, a Pickupable (&" << (*temp) << ") didn't unregister itself as it should have." << std::endl;;
     80                it++;
     81            }
    7182        }
    7283
     
    8495        this->isForPlayer_ = true;
    8596    }
    86    
     97
    8798    //----------------------------
    8899    // RadarListener
  • code/trunk/src/orxonox/interfaces/NotificationListener.h

    r5929 r7163  
    4747    class Notification;
    4848
     49    /**
     50    @brief
     51        NotificationListener interface.
     52    @author
     53        Fabian 'x3n' Landau
     54    */
    4955    class _OrxonoxExport NotificationListener : virtual public OrxonoxClass
    5056    {
  • code/trunk/src/orxonox/interfaces/PickupCarrier.h

    • Property svn:eol-style set to native
    r6711 r7163  
    4545#include "core/OrxonoxClass.h"
    4646
    47 namespace orxonox // tolua_export
    48 { // tolua_export
     47namespace orxonox
     48{
    4949
    5050    //! Forward-declarations.
     
    5454    class InvisiblePickup;
    5555    class MetaPickup;
     56    class DronePickup;
    5657    class SpeedPickup;
    5758
     
    6263        Damian 'Mozork' Frick
    6364    */
    64     class _OrxonoxExport PickupCarrier  // tolua_export
    65         : virtual public OrxonoxClass
    66     { // tolua_export
     65    class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass
     66    {
    6767        //! So that the different Pickupables have full access to their PickupCarrier.
    6868        friend class Pickupable;
    6969        friend class PickupManager;
    70         //! Friends. 
     70        //! Friends.
    7171        friend class Pickup;
    7272        friend class HealthPickup;
    7373        friend class InvisiblePickup;
    7474        friend class MetaPickup;
     75        friend class DronePickup;
    7576        friend class SpeedPickup;
    7677
     
    7879            PickupCarrier(); //!< Constructor.
    7980            virtual ~PickupCarrier(); //!< Destructor.
    80 
    81             /**
    82             @brief Can be called to pick up a Pickupable.
    83             @param pickup A pointer to the Pickupable.
    84             @return Returns true if the Pickupable was picked up, false if not.
    85             */
    86             bool pickup(Pickupable* pickup)
    87                 {
    88                     bool pickedUp = this->pickups_.insert(pickup).second;
    89                     if(pickedUp)
    90                     {
    91                         COUT(4) << "Picked up Pickupable " << pickup->getIdentifier()->getName() << "(&" << pickup << ")." << std::endl;
    92                         pickup->pickedUp(this);
    93                     }
    94                     return pickedUp;
    95                 }
    96 
    97             /**
    98             @brief Can be called to drop a Pickupable.
    99             @param pickup A pointer to the Pickupable.
    100             @param drop If the Pickupable should just be removed from the PickupCarrier without further action, this can be set to false. true is default.
    101             @return Returns true if the Pickupable has been dropped, false if not.
    102             */
    103             bool drop(Pickupable* pickup, bool drop = true)
    104                 {
    105                     bool dropped = this->pickups_.erase(pickup) == 1;
    106                     if(dropped && drop)
    107                     {
    108                         COUT(4) << "Dropping Pickupable " << pickup->getIdentifier()->getName() << "(&" << pickup << ")." << std::endl;
    109                         pickup->dropped();
    110                     }
    111                     return dropped;
    112                 }
     81            void preDestroy(void);
    11382
    11483            /**
     
    169138            */
    170139            virtual const Vector3& getCarrierPosition(void) = 0;
    171            
    172             /**
    173             @brief Get the name of this PickupCarrier.
    174             @return Returns the name as a string.
    175             */
    176             const std::string& getCarrierName(void) { return this->carrierName_; } // tolua_export
    177            
    178         protected:       
     140
     141        protected:
    179142            /**
    180143            @brief Get all direct children of this PickupSpawner.
     
    197160            std::set<Pickupable*>& getPickups(void)
    198161                { return this->pickups_; }
    199                
    200             /**
    201             @brief Set the name of this PickupCarrier.
    202                    The name needs to be set in the constructor of every class inheriting from PickupCarrier, by calling setCarrierName().
    203             @param name The name to be set.
    204             */
    205             void setCarrierName(const std::string& name)
    206                 { this->carrierName_ = name; }
    207        
     162
    208163        private:
    209164            std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier.
    210             std::string carrierName_; //!< The name of the PickupCarrier, as displayed in the PickupInventory.
    211            
     165
    212166            /**
    213             @brief Get the number of carrier children this PickupCarrier has.
    214             @return Returns the number of carrier children.
     167            @brief Adds a Pickupable to the list of pickups that are carried by this PickupCarrier.
     168            @param pickup A pointer to the pickup to be added.
     169            @return Returns true if successfull, false if the Pickupable was already present.
    215170            */
    216             unsigned int getNumCarrierChildren(void)
     171            bool addPickup(Pickupable* pickup)
    217172                {
    218                     std::vector<PickupCarrier*>* list = this->getCarrierChildren();
    219                     unsigned int size = list->size();
    220                     delete list;
    221                     return size;
     173                    COUT(4) << "Adding Pickupable (&" << pickup << ") to PickupCarrier (&" << this << ")" << std::endl;
     174                    return this->pickups_.insert(pickup).second;
    222175                }
    223            
     176
    224177            /**
    225             @brief Get the index-th child of this PickupCarrier.
    226             @param index The index of the child to return.
    227             @return Returns the index-th child.
     178            @brief Removes a Pickupable from the list of pickups that are carried by thsi PickupCarrier.
     179            @param pickup A pointer to the pickup to be removed.
     180            @return Returns true if successfull, false if the Pickupable was not present in the list.
    228181            */
    229             PickupCarrier* getCarrierChild(unsigned int index)
     182            bool removePickup(Pickupable* pickup)
    230183                {
    231                     std::vector<PickupCarrier*>* list = this->getCarrierChildren();
    232                     if(list->size() < index)
    233                         return NULL;
    234                     PickupCarrier* carrier = (*list)[index];
    235                     delete list;
    236                     return carrier;
     184                    COUT(4) << "Removing Pickupable (&" << pickup << ") from PickupCarrier (&" << this << ")" << std::endl;
     185                    return this->pickups_.erase(pickup) == 1;
    237186                }
    238            
    239             /**
    240             @brief Get the number of Pickupables this PickupCarrier carries.
    241             @return returns the number of pickups.
    242             */
    243             unsigned int getNumPickups(void)
    244                 { return this->pickups_.size(); }
    245            
    246             /**
    247             @brief Get the index-th Pickupable of this PickupCarrier.
    248             @param index The index of the Pickupable to return.
    249             @return Returns the index-th pickup.
    250             */
    251             Pickupable* getPickup(unsigned int index)
    252                 {
    253                     std::set<Pickupable*>::iterator it;
    254                     for(it = this->pickups_.begin(); index != 0 && it != this->pickups_.end(); it++)
    255                         index--;
    256                     if(it == this->pickups_.end())
    257                         return NULL;
    258                     return *it;
    259                 }
    260            
    261     }; // tolua_export
    262 } // tolua_export
     187
     188    };
     189}
    263190
    264191#endif /* _PickupCarrier_H__ */
  • code/trunk/src/orxonox/interfaces/Pickupable.cc

    • Property svn:eol-style set to native
    r6901 r7163  
    3434#include "Pickupable.h"
    3535
     36#include "core/LuaState.h"
     37#include "core/GUIManager.h"
    3638#include "core/Identifier.h"
    3739#include "core/CoreIncludes.h"
     40#include "util/Convert.h"
     41#include "infos/PlayerInfo.h"
    3842#include "pickup/PickupIdentifier.h"
     43#include "worldentities/pawns/Pawn.h"
    3944#include "PickupCarrier.h"
    4045
    4146namespace orxonox
    4247{
    43    
     48
    4449    /**
    4550    @brief
     
    4752    */
    4853    Pickupable::Pickupable() : pickupIdentifier_(NULL), used_(false), pickedUp_(false)
    49     {       
     54    {
    5055        RegisterRootObject(Pickupable);
    51        
     56
    5257        this->carrier_ = NULL;
    53        
     58
    5459        this->pickupIdentifier_ = new PickupIdentifier(this);
    55     }
    56    
    57     /**
    58     @brief
    59         Destructor.
     60        this->beingDestroyed_ = false;
     61        this->enabled_ = true;
     62    }
     63
     64    /**
     65    @brief
     66        Destructor.
    6067    */
    6168    Pickupable::~Pickupable()
    6269    {
    63         if(this->isUsed())
    64             this->setUsed(false);
    65        
    66         if(this->isPickedUp() && this->getCarrier() != NULL)
    67         {
    68             this->getCarrier()->drop(this, false);
    69             this->setCarrier(NULL);
    70         }
    71        
     70        COUT(4) << "Pickupable (" << this->getIdentifier()->getName() << ") (&" << this << ") destroyed." << std::endl;
    7271        if(this->pickupIdentifier_ != NULL)
    7372            this->pickupIdentifier_->destroy();
    7473    }
    75    
     74
     75    /**
     76    @brief
     77        A method that is called by OrxonoxClass::destroy() before the object is actually destroyed.
     78    */
     79    void Pickupable::preDestroy(void)
     80    {
     81        this->beingDestroyed_ = true;
     82
     83        if(this->isPickedUp())
     84            this->drop(false); // Drops the pickup without creating a PickupSpawner.
     85    }
     86
     87    /**
     88    @brief
     89        Is called internally within the pickup module to destroy pickups.
     90    */
     91    void Pickupable::destroy(void)
     92    {
     93        this->destroyPickup();
     94    }
     95
     96    /**
     97    @brief
     98        Destroys a Pickupable.
     99        If the Pickupable is already in the process of being destroyed a warning is displayed and this method is skipped.
     100    */
     101    void Pickupable::destroyPickup(void)
     102    {
     103        if(!this->beingDestroyed_)
     104            this->OrxonoxClass::destroy();
     105        else
     106            COUT(2) << this->getIdentifier()->getName() << " may be unsafe. " << std::endl;
     107    }
     108
    76109    /**
    77110    @brief
     
    84117    bool Pickupable::setUsed(bool used)
    85118    {
    86         if(this->used_ == used)
    87             return false;
    88        
     119        if(this->used_ == used || !this->isPickedUp()) // If either the used status of the Pickupable doesn't change or it isn't picked up.
     120            return false;
     121
     122        if((!this->isUsable() && used) || (!this->isUnusable() && !used)) // If either the Pickupable is requested to be used but it is not usable or the Pickupable is requested to be unused, while it is not unusable.
     123            return false;
     124
    89125        COUT(4) << "Pickupable (&" << this << ") set to used " << used << "." << std::endl;
    90        
     126
    91127        this->used_ = used;
    92128        this->changedUsed();
    93         return true;
    94     }
    95    
     129
     130        GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()");
     131        return true;
     132    }
     133
    96134    /**
    97135    @brief
     
    106144        if(carrier == NULL)
    107145            return false;
     146
    108147        return this->isTarget(carrier->getIdentifier());
    109148    }
    110    
     149
    111150    /**
    112151    @brief
     
    125164                return true;
    126165        }
     166
    127167        return false;
    128168    }
    129        
     169
    130170    /**
    131171    @brief
     
    140180        return this->addTarget(target->getIdentifier());
    141181    }
    142    
     182
    143183    /**
    144184    @brief
     
    153193        if(this->isTarget(target)) //!< If the input target is already present in the list of targets.
    154194            return false;
    155        
     195
    156196        COUT(4) << "Target " << target->getName() << " added to Pickupable (&" << this << ")." << std::endl;
    157197        this->targets_.push_back(target);
    158198        return true;
    159199    }
    160    
    161     /**
    162     @brief 
    163         Sets the Pickupable to picked up.
    164         This method will be called by the PickupCarrier picking the Pickupable up.
     200
     201    /**
     202    @brief
     203        Can be called to pick up a Pickupable.
    165204    @param carrier
    166         The PickupCarrier that picked the Pickupable up.
    167     @return
    168         Returns false if, for some reason, the pickup could not be picked up, e.g. it was picked up already.
    169     */
    170     bool Pickupable::pickedUp(PickupCarrier* carrier)
    171     {
    172         if(this->isPickedUp()) //!< If the Pickupable is already picked up.
    173             return false;
     205        A pointer to the PickupCarrier that picks up the Pickupable.
     206    @return
     207        Returns true if the Pickupable was picked up, false if not.
     208    */
     209    bool Pickupable::pickup(PickupCarrier* carrier)
     210    {
     211        if(carrier == NULL || this->isPickedUp()) //!< If carrier is NULL or the Pickupable is already picked up.
     212            return false;
     213
     214        if(!this->setCarrier(carrier))
     215        {
     216            COUT(3) << "A Pickupable (&" << this << ") was trying to be added to a PickupCarrier, but was already present." << std::endl;
     217            return false;
     218        }
    174219       
     220        this->setPickedUp(true);
    175221        COUT(4) << "Pickupable (&" << this << ") got picked up by a PickupCarrier (&" << carrier << ")." << std::endl;
    176         this->setCarrier(carrier);
    177         this->setPickedUp(true);
    178         return true;
    179     }
    180    
     222        return true;
     223    }
     224
     225    /**
     226    @brief
     227        Can be called to drop a Pickupable.
     228    @param createSpawner
     229        If true a spawner is to be created for the dropped Pickupable. True is default.
     230    @return
     231        Returns true if the Pickupable has been dropped, false if not.
     232    */
     233    bool Pickupable::drop(bool createSpawner)
     234    {
     235        if(!this->isPickedUp()) // If the Pickupable is not picked up.
     236            return false;
     237
     238        assert(this->getCarrier()); // The Carrier cannot be NULL at this point.
     239        if(!this->getCarrier()->removePickup(this)) //TODO Shouldn't this be a little later?
     240            COUT(2) << "Pickupable (&" << this << ", " << this->getIdentifier()->getName() << ") is being dropped, but it was not present in the PickupCarriers list of pickups." << std::endl;
     241
     242        COUT(4) << "Pickupable (&" << this << ") got dropped up by a PickupCarrier (&" << this->getCarrier() << ")." << std::endl;
     243        this->setUsed(false);
     244        this->setPickedUp(false);
     245
     246        bool created = false;
     247        if(createSpawner)
     248            created = this->createSpawner();
     249
     250        this->setCarrier(NULL);
     251
     252        if(!created && createSpawner) // If a PickupSpawner should have been created but wasn't.
     253            this->destroy();
     254
     255        return true;
     256    }
     257
    181258    /**
    182259    @brief
     
    189266    bool Pickupable::setPickedUp(bool pickedUp)
    190267    {
    191         if(this->pickedUp_ == pickedUp)
    192             return false;
    193        
     268        if(this->pickedUp_ == pickedUp) // If the picked up status has not changed.
     269            return false;
     270
    194271        COUT(4) << "Pickupable (&" << this << ") set to pickedUp " << pickedUp << "." << std::endl;
    195        
     272
    196273        this->pickedUp_ = pickedUp;
     274        if(!pickedUp) // if the Pickupable has been dropped it unregisters itself with its PickupCarrier.
     275            this->getCarrier()->removePickup(this);
    197276        this->changedPickedUp();
    198         return true;
    199     }
    200        
     277        GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()");
     278        return true;
     279    }
     280
    201281    /**
    202282    @brief
     
    204284    @param carrier
    205285        Sets the input PickupCarrier as the carrier of the pickup.
    206     */
    207     inline bool Pickupable::setCarrier(PickupCarrier* carrier)
    208     {
    209         if(this->carrier_ == carrier)
    210             return false;
    211        
     286    @param tell
     287        If true (default) the pickup is added to the list of pickups in the PickupCarrier.
     288    @return
     289        Returns true if successful, false if not.
     290    */
     291    bool Pickupable::setCarrier(orxonox::PickupCarrier* carrier, bool tell)
     292    {
     293        if(this->carrier_ == carrier) // If the PickupCarrier doesn't change.
     294            return false;
     295
    212296        COUT(4) << "Pickupable (&" << this << ") changed Carrier (& " << carrier << ")." << std::endl;
     297
     298        if(carrier != NULL && tell)
     299        {
     300            if(!carrier->addPickup(this))
     301                return false;
     302        }
    213303       
    214304        this->carrier_ = carrier;
     
    216306        return true;
    217307    }
    218    
    219     /**
    220     @brief
    221         Sets the Pickupable to not picked up or dropped.
    222         This method will be called by the PickupCarrier dropping the Pickupable.
    223     @return
    224         Returns false if the pickup could not be dropped.
    225     */
    226     bool Pickupable::dropped(void)
    227     {
    228         if(!this->isPickedUp()) //!< If the Pickupable is not picked up.
    229             return false;
    230        
    231         COUT(4) << "Pickupable (&" << this << ") got dropped up by a PickupCarrier (&" << this->getCarrier() << ")." << std::endl;
    232         this->setUsed(false);
    233         this->setPickedUp(false);
    234        
    235         bool created = this->createSpawner();
    236        
    237         this->setCarrier(NULL);
    238        
    239         if(!created)
    240         {
    241             this->destroy();
    242         }
    243        
    244         return true;
    245     }
    246    
     308
     309    /**
     310    @brief
     311        Is called by the PickupCarrier when it is being destroyed.
     312    */
     313    void Pickupable::carrierDestroyed(void)
     314    {
     315        this->destroy();
     316    }
     317
    247318    /**
    248319    @brief
     
    255326        OrxonoxClass* item = NULL;
    256327        this->clone(item);
    257        
     328
    258329        Pickupable* pickup = dynamic_cast<Pickupable*>(item);
    259        
     330
    260331        COUT(4) << "Pickupable (&" << this << ") cloned. Clone is new Pickupable (&" << pickup << ")." << std::endl;
    261332        return pickup;
    262333    }
    263    
     334
    264335    /**
    265336    @brief
     
    273344        SUPER(Pickupable, clone, item);
    274345    }
    275    
     346
     347    /**
     348    @brief
     349        Method to transcribe a Pickupable as a Rewardable to the player.
     350    @param player
     351        A pointer to the PlayerInfo, do whatever you want with it.
     352    @return
     353        Return true if successful.
     354    */
     355    bool Pickupable::reward(PlayerInfo* player)
     356    {
     357        ControllableEntity* entity = player->getControllableEntity();
     358        Pawn* pawn = static_cast<Pawn*>(entity);
     359        PickupCarrier* carrier = static_cast<PickupCarrier*>(pawn);
     360        return this->pickup(carrier);
     361    }
     362
    276363}
  • 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__ */
  • code/trunk/src/orxonox/interfaces/RadarListener.h

    r5781 r7163  
    4141        virtual ~RadarListener() { }
    4242
    43         virtual void displayObject(RadarViewable* viewable, bool bIsMarked) = 0;
     43        virtual void addObject(RadarViewable* viewable) = 0;
     44        virtual void removeObject(RadarViewable* viewable) = 0;
     45        virtual void objectChanged(RadarViewable* viewable) = 0;
    4446        virtual float getRadarSensitivity() const = 0;
    4547        virtual void radarTick(float dt) = 0;
  • code/trunk/src/orxonox/interfaces/RadarViewable.cc

    r6417 r7163  
    2929#include "RadarViewable.h"
    3030
    31 #include <OgreSceneManager.h>
    32 #include <OgreSceneNode.h>
    33 #include <OgreEntity.h>
    34 
    3531#include "util/StringUtils.h"
    3632#include "core/CoreIncludes.h"
    37 #include "tools/DynamicLines.h"
     33#include "core/GameMode.h"
    3834#include "worldentities/WorldEntity.h"
    3935#include "Radar.h"
    4036#include "Scene.h"
    41 #include "overlays/Map.h"
    4237
    4338namespace orxonox
     
    4641        @brief Constructor.
    4742    */
    48     RadarViewable::RadarViewable()
    49         : MapNode_(NULL)
    50         , MapEntity_(NULL)
    51         , line_(NULL)
    52         , LineNode_(NULL)
    53         , isHumanShip_(false)
     43    RadarViewable::RadarViewable(BaseObject* creator, const WorldEntity* wePtr)
     44        : isHumanShip_(false)
    5445        , bVisibility_(true)
     46        , bInitialized_(false)
     47        , creator_(creator)
     48        , wePtr_(wePtr)
    5549        , radarObjectCamouflage_(0.0f)
    5650        , radarObjectShape_(Dot)
     
    6054
    6155        this->uniqueId_=getUniqueNumberString();
    62 /*
    63         if(Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr())
     56        if( GameMode::showsGraphics() )
    6457        {
    65             this->addEntity();
     58            this->radar_ = this->creator_->getScene()->getRadar();
     59            this->radar_->addRadarObject(this);
    6660        }
    67 
    68         */
     61        this->bInitialized_ = true;
    6962    }
    7063
     
    7265    RadarViewable::~RadarViewable()
    7366    {
    74         if (this->isHumanShip_ && MapNode_)
    75             MapNode_->removeAllChildren();
    7667
    77         if (MapNode_)
    78             delete MapNode_;
    79 
    80         if (MapEntity_)
    81             delete MapEntity_;
    82 
    83         if (line_)
    84             delete line_;
    85 
    86         if (LineNode_)
    87             delete LineNode_;
    88     }
    89 
    90     void RadarViewable::addMapEntity()
    91     { //TODO Check shape and add accordantly
    92         if( this->MapNode_ && !this->MapEntity_ && Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr() )
     68        if( this->bInitialized_ )
    9369        {
    94             COUT(0) << "Adding " << this->uniqueId_ << " to Map.\n";
    95             this->MapEntity_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createEntity( this->uniqueId_, "drone.mesh");
    96             /*this->line_ =  Map::getSingletonPtr()->getMapSceneManagerPtr()->createManualObject(this->uniqueId_ + "_l");
    97             this->line_->begin("Map/line_", Ogre::RenderOperation::OT_LINE_STRIP);
    98             //line_->position(0, -it->getRVWorldPosition().y, 0);
    99             //this->line_->position(0, -20, 0);
    100             this->line_->position(0, 0, -10); //Front Arrow
    101             this->line_->position(0, 0, 0);
    102 
    103             this->line_->end(); */
    104             this->line_ = new Ogre::DynamicLines(Ogre::RenderOperation::OT_LINE_LIST);
    105             this->line_->addPoint( Vector3(0,0,0) );
    106             this->line_->addPoint( Vector3(0,0,0) );
    107 
    108             this->MapNode_->attachObject( this->MapEntity_ );
    109 
    110             this->LineNode_ = this->MapNode_->createChildSceneNode();
    111             this->LineNode_->attachObject( this->line_ );
    112         }
    113         else
    114         {
    115             COUT(0) << "Unable to load " << this->uniqueId_ << " to Map.\n";
     70            if( GameMode::showsGraphics() )
     71            {
     72                this->radar_->removeRadarObject(this);
     73            }
    11674        }
    11775    }
    11876
    119     void RadarViewable::updateMapPosition()
    120     {
    121         if( this->MapNode_ )
    122         {
    123             this->MapNode_->setPosition( this->getRVWorldPosition() );
    124             this->MapNode_->translate( this->getRVOrientedVelocity(), static_cast<Ogre::Node::TransformSpace>(3) );
    125             this->MapNode_->setOrientation( this->getWorldEntity()->getOrientation() );
    126 //Vector3 v = this->getRVWorldPosition();
    127             //this->line_->setPoint(1, Vector3(0,v.y,0) );
    128             this->line_->setPoint(1, Vector3( 0, static_cast<float>(static_cast<int>( -Map::getSingletonPtr()->movablePlane_->getDistance( this->getRVWorldPosition() ) ) ) ,0 ));
    129             this->line_->update();
    130             if( Map::getSingletonPtr()->playerShipNode_ )
    131                 this->LineNode_->setDirection( Map::getSingletonPtr()->playerShipNode_->getLocalAxes().GetColumn(1) ,Ogre::Node::TS_WORLD,Vector3::UNIT_Y);
    132         }
    133     }
    134 
    135     void RadarViewable::setRadarObjectDescription(const std::string& str)
    136     {
    137         Radar* radar = this->getWorldEntity()->getScene()->getRadar();
    138         if (radar)
    139             this->radarObjectShape_ = radar->addObjectDescription(str);
    140         else
    141         {
    142             CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl;
    143         }
    144         this->radarObjectDescription_ = str;
    145     }
     77//     void RadarViewable::setRadarObjectDescription(const std::string& str)
     78//     {
     79//         Radar* radar = this->getWorldEntity()->getScene()->getRadar();
     80//         if (radar)
     81//             this->radarObjectShape_ = radar->addObjectDescription(str);
     82//         else
     83//         {
     84//             CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl;
     85//         }
     86//         this->radarObjectDescription_ = str;
     87//     }
    14688
    14789    const Vector3& RadarViewable::getRVWorldPosition() const
     
    167109        }
    168110    }
     111
     112    void RadarViewable::settingsChanged()
     113    {
     114        if( GameMode::showsGraphics() )
     115        {
     116            this->radar_->radarObjectChanged(this);
     117        }
     118    }
    169119}
  • code/trunk/src/orxonox/interfaces/RadarViewable.h

    r5781 r7163  
    3636
    3737#include "util/Math.h"
    38 #include "util/OgreForwardRefs.h"
    3938#include "core/OrxonoxClass.h"
     39#include "core/SmartPtr.h"
    4040
    4141namespace orxonox
    4242{
     43    class BaseObject;
     44
    4345    /**
    4446    @brief Interface for receiving window events.
     
    5658
    5759    public:
    58         RadarViewable();
     60        RadarViewable(BaseObject* creator, const WorldEntity* wePtr);
    5961        virtual ~RadarViewable();
    6062
    6163        inline void setRadarObjectCamouflage(float camouflage)
    62             { this->radarObjectCamouflage_ = camouflage; }
     64            {
     65                if( this->radarObjectCamouflage_ != camouflage )
     66                {
     67                    this->radarObjectCamouflage_ = camouflage;
     68                    this->settingsChanged();
     69                }
     70            }
    6371        inline float getRadarObjectCamouflage() const
    6472            { return this->radarObjectCamouflage_; }
    6573
    6674        inline void setRadarObjectColour(const ColourValue& colour)
    67             { this->radarObjectColour_ = colour; }
     75            {
     76                if(this->radarObjectColour_ != colour)
     77                {
     78                    this->radarObjectColour_ = colour;
     79                    this->settingsChanged();
     80                }
     81            }
    6882        inline const ColourValue& getRadarObjectColour() const
    6983            { return this->radarObjectColour_; }
    7084
    71         void setRadarObjectDescription(const std::string& str);
    72         inline const std::string& getRadarObjectDescription() const
    73             { return this->radarObjectDescription_; }
     85//         void setRadarObjectDescription(const std::string& str);
     86//         inline const std::string& getRadarObjectDescription() const
     87//             { return this->radarObjectDescription_; }
    7488
    7589        inline void setRadarVisibility(bool b)
    76             { this->bVisibility_ = b; }
     90            {
     91                if(b!=this->bVisibility_)
     92                {
     93                    this->bVisibility_ = b;
     94                    this->settingsChanged();
     95                }
     96            }
    7797        inline bool getRadarVisibility() const
    7898            { return this->bVisibility_; }
    7999
    80         virtual const WorldEntity* getWorldEntity() const = 0;
     100        virtual const WorldEntity* getWorldEntity() const{ return this->wePtr_; }
    81101
    82102        const Vector3& getRVWorldPosition() const;
     
    84104
    85105        inline void setRadarObjectShape(Shape shape)
    86             { this->radarObjectShape_ = shape; }
     106            {
     107                if( this->radarObjectShape_ != shape )
     108                {
     109                    this->radarObjectShape_ = shape;
     110                    this->settingsChanged();
     111                }
     112            }
    87113        inline Shape getRadarObjectShape() const
    88114            { return this->radarObjectShape_; }
     115        void settingsChanged();
    89116
    90 /*
    91         inline void setMapNode(Ogre::SceneNode * node)
    92             { this->MapNode_ = node; }
    93         inline Ogre::SceneNode * getMapNode() const
    94             { return this->MapNode_; }
    95         inline void setMapEntity(Ogre::Entity * ent)
    96             { this->MapEntity_ = ent; }
    97         inline Ogre::Entity * getMapEntity() const
    98             { return this->MapEntity_; }
    99 */
    100         //Used for Map
    101         Ogre::SceneNode * MapNode_;
    102         Ogre::Entity * MapEntity_;
    103         Ogre::DynamicLines* line_;
    104         Ogre::SceneNode * LineNode_;
    105         void addMapEntity();
    106         void updateMapPosition();
     117
    107118        bool isHumanShip_;
    108119        inline const std::string& getUniqueId()
     
    115126        void validate(const WorldEntity* object) const;
    116127        bool bVisibility_;
     128        bool bInitialized_;
    117129        //Map
    118130        std::string uniqueId_;
     131        BaseObject* creator_;
    119132
    120133
    121134        //Radar
     135        const WorldEntity* wePtr_;
     136        SmartPtr<Radar> radar_;
    122137        float radarObjectCamouflage_;
    123138        Shape radarObjectShape_;
  • code/trunk/src/orxonox/interfaces/Rewardable.h

    r6417 r7163  
    4848        Damian 'Mozork' Frick
    4949    */
    50     class _OrxonoxExport Rewardable : public OrxonoxClass
     50    class _OrxonoxExport Rewardable : virtual public OrxonoxClass
    5151    {
    5252        public:
     
    5959                Must be implemented by every class inheriting from Rewardable.
    6060            @param player
    61                 A pointer to the ControllableEntity, do whatever you want with it.
     61                A pointer to the PlayerInfo, do whatever you want with it.
    6262            @return
    6363                Return true if successful.
Note: See TracChangeset for help on using the changeset viewer.