コード例 #1
0
    public override void HandleItemDrag(string name, ItemBase draggedItem, DragAndDropManager.DragRemoveItem dragDelegate, SegmentEntity targetEntity)
    {
        ExtraStorageHoppers hopper      = targetEntity as ExtraStorageHoppers;
        ItemBase            itemForSlot = this.GetItemForSlot(hopper, name);
        bool flag = true;

        if (itemForSlot != null)
        {
            flag = (draggedItem.mnItemID == itemForSlot.mnItemID);
        }
        if (hopper.OT && hopper.IsEmpty() && !hopper.ExemplarSet)
        {
            hopper.SetExemplar(draggedItem);
        }
        if (name == "ItemSlot" + this.SlotCount && flag && hopper.IsNotFull() && hopper.CheckExemplar(draggedItem))
        {
            ItemBase itemBase         = ItemManager.CloneItem(draggedItem);
            int      currentStackSize = ItemManager.GetCurrentStackSize(itemBase);
            if (hopper.RemainingCapacity < currentStackSize)
            {
                ItemManager.SetItemCount(itemBase, hopper.RemainingCapacity);
            }
            ExtraStorageHopperWindowNew.StoreItems(WorldScript.mLocalPlayer, hopper, itemBase);
            InventoryPanelScript.mbDirty = true;
            SurvivalHotBarManager.MarkAsDirty();
            SurvivalHotBarManager.MarkContentDirty();
            ExtraStorageHopperWindowNew.networkRedraw = true;
        }
    }
コード例 #2
0
    private void PlayerExtractRequest()
    {
        Player player    = WorldScript.mLocalPlayer;
        int    lensCount = 0;

        if (player == null)
        {
            return;
        }

        if (mStoredLenses != null)
        {
            lensCount = mStoredLenses.GetAmount();
        }
        if (lensCount > 0)
        {
            Debug.Log("[Auto Lens Swapper] Removing " + lensCount + " lenses from machine, placing into " + player.mUserName);
            if (!player.mInventory.AddItem(mStoredLenses))
            {
                ItemManager.instance.DropItem(mStoredLenses, player.mnWorldX, player.mnWorldY, player.mnWorldZ, Vector3.zero);
                Debug.Log("[Auto Lens Swapper] Player's inventory did not accept lenses. Dropping at player's feet.");
            }
        }
        mStoredLenses = null;
        mTargetLens   = null;

        if (mStatus == eStatuses.Running)
        {
            mbHaltedEarly = true;
            mStatus       = eStatuses.Done;
        }
        else if (mStatus == eStatuses.Done)
        {
            mnTrackLPTs      = 0;
            mnTrackSwaps     = 0;
            mnSegmentEIndex1 = 0;
            mnSegmentEIndex2 = 0;
            mnSegmentID      = 0;
            mbHaltedEarly    = false;
            mStatus          = eStatuses.Stopped;
        }


        MarkDirtyDelayed();
        RequestImmediateNetworkUpdate();
        player.mInventory.VerifySuitUpgrades(); //Shouldn't be needed, but lets be safe.
        SurvivalHotBarManager.MarkAsDirty();
        SurvivalHotBarManager.MarkContentDirty();
        UIManager.ForceNGUIUpdate = 0.1f;
        RequestImmediateNetworkUpdate();
        AudioHUDManager.instance.OrePickup();
    }
