public override void Update() { if (Application.loadedLevelName == "GAME") { if (!m_isLoaded) { if (GameObject.Find("PLAYER") == null) { return; } if (GameObject.Find("STORE/StoreCashRegister/Register") == null) { return; } m_instance = this; SetupMod(); m_isLoaded = true; } } else if (Application.loadedLevelName != "GAME" && m_isLoaded) { m_isLoaded = false; } }
private void ShowIndexOn(RawImage image, int index) { if (index >= 0 && index < m_files.Count()) { StartCoroutine(Magazines.LoadImage(m_files[index], (d) => { image.texture = d; })); image.color = Color.white; } else image.color = Color.clear; }
internal void Setup(string path) { try { m_magazineDirectory = new FileInfo(path).Directory.Name; Load(); GameHook.InjectStateHook(GameObject.Find("STORE/StoreCashRegister/Register"), "Purchase", OnBuyHook); m_baseFile = path; m_data = SaveUtil.DeserializeReadFile <Magazine>(m_baseFile); GameHook.InjectStateHook(GameObject.Find("ITEMS"), "Save game", Save); ModConsole.Print("Setting up " + m_data.name); m_guiUseBool = PlayMakerGlobals.Instance.Variables.FindFsmBool("GUIuse"); m_guiBuyBool = PlayMakerGlobals.Instance.Variables.FindFsmBool("GUIbuy"); m_guiInteractString = PlayMakerGlobals.Instance.Variables.FindFsmString("GUIinteraction"); m_rigidbody = GetComponent <Rigidbody>(); if (IsBought) { MakeInteractable(); transform.position = new Vector3(m_saveData.posX, m_saveData.posY, m_saveData.posZ); transform.rotation = Quaternion.Euler(m_saveData.rotX, m_saveData.rotY, m_saveData.rotZ); } else { // add this for sale Magazines.Instance.Rack.AddMagazineForSale(this); } m_files = Directory.GetFiles(Path.Combine(Path.GetDirectoryName(path), "Pages")); m_files = m_files.ToList().OrderBy(f => int.Parse(Path.GetFileNameWithoutExtension(f))).ToArray(); StartCoroutine(Magazines.LoadImage(m_files[0], SetCover)); } catch (Exception e) { ModConsole.Error(e.ToString()); } }