Ejemplo n.º 1
0
        public static void getIcon(ushort id, ushort skin, byte quality, byte[] state, ItemAsset itemAsset, SkinAsset skinAsset, int x, int y, bool scale, ItemIconReady callback)
        {
            if (itemAsset != null && id != itemAsset.id)
            {
                Debug.LogError("ID and item asset ID are not in sync!");
            }
            if (skinAsset != null && skin != skinAsset.id)
            {
                Debug.LogError("ID and skin asset ID are not in sync!");
            }
            Texture2D texture2D;

            if (state.Length == 0 && skin == 0 && x == (int)(itemAsset.size_x * 50) && y == (int)(itemAsset.size_y * 50) && ItemTool.cache.TryGetValue(id, out texture2D))
            {
                if (texture2D != null)
                {
                    callback(texture2D);
                    return;
                }
                ItemTool.cache.Remove(id);
            }
            ItemIconInfo itemIconInfo = new ItemIconInfo();

            itemIconInfo.id        = id;
            itemIconInfo.skin      = skin;
            itemIconInfo.quality   = quality;
            itemIconInfo.state     = state;
            itemIconInfo.itemAsset = itemAsset;
            itemIconInfo.skinAsset = skinAsset;
            itemIconInfo.x         = x;
            itemIconInfo.y         = y;
            itemIconInfo.scale     = scale;
            itemIconInfo.callback  = callback;
            ItemTool.icons.Enqueue(itemIconInfo);
        }
Ejemplo n.º 2
0
        private void Update()
        {
            if (ItemTool.icons == null || ItemTool.icons.Count == 0)
            {
                return;
            }
            ItemIconInfo itemIconInfo = ItemTool.icons.Dequeue();

            if (itemIconInfo == null)
            {
                return;
            }
            if (itemIconInfo.itemAsset == null)
            {
                return;
            }
            Transform item = ItemTool.getItem(itemIconInfo.id, itemIconInfo.skin, itemIconInfo.quality, itemIconInfo.state, false, itemIconInfo.itemAsset, itemIconInfo.skinAsset);

            item.position = new Vector3(-256f, -256f, 0f);
            Transform transform;

            if (itemIconInfo.scale && itemIconInfo.skin != 0)
            {
                if (itemIconInfo.itemAsset.size2_z == 0f)
                {
                    item.position = new Vector3(0f, -256f, -256f);
                    Object.Destroy(item.gameObject);
                    Assets.errors.Add("Failed to create a skin icon of size 0 for " + itemIconInfo.id + ".");
                    return;
                }
                transform = item.FindChild("Icon2");
                if (transform == null)
                {
                    item.position = new Vector3(0f, -256f, -256f);
                    Object.Destroy(item.gameObject);
                    Assets.errors.Add("Failed to find a skin icon hook on " + itemIconInfo.id + ".");
                    return;
                }
            }
            else
            {
                if (itemIconInfo.itemAsset.size_z == 0f)
                {
                    item.position = new Vector3(0f, -256f, -256f);
                    Object.Destroy(item.gameObject);
                    Assets.errors.Add("Failed to create an item icon of size 0 for " + itemIconInfo.id + ".");
                    return;
                }
                transform = item.FindChild("Icon");
                if (transform == null)
                {
                    item.position = new Vector3(0f, -256f, -256f);
                    Object.Destroy(item.gameObject);
                    Assets.errors.Add("Failed to find an item icon hook on " + itemIconInfo.id + ".");
                    return;
                }
            }
            ItemTool.tool.transform.position = transform.position;
            ItemTool.tool.transform.rotation = transform.rotation;
            RenderTexture temporary = RenderTexture.GetTemporary(itemIconInfo.x, itemIconInfo.y, 16, 0, 2);

            temporary.name = string.Concat(new object[]
            {
                "Item_Render_",
                itemIconInfo.id,
                "_",
                itemIconInfo.skin
            });
            RenderTexture.active = temporary;
            ItemTool.tool.GetComponent <Camera>().targetTexture    = temporary;
            ItemTool.tool.GetComponent <Camera>().orthographicSize = itemIconInfo.itemAsset.size_z;
            if (itemIconInfo.scale)
            {
                if (itemIconInfo.skin != 0)
                {
                    ItemTool.tool.GetComponent <Camera>().orthographicSize = itemIconInfo.itemAsset.size2_z;
                }
                else
                {
                    float num = (float)itemIconInfo.itemAsset.size_x / (float)itemIconInfo.itemAsset.size_y;
                    ItemTool.tool.GetComponent <Camera>().orthographicSize *= num;
                }
            }
            bool        fog                 = RenderSettings.fog;
            AmbientMode ambientMode         = RenderSettings.ambientMode;
            Color       ambientSkyColor     = RenderSettings.ambientSkyColor;
            Color       ambientEquatorColor = RenderSettings.ambientEquatorColor;
            Color       ambientGroundColor  = RenderSettings.ambientGroundColor;

            RenderSettings.fog                 = false;
            RenderSettings.ambientMode         = 1;
            RenderSettings.ambientSkyColor     = Color.white;
            RenderSettings.ambientEquatorColor = Color.white;
            RenderSettings.ambientGroundColor  = Color.white;
            if (Provider.isConnected)
            {
                LevelLighting.setEnabled(false);
            }
            ItemTool.tool.GetComponent <Light>().enabled       = true;
            ItemTool.tool.GetComponent <Camera>().cullingMask  = RayMasks.ITEM;
            ItemTool.tool.GetComponent <Camera>().farClipPlane = 16f;
            ItemTool.tool.GetComponent <Camera>().Render();
            ItemTool.tool.GetComponent <Light>().enabled = false;
            if (Provider.isConnected)
            {
                LevelLighting.setEnabled(true);
            }
            RenderSettings.fog                 = fog;
            RenderSettings.ambientMode         = ambientMode;
            RenderSettings.ambientSkyColor     = ambientSkyColor;
            RenderSettings.ambientEquatorColor = ambientEquatorColor;
            RenderSettings.ambientGroundColor  = ambientGroundColor;
            item.position = new Vector3(0f, -256f, -256f);
            Object.Destroy(item.gameObject);
            Texture2D texture2D = new Texture2D(itemIconInfo.x, itemIconInfo.y, 5, false, true);

            texture2D.name = string.Concat(new object[]
            {
                "Item_Icon_",
                itemIconInfo.id,
                "_",
                itemIconInfo.skin
            });
            texture2D.filterMode = 0;
            texture2D.ReadPixels(new Rect(0f, 0f, (float)itemIconInfo.x, (float)itemIconInfo.y), 0, 0);
            texture2D.Apply();
            RenderTexture.ReleaseTemporary(temporary);
            if (itemIconInfo.callback != null)
            {
                itemIconInfo.callback(texture2D);
            }
            if (itemIconInfo.state.Length == 0 && itemIconInfo.skin == 0 && itemIconInfo.x == (int)(itemIconInfo.itemAsset.size_x * 50) && itemIconInfo.y == (int)(itemIconInfo.itemAsset.size_y * 50) && !ItemTool.cache.ContainsKey(itemIconInfo.id))
            {
                ItemTool.cache.Add(itemIconInfo.id, texture2D);
            }
        }
