Exemplo n.º 1
0
    private void AddItem(InventoryDef item)
    {
        GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.ItemPrefab);

        gameObject.transform.SetParent(this.ItemParent, false);
        gameObject.GetComponent <ItemStoreItem>().Init(item);
    }
Exemplo n.º 2
0
 internal void AddToCart(InventoryDef item)
 {
     this.Cart.Add(item);
     this.AddToCartSound.Play();
     this.UpdateShoppingList();
     GameAnalytics.NewDesignEvent("itemstore:addtocart");
 }
Exemplo n.º 3
0
 internal void Init(InventoryDef item)
 {
     this.item = item;
     this.Icon.Load(item.IconUrlLarge);
     this.Name.text  = item.Name;
     this.Price.text = item.LocalPriceFormatted;
 }
    public static ulong FindSkin(int itemID, int skinID)
    {
        ItemDefinition itemDefinition = ItemManager.FindItemDefinition(itemID);

        if (itemDefinition == null)
        {
            return((ulong)0);
        }
        InventoryDef inventoryDef = Steamworks.SteamInventory.FindDefinition(skinID);

        if (inventoryDef != null)
        {
            ulong property = inventoryDef.GetProperty <ulong>("workshopdownload");
            if (property != 0)
            {
                string str = inventoryDef.GetProperty <string>("itemshortname");
                if (str == itemDefinition.shortname || str == itemDefinition.name)
                {
                    return(property);
                }
            }
        }
        for (int i = 0; i < (int)itemDefinition.skins.Length; i++)
        {
            if (itemDefinition.skins[i].id == skinID)
            {
                return((ulong)skinID);
            }
        }
        return((ulong)0);
    }
Exemplo n.º 5
0
        public static void print_approved_skins(ConsoleSystem.Arg arg)
        {
            if (!SteamServer.IsValid)
            {
                return;
            }
            if (SteamInventory.Definitions == null)
            {
                return;
            }
            TextTable textTable = new TextTable();

            textTable.AddColumn("name");
            textTable.AddColumn("itemshortname");
            textTable.AddColumn("workshopid");
            textTable.AddColumn("workshopdownload");
            InventoryDef[] definitions = SteamInventory.Definitions;
            for (int i = 0; i < (int)definitions.Length; i++)
            {
                InventoryDef inventoryDef = definitions[i];
                string       name         = inventoryDef.Name;
                string       property     = inventoryDef.GetProperty("itemshortname");
                string       str          = inventoryDef.GetProperty("workshopid");
                string       property1    = inventoryDef.GetProperty("workshopdownload");
                textTable.AddRow(new string[] { name, property, str, property1 });
            }
            arg.ReplyWith(textTable.ToString());
        }
Exemplo n.º 6
0
    public void GiveDefaultItems()
    {
        this.Strip();
        ulong property = (ulong)0;
        int   infoInt  = base.baseEntity.GetInfoInt("client.rockskin", 0);

        if (infoInt > 0 && base.baseEntity.blueprints.steamInventory.HasItem(infoInt))
        {
            InventoryDef inventoryDef = Steamworks.SteamInventory.FindDefinition(infoInt);
            if (inventoryDef != null)
            {
                property = inventoryDef.GetProperty <ulong>("workshopdownload");
            }
        }
        this.GiveItem(ItemManager.CreateByName("rock", 1, property), this.containerBelt);
        this.GiveItem(ItemManager.CreateByName("torch", 1, (ulong)0), this.containerBelt);
        if (PlayerInventory.IsBirthday())
        {
            this.GiveItem(ItemManager.CreateByName("cakefiveyear", 1, (ulong)0), this.containerBelt);
            this.GiveItem(ItemManager.CreateByName("partyhat", 1, (ulong)0), this.containerWear);
        }
        if (PlayerInventory.IsChristmas())
        {
            this.GiveItem(ItemManager.CreateByName("snowball", 1, (ulong)0), this.containerBelt);
            this.GiveItem(ItemManager.CreateByName("snowball", 1, (ulong)0), this.containerBelt);
            this.GiveItem(ItemManager.CreateByName("snowball", 1, (ulong)0), this.containerBelt);
        }
    }
 public void Show(InventoryDef item)
 {
     this.item = item;
     this.Icon.Load(item.IconUrlLarge);
     this.Name.text        = item.Name;
     this.Description.text = item.Description.BBCodeToUnity();
     this.Price.text       = item.LocalPriceFormatted;
     base.gameObject.SetActive(true);
     base.GetComponent <CanvasGroup>().alpha = 0f;
     LeanTween.alphaCanvas(base.GetComponent <CanvasGroup>(), 1f, 0.1f);
 }
