// Token: 0x06002EB5 RID: 11957 RVA: 0x00131B38 File Offset: 0x0012FF38
 private void Start()
 {
     this._isBuilding  = false;
     this._dragStart   = Vector2.zero;
     this._dragEnd     = Vector2.zero;
     this._isDragging  = false;
     this.selection    = new List <WorkzoneSelection>();
     this.handlePlane  = default(Plane);
     this.group        = new GameObject().transform;
     this.group.name   = "Group";
     this.group.parent = Level.editing;
     this.handle       = ((GameObject)UnityEngine.Object.Instantiate(Resources.Load("Edit/Handles"))).transform;
     this.handle.name  = "Handle";
     this.handle.gameObject.SetActive(false);
     this.handle.parent = Level.editing;
     Layerer.relayer(this.handle, LayerMasks.VIEWMODEL);
     this.transformHandle = this.handle.FindChild("Transform");
     this.planeHandle     = this.handle.FindChild("Plane");
     this.rotateHandle    = this.handle.FindChild("Rotate");
     this.dragMode        = EDragMode.TRANSFORM;
     this.dragCoordinate  = EDragCoordinate.GLOBAL;
     this.dragable        = new List <EditorDrag>();
     this.snapTransform   = 1f;
     this.snapRotation    = 15f;
 }
