Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 27, 2010, 10:44:10 PM (14 years ago)
Author:
dafrick
Message:

Loads of changes.
1) PickupInventory should now be working even for extreme cases.
2) Added support for inactive Spawnpoints in Gametype.
3) Made Pickupable rewardble. meaning from now on any Pickupable can be given as a reward for completing Quests.
4) Added some keybinds to KeybindMenu, such as PickupInventory, QuestGUI and Chat.

Location:
code/branches/presentation3/src/orxonox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3/src/orxonox/gametypes/Gametype.cc

    r6417 r6996  
    309309        if (this->spawnpoints_.size() > 0)
    310310        {
     311            SpawnPoint* fallbackSpawnPoint = NULL;
    311312            unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
    312313            unsigned int index = 0;
     314            std::set<SpawnPoint*> activeSpawnPoints = this->spawnpoints_;
    313315            for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it)
     316            {
     317                if (index == randomspawn)
     318                    fallbackSpawnPoint = (*it);
     319
     320                if (!(*it)->isActive())
     321                    activeSpawnPoints.erase(*it);
     322
     323                ++index;
     324            }
     325
     326            randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
     327            index = 0;
     328            for (std::set<SpawnPoint*>::const_iterator it = activeSpawnPoints.begin(); it != activeSpawnPoints.end(); ++it)
    314329            {
    315330                if (index == randomspawn)
    316331                    return (*it);
    317 
     332               
    318333                ++index;
    319334            }
     335
     336            return fallbackSpawnPoint;
    320337        }
    321338        return 0;
  • code/branches/presentation3/src/orxonox/interfaces/Pickupable.cc

    r6901 r6996  
    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
     
    9196        this->used_ = used;
    9297        this->changedUsed();
     98
     99        GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()");
    93100        return true;
    94101    }
     
    196203        this->pickedUp_ = pickedUp;
    197204        this->changedPickedUp();
     205        GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()");
    198206        return true;
    199207    }
     
    273281        SUPER(Pickupable, clone, item);
    274282    }
     283
     284    /**
     285    @brief
     286        Method to transcribe a Pickupable as a Rewardable to the player.
     287    @param player
     288        A pointer to the PlayerInfo, do whatever you want with it.
     289    @return
     290        Return true if successful.
     291    */
     292    bool Pickupable::reward(PlayerInfo* player)
     293    {
     294        ControllableEntity* entity = player->getControllableEntity();
     295        Pawn* pawn = static_cast<Pawn*>(entity);
     296        PickupCarrier* carrier = static_cast<PickupCarrier*>(pawn);
     297        return carrier->pickup(this);
     298    }
    275299   
    276300}
  • code/branches/presentation3/src/orxonox/interfaces/Pickupable.h

    r6965 r6996  
    4141
    4242#include "core/OrxonoxClass.h"
     43#include "Rewardable.h"
    4344
    4445namespace orxonox // tolua_export
     
    5253    */
    5354    class _OrxonoxExport Pickupable  // tolua_export
    54         : virtual public OrxonoxClass
     55        : virtual public OrxonoxClass, public Rewardable
    5556    {  // tolua_export
    5657        protected:
     
    141142            std::list<Identifier*> targets_; //!< The possible targets of this pickup.
    142143
     144        // For implementing the Rewardable interface:
     145        public:
     146            virtual bool reward(PlayerInfo* player); //!< Method to transcribe a Pickupable as a Rewardable to the player.
     147
    143148    };  // tolua_export
    144149   
  • code/branches/presentation3/src/orxonox/interfaces/Rewardable.h

    r6417 r6996  
    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.