internal string OnParseScript(string text) { Logger.LogFine($"[API] - OnParseScript invoked"); if (_OnParseScriptHook == null) { return(text); } string retVal = text; Delegate[] invocationList = _OnParseScriptHook.GetInvocationList(); foreach (ParseScriptProxy i in invocationList) { try { retVal = i.Invoke(retVal); } catch (Exception ex) { Logger.LogError("[API] - " + ex); } } return(retVal); }
internal void OnPlayerSetCostume(SkinnedMeshRenderer skinnedMeshRenderer) { Logger.LogFine($"[API] - OnPlayerSetCostume invoked"); if (_OnPlayerSetCostumeHook == null) { return; } Delegate[] invocationList = _OnPlayerSetCostumeHook.GetInvocationList(); foreach (PlayerSetCostumeCallback i in invocationList) { try { i.Invoke(skinnedMeshRenderer); } catch (Exception ex) { Logger.LogError("[API] - " + ex); } } }
/// <summary> /// Invoked once the player object state is marked as loaded /// </summary> internal void OnPlayerUnLoad() { Logger.LogFine($"[API] - OnPlayerUnLoad invoked"); if (_PlayerUnLoaded == null) { return; } Delegate[] invocationList = _PlayerUnLoaded.GetInvocationList(); foreach (PlayerUnLoadedCallback i in invocationList) { try { i.Invoke(); } catch (Exception ex) { Logger.LogError("[API] - " + ex); } } }
internal void OnSaveGameAfterSave() { Logger.LogFine($"[API] - OnSaveGameAfterSave invoked"); if (_OnPostSaveGameHook == null) { return; } Delegate[] invocationList = _OnPostSaveGameHook.GetInvocationList(); foreach (SaveGameAfterSaveCallback i in invocationList) { try { i.Invoke(); } catch (Exception ex) { Logger.LogError("[API] - " + ex); } } }
public void Update() { if (Input.GetKeyDown(KeyCode.F11)) { _visible = !_visible; var cg = OverlayCanvas.GetComponent <CanvasGroup>(); StartCoroutine(_visible ? CanvasUtil.FadeInCanvasGroup(cg) : CanvasUtil.FadeOutCanvasGroup(cg)); } textComp.text = ""; if (!_enabled || !_visible || PlayerMachine == null) { return; } if (Input.GetKeyDown(KeyCode.F1) || Input.GetKeyDown(KeyCode.Keypad1)) { bool?a = PlayerMachine.CoyoteFrameEnabled; PlayerMachine.CoyoteFrameEnabled = a.HasValue ? (a.Value ? false : new bool?()) : true; } if (Input.GetKeyDown(KeyCode.LeftBracket)) { if (--currentCostIdx < 0) { currentCostIdx = costumeNames.Length - 1; } } else if (Input.GetKeyDown(KeyCode.RightBracket)) { currentCostIdx = (currentCostIdx + 1) % (costumeNames.Length); } else if (Input.GetKeyDown(KeyCode.F2) || Input.GetKeyDown(KeyCode.Keypad2)) { PlayerMachine.SetCostume((Costumes)currentCostIdx); GameObject.FindGameObjectWithTag("Manager").GetComponent <DialogueSystem>().UpdateCostumePortrait(); } if (dialogueCache.Count > 0) { if (Input.GetKeyDown(KeyCode.Comma)) { if (--currentNpcIdx < 0) { currentNpcIdx = dialogueCache.Count - 1; } } else if (Input.GetKeyDown(KeyCode.Period)) { currentNpcIdx = (currentNpcIdx + 1) % dialogueCache.Count; } else if (Input.GetKeyDown(KeyCode.F3)) { GameObject.FindGameObjectWithTag("Manager").GetComponent <DialogueSystem>().Begin(dialogueCache[currentNpcIdx].TextAsset, null); } } if (Input.GetKeyDown(KeyCode.F4) || Input.GetKeyDown(KeyCode.Keypad4)) { if (Time.timeScale > 0) { float timeScale = Time.timeScale / 2; if (timeScale < 0.25f) { timeScale = 2.0f; } Time.timeScale = timeScale; } } if ((Input.GetKeyDown(KeyCode.F5) || Input.GetKeyDown(KeyCode.Keypad5) || Input.GetMouseButtonDown(4)) && !PlayerMachine.currentState.Equals(PlayerStates.Loading)) { PlayerMachine.EndScene(); } if (Input.GetKeyDown(KeyCode.F6) || Input.GetKeyDown(KeyCode.Keypad6)) { ++QualitySettings.vSyncCount; QualitySettings.vSyncCount %= 3; } bool inVoid = SceneManager.GetActiveScene().name == "void"; if ((Input.GetKeyDown(KeyCode.F7) || Input.GetKeyDown(KeyCode.Keypad7)) && !PlayerMachine.currentState.Equals(PlayerStates.Loading)) { var pizza = FindObjectOfType <PizzaBox>(); if (pizza == null) { Logger.LogError("No PizzaBox!"); } else { string level = (!inVoid) ? "void" : levelNames[currentLvlIdx]; deathPlaneStatus = true; GameObject.Find("Global Manager").GetComponent <Manager>().LoadScene(level, pizza.ExitId, pizza.gameObject); } } else if (inVoid && Input.GetKeyDown(KeyCode.L)) { do { currentLvlIdx = (currentLvlIdx + 1) % levelNames.Length; } while (levelNames[currentLvlIdx] == SceneManager.GetActiveScene().name); } if (!inVoid && Input.GetKeyDown(KeyCode.K)) { var key = FindObjectsOfType <Key>(); foreach (var k in key) { if (!k.pickedUp) { k.transform.position = PlayerMachine.gameObject.transform.position; } } } if (Input.GetKeyDown(KeyCode.G)) { talkVolumeRenderFlag = !talkVolumeRenderFlag; if (talkVolumeRenderFlag) { tvRadiusCache.UpdateCache(TalkVolumeCreator, talkVolumeRenderFlag); } else { tvRadiusCache.ToggleAllObjects(talkVolumeRenderFlag); } } if (Input.GetKeyDown(KeyCode.T) && !PlayerMachine.currentState.Equals(PlayerStates.Loading)) { SetupNoClip(!NoClipActive); } if (Input.GetKeyDown(KeyCode.M)) { var deathPlanes = FindObjectsOfType <VoidOut>(); deathPlaneStatus = !deathPlaneStatus; foreach (var d in deathPlanes) { d.setActive(deathPlaneStatus); } } else if (Input.GetKeyDown(KeyCode.V)) { collisionRenderFlag = !collisionRenderFlag; if (collisionRenderFlag) { collPlaneCache.UpdateCache(VoidOutCreator, collisionRenderFlag); } else { collPlaneCache.ToggleAllObjects(collisionRenderFlag); } } if ((Input.GetMouseButtonDown(3) || Input.GetKeyDown(KeyCode.R)) && (PlayerMachine.currentState.Equals(PlayerStates.Jump) || PlayerMachine.currentState.Equals(PlayerStates.Loading)) && warpCam.enabled) { MoveWarpCam(); yaw = warpCam.transform.eulerAngles.y; pitch = warpCam.transform.eulerAngles.x; } else if (Input.GetMouseButton(2)) { yaw += Input.GetAxis("Mouse X") * 2f; pitch -= Input.GetAxis("Mouse Y") * 2f; warpCam.transform.eulerAngles = new Vector3(pitch, yaw, 0f); } else if (Input.GetKeyDown(KeyCode.B)) { warpCam.enabled = !warpCam.enabled; } if (Input.GetKeyDown(KeyCode.N) && modTextures.ContainsKey("glass")) { if (Physics.Raycast( PlayerMachine.transform.position + PlayerMachine.controller.up * PlayerMachine.controller.height * 0.85f, PlayerMachine.lookDirection, out RaycastHit objHit)) { Logger.LogFine($"Hit an object: {objHit.collider.gameObject.name}"); var renderer = objHit.collider.gameObject.GetComponent <Renderer>(); var shader = Shader.Find("psx/trasparent/vertexlit"); if (renderer && shader) { for (int i = 0; i < renderer.materials.Length; ++i) { var matl = renderer.materials[i]; matl.shader = shader; matl.SetTexture("_MainTex", modTextures["glass"]); matl.SetColor("_Color", Color.blue); renderer.materials[i] = matl; } GameObject go = new GameObject(); Vector3 start = PlayerMachine.transform.position + PlayerMachine.controller.up * PlayerMachine.controller.height * 0.85f; go.transform.position = start; var lineRenderer = go.AddComponent <LineRenderer>(); lineRenderer.material = new Material(Shader.Find("Standard")); lineRenderer.material.SetColor("_Color", Color.red); lineRenderer.startColor = Color.red; lineRenderer.endColor = Color.red; lineRenderer.startWidth = 0.1f; lineRenderer.SetPosition(0, start); lineRenderer.SetPosition(1, objHit.point); Destroy(go, 0.3f); } } } if (Input.GetKeyDown(KeyCode.F8) || Input.GetKeyDown(KeyCode.Keypad8)) { CamEventReset = !CamEventReset; } deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f; bool?b = PlayerMachine.CoyoteFrameEnabled; textBuilder.Length = 0; textBuilder.AppendFormat("FPS: {0:F3}\n", 1f / deltaTime); textBuilder.AppendFormat("<F1>: Coyote Frames: {0}\n", b.HasValue ? OnOffStr(b.Value) : "Default"); textBuilder.Append("<F2><[]>: Set Costume: ").AppendLine(costumeNames[currentCostIdx]); if (dialogueCache.Count > 0) { textBuilder.AppendFormat("<F3><,.>: Dialogue: ").AppendLine(dialogueCache[currentNpcIdx].NpcName); } textBuilder.Append("<F4>: Time Scale: x").AppendLine(Time.timeScale.ToString("F2")); textBuilder.Append("<F5>: Text Storage/Warp\n"); textBuilder.AppendFormat("<F6>: VSync Count :{0}\n", QualitySettings.vSyncCount); textBuilder.AppendFormat("<F7><L>: Level Load: {0}\n", !inVoid ? "void" : levelNames[currentLvlIdx]); if (camEventsFound) { textBuilder.AppendFormat("<F8>: Repeat Cam Events: {0}\n", OnOffStr(CamEventReset)); } textBuilder.Append("<V>: Render Death Planes: ").AppendLine(OnOffStr(collisionRenderFlag)); textBuilder.Append("<M>: Active Death Planes: ").AppendLine(OnOffStr(deathPlaneStatus)); textBuilder.Append("<G>: Show NPC Talk Zone: ").AppendLine(OnOffStr(talkVolumeRenderFlag)); textBuilder.Append("<K>: Get All Keys\n"); textBuilder.Append("<R><noparse><B></noparse>: Warp Cam Move/Toggle\n"); textBuilder.Append("<N>: Set Obj Transparent\n"); textBuilder.Append("<T>: NoClip: ").AppendLine(OnOffStr(NoClipActive)); textBuilder.Append("<F11> Toggle UI\n").AppendLine(); textBuilder.Append("Move Dir:").AppendLine(PlayerMachine.moveDirection.ToString()); textBuilder.Append("Pos:").AppendLine(PlayerMachine.transform.position.ToString()); textBuilder.Append("SpawnPos:").AppendLine(PlayerMachine.LastGroundLoc.ToString()); textBuilder.Append("Look Dir:").AppendLine(PlayerMachine.lookDirection.ToString()); textBuilder.Append("Player State:").AppendLine(PlayerMachine.currentState.ToString()); if (bossController) { textBuilder.AppendLine(); textBuilder.Append("Boss Health: ").AppendLine(bossController.Health.ToString()); textBuilder.Append("Boss State: ").AppendLine(bossStates[(int)BossController.State]); } if (warpCam.enabled) { textBuilder.AppendLine(); textBuilder.Append("LGP:").AppendLine(PlayerMachine.controller.LastGroundPos.ToString()); textBuilder.Append("LGO:").AppendLine(PlayerMachine.controller.LastGroundOffset.ToString()); textBuilder.Append("LGR:").AppendLine(PlayerMachine.controller.LastGroundRot.ToString()); textBuilder.Append("CG:").AppendLine(PlayerMachine.controller.currentGround.transform.position.ToString()); textBuilder.Append("CR:").AppendLine(PlayerMachine.controller.currentGround.transform.rotation.ToString()); textBuilder.Append("Warp Pos:").AppendLine(warpSimPos.ToString()); } // Set text causes visual glitches textComp.text += textBuilder.ToString(); }