Exemplo n.º 8
0
 internal void ShowModal(InventoryDef item)
 {
     this.ItemStoreInfoModal.Show(item);
 }
Exemplo n.º 9
0
        public IEnumerator LoadIcon(ulong workshopId, string directory = null, AssetBundle bundle = null)
        {
            Skin str = null;
            AssetBundleRequest assetBundleRequest;

            TimeWarning.BeginSample("Skin.LoadIcon");
            if (bundle != null)
            {
                TimeWarning.BeginSample("ManifestName");
                str.manifestName = string.Concat("Assets/Skins/", workshopId, "/manifest.txt");
                TimeWarning.EndSample();
                TimeWarning.BeginSample("LoadAssetAsync");
                assetBundleRequest = bundle.LoadAssetAsync <TextAsset>(str.manifestName);
                TimeWarning.EndSample();
                TimeWarning.EndSample();
                yield return(assetBundleRequest);

                TimeWarning.BeginSample("Skin.LoadIcon");
                TimeWarning.BeginSample("AssetBundleRequest");
                str.manifestAsset = assetBundleRequest.asset as TextAsset;
                TimeWarning.EndSample();
                if (str.manifestAsset != null)
                {
                    TimeWarning.BeginSample("TextAsset");
                    str.manifestContent = str.manifestAsset.text;
                    TimeWarning.EndSample();
                }
                assetBundleRequest = null;
            }
            if (str.manifestContent == null && directory != null)
            {
                TimeWarning.BeginSample("ManifestName");
                str.manifestName = string.Concat(directory, "/manifest.txt");
                TimeWarning.EndSample();
                TimeWarning.BeginSample("File.Exists");
                bool flag = File.Exists(str.manifestName);
                TimeWarning.EndSample();
                if (flag)
                {
                    TimeWarning.EndSample();
                    yield return(Global.Runner.StartCoroutine(Parallel.Coroutine(new Action(str.LoadManifestFromFile))));

                    TimeWarning.BeginSample("Skin.LoadIcon");
                }
            }
            if (str.manifestContent != null)
            {
                TimeWarning.EndSample();
                yield return(Global.Runner.StartCoroutine(Parallel.Coroutine(new Action(str.DeserializeManifest))));

                TimeWarning.BeginSample("Skin.LoadIcon");
            }
            if (str.manifest == null)
            {
                UnityEngine.Debug.LogWarning(string.Concat("Invalid skin manifest: ", str.manifestName));
                TimeWarning.EndSample();
                yield break;
            }
            TimeWarning.BeginSample("Skinnable.FindForItem");
            str.Skinnable = Skinnable.FindForItem(str.manifest.ItemType);
            TimeWarning.EndSample();
            if (bundle != null)
            {
                TimeWarning.BeginSample("IconName");
                str.iconName = string.Concat("Assets/Skins/", workshopId, "/icon.png");
                TimeWarning.EndSample();
                TimeWarning.BeginSample("LoadAssetAsync");
                assetBundleRequest = bundle.LoadAssetAsync <Sprite>(str.iconName);
                TimeWarning.EndSample();
                TimeWarning.EndSample();
                yield return(assetBundleRequest);

                TimeWarning.BeginSample("Skin.LoadIcon");
                TimeWarning.BeginSample("AssetBundleRequest");
                Sprite sprite = assetBundleRequest.asset as Sprite;
                TimeWarning.EndSample();
                if (sprite != null)
                {
                    TimeWarning.BeginSample("Sprite");
                    str.sprite = sprite;
                    TimeWarning.EndSample();
                }
                assetBundleRequest = null;
            }
            if (str.sprite == null && SteamClient.IsValid)
            {
                string         empty       = string.Empty;
                InventoryDef[] definitions = SteamInventory.Definitions;
                TimeWarning.BeginSample("IconName");
                str.iconName = workshopId.ToString();
                TimeWarning.EndSample();
                if (definitions != null)
                {
                    TimeWarning.BeginSample("FindItemDefinition");
                    int length = (int)definitions.Length - 1;
                    while (length >= 0)
                    {
                        InventoryDef inventoryDef = definitions[length];
                        string       property     = inventoryDef.GetProperty("workshopdownload");
                        if (str.iconName != property)
                        {
                            length--;
                        }
                        else
                        {
                            empty = inventoryDef.IconUrlLarge;
                            break;
                        }
                    }
                    TimeWarning.EndSample();
                }
                if (!string.IsNullOrEmpty(empty))
                {
                    TimeWarning.BeginSample("UnityWebRequestTexture.GetTexture");
                    UnityWebRequest texture = UnityWebRequestTexture.GetTexture(empty);
                    texture.timeout = Mathf.CeilToInt(WorkshopSkin.DownloadTimeout);
                    TimeWarning.EndSample();
                    TimeWarning.EndSample();
                    yield return(texture.SendWebRequest());

                    TimeWarning.BeginSample("Skin.LoadIcon");
                    if (texture.isDone && !texture.isHttpError && !texture.isNetworkError)
                    {
                        TimeWarning.BeginSample("DownloadHandlerTexture.GetContent");
                        Texture2D content = DownloadHandlerTexture.GetContent(texture);
                        TimeWarning.EndSample();
                        TimeWarning.BeginSample("Sprite");
                        str.sprite = Sprite.Create(content, new Rect(0f, 0f, 512f, 512f), Vector2.zero, 100f, 0, SpriteMeshType.FullRect);
                        TimeWarning.EndSample();
                    }
                    TimeWarning.BeginSample("UnityWebRequest.Dispose");
                    texture.Dispose();
                    TimeWarning.EndSample();
                    texture = null;
                }
            }
            if (str.sprite == null && directory != null)
            {
                TimeWarning.BeginSample("IconName");
                str.iconName = string.Concat(directory, "/icon.png");
                TimeWarning.EndSample();
                TimeWarning.BeginSample("File.Exists");
                bool flag1 = File.Exists(str.iconName);
                TimeWarning.EndSample();
                if (flag1)
                {
                    TimeWarning.BeginSample("AsyncTextureLoad.Invoke");
                    AsyncTextureLoad asyncTextureLoad = new AsyncTextureLoad(str.iconName, false, false, true, false);
                    TimeWarning.EndSample();
                    TimeWarning.EndSample();
                    yield return(asyncTextureLoad);

                    TimeWarning.BeginSample("Skin.LoadIcon");
                    TimeWarning.BeginSample("AsyncTextureLoad.Texture");
                    Texture2D texture2D = asyncTextureLoad.texture;
                    TimeWarning.EndSample();
                    TimeWarning.BeginSample("Sprite");
                    str.sprite = Sprite.Create(texture2D, new Rect(0f, 0f, 512f, 512f), Vector2.zero, 100f, 0, SpriteMeshType.FullRect);
                    TimeWarning.EndSample();
                    asyncTextureLoad = null;
                }
            }
            if (str.sprite != null)
            {
                str.IconLoaded = true;
                if (str.OnIconLoaded != null)
                {
                    str.OnIconLoaded();
                }
            }
            TimeWarning.EndSample();
        }
