Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 14, 2009, 4:36:56 PM (16 years ago)
Author:
dafrick
Message:

Made DroppedItem inherit from PickupSpawner. Also minor changes in PickupSpawner.

Location:
code/branches/pickup2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup2

  • code/branches/pickup2/src/orxonox/pickup/DroppedItem.h

    r5947 r5953  
    3737#include "OrxonoxPrereqs.h"
    3838
    39 #include "tools/Timer.h"
    40 #include "tools/interfaces/Tickable.h"
    41 #include "worldentities/StaticEntity.h"
     39#include "PickupSpawner.h"
    4240
    4341namespace orxonox
    4442{
    45     class _OrxonoxExport DroppedItem : public StaticEntity, public Tickable
     43    class _OrxonoxExport DroppedItem : public PickupSpawner
    4644    {
    47     public:
    48         DroppedItem(BaseObject* creator);
    49         virtual ~DroppedItem();
     45        public:
     46            DroppedItem(BaseObject* creator);
     47            DroppedItem(BaseObject* creator, BaseItem* item, float triggerDistance, float respawnTime, int maxSpawnedItems);
     48            virtual ~DroppedItem();
    5049
    51         //TODO: Comment.
    52         //DroppedItem -> Item with no owner, alone in space?
    53         //Would be much nicer if it would be triggered by a standard issue DistanceTrigger.
    54         //Where is this created? I see no XMLPort.
    55         //Where is the item for this created? What happens if more than one pawn triggers this?
    56         //Add more than just one items, or even better create the ability to add a Collection.? Rename to ...?
     50            static DroppedItem* createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour = ColourValue(0.5f, 1.0f, 0.3f), float timeToLive = 0);
     51            static DroppedItem* createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour = ColourValue(0.5f, 1.0f, 0.3f), float timeToLive = 0);
    5752
    58         void tick(float dt);
    59         void trigger(Pawn* pawn);
     53        protected:
     54            virtual BaseItem* getItem(void);
    6055
    61         static DroppedItem* createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour = ColourValue(0.5f, 1.0f, 0.3f), float timeToLive = 0);
    62         static DroppedItem* createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour = ColourValue(0.5f, 1.0f, 0.3f), float timeToLive = 0);
     56        private:
    6357
    64         void createTimer(); //TODO: Can this be made private, too?
    65         void timerCallback(); //TODO: This should really be private.
     58            BaseItem* item_; //!< The dropped item.
    6659
    67         inline float getTriggerDistance() const
    68             { return this->triggerDistance_; }
    69         inline void setTriggerDistance(float distance)
    70             { this->triggerDistance_ = distance; }
    71 
    72         inline BaseItem* getItem() const
    73             { return this->item_; }
    74         //TODO: Needs to be public?
    75         inline void setItem(BaseItem* item)
    76             { this->item_ = item; }
    77 
    78         inline float getTimeToLive() const
    79             { return this->timeToLive_; }
    80         //TODO: Needs to be public?
    81         inline void setTimeToLive(float time)
    82             { this->timeToLive_ = time; }
    83     private:
    84         float timeToLive_;
    85         float triggerDistance_;
    86         BaseItem* item_;
    87 
    88         Timer timer_;
    8960    };
    9061}
Note: See TracChangeset for help on using the changeset viewer.