123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #include "Inventory.h"
- #include "Area.h"
- using namespace Framework;
- Inventory::Inventory( const Framework::Vec3<float> location, bool hasInventory )
- : ReferenceCounter(),
- location( location )
- {
- if( hasInventory )
- {
- pullSlotsOrder = new Framework::RCArray<ItemSlot>();
- pushSlotsOrder = new Framework::RCArray<ItemSlot>();
- }
- else
- {
- pullSlotsOrder = 0;
- pushSlotsOrder = 0;
- }
- }
- Inventory::~Inventory()
- {
- if( pullSlotsOrder )
- pullSlotsOrder->release();
- if( pushSlotsOrder )
- pushSlotsOrder->release();
- }
- void Inventory::loadInventory( Framework::StreamReader *zReader )
- {
- if( pushSlotsOrder )
- {
- for( auto iterator = pushSlotsOrder->getIterator(); iterator; iterator++ )
- {
- int size = 0;
- zReader->lese( (char *)&size, 4 );
- if( size != 0 )
- {
- int id = 0;
- zReader->lese( (char *)&id, 4 );
- Item *item = StaticRegistry<ItemType>::INSTANCE.zElement( id )->loadItem( zReader );
- iterator->setItems( new ItemStack( item, size ) );
- }
- }
- }
- }
|