Ejemplo n.º 3
0
        // Token: 0x0600342C RID: 13356 RVA: 0x0015455C File Offset: 0x0015295C
        private void Update()
        {
            if (ItemTool.icons == null || ItemTool.icons.Count == 0)
            {
                return;
            }
            ItemIconInfo itemIconInfo = ItemTool.icons.Dequeue();

            if (itemIconInfo == null)
            {
                return;
            }
            if (itemIconInfo.itemAsset == null)
            {
                return;
            }
            this.currentIconTags         = itemIconInfo.tags;
            this.currentIconDynamicProps = itemIconInfo.dynamic_props;
            Transform item = ItemTool.getItem(itemIconInfo.id, itemIconInfo.skin, itemIconInfo.quality, itemIconInfo.state, false, itemIconInfo.itemAsset, itemIconInfo.skinAsset, new GetStatTrackerValueHandler(this.getIconStatTrackerValue));

            item.position = new Vector3(-256f, -256f, 0f);
            Transform transform;

            if (itemIconInfo.scale && itemIconInfo.skin != 0)
            {
                if (itemIconInfo.itemAsset.size2_z == 0f)
                {
                    item.position = new Vector3(0f, -256f, -256f);
                    UnityEngine.Object.Destroy(item.gameObject);
                    Assets.errors.Add("Failed to create a skin icon of size 0 for " + itemIconInfo.id + ".");
                    return;
                }
                transform = item.FindChild("Icon2");
                if (transform == null)
                {
                    item.position = new Vector3(0f, -256f, -256f);
                    UnityEngine.Object.Destroy(item.gameObject);
                    Assets.errors.Add("Failed to find a skin icon hook on " + itemIconInfo.id + ".");
                    return;
                }
            }
            else
            {
                if (itemIconInfo.itemAsset.size_z == 0f)
                {
                    item.position = new Vector3(0f, -256f, -256f);
                    UnityEngine.Object.Destroy(item.gameObject);
                    Assets.errors.Add("Failed to create an item icon of size 0 for " + itemIconInfo.id + ".");
                    return;
                }
                transform = item.FindChild("Icon");
                if (transform == null)
                {
                    item.position = new Vector3(0f, -256f, -256f);
                    UnityEngine.Object.Destroy(item.gameObject);
                    Assets.errors.Add("Failed to find an item icon hook on " + itemIconInfo.id + ".");
                    return;
                }
            }
            float num = itemIconInfo.itemAsset.size_z;

            if (itemIconInfo.scale)
            {
                if (itemIconInfo.skin != 0)
                {
                    num = itemIconInfo.itemAsset.size2_z;
                }
                else
                {
                    float num2 = (float)itemIconInfo.itemAsset.size_x / (float)itemIconInfo.itemAsset.size_y;
                    num *= num2;
                }
            }
            Texture2D texture2D = ItemTool.captureIcon(itemIconInfo.id, itemIconInfo.skin, item, transform, itemIconInfo.x, itemIconInfo.y, num);

            if (itemIconInfo.callback != null)
            {
                itemIconInfo.callback(texture2D);
            }
            if (itemIconInfo.state.Length == 0 && itemIconInfo.skin == 0 && itemIconInfo.x == (int)(itemIconInfo.itemAsset.size_x * 50) && itemIconInfo.y == (int)(itemIconInfo.itemAsset.size_y * 50) && !ItemTool.cache.ContainsKey(itemIconInfo.id))
            {
                ItemTool.cache.Add(itemIconInfo.id, texture2D);
            }
        }