Ejemplo n.º 1
0
        // Token: 0x06003424 RID: 13348 RVA: 0x00153C00 File Offset: 0x00152000
        public static Transform getItem(ushort id, ushort skin, byte quality, byte[] state, bool viewmodel, ItemAsset itemAsset, SkinAsset skinAsset, List <Mesh> outTempMeshes, out Material tempMaterial, GetStatTrackerValueHandler statTrackerCallback)
        {
            tempMaterial = null;
            if (itemAsset != null && itemAsset.item != null)
            {
                if (id != itemAsset.id)
                {
                    Debug.LogError("ID and asset ID are not in sync!");
                }
                Transform transform = UnityEngine.Object.Instantiate <GameObject>(itemAsset.item).transform;
                transform.name = id.ToString();
                if (viewmodel)
                {
                    Layerer.viewmodel(transform);
                }
                if (skinAsset != null)
                {
                    if (skinAsset.overrideMeshes != null && skinAsset.overrideMeshes.Count > 0)
                    {
                        HighlighterTool.remesh(transform, skinAsset.overrideMeshes, outTempMeshes, true);
                    }
                    else if (outTempMeshes != null)
                    {
                        outTempMeshes.Clear();
                    }
                    if (skinAsset.primarySkin != null)
                    {
                        if (skinAsset.isPattern)
                        {
                            Material material = UnityEngine.Object.Instantiate <Material>(skinAsset.primarySkin);
                            material.SetTexture("_AlbedoBase", itemAsset.albedoBase);
                            material.SetTexture("_MetallicBase", itemAsset.metallicBase);
                            material.SetTexture("_EmissionBase", itemAsset.emissionBase);
                            HighlighterTool.rematerialize(transform, material, out tempMaterial);
                        }
                        else
                        {
                            HighlighterTool.rematerialize(transform, skinAsset.primarySkin, out tempMaterial);
                        }
                    }
                }
                else if (outTempMeshes != null)
                {
                    outTempMeshes.Clear();
                }
                if (itemAsset.type == EItemType.GUN)
                {
                    Attachments attachments = transform.gameObject.AddComponent <Attachments>();
                    attachments.isSkinned = true;
                    attachments.updateGun((ItemGunAsset)itemAsset, skinAsset);
                    attachments.updateAttachments(state, viewmodel);
                }
                EStatTrackerType estatTrackerType;
                int num;
                if (!Dedicator.isDedicated && statTrackerCallback != null && statTrackerCallback(out estatTrackerType, out num))
                {
                    StatTracker statTracker = transform.gameObject.AddComponent <StatTracker>();
                    statTracker.statTrackerCallback = statTrackerCallback;
                    statTracker.updateStatTracker(viewmodel);
                }
                return(transform);
            }
            Transform transform2 = new GameObject().transform;

            transform2.name = id.ToString();
            if (viewmodel)
            {
                transform2.tag = "Viewmodel";
                transform2.gameObject.layer = LayerMasks.VIEWMODEL;
            }
            else
            {
                transform2.tag = "Item";
                transform2.gameObject.layer = LayerMasks.ITEM;
            }
            return(transform2);
        }