Exemplo n.º 10
0
 public void Init(int index, InventoryDef def)
 {
     this.Index      = index;
     this.Name.text  = def.Name;
     this.Price.text = def.LocalPriceFormatted;
 }
Exemplo n.º 11
0
    public bool HasUnlocked(ItemDefinition targetItem)
    {
        int i;

        if (!targetItem.Blueprint || !targetItem.Blueprint.NeedsSteamItem)
        {
            int[] numArray = ItemManager.defaultBlueprints;
            for (i = 0; i < (int)numArray.Length; i++)
            {
                if (numArray[i] == targetItem.itemid)
                {
                    return(true);
                }
            }
            if (!base.baseEntity.isServer)
            {
                return(false);
            }
            return(this.IsUnlocked(targetItem));
        }
        if (targetItem.steamItem != null && !this.steamInventory.HasItem(targetItem.steamItem.id))
        {
            return(false);
        }
        if (targetItem.steamItem == null)
        {
            bool flag = false;
            ItemSkinDirectory.Skin[] skinArray = targetItem.skins;
            i = 0;
            while (i < (int)skinArray.Length)
            {
                ItemSkinDirectory.Skin skin = skinArray[i];
                if (!this.steamInventory.HasItem(skin.id))
                {
                    i++;
                }
                else
                {
                    flag = true;
                    break;
                }
            }
            if (!flag && targetItem.skins2 != null)
            {
                InventoryDef[] inventoryDefArray = targetItem.skins2;
                i = 0;
                while (i < (int)inventoryDefArray.Length)
                {
                    InventoryDef inventoryDef = inventoryDefArray[i];
                    if (!this.steamInventory.HasItem(inventoryDef.Id))
                    {
                        i++;
                    }
                    else
                    {
                        flag = true;
                        break;
                    }
                }
            }
            if (!flag)
            {
                return(false);
            }
        }
        return(true);
    }