Exemple #1
0
        public PyDataType BatchCertificateUpdate(PyDictionary updates, CallInformation call)
        {
            call.Client.EnsureCharacterIsSelected();

            foreach ((PyInteger key, PyInteger value) in updates.GetEnumerable <PyInteger, PyInteger>())
            {
                this.UpdateCertificateFlags(key, value, call);
            }

            return(null);
        }
Exemple #2
0
        public PyDataType UnasembleItems(PyDictionary validIDsByStationID, PyList skipChecks, CallInformation call)
        {
            int characterID = call.Client.EnsureCharacterIsSelected();
            List <RepairDB.ItemRepackageEntry> entries = new List <RepairDB.ItemRepackageEntry>();

            bool ignoreContractVoiding       = false;
            bool ignoreRepackageWithUpgrades = false;

            foreach (PyString check in skipChecks.GetEnumerable <PyString>())
            {
                if (check == "RepairUnassembleVoidsContract")
                {
                    ignoreContractVoiding = true;
                }
                if (check == "ConfirmRepackageSomethingWithUpgrades")
                {
                    ignoreRepackageWithUpgrades = true;
                }
            }

            foreach ((PyInteger stationID, PyList itemIDs) in validIDsByStationID.GetEnumerable <PyInteger, PyList>())
            {
                foreach (PyInteger itemID in itemIDs.GetEnumerable <PyInteger>())
                {
                    RepairDB.ItemRepackageEntry entry = this.RepairDB.GetItemToRepackage(itemID, characterID, stationID);

                    if (entry.HasContract == true && ignoreContractVoiding == false)
                    {
                        throw new RepairUnassembleVoidsContract(itemID);
                    }
                    if (entry.HasUpgrades == true && ignoreRepackageWithUpgrades == false)
                    {
                        throw new ConfirmRepackageSomethingWithUpgrades();
                    }
                    if (entry.Damage != 0.0)
                    {
                        throw new CantRepackageDamagedItem();
                    }

                    entries.Add(entry);
                }
            }

            foreach (RepairDB.ItemRepackageEntry entry in entries)
            {
                if (entry.Singleton == false)
                {
                    continue;
                }

                // extra situation, the repair is happening on a item in our node, the client must know immediately
                if (entry.NodeID == this.Container.NodeID || this.SystemManager.StationBelongsToUs(entry.LocationID) == true)
                {
                    ItemEntity item = this.ItemFactory.LoadItem(entry.ItemID, out bool loadRequired);

                    // the item is an inventory, take everything out!
                    if (item is ItemInventory inventory)
                    {
                        foreach ((int _, ItemEntity itemInInventory) in inventory.Items)
                        {
                            // if the item is in a rig slot, destroy it
                            if (itemInInventory.IsInRigSlot() == true)
                            {
                                Flags oldFlag = itemInInventory.Flag;
                                this.ItemFactory.DestroyItem(itemInInventory);
                                // notify the client about the change
                                call.Client.NotifyMultiEvent(OnItemChange.BuildLocationChange(itemInInventory, oldFlag, entry.ItemID));
                            }
                            else
                            {
                                Flags oldFlag = itemInInventory.Flag;
                                // update item's location
                                itemInInventory.LocationID = entry.LocationID;
                                itemInInventory.Flag       = Flags.Hangar;

                                // notify the client about the change
                                call.Client.NotifyMultiEvent(OnItemChange.BuildLocationChange(itemInInventory, oldFlag, entry.ItemID));
                                // save the item
                                itemInInventory.Persist();
                            }
                        }
                    }

                    // update the singleton flag too
                    item.Singleton = false;
                    call.Client.NotifyMultiEvent(OnItemChange.BuildSingletonChange(item, true));

                    // load was required, the item is not needed anymore
                    if (loadRequired == true)
                    {
                        this.ItemFactory.UnloadItem(item);
                    }
                }
                else
                {
                    long nodeID = this.SystemManager.GetNodeStationBelongsTo(entry.LocationID);

                    if (nodeID > 0)
                    {
                        Notifications.Nodes.Inventory.OnItemChange change = new Notifications.Nodes.Inventory.OnItemChange();

                        change.AddChange(entry.ItemID, "singleton", true, false);

                        this.NotificationManager.NotifyNode(nodeID, change);
                    }
                }

                // finally repackage the item
                this.RepairDB.RepackageItem(entry.ItemID, entry.LocationID);
                // remove any insurance contract for the ship
                this.InsuranceDB.UnInsureShip(entry.ItemID);
            }

            return(null);
        }