Exemplo n.º 2
0
        public static Transform getItem(ushort id, ushort skin, byte quality, byte[] state, bool viewmodel, ItemAsset itemAsset, SkinAsset skinAsset, out Material tempMaterial)
        {
            tempMaterial = null;
            if (itemAsset != null && itemAsset.item != null)
            {
                if (id != itemAsset.id)
                {
                    Debug.LogError("ID and asset ID are not in sync!");
                }
                Transform transform = Object.Instantiate <GameObject>(itemAsset.item).transform;
                transform.name = id.ToString();
                if (viewmodel)
                {
                    Layerer.viewmodel(transform);
                }
                if (skinAsset != null && skinAsset.primarySkin != null)
                {
                    if (skinAsset.isPattern)
                    {
                        Material material = 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);
                    }
                }
                if (itemAsset.type == EItemType.GUN)
                {
                    Attachments attachments = transform.gameObject.AddComponent <Attachments>();
                    attachments.isSkinned = true;
                    attachments.updateGun((ItemGunAsset)itemAsset, skinAsset);
                    attachments.updateAttachments(state, 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);
        }
Exemplo n.º 3
0
		// Token: 0x06003A3B RID: 14907 RVA: 0x001BE148 File Offset: 0x001BC548
		public static void relayer(Transform target, int layer)
		{
			if (target == null)
			{
				return;
			}
			target.gameObject.layer = layer;
			for (int i = 0; i < target.childCount; i++)
			{
				Layerer.relayer(target.GetChild(i), layer);
			}
		}
Exemplo n.º 4
0
        // Token: 0x060018FB RID: 6395 RVA: 0x0008CC54 File Offset: 0x0008B054
        public void updateStatTracker(bool viewmodel)
        {
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Economy/Attachments/Stat_Tracker"));

            gameObject.transform.SetParent(this.statTrackerHook);
            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localRotation = Quaternion.identity;
            this.statTrackerText = gameObject.GetComponentInChildren <Text>();
            if (viewmodel)
            {
                Layerer.relayer(gameObject.transform, LayerMasks.VIEWMODEL);
            }
        }
Exemplo n.º 5
0
        // Token: 0x06002168 RID: 8552 RVA: 0x000B5FB4 File Offset: 0x000B43B4
        public override void updateState(Asset asset, byte[] state)
        {
            base.updateState(asset, state);
            if (!this.isInit)
            {
                this.isInit    = true;
                this._npcAsset = (asset as ObjectNPCAsset);
                if (!Dedicator.isDedicated)
                {
                    Transform transform  = base.transform.FindChild("Root");
                    Transform transform2 = transform.FindChild("Skeleton");
                    this.skull           = transform2.FindChild("Spine").FindChild("Skull");
                    this.anim            = transform.GetComponent <Animation>();
                    this.humanAnim       = transform.GetComponent <HumanAnimator>();
                    transform.localScale = new Vector3((float)((!this.npcAsset.isBackward) ? 1 : -1), 1f, 1f);
                    ItemAsset itemAsset  = (ItemAsset)Assets.find(EAssetType.ITEM, this.npcAsset.primary);
                    ItemAsset itemAsset2 = (ItemAsset)Assets.find(EAssetType.ITEM, this.npcAsset.secondary);
                    ItemAsset itemAsset3 = (ItemAsset)Assets.find(EAssetType.ITEM, this.npcAsset.tertiary);
                    ItemAsset itemAsset4 = null;
                    Transform parent     = transform2.FindChild("Spine").FindChild("Primary_Melee");
                    Transform parent2    = transform2.FindChild("Spine").FindChild("Primary_Large_Gun");
                    Transform parent3    = transform2.FindChild("Spine").FindChild("Primary_Small_Gun");
                    Transform parent4    = transform2.FindChild("Right_Hip").FindChild("Right_Leg").FindChild("Secondary_Melee");
                    Transform parent5    = transform2.FindChild("Right_Hip").FindChild("Right_Leg").FindChild("Secondary_Gun");
                    Transform parent6    = transform2.FindChild("Spine").FindChild("Left_Shoulder").FindChild("Left_Arm").FindChild("Left_Hand").FindChild("Left_Hook");
                    Transform parent7    = transform2.FindChild("Spine").FindChild("Right_Shoulder").FindChild("Right_Arm").FindChild("Right_Hand").FindChild("Right_Hook");
                    this.clothes          = transform.GetComponent <HumanClothes>();
                    this.clothes.shirt    = this.npcAsset.shirt;
                    this.clothes.pants    = this.npcAsset.pants;
                    this.clothes.hat      = this.npcAsset.hat;
                    this.clothes.backpack = this.npcAsset.backpack;
                    this.clothes.vest     = this.npcAsset.vest;
                    this.clothes.mask     = this.npcAsset.mask;
                    this.clothes.glasses  = this.npcAsset.glasses;
                    this.clothes.face     = this.npcAsset.face;
                    this.clothes.hair     = this.npcAsset.hair;
                    this.clothes.beard    = this.npcAsset.beard;
                    this.clothes.skin     = this.npcAsset.skin;
                    this.clothes.color    = this.npcAsset.color;
                    this.clothes.apply();
                    if (this.npcAsset.primary != 0 && itemAsset != null)
                    {
                        Material  material;
                        Transform item = ItemTool.getItem(itemAsset.id, 0, 100, itemAsset.getState(), false, itemAsset, null, out material, null);
                        if (this.npcAsset.equipped == ESlotType.PRIMARY)
                        {
                            if (itemAsset.isBackward)
                            {
                                item.transform.parent = parent6;
                            }
                            else
                            {
                                item.transform.parent = parent7;
                            }
                            itemAsset4 = itemAsset;
                        }
                        else if (itemAsset.type == EItemType.MELEE)
                        {
                            item.transform.parent = parent;
                        }
                        else if (itemAsset.slot == ESlotType.PRIMARY)
                        {
                            item.transform.parent = parent2;
                        }
                        else
                        {
                            item.transform.parent = parent3;
                        }
                        item.localPosition = Vector3.zero;
                        item.localRotation = Quaternion.Euler(0f, 0f, 90f);
                        item.localScale    = Vector3.one;
                        UnityEngine.Object.Destroy(item.GetComponent <Collider>());
                        Layerer.enemy(item);
                    }
                    if (this.npcAsset.secondary != 0 && itemAsset2 != null)
                    {
                        Material  material2;
                        Transform item2 = ItemTool.getItem(itemAsset2.id, 0, 100, itemAsset2.getState(), false, itemAsset2, null, out material2, null);
                        if (this.npcAsset.equipped == ESlotType.SECONDARY)
                        {
                            if (itemAsset2.isBackward)
                            {
                                item2.transform.parent = parent6;
                            }
                            else
                            {
                                item2.transform.parent = parent7;
                            }
                            itemAsset4 = itemAsset2;
                        }
                        else if (itemAsset2.type == EItemType.MELEE)
                        {
                            item2.transform.parent = parent4;
                        }
                        else
                        {
                            item2.transform.parent = parent5;
                        }
                        item2.localPosition = Vector3.zero;
                        item2.localRotation = Quaternion.Euler(0f, 0f, 90f);
                        item2.localScale    = Vector3.one;
                        UnityEngine.Object.Destroy(item2.GetComponent <Collider>());
                        Layerer.enemy(item2);
                    }
                    if (this.npcAsset.tertiary != 0 && itemAsset3 != null && this.npcAsset.equipped == ESlotType.TERTIARY)
                    {
                        Material  material3;
                        Transform item3 = ItemTool.getItem(itemAsset3.id, 0, 100, itemAsset3.getState(), false, itemAsset3, null, out material3, null);
                        if (itemAsset3.isBackward)
                        {
                            item3.transform.parent = parent6;
                        }
                        else
                        {
                            item3.transform.parent = parent7;
                        }
                        itemAsset4          = itemAsset3;
                        item3.localPosition = Vector3.zero;
                        item3.localRotation = Quaternion.Euler(0f, 0f, 90f);
                        item3.localScale    = Vector3.one;
                        UnityEngine.Object.Destroy(item3.GetComponent <Collider>());
                        Layerer.enemy(item3);
                    }
                    if (itemAsset4 != null)
                    {
                        Transform mix  = transform2.FindChild("Spine").FindChild("Left_Shoulder");
                        Transform mix2 = transform2.FindChild("Spine").FindChild("Right_Shoulder");
                        int       i    = 0;
                        while (i < itemAsset4.animations.Length)
                        {
                            AnimationClip animationClip = itemAsset4.animations[i];
                            if (animationClip.name == "Equip")
                            {
                                this.hasEquip = true;
                                goto IL_683;
                            }
                            if (animationClip.name == "Sprint_Start" || animationClip.name == "Sprint_Stop")
                            {
                                this.hasSafety = true;
                                goto IL_683;
                            }
                            if (animationClip.name == "Inspect")
                            {
                                this.hasInspect = true;
                                goto IL_683;
                            }
IL_6E3:
                            i++;
                            continue;
IL_683:
                            this.anim.AddClip(animationClip, animationClip.name);
                            this.anim[animationClip.name].AddMixingTransform(mix, true);
                            this.anim[animationClip.name].AddMixingTransform(mix2, true);
                            this.anim[animationClip.name].layer = 1;
                            goto IL_6E3;
                        }
                    }
                    this.anim["Idle_Kick_Left"].AddMixingTransform(transform2.FindChild("Left_Hip"), true);
                    this.anim["Idle_Kick_Left"].layer = 2;
                    this.anim["Idle_Kick_Right"].AddMixingTransform(transform2.FindChild("Right_Hip"), true);
                    this.anim["Idle_Kick_Right"].layer = 2;
                    this.updateAnimation();
                }
            }
        }
Exemplo n.º 6
0
 // Token: 0x060018F4 RID: 6388 RVA: 0x0008BC48 File Offset: 0x0008A048
 public void updateAttachments(byte[] state, bool viewmodel)
 {
     if (state == null || state.Length != 18)
     {
         return;
     }
     base.transform.localScale = Vector3.one;
     this._sightID             = BitConverter.ToUInt16(state, 0);
     this._tacticalID          = BitConverter.ToUInt16(state, 2);
     this._gripID     = BitConverter.ToUInt16(state, 4);
     this._barrelID   = BitConverter.ToUInt16(state, 6);
     this._magazineID = BitConverter.ToUInt16(state, 8);
     if (this.sightModel != null)
     {
         UnityEngine.Object.Destroy(this.sightModel.gameObject);
         this._sightModel = null;
     }
     try
     {
         this._sightAsset = (ItemSightAsset)Assets.find(EAssetType.ITEM, this.sightID);
     }
     catch
     {
         this._sightAsset = null;
     }
     this.tempSightMaterial = null;
     if (this.sightAsset != null && this.sightHook != null)
     {
         this._sightModel                        = UnityEngine.Object.Instantiate <GameObject>(this.sightAsset.sight).transform;
         this.sightModel.name                    = "Sight";
         this.sightModel.transform.parent        = this.sightHook;
         this.sightModel.transform.localPosition = Vector3.zero;
         this.sightModel.transform.localRotation = Quaternion.identity;
         this.sightModel.localScale              = Vector3.one;
         if (viewmodel)
         {
             Layerer.viewmodel(this.sightModel);
         }
         if (this.gunAsset != null && this.skinAsset != null && this.skinAsset.secondarySkins != null)
         {
             Material material = null;
             if (!this.skinAsset.secondarySkins.TryGetValue(this.sightID, out material) && this.skinAsset.hasSight && this.sightAsset.isPaintable)
             {
                 if (this.sightAsset.albedoBase != null && this.skinAsset.attachmentSkin != null)
                 {
                     material = UnityEngine.Object.Instantiate <Material>(this.skinAsset.attachmentSkin);
                     material.SetTexture("_AlbedoBase", this.sightAsset.albedoBase);
                     material.SetTexture("_MetallicBase", this.sightAsset.metallicBase);
                     material.SetTexture("_EmissionBase", this.sightAsset.emissionBase);
                 }
                 else if (this.skinAsset.tertiarySkin != null)
                 {
                     material = this.skinAsset.tertiarySkin;
                 }
             }
             if (material != null)
             {
                 HighlighterTool.rematerialize(this.sightModel, material, out this.tempSightMaterial);
             }
         }
     }
     if (this.tacticalModel != null)
     {
         UnityEngine.Object.Destroy(this.tacticalModel.gameObject);
         this._tacticalModel = null;
     }
     try
     {
         this._tacticalAsset = (ItemTacticalAsset)Assets.find(EAssetType.ITEM, this.tacticalID);
     }
     catch
     {
         this._tacticalAsset = null;
     }
     this.tempTacticalMaterial = null;
     if (this.tacticalAsset != null && this.tacticalHook != null)
     {
         this._tacticalModel                        = UnityEngine.Object.Instantiate <GameObject>(this.tacticalAsset.tactical).transform;
         this.tacticalModel.name                    = "Tactical";
         this.tacticalModel.transform.parent        = this.tacticalHook;
         this.tacticalModel.transform.localPosition = Vector3.zero;
         this.tacticalModel.transform.localRotation = Quaternion.identity;
         this.tacticalModel.localScale              = Vector3.one;
         if (viewmodel)
         {
             Layerer.viewmodel(this.tacticalModel);
         }
         if (this.gunAsset != null && this.skinAsset != null && this.skinAsset.secondarySkins != null)
         {
             Material material2 = null;
             if (!this.skinAsset.secondarySkins.TryGetValue(this.tacticalID, out material2) && this.skinAsset.hasTactical && this.tacticalAsset.isPaintable)
             {
                 if (this.tacticalAsset.albedoBase != null && this.skinAsset.attachmentSkin != null)
                 {
                     material2 = UnityEngine.Object.Instantiate <Material>(this.skinAsset.attachmentSkin);
                     material2.SetTexture("_AlbedoBase", this.tacticalAsset.albedoBase);
                     material2.SetTexture("_MetallicBase", this.tacticalAsset.metallicBase);
                     material2.SetTexture("_EmissionBase", this.tacticalAsset.emissionBase);
                 }
                 else if (this.skinAsset.tertiarySkin != null)
                 {
                     material2 = this.skinAsset.tertiarySkin;
                 }
             }
             if (material2 != null)
             {
                 HighlighterTool.rematerialize(this.tacticalModel, material2, out this.tempTacticalMaterial);
             }
         }
     }
     if (this.gripModel != null)
     {
         UnityEngine.Object.Destroy(this.gripModel.gameObject);
         this._gripModel = null;
     }
     try
     {
         this._gripAsset = (ItemGripAsset)Assets.find(EAssetType.ITEM, this.gripID);
     }
     catch
     {
         this._gripAsset = null;
     }
     this.tempGripMaterial = null;
     if (this.gripAsset != null && this.gripHook != null)
     {
         this._gripModel                        = UnityEngine.Object.Instantiate <GameObject>(this.gripAsset.grip).transform;
         this.gripModel.name                    = "Grip";
         this.gripModel.transform.parent        = this.gripHook;
         this.gripModel.transform.localPosition = Vector3.zero;
         this.gripModel.transform.localRotation = Quaternion.identity;
         this.gripModel.localScale              = Vector3.one;
         if (viewmodel)
         {
             Layerer.viewmodel(this.gripModel);
         }
         if (this.gunAsset != null && this.skinAsset != null && this.skinAsset.secondarySkins != null)
         {
             Material material3 = null;
             if (!this.skinAsset.secondarySkins.TryGetValue(this.gripID, out material3) && this.skinAsset.hasGrip && this.gripAsset.isPaintable)
             {
                 if (this.gripAsset.albedoBase != null && this.skinAsset.attachmentSkin != null)
                 {
                     material3 = UnityEngine.Object.Instantiate <Material>(this.skinAsset.attachmentSkin);
                     material3.SetTexture("_AlbedoBase", this.gripAsset.albedoBase);
                     material3.SetTexture("_MetallicBase", this.gripAsset.metallicBase);
                     material3.SetTexture("_EmissionBase", this.gripAsset.emissionBase);
                 }
                 else if (this.skinAsset.tertiarySkin != null)
                 {
                     material3 = this.skinAsset.tertiarySkin;
                 }
             }
             if (material3 != null)
             {
                 HighlighterTool.rematerialize(this.gripModel, material3, out this.tempGripMaterial);
             }
         }
     }
     if (this.barrelModel != null)
     {
         UnityEngine.Object.Destroy(this.barrelModel.gameObject);
         this._barrelModel = null;
     }
     try
     {
         this._barrelAsset = (ItemBarrelAsset)Assets.find(EAssetType.ITEM, this.barrelID);
     }
     catch
     {
         this._barrelAsset = null;
     }
     this.tempBarrelMaterial = null;
     if (this.barrelAsset != null && this.barrelHook != null)
     {
         this._barrelModel                        = UnityEngine.Object.Instantiate <GameObject>(this.barrelAsset.barrel).transform;
         this.barrelModel.name                    = "Barrel";
         this.barrelModel.transform.parent        = this.barrelHook;
         this.barrelModel.transform.localPosition = Vector3.zero;
         this.barrelModel.transform.localRotation = Quaternion.identity;
         this.barrelModel.localScale              = Vector3.one;
         if (viewmodel)
         {
             Layerer.viewmodel(this.barrelModel);
         }
         if (this.gunAsset != null && this.skinAsset != null && this.skinAsset.secondarySkins != null)
         {
             Material material4 = null;
             if (!this.skinAsset.secondarySkins.TryGetValue(this.barrelID, out material4) && this.skinAsset.hasBarrel && this.barrelAsset.isPaintable)
             {
                 if (this.barrelAsset.albedoBase != null && this.skinAsset.attachmentSkin != null)
                 {
                     material4 = UnityEngine.Object.Instantiate <Material>(this.skinAsset.attachmentSkin);
                     material4.SetTexture("_AlbedoBase", this.barrelAsset.albedoBase);
                     material4.SetTexture("_MetallicBase", this.barrelAsset.metallicBase);
                     material4.SetTexture("_EmissionBase", this.barrelAsset.emissionBase);
                 }
                 else if (this.skinAsset.tertiarySkin != null)
                 {
                     material4 = this.skinAsset.tertiarySkin;
                 }
             }
             if (material4 != null)
             {
                 HighlighterTool.rematerialize(this.barrelModel, material4, out this.tempBarrelMaterial);
             }
         }
     }
     if (this.magazineModel != null)
     {
         UnityEngine.Object.Destroy(this.magazineModel.gameObject);
         this._magazineModel = null;
     }
     try
     {
         this._magazineAsset = (ItemMagazineAsset)Assets.find(EAssetType.ITEM, this.magazineID);
     }
     catch
     {
         this._magazineAsset = null;
     }
     this.tempMagazineMaterial = null;
     if (this.magazineAsset != null && this.magazineHook != null)
     {
         Transform transform = null;
         if (this.magazineAsset.calibers.Length > 0)
         {
             transform = this.magazineHook.FindChild("Caliber_" + this.magazineAsset.calibers[0]);
         }
         if (transform == null)
         {
             transform = this.magazineHook;
         }
         this._magazineModel                        = UnityEngine.Object.Instantiate <GameObject>(this.magazineAsset.magazine).transform;
         this.magazineModel.name                    = "Magazine";
         this.magazineModel.transform.parent        = transform;
         this.magazineModel.transform.localPosition = Vector3.zero;
         this.magazineModel.transform.localRotation = Quaternion.identity;
         this.magazineModel.localScale              = Vector3.one;
         if (viewmodel)
         {
             Layerer.viewmodel(this.magazineModel);
         }
         if (this.gunAsset != null && this.skinAsset != null && this.skinAsset.secondarySkins != null)
         {
             Material material5 = null;
             if (!this.skinAsset.secondarySkins.TryGetValue(this.magazineID, out material5) && this.skinAsset.hasMagazine && this.magazineAsset.isPaintable)
             {
                 if (this.magazineAsset.albedoBase != null && this.skinAsset.attachmentSkin != null)
                 {
                     material5 = UnityEngine.Object.Instantiate <Material>(this.skinAsset.attachmentSkin);
                     material5.SetTexture("_AlbedoBase", this.magazineAsset.albedoBase);
                     material5.SetTexture("_MetallicBase", this.magazineAsset.metallicBase);
                     material5.SetTexture("_EmissionBase", this.magazineAsset.emissionBase);
                 }
                 else if (this.skinAsset.tertiarySkin != null)
                 {
                     material5 = this.skinAsset.tertiarySkin;
                 }
             }
             if (material5 != null)
             {
                 HighlighterTool.rematerialize(this.magazineModel, material5, out this.tempMagazineMaterial);
             }
         }
     }
     if (this.tacticalModel != null && this.tacticalModel.childCount > 0)
     {
         this._lightHook  = this.tacticalModel.transform.FindChild("Model_0").FindChild("Light");
         this._light2Hook = this.tacticalModel.transform.FindChild("Model_0").FindChild("Light2");
         if (viewmodel)
         {
             if (this.lightHook != null)
             {
                 this.lightHook.tag = "Viewmodel";
                 this.lightHook.gameObject.layer = LayerMasks.VIEWMODEL;
                 Transform transform2 = this.lightHook.FindChild("Light");
                 if (transform2 != null)
                 {
                     transform2.tag = "Viewmodel";
                     transform2.gameObject.layer = LayerMasks.VIEWMODEL;
                 }
             }
             if (this.light2Hook != null)
             {
                 this.light2Hook.tag = "Viewmodel";
                 this.light2Hook.gameObject.layer = LayerMasks.VIEWMODEL;
                 Transform transform3 = this.light2Hook.FindChild("Light");
                 if (transform3 != null)
                 {
                     transform3.tag = "Viewmodel";
                     transform3.gameObject.layer = LayerMasks.VIEWMODEL;
                 }
             }
         }
         else
         {
             LightLODTool.applyLightLOD(this.lightHook);
             LightLODTool.applyLightLOD(this.light2Hook);
         }
     }
     else
     {
         this._lightHook  = null;
         this._light2Hook = null;
     }
     if (this.sightModel != null)
     {
         this._aimHook = this.sightModel.transform.FindChild("Model_0").FindChild("Aim");
         if (this.aimHook != null)
         {
             Transform transform4 = this.aimHook.parent.FindChild("Reticule");
             if (transform4 != null)
             {
                 Renderer component = transform4.GetComponent <Renderer>();
                 Material material6 = component.material;
                 material6.SetColor("_Color", OptionsSettings.criticalHitmarkerColor);
                 material6.SetColor("_EmissionColor", OptionsSettings.criticalHitmarkerColor);
             }
         }
         this._reticuleHook = this.sightModel.transform.FindChild("Model_0").FindChild("Reticule");
     }
     else
     {
         this._aimHook      = null;
         this._reticuleHook = null;
     }
     if (this.aimHook != null)
     {
         this._scopeHook = this.aimHook.FindChild("Scope");
     }
     else
     {
         this._scopeHook = null;
     }
     if (this.rope != null && viewmodel)
     {
         this.rope.tag = "Viewmodel";
         this.rope.gameObject.layer = LayerMasks.VIEWMODEL;
     }
     this.wasSkinned = true;
     this.applyVisual();
 }
Exemplo n.º 7
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);
        }