void AddItemToInventory(ItemRequest request)
    {
        if (!isOwner)
        {
            return;
        }
        Item shipped_item = amazon.RequestItem(request.item_name);

        if (SharedItem.isSharedItem(shipped_item))
        {
            if (!isServer)
            {
                InvokeServerRpc(RPC_AddSharedItem, request.item_name, 1, channel: INVMANG_CHANNEL);
            }
            else
            {
                string            item_name = request.item_name;
                uint              clientId  = NetworkingManager.singleton.LocalClientId;
                NetworkSharedItem netItem   = new NetworkSharedItem(item_name);
                networkInv.AddItemStack(item_name, netItem, 1);
            }
        }
        if (AbilityItem.isAbilityItem(shipped_item))
        {
            shipped_item.context   = this;
            shipped_item.menu_form = image;
            actionSlots.ability_items[shipped_item.name()] = (AbilityItem)shipped_item;
            actionSlots.ChangeAbilityItem(actionSlots.ability_items.GetStackCount(), shipped_item.name());
        }
        GameObject.Destroy(request.gameObject);
    }
Exemple #2
0
    private bool NetworkSwapSharedItem(string item_name, int clientId, out NetworkSharedItem netItem, int count)
    {
        bool success = false;

        netItem = default(NetworkSharedItem);
        success = networkInv.RevokeItem(item_name, (int)clientId, true);
        if (!success)
        {
            return(false);
        }
        return(networkInv.RequestItem(item_name, (int)clientId, out netItem));
    }
Exemple #3
0
    private void RPC_AddSharedItem(string item_name, int num)
    {
        NetworkSharedItem netItem = new NetworkSharedItem(item_name);

        networkInv.AddItemStack(item_name, netItem, num);
    }