def __init__(self, owner): self.owner = owner self.containers = { InventorySlots.SLOT_INBACKPACK: ContainerManager(is_backpack=True, owner=self.owner.guid), InventorySlots.SLOT_BAG1: None, InventorySlots.SLOT_BAG2: None, InventorySlots.SLOT_BAG3: None, InventorySlots.SLOT_BAG4: None }
def __init__(self, owner): self.owner = owner # Avoid player thread from updating inventory if there are ongoing changes triggered from another thread. # e.g. Any opcode handler that touches inventory outside tick rate. self.update_locked = False self.containers = { InventorySlots.SLOT_INBACKPACK: ContainerManager(is_backpack=True, owner=self.owner.guid), InventorySlots.SLOT_BAG1: None, InventorySlots.SLOT_BAG2: None, InventorySlots.SLOT_BAG3: None, InventorySlots.SLOT_BAG4: None }
def generate_item(item_template, owner, bag, slot, creator=0, count=1): if item_template and item_template.entry > 0: item = CharacterInventory(owner=owner, creator=creator, item_template=item_template.entry, stackcount=count, slot=slot, bag=bag) RealmDatabaseManager.character_inventory_add_item(item) if item_template.inventory_type == InventoryTypes.BAG: from game.world.managers.objects.item.ContainerManager import ContainerManager item_mgr = ContainerManager(owner=owner, item_template=item_template, item_instance=item) else: item_mgr = ItemManager(item_template=item_template, item_instance=item) return item_mgr return None