public static Material paint(ushort shirt, ushort pants, bool isMega) { Texture2D texture2D = Object.Instantiate <Texture2D>((!isMega) ? ZombieClothing.zombieTexture : ZombieClothing.megaTexture); texture2D.name = string.Concat(new object[] { "Zombie_", (!isMega) ? "Normal" : "Mega", "_", shirt, "_", pants }); texture2D.hideFlags = 61; if (shirt != 0) { ItemShirtAsset itemShirtAsset = (ItemShirtAsset)Assets.find(EAssetType.ITEM, shirt); if (itemShirtAsset != null) { for (int i = 0; i < itemShirtAsset.shirt.width; i++) { for (int j = 0; j < itemShirtAsset.shirt.height; j++) { if (itemShirtAsset.shirt.GetPixel(i, j).a > 0f) { texture2D.SetPixel(i, j, itemShirtAsset.shirt.GetPixel(i, j)); } } } } } if (pants != 0) { ItemPantsAsset itemPantsAsset = (ItemPantsAsset)Assets.find(EAssetType.ITEM, pants); if (itemPantsAsset != null) { for (int k = 0; k < itemPantsAsset.pants.width; k++) { for (int l = 0; l < itemPantsAsset.pants.height; l++) { if (itemPantsAsset.pants.GetPixel(k, l).a > 0f) { texture2D.SetPixel(k, l, itemPantsAsset.pants.GetPixel(k, l)); } } } } } texture2D.Apply(); Material material = new Material(ZombieClothing.shader); material.name = string.Concat(new object[] { "Zombie_", (!isMega) ? "Normal" : "Mega", "_", shirt, "_", pants }); material.hideFlags = 61; material.mainTexture = texture2D; material.SetFloat("_Glossiness", 0f); return(material); }
public void apply() { if (Dedicator.isDedicated) { return; } ItemShirtAsset itemShirtAsset = (this.visualShirtAsset == null || !this.isVisual) ? this.shirtAsset : this.visualShirtAsset; ItemPantsAsset itemPantsAsset = (this.visualPantsAsset == null || !this.isVisual) ? this.pantsAsset : this.visualPantsAsset; if (this.needsClothesUpdate || this.needsShirtUpdate || this.needsPantsUpdate) { this.clothing.shirt = null; this.clothing.shirtEmission = null; this.clothing.shirtMetallic = null; this.clothing.flipShirt = false; if (itemShirtAsset != null) { this.clothing.shirt = itemShirtAsset.shirt; this.clothing.shirtEmission = itemShirtAsset.emission; this.clothing.shirtMetallic = itemShirtAsset.metallic; this.clothing.flipShirt = (this.hand && itemShirtAsset.ignoreHand); } this.clothing.pants = null; this.clothing.pantsEmission = null; this.clothing.pantsMetallic = null; if (itemPantsAsset != null) { this.clothing.pants = itemPantsAsset.pants; this.clothing.pantsEmission = itemPantsAsset.emission; this.clothing.pantsMetallic = itemPantsAsset.metallic; } this.clothing.apply(); if (this.materialClothing != null) { this.materialClothing.mainTexture = this.clothing.texture; this.materialClothing.SetTexture("_EmissionMap", this.clothing.emission); this.materialClothing.SetTexture("_MetallicGlossMap", this.clothing.metallic); } } if (!this.isMine) { if (this.needsShirtUpdate) { if (this.isUpper && this.upperSystems != null) { for (int i = 0; i < this.upperSystems.Length; i++) { Transform transform = this.upperSystems[i]; if (transform != null) { Object.Destroy(transform.gameObject); } } this.isUpper = false; } if (this.isVisual && this.isMythic && this.visualShirt != 0) { ushort inventoryMythicID = Provider.provider.economyService.getInventoryMythicID(this.visualShirt); if (inventoryMythicID != 0) { ItemTool.applyEffect(this.upperBones, this.upperSystems, inventoryMythicID, EEffectType.AREA); this.isUpper = true; } } } if (this.needsPantsUpdate) { if (this.isLower && this.lowerSystems != null) { for (int j = 0; j < this.lowerSystems.Length; j++) { Transform transform2 = this.lowerSystems[j]; if (transform2 != null) { Object.Destroy(transform2.gameObject); } } this.isLower = false; } if (this.isVisual && this.isMythic && this.visualPants != 0) { ushort inventoryMythicID2 = Provider.provider.economyService.getInventoryMythicID(this.visualPants); if (inventoryMythicID2 != 0) { ItemTool.applyEffect(this.lowerBones, this.lowerSystems, inventoryMythicID2, EEffectType.AREA); this.isLower = true; } } } ItemHatAsset itemHatAsset = (this.visualHatAsset == null || !this.isVisual) ? this.hatAsset : this.visualHatAsset; ItemBackpackAsset itemBackpackAsset = (this.visualBackpackAsset == null || !this.isVisual) ? this.backpackAsset : this.visualBackpackAsset; ItemVestAsset itemVestAsset = (this.visualVestAsset == null || !this.isVisual) ? this.vestAsset : this.visualVestAsset; ItemMaskAsset itemMaskAsset = (this.visualMaskAsset == null || !this.isVisual) ? this.maskAsset : this.visualMaskAsset; ItemGlassesAsset itemGlassesAsset = (this.visualGlassesAsset == null || !this.isVisual || (this.glassesAsset != null && (this.glassesAsset.vision != ELightingVision.NONE || this.glassesAsset.isBlindfold))) ? this.glassesAsset : this.visualGlassesAsset; bool flag = true; bool flag2 = true; if (this.needsHatUpdate) { if (this.hatModel != null) { Object.Destroy(this.hatModel.gameObject); } if (itemHatAsset != null && itemHatAsset.hat != null) { this.hatModel = Object.Instantiate <GameObject>(itemHatAsset.hat).transform; this.hatModel.name = "Hat"; this.hatModel.transform.parent = this.skull; this.hatModel.transform.localPosition = Vector3.zero; this.hatModel.transform.localRotation = Quaternion.identity; this.hatModel.transform.localScale = Vector3.one; if (!this.isView) { Object.Destroy(this.hatModel.GetComponent <Collider>()); } if (this.isVisual && this.isMythic && this.visualHat != 0) { ushort inventoryMythicID3 = Provider.provider.economyService.getInventoryMythicID(this.visualHat); if (inventoryMythicID3 != 0) { ItemTool.applyEffect(this.hatModel, inventoryMythicID3, EEffectType.HOOK); } } } } if (itemHatAsset != null && itemHatAsset.hat != null) { if (!itemHatAsset.hasHair) { flag = false; } if (!itemHatAsset.hasBeard) { flag2 = false; } } if (this.needsBackpackUpdate) { if (this.backpackModel != null) { Object.Destroy(this.backpackModel.gameObject); } if (itemBackpackAsset != null && itemBackpackAsset.backpack != null) { this.backpackModel = Object.Instantiate <GameObject>(itemBackpackAsset.backpack).transform; this.backpackModel.name = "Backpack"; this.backpackModel.transform.parent = this.spine; this.backpackModel.transform.localPosition = Vector3.zero; this.backpackModel.transform.localRotation = Quaternion.identity; this.backpackModel.transform.localScale = Vector3.one; if (!this.isView) { Object.Destroy(this.backpackModel.GetComponent <Collider>()); } if (this.isVisual && this.isMythic && this.visualBackpack != 0) { ushort inventoryMythicID4 = Provider.provider.economyService.getInventoryMythicID(this.visualBackpack); if (inventoryMythicID4 != 0) { ItemTool.applyEffect(this.backpackModel, inventoryMythicID4, EEffectType.HOOK); } } this.backpackModel.gameObject.SetActive(this.hasBackpack); } } if (this.needsVestUpdate) { if (this.vestModel != null) { Object.Destroy(this.vestModel.gameObject); } if (itemVestAsset != null && itemVestAsset.vest != null) { this.vestModel = Object.Instantiate <GameObject>(itemVestAsset.vest).transform; this.vestModel.name = "Vest"; this.vestModel.transform.parent = this.spine; this.vestModel.transform.localPosition = Vector3.zero; this.vestModel.transform.localRotation = Quaternion.identity; this.vestModel.transform.localScale = Vector3.one; if (!this.isView) { Object.Destroy(this.vestModel.GetComponent <Collider>()); } if (this.isVisual && this.isMythic && this.visualVest != 0) { ushort inventoryMythicID5 = Provider.provider.economyService.getInventoryMythicID(this.visualVest); if (inventoryMythicID5 != 0) { ItemTool.applyEffect(this.vestModel, inventoryMythicID5, EEffectType.HOOK); } } } } if (this.needsMaskUpdate) { if (this.maskModel != null) { Object.Destroy(this.maskModel.gameObject); } if (itemMaskAsset != null && itemMaskAsset.mask != null) { this.maskModel = Object.Instantiate <GameObject>(itemMaskAsset.mask).transform; this.maskModel.name = "Mask"; this.maskModel.transform.parent = this.skull; this.maskModel.transform.localPosition = Vector3.zero; this.maskModel.transform.localRotation = Quaternion.identity; this.maskModel.transform.localScale = Vector3.one; if (!this.isView) { Object.Destroy(this.maskModel.GetComponent <Collider>()); } if (this.isVisual && this.isMythic && this.visualMask != 0) { ushort inventoryMythicID6 = Provider.provider.economyService.getInventoryMythicID(this.visualMask); if (inventoryMythicID6 != 0) { ItemTool.applyEffect(this.maskModel, inventoryMythicID6, EEffectType.HOOK); } } } } if (itemMaskAsset != null && itemMaskAsset.mask != null) { if (!itemMaskAsset.hasHair) { flag = false; } if (!itemMaskAsset.hasBeard) { flag2 = false; } } if (this.needsGlassesUpdate) { if (this.glassesModel != null) { Object.Destroy(this.glassesModel.gameObject); } if (itemGlassesAsset != null && itemGlassesAsset.glasses != null) { this.glassesModel = Object.Instantiate <GameObject>(itemGlassesAsset.glasses).transform; this.glassesModel.name = "Glasses"; this.glassesModel.transform.parent = this.skull; this.glassesModel.transform.localPosition = Vector3.zero; this.glassesModel.transform.localRotation = Quaternion.identity; this.glassesModel.localScale = Vector3.one; if (!this.isView) { Object.Destroy(this.glassesModel.GetComponent <Collider>()); } if (this.isVisual && this.isMythic && this.visualGlasses != 0) { ushort inventoryMythicID7 = Provider.provider.economyService.getInventoryMythicID(this.visualGlasses); if (inventoryMythicID7 != 0) { ItemTool.applyEffect(this.glassesModel, inventoryMythicID7, EEffectType.HOOK); } } } } if (itemGlassesAsset != null && itemGlassesAsset.glasses != null) { if (!itemGlassesAsset.hasHair) { flag = false; } if (!itemGlassesAsset.hasBeard) { flag2 = false; } } if (this.materialHair != null) { this.materialHair.color = this.color; } if (this.hasHair != flag) { this.hasHair = flag; this.needsHairUpdate = true; } if (this.needsHairUpdate) { if (this.hairModel != null) { Object.Destroy(this.hairModel.gameObject); } if (this.hasHair) { Object @object = Resources.Load("Hairs/" + this.hair + "/Hair"); if (@object != null) { this.hairModel = ((GameObject)Object.Instantiate(@object)).transform; this.hairModel.name = "Hair"; this.hairModel.transform.parent = this.skull; this.hairModel.transform.localPosition = Vector3.zero; this.hairModel.transform.localRotation = Quaternion.identity; this.hairModel.transform.localScale = Vector3.one; if (this.hairModel.FindChild("Model_0") != null) { this.hairModel.FindChild("Model_0").GetComponent <Renderer>().sharedMaterial = this.materialHair; } } } } if (this.hasBeard != flag2) { this.hasBeard = flag2; this.needsBeardUpdate = true; } if (this.needsBeardUpdate) { if (this.beardModel != null) { Object.Destroy(this.beardModel.gameObject); } if (this.hasBeard) { Object object2 = Resources.Load("Beards/" + this.beard + "/Beard"); if (object2 != null) { this.beardModel = ((GameObject)Object.Instantiate(object2)).transform; this.beardModel.name = "Beard"; this.beardModel.transform.parent = this.skull; this.beardModel.transform.localPosition = Vector3.zero; this.beardModel.transform.localRotation = Quaternion.identity; this.beardModel.localScale = Vector3.one; if (this.beardModel.FindChild("Model_0") != null) { this.beardModel.FindChild("Model_0").GetComponent <Renderer>().sharedMaterial = this.materialHair; } } } } } this.updateAll(false); }