| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #pragma once
- #include <Text.h>
- #include "Area.h"
- #include "TypeRegistry.h"
- class Inventory;
- class ItemStack;
- class ItemSlotIDSetter
- {
- protected:
- virtual void setId(int id) = 0;
- friend Inventory;
- };
- class ItemSlot : public virtual Framework::ReferenceCounter,
- public ItemSlotIDSetter
- {
- private:
- ItemStack* items;
- int maxSize;
- Directions allowedPullSide;
- Directions allowedPushSides;
- int pullPriority;
- int pushPriority;
- bool allowHigherStackSize;
- Framework::Text name;
- int id;
- void setId(int id) override;
- public:
- ItemSlot(Framework::Text name,
- int maxSize,
- int pullPriority,
- int pushPriority,
- int allowedPullSides,
- int allowedPushSides,
- bool allowHigherStackSize);
- ~ItemSlot();
- ItemStack* takeItemsOut(int count, Direction dir);
- void addItems(ItemStack* zStack, Direction dir);
- void update();
- int numberOfAddableItems(const ItemStack* zStack, Direction dir) const;
- const ItemStack* zStack() const;
- int getPullPriority() const;
- int getPushPriority() const;
- bool isFull() const;
- int getFreeSpace() const;
- bool isEmpty() const;
- int getNumberOfItems() const;
- const Framework::Text& getName() const;
- int getId() const;
- friend class ItemSlotFactory;
- };
- class ItemSlotFactory : public ObjectTypeFactory<ItemSlot>
- {
- public:
- ItemSlotFactory();
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- ItemSlot* fromJson(Framework::JSON::JSONObject* zJson) const override;
- Framework::JSON::JSONObject* toJsonObject(ItemSlot* zObject) const override;
- };
|