// Token: 0x060018F2 RID: 6386 RVA: 0x0008BB44 File Offset: 0x00089F44 public void applyVisual() { if (this.isSkinned != this.wasSkinned) { this.wasSkinned = this.isSkinned; if (this.tempSightMaterial != null) { HighlighterTool.rematerialize(this.sightModel, this.tempSightMaterial, out this.tempSightMaterial); } if (this.tempTacticalMaterial != null) { HighlighterTool.rematerialize(this.tacticalModel, this.tempTacticalMaterial, out this.tempTacticalMaterial); } if (this.tempGripMaterial != null) { HighlighterTool.rematerialize(this.gripModel, this.tempGripMaterial, out this.tempGripMaterial); } if (this.tempBarrelMaterial != null) { HighlighterTool.rematerialize(this.barrelModel, this.tempBarrelMaterial, out this.tempBarrelMaterial); } if (this.tempMagazineMaterial != null) { HighlighterTool.rematerialize(this.magazineModel, this.tempMagazineMaterial, out this.tempMagazineMaterial); } } }
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); }
// 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(); }
// 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); }