Beispiel #1
0
        private PySubStruct BindInventory(ItemInventory inventoryItem, int characterID, Client client, Flags flag)
        {
            ItemInventory inventory = inventoryItem;

            // create a meta inventory only if required
            if (inventoryItem is not Ship && inventoryItem is not Character)
            {
                inventory = this.ItemFactory.MetaInventoryManager.RegisterMetaInventoryForOwnerID(inventoryItem, characterID);
            }

            // create an instance of the inventory service and bind it to the item data
            return(BoundInventory.BindInventory(this.ItemDB, inventory, flag, this.ItemFactory, this.NodeContainer, this.BoundServiceManager, client));
        }
Beispiel #2
0
        public PyDataType GetInventoryFromId(PyInteger itemID, PyInteger one, CallInformation call)
        {
            int        callerCharacterID = call.Client.EnsureCharacterIsSelected();
            ItemEntity inventoryItem     = this.ItemManager.LoadItem(itemID);

            // also make sure it's a container
            if (inventoryItem is ItemInventory == false)
            {
                throw new ItemNotContainer(itemID);
            }

            // build the meta inventory item now
            ItemInventory inventoryByOwner = this.ItemManager.MetaInventoryManager.RegisterMetaInventoryForOwnerID(inventoryItem as ItemInventory,
                                                                                                                   callerCharacterID);

            // create an instance of the inventory service and bind it to the item data
            return(BoundInventory.BindInventory(this.ItemDB, inventoryByOwner, ItemFlags.None, this.ItemManager, this.NodeContainer, this.BoundServiceManager));
        }
Beispiel #3
0
        public PyDataType GetInventory(PyInteger containerID, PyNone none, CallInformation call)
        {
            int callerCharacterID = call.Client.EnsureCharacterIsSelected();

            ItemFlags flag = ItemFlags.None;

            switch ((int)containerID)
            {
            case (int)ItemContainer.Wallet:
                flag = ItemFlags.Wallet;
                break;

            case (int)ItemContainer.Hangar:
                flag = ItemFlags.Hangar;
                break;

            case (int)ItemContainer.Character:
                flag = ItemFlags.Skill;
                break;

            case (int)ItemContainer.Global:
                flag = ItemFlags.None;
                break;

            default:
                throw new CustomError($"Trying to open container ID ({containerID.Value}) is not supported");
            }

            // get the inventory item first
            ItemEntity inventoryItem = this.ItemManager.LoadItem(this.mObjectID);

            // also make sure it's a container
            if (inventoryItem is ItemInventory == false)
            {
                throw new ItemNotContainer(inventoryItem.ID);
            }

            // build the meta inventory item now
            ItemInventory inventoryByOwner = this.ItemManager.MetaInventoryManager.RegisterMetaInventoryForOwnerID(inventoryItem as ItemInventory,
                                                                                                                   callerCharacterID);

            // create an instance of the inventory service and bind it to the item data
            return(BoundInventory.BindInventory(this.ItemDB, inventoryByOwner, flag, this.ItemManager, this.NodeContainer, this.BoundServiceManager));
        }
Beispiel #4
0
        public static PyDataType BindInventory(ItemDB itemDB, ItemInventory item, ItemFlags flag, ItemManager itemManager, NodeContainer nodeContainer, BoundServiceManager boundServiceManager)
        {
            BoundService instance = new BoundInventory(itemDB, item, flag, itemManager, nodeContainer, boundServiceManager);
            // bind the service
            int boundID = boundServiceManager.BoundService(instance);
            // build the bound service string
            string boundServiceStr = boundServiceManager.BuildBoundServiceString(boundID);

            // TODO: the expiration time is 1 day, might be better to properly support this?
            // TODO: investigate these a bit more closely in the future
            // TODO: i'm not so sure about the expiration time
            PyTuple boundServiceInformation = new PyTuple(new PyDataType[]
            {
                boundServiceStr, DateTime.UtcNow.Add(TimeSpan.FromDays(1)).ToFileTime()
            });

            // after the service is bound the call can be run (if required)
            return(new PySubStruct(new PySubStream(boundServiceInformation)));
        }