コード例 #1
0
    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);
    }
コード例 #2
0
    private void RPC_AddSharedItem(string item_name, int num)
    {
        NetworkSharedItem netItem = new NetworkSharedItem(item_name);

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