Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 29, 2010, 12:30:32 PM (15 years ago)
Author:
dafrick
Message:

Working towards a functioning PickupInventory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup4/src/modules/pickup/PickupManager.cc

    r6540 r6632  
    3535
    3636#include "core/CoreIncludes.h"
     37#include "core/LuaState.h"
     38#include "core/GUIManager.h"
    3739#include "core/ScopedSingletonManager.h"
    3840#include "core/Identifier.h"
    3941#include "interfaces/PickupCarrier.h"
     42#include "infos/PlayerInfo.h"
    4043#include "worldentities/pawns/Pawn.h"
    4144#include "PickupRepresentation.h"
    4245
     46#include "ToluaBindPickup.h"
     47
    4348namespace orxonox
    4449{
    45 
     50    // Register tolua_open function when loading the library
     51    DeclareToluaInterface(Pickup);
     52   
    4653    ManageScopedSingleton(PickupManager, ScopeID::Root, false);
     54   
     55    /*static*/ const std::string PickupManager::guiName_s = "PickupInventory";
    4756   
    4857    /**
     
    110119    }
    111120   
     121    PickupCarrier* PickupManager::getPawn(void)
     122    {
     123        Pawn* pawn = dynamic_cast<Pawn*>(GUIManager::getInstancePtr()->getPlayer(PickupManager::guiName_s)->getControllableEntity());
     124        if(pawn == NULL)
     125            return NULL;
     126        return dynamic_cast<PickupCarrier*>(pawn);
     127    }
     128   
     129    unsigned int PickupManager::getNumCarrierChildren(PickupCarrier* carrier)
     130    {
     131        return carrier->getNumCarrierChildren();
     132    }
     133           
     134    PickupCarrier* PickupManager::getCarrierChild(unsigned int index, PickupCarrier* carrier)
     135    {
     136        return carrier->getCarrierChild(index);
     137    }
     138   
     139    PickupRepresentation* PickupManager::getPickupRepresentation(unsigned int index, PickupCarrier* carrier)
     140    {
     141        Pickupable* pickup = carrier->getPickup(index);
     142        if(pickup == NULL)
     143            return NULL;
     144       
     145        return this->getRepresentation(pickup->getPickupIdentifier());
     146    }
     147   
     148
     149    unsigned int PickupManager::getNumPickups(PickupCarrier* carrier)
     150    {
     151        return carrier->getNumPickups();
     152    }
     153   
     154    void PickupManager::dropPickup(unsigned int index, PickupCarrier* carrier)
     155    {
     156        Pickupable* pickup = carrier->getPickup(index);
     157        carrier->drop(pickup);
     158    }
     159   
     160    void PickupManager::usePickup(unsigned int index, PickupCarrier* carrier, bool use)
     161    {
     162        Pickupable* pickup = carrier->getPickup(index);
     163        pickup->setUsed(use);
     164    }
     165   
    112166}
Note: See TracChangeset for help on using the changeset viewer.