using GadgetCore.API; using System.Collections; using UnityEngine; namespace Subworlds.Scripts { public class OldChestScript : MonoBehaviour { private bool opened = false; private void Awake() { base.name = "chest"; } private void Start() { } [RPC] private void Open() { if (!this.opened) { this.opened = true; base.GetComponent().RPC("OpenMat", RPCMode.AllBuffered, new object[0]); this.DropItems(); } } private void DropItems() { base.GetComponent().RPC("DropLocal", RPCMode.All, new object[0]); } [RPC] private void DropLocal() { if (Menuu.curAugment == 12) StartCoroutine(DropLocalLoot()); StartCoroutine(DropLocalLoot()); } private IEnumerator DropLocalLoot() { yield return new WaitForSeconds(0.2f); var item = GadgetCoreAPI.EmptyItem(); item.id = Core.itemOldTex.GetID(); GadgetCoreAPI.DropItemLocal(gameObject.transform.position, item); yield return new WaitForSeconds(0.2f); GadgetCoreAPI.SpawnExp(gameObject.transform.position, 25); yield return new WaitForSeconds(0.2f); GadgetCoreAPI.SpawnExp(gameObject.transform.position, 10); yield return new WaitForSeconds(0.2f); GadgetCoreAPI.SpawnExp(gameObject.transform.position, 20); yield break; } private static Texture2D textureOldChestOpen = GadgetCoreAPI.LoadTexture2D("oldChestOpen.png"); [RPC] private void OpenMat() { Menuu.characterStat[8]++; GameScript.cadetValue += 2; base.GetComponent().PlayOneShot((AudioClip)Resources.Load("Au/chest"), Menuu.soundLevel / 10f); base.GetComponent().enabled = false; Renderer renderer = gameObject.transform.GetChild(0).gameObject.GetComponentInChildren(); renderer.material = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = textureOldChestOpen }; } } }