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()); }
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); }
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 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(); }