コード例 #3
0
    private void PlayerStoreRequest()
    {
        int      lnAvailable = 0;
        ItemBase itemToStore = UIManager.instance.GetCurrentHotBarItemOrCubeAsItem(out lnAvailable, true);
        Player   player      = WorldScript.mLocalPlayer;

        if (player == null)
        {
            return;
        }
        if (lnAvailable < 0)
        {
            return;
        }
        if (itemToStore == null)
        {
            return;
        }
        if (!isValidLensID(itemToStore.mnItemID))
        {
            Debug.Log("[Auto Lens Swapper] Player " + player.mUserName + " tried inserting a non-lens, but was denied!");
            Debug.Log("[Auto Lens Swapper] itemID: " + itemToStore.mnItemID + " itemName: " + itemToStore.GetName());
            return;
        }
        if (mTargetLens != null)
        {
            if (itemToStore.mnItemID != mTargetLens.mnItemID && getStorageAvailable() < mnStorageMax)
            {
                Debug.Log("[Auto Lens Swapper][info] Player " + player.mUserName + " tried inserting a differing lens than what was still in the machine!");
                return;
            }
        }

        //Easy case, only setting target, not modifying storage.
        //(User didn't have any lenses on them, but they had the target in their hotbar)
        if (lnAvailable == 0)
        {
            Debug.Log("[Auto Lens Swapper][info] Player " + player.mUserName + " set target (new) lens without depositing any.");
            mTargetLens = ItemManager.SpawnItem(itemToStore.mnItemID);
            if (player.mbIsLocalPlayer)
            {
                Color lCol = Color.red;
                FloatingCombatTextManager.instance.QueueText(mnX, mnY + 1L, mnZ, 0.75f, string.Format("Lens Swapper set to: \n", (object)player.GetItemName(itemToStore)), lCol, 1.5f, 64f);
            }
            return;
        }

        int amount           = lnAvailable;
        int storageAvailable = getStorageAvailable();
        int maxStackSize     = ItemManager.GetMaxStackSize(itemToStore);

        //Determine amount that can be transfered.
        if (itemToStore.mnItemID == -1)
        {
            return;
        }
        if (amount > 10 && Input.GetKey(KeyCode.LeftShift))
        {
            amount = 10;
        }
        if (amount > 1 && Input.GetKey(KeyCode.LeftControl))
        {
            amount = 1;
        }
        if (amount > getStorageAvailable())
        {
            amount = getStorageAvailable();
        }
        if (amount > ItemManager.GetMaxStackSize(itemToStore))
        {
            amount = ItemManager.GetMaxStackSize(itemToStore);
        }
        ItemManager.SetItemCount(itemToStore, amount);

        if (!player.mInventory.RemoveItemByExample(itemToStore, true))
        {
            Debug.Log("[Auto Lens Swapper][info] Player " + player.mUserName + " doesnt have " + itemToStore.GetName());
            return;
        }
        mTargetLens = ItemManager.SpawnItem(itemToStore.mnItemID);
        if (mStoredLenses == null || mStoredLenses.mnItemID != mTargetLens.mnItemID)
        {
            mStoredLenses = ItemManager.SpawnItem(itemToStore.mnItemID);
            AddLenses(-1);// SpawnItem starts with the amount as 1.
        }
        AddLenses(amount);
        player.mInventory.VerifySuitUpgrades(); //Shouldn't be needed, but lets be safe.
        Debug.Log("[Auto Lens Swapper][info] Player " + player.mUserName + " stored lenses manually!");

        //render in-world pop-up text.
        if (player.mbIsLocalPlayer)
        {
            Color lCol = Color.cyan;
            FloatingCombatTextManager.instance.QueueText(mnX, mnY + 1L, mnZ, 0.75f, string.Format(PersistentSettings.GetString("Stored_X"), (object)player.GetItemName(itemToStore)), lCol, 1.5f, 64f);
        }
        //else
        //StorageHopperWindowNew.networkRedraw = true;
        player.mInventory.VerifySuitUpgrades();

        /*
         * if (!WorldScript.mbIsServer)
         *  NetworkManager.instance.SendInterfaceCommand(nameof(StorageHopperWindowNew), nameof(StoreItems), (string)null, itemToStore, (SegmentEntity)hopper, 0.0f);
         */
        // ^^^ Reimplement?

        MarkDirtyDelayed();
        RequestImmediateNetworkUpdate();
        UIManager.ForceNGUIUpdate = 0.1f;
        AudioHUDManager.instance.HUDOut();
        SurvivalHotBarManager.MarkAsDirty();
        SurvivalHotBarManager.MarkContentDirty();
    }