From 0dd33e0d691d674bbcf4d24eb26713ac64f52628 Mon Sep 17 00:00:00 2001 From: Spectral Platypus Date: Tue, 18 May 2021 23:17:42 -0400 Subject: [PATCH] Pepperoni: - Fixed dialogue portrait behavior for Noid - Set version to 3.2 - Global code cleanup (styling) PPR Mod: - Fixed exceptions for non-player collisions - Set version to 2.1 --- ExampleMods/BGMute/BGMute.cs | 1 - ExampleMods/BuilderNoid/BuilderNoid.cs | 8 +- .../BuilderNoid/Properties/AssemblyInfo.cs | 1 - ExampleMods/BuilderNoid/ProtoBlock.cs | 140 +++++++++--------- ExampleMods/PPR_Standalone/PPRMod.cs | 11 +- Pepperoni/Console.cs | 6 +- Pepperoni/ModHooks.cs | 2 +- Pepperoni/Patches/DialogueSystem.cs | 5 +- Pepperoni/Patches/PlayerMachine.cs | 4 - 9 files changed, 86 insertions(+), 92 deletions(-) diff --git a/ExampleMods/BGMute/BGMute.cs b/ExampleMods/BGMute/BGMute.cs index c904e30..209bed4 100644 --- a/ExampleMods/BGMute/BGMute.cs +++ b/ExampleMods/BGMute/BGMute.cs @@ -1,6 +1,5 @@ using Pepperoni; using UnityEngine; -using UnityEngine.SceneManagement; namespace BGMute { diff --git a/ExampleMods/BuilderNoid/BuilderNoid.cs b/ExampleMods/BuilderNoid/BuilderNoid.cs index 07e369c..4f30f65 100644 --- a/ExampleMods/BuilderNoid/BuilderNoid.cs +++ b/ExampleMods/BuilderNoid/BuilderNoid.cs @@ -93,24 +93,24 @@ private void OnEarlyUpdate(PlayerMachine playerMachine) if (Kueido.Input.Dab.Pressed) { protoBlock.SetActive(true); - + state = BlockState.Placing; } break; case BlockState.Placing: if (Kueido.Input.Dab.Held) { - Vector3 normal = + Vector3 normal = (playerMachine.currentState.Equals(PlayerStates.Walk)) ? playerMachine.controller.currentGround.PrimaryNormal() : playerMachine.controller.up; protoBlock.transform.position = playerMachine.transform.position + (normal * 2f) + - (playerMachine.lookDirection * 5 * (playerMachine.Camera.zoom2+ 0.3f)); + (playerMachine.lookDirection * 5 * (playerMachine.Camera.zoom2 + 0.3f)); protoBlock.transform.up = normal; } else { // Place block etc - if(protoBlock.GetComponent().IsFree()) + if (protoBlock.GetComponent().IsFree()) { PlaceBlock(protoBlock.transform.position, protoBlock.transform.rotation); } diff --git a/ExampleMods/BuilderNoid/Properties/AssemblyInfo.cs b/ExampleMods/BuilderNoid/Properties/AssemblyInfo.cs index cd33735..0f95c77 100644 --- a/ExampleMods/BuilderNoid/Properties/AssemblyInfo.cs +++ b/ExampleMods/BuilderNoid/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/ExampleMods/BuilderNoid/ProtoBlock.cs b/ExampleMods/BuilderNoid/ProtoBlock.cs index 8e04bbc..4b4b4c7 100644 --- a/ExampleMods/BuilderNoid/ProtoBlock.cs +++ b/ExampleMods/BuilderNoid/ProtoBlock.cs @@ -1,88 +1,84 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; +using UnityEngine; namespace BuilderNoid { - class ProtoBlock : MonoBehaviour - { - MeshRenderer meshRenderer; - MeshFilter meshFilter; - BoxCollider collider; - const float box_extent = 0.75f; - LayerMask Walkable = new LayerMask(); - void Start() - { - meshRenderer = gameObject.AddComponent(); - meshFilter = gameObject.AddComponent(); - collider = gameObject.AddComponent(); - gameObject.layer = 0; - Walkable.value = 425984; - CreateCube(); - } + class ProtoBlock : MonoBehaviour + { + MeshRenderer meshRenderer; + MeshFilter meshFilter; + BoxCollider collider; + const float box_extent = 0.75f; + LayerMask Walkable = new LayerMask(); + void Start() + { + meshRenderer = gameObject.AddComponent(); + meshFilter = gameObject.AddComponent(); + collider = gameObject.AddComponent(); + gameObject.layer = 0; + Walkable.value = 425984; + CreateCube(); + } - private void CreateCube() - { - Vector3[] vertices = { - new Vector3 (-box_extent, -box_extent, -box_extent), - new Vector3 (box_extent, -box_extent, -box_extent), - new Vector3 (box_extent, box_extent, -box_extent), - new Vector3 (-box_extent, box_extent, -box_extent), - new Vector3 (-box_extent, box_extent, box_extent), - new Vector3 (box_extent, box_extent, box_extent), - new Vector3 (box_extent, -box_extent, box_extent), - new Vector3 (-box_extent, -box_extent, box_extent), - }; + private void CreateCube() + { + Vector3[] vertices = { + new Vector3 (-box_extent, -box_extent, -box_extent), + new Vector3 (box_extent, -box_extent, -box_extent), + new Vector3 (box_extent, box_extent, -box_extent), + new Vector3 (-box_extent, box_extent, -box_extent), + new Vector3 (-box_extent, box_extent, box_extent), + new Vector3 (box_extent, box_extent, box_extent), + new Vector3 (box_extent, -box_extent, box_extent), + new Vector3 (-box_extent, -box_extent, box_extent), + }; - int[] triangles = { - 0, 2, 1, //face front + int[] triangles = { + 0, 2, 1, //face front 0, 3, 2, - 2, 3, 4, //face top + 2, 3, 4, //face top 2, 4, 5, - 1, 2, 5, //face right + 1, 2, 5, //face right 1, 5, 6, - 0, 7, 4, //face left + 0, 7, 4, //face left 0, 4, 3, - 5, 4, 7, //face back + 5, 4, 7, //face back 5, 7, 6, - 0, 6, 7, //face bottom + 0, 6, 7, //face bottom 0, 1, 6 - }; + }; - Mesh mesh = meshFilter.mesh; - mesh.Clear(); - mesh.vertices = vertices; - mesh.triangles = triangles; - mesh.RecalculateBounds(); - mesh.RecalculateNormals(); + Mesh mesh = meshFilter.mesh; + mesh.Clear(); + mesh.vertices = vertices; + mesh.triangles = triangles; + mesh.RecalculateBounds(); + mesh.RecalculateNormals(); - Shader s = Shader.Find("psx/vertexlit"); - if (s != null) - { - meshRenderer.material = new Material(s); - var c = Color.red; - c.a = 0.5f; - //meshRenderer.material.SetTexture("_MainTex", BuilderNoid.blockTexture); - } + Shader s = Shader.Find("psx/vertexlit"); + if (s != null) + { + meshRenderer.material = new Material(s); + var c = Color.red; + c.a = 0.5f; + //meshRenderer.material.SetTexture("_MainTex", BuilderNoid.blockTexture); + } - collider.center = mesh.bounds.center; - collider.size = mesh.bounds.size; - collider.enabled = true; - } - private void Update() - { - if(Physics.CheckBox(meshRenderer.bounds.center, new Vector3(box_extent, box_extent, box_extent), gameObject.transform.rotation, Walkable)) - { - meshRenderer.material.color = Color.red; - } - else - { - meshRenderer.material.color = Color.green; - } - } + collider.center = mesh.bounds.center; + collider.size = mesh.bounds.size; + collider.enabled = true; + } + private void Update() + { + if (Physics.CheckBox(meshRenderer.bounds.center, new Vector3(box_extent, box_extent, box_extent), gameObject.transform.rotation, Walkable)) + { + meshRenderer.material.color = Color.red; + } + else + { + meshRenderer.material.color = Color.green; + } + } - public bool IsFree() => meshRenderer.material.color == Color.green; - } + public bool IsFree() => meshRenderer.material.color == Color.green; + } } \ No newline at end of file diff --git a/ExampleMods/PPR_Standalone/PPRMod.cs b/ExampleMods/PPR_Standalone/PPRMod.cs index 8caf11e..da941cc 100644 --- a/ExampleMods/PPR_Standalone/PPRMod.cs +++ b/ExampleMods/PPR_Standalone/PPRMod.cs @@ -11,7 +11,7 @@ namespace PPR_Standalone { public class PPRMod : Mod { - public PPRMod() : base("PPR", "2.1") + public PPRMod() : base("PPR", "2.2") { } @@ -92,11 +92,16 @@ public void OnPepObtain(int pepCount, Collider other) if (pepCount > 0 && other != null) { PlayerMachine p = other.GetComponent(); - if (!p.voided && !PlayerMachine.CurrentCostume.Equals(Costumes.Miku)) + + if (p && !p.voided && !PlayerMachine.CurrentCostume.Equals(Costumes.Miku)) { int costumeIndex = Convert.ToInt32(Math.Truncate(UnityEngine.Random.Range(0f, 3.99f))); p.SetCostume((Costumes)costumeIndex); - Manager.Dialogue.UpdateCostumePortrait(); + + if ((Costumes)costumeIndex != Costumes.Default) + { + Manager.Dialogue.UpdateCostumePortrait(); + } if (UnityEngine.Random.value <= zapPercent) { diff --git a/Pepperoni/Console.cs b/Pepperoni/Console.cs index ad63d7a..555737b 100644 --- a/Pepperoni/Console.cs +++ b/Pepperoni/Console.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Runtime.InteropServices; +using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; diff --git a/Pepperoni/ModHooks.cs b/Pepperoni/ModHooks.cs index 3fc185b..36304fe 100644 --- a/Pepperoni/ModHooks.cs +++ b/Pepperoni/ModHooks.cs @@ -37,7 +37,7 @@ public class ModHooks /// /// Mod API Version Minor Number /// - private const int _modVersionMinor = 0; + private const int _modVersionMinor = 2; /// /// Mod API Version string in "vX.Y" format diff --git a/Pepperoni/Patches/DialogueSystem.cs b/Pepperoni/Patches/DialogueSystem.cs index 6e1f368..6cd112f 100644 --- a/Pepperoni/Patches/DialogueSystem.cs +++ b/Pepperoni/Patches/DialogueSystem.cs @@ -12,11 +12,14 @@ class DialogueSystem : global::DialogueSystem private extern void orig_Start(); private void Start() { - noidPortraits = new portrait[4]; + noidPortraits = new portrait[5]; for (int k = 0; k < 4; k++) { noidPortraits[k] = Portraits[k]; } + // eye blink? + noidPortraits[4] = Portraits[7]; + orig_Start(); } private extern void orig_ParseScriptFile(string Text); diff --git a/Pepperoni/Patches/PlayerMachine.cs b/Pepperoni/Patches/PlayerMachine.cs index 3992c57..eaf82d3 100644 --- a/Pepperoni/Patches/PlayerMachine.cs +++ b/Pepperoni/Patches/PlayerMachine.cs @@ -1,9 +1,5 @@ using MonoMod; -using System; using System.Collections; -using System.IO; -using System.Reflection; -using System.Runtime.InteropServices; using UnityEngine; #pragma warning disable CS0108, CS0626, CS0114, CS0169, CS0649