Beispiel #1
0
        public static bool TakeItem(Player player, QuantumStorageControllerMachine quantumStorageController,
                                    ItemBase itemBase)
        {
            var itemBaseCopy = itemBase.NewInstance();
            var amount       = itemBase.GetAmount();

            quantumStorageController.TakeItem(ref itemBase);

            itemBase.SetAmount(amount - itemBase.GetAmount());

            if (!player.mInventory.AddItem(itemBase))
            {
                quantumStorageController.AddItem(ref itemBase);
                if (itemBase.GetAmount() > 0)
                {
                    ItemManager.instance.DropItem(itemBase,
                                                  WorldScript.mLocalPlayer.mnWorldX, WorldScript.mLocalPlayer.mnWorldY,
                                                  WorldScript.mLocalPlayer.mnWorldZ,
                                                  Vector3.zero);
                }

                return(false);
            }

            quantumStorageController.Dirty = true;

            if (!WorldScript.mbIsServer)
            {
                NetworkManager.instance.SendInterfaceCommand(QuantumStorageMod.QuantumIoPortWindowKey,
                                                             "TakeItem",
                                                             null, itemBaseCopy, quantumStorageController, 0.0f);
            }

            return(true);
        }
Beispiel #2
0
        public static void StoreItem(Player player, QuantumStorageControllerMachine quantumStorageController,
                                     ItemBase itemToStore)
        {
            var itemToStoreCopy = itemToStore.NewInstance();

            if (player == WorldScript.mLocalPlayer &&
                !WorldScript.mLocalPlayer.mInventory.RemoveItemByExample(itemToStore, true))
            {
                return;
            }

            quantumStorageController.AddItem(ref itemToStore);
            quantumStorageController.Dirty = true;

            if (itemToStore != null && itemToStore.GetAmount() > 0)
            {
                if (player == WorldScript.mLocalPlayer)
                {
                    WorldScript.mLocalPlayer.mInventory.AddItem(itemToStore);
                }
            }


            if (!WorldScript.mbIsServer)
            {
                NetworkManager.instance.SendInterfaceCommand(QuantumStorageMod.QuantumIoPortWindowKey,
                                                             "StoreItem",
                                                             null, itemToStoreCopy, quantumStorageController, 0.0f);
            }
        }