Skip to content

Commit

Permalink
Pepperoni:
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
SpectralPlatypus committed May 19, 2021
1 parent 667a93b commit 0dd33e0
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 92 deletions.
1 change: 0 additions & 1 deletion ExampleMods/BGMute/BGMute.cs
@@ -1,6 +1,5 @@
using Pepperoni;
using UnityEngine;
using UnityEngine.SceneManagement;

namespace BGMute
{
Expand Down
8 changes: 4 additions & 4 deletions ExampleMods/BuilderNoid/BuilderNoid.cs
Expand Up @@ -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<ProtoBlock>().IsFree())
if (protoBlock.GetComponent<ProtoBlock>().IsFree())
{
PlaceBlock(protoBlock.transform.position, protoBlock.transform.rotation);
}
Expand Down
1 change: 0 additions & 1 deletion 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
Expand Down
140 changes: 68 additions & 72 deletions 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<MeshRenderer>();
meshFilter = gameObject.AddComponent<MeshFilter>();
collider = gameObject.AddComponent<BoxCollider>();
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<MeshRenderer>();
meshFilter = gameObject.AddComponent<MeshFilter>();
collider = gameObject.AddComponent<BoxCollider>();
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;
}
}
11 changes: 8 additions & 3 deletions ExampleMods/PPR_Standalone/PPRMod.cs
Expand Up @@ -11,7 +11,7 @@ namespace PPR_Standalone
{
public class PPRMod : Mod
{
public PPRMod() : base("PPR", "2.1")
public PPRMod() : base("PPR", "2.2")
{
}

Expand Down Expand Up @@ -92,11 +92,16 @@ public void OnPepObtain(int pepCount, Collider other)
if (pepCount > 0 && other != null)
{
PlayerMachine p = other.GetComponent<PlayerMachine>();
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)
{
Expand Down
6 changes: 1 addition & 5 deletions 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;

Expand Down
2 changes: 1 addition & 1 deletion Pepperoni/ModHooks.cs
Expand Up @@ -37,7 +37,7 @@ public class ModHooks
/// <summary>
/// Mod API Version Minor Number
/// </summary>
private const int _modVersionMinor = 0;
private const int _modVersionMinor = 2;

/// <summary>
/// Mod API Version string in "vX.Y" format
Expand Down
5 changes: 4 additions & 1 deletion Pepperoni/Patches/DialogueSystem.cs
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions 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
Expand Down

0 comments on commit 0dd33e0

Please sign in to comment.