Skip to content

Commit a53b6b4

Browse files
committed
add trigger visibility toggle
1 parent 7d8d3c0 commit a53b6b4

File tree

5 files changed

+97
-1
lines changed

5 files changed

+97
-1
lines changed

Main.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@
55
using System.Threading.Tasks;
66
using MelonLoader;
77
using UnityEngine;
8-
[assembly: MelonInfo(typeof(SuperliminalPracticeMod.Main), "Superliminal Practice Mod", "0.2.1", "Micrologist#2351")]
8+
using Harmony;
9+
10+
[assembly: MelonInfo(typeof(SuperliminalPracticeMod.Main), "Superliminal Practice Mod", "0.3.0", "Micrologist#2351")]
911
[assembly: MelonGame("PillowCastle", "Superliminal")]
1012
[assembly: MelonGame("PillowCastle", "SuperliminalSteam")]
1113

1214
namespace SuperliminalPracticeMod
1315
{
1416
public class Main : MelonMod
1517
{
18+
19+
public override void OnApplicationStart()
20+
{
21+
MelonLogger.Log("Trying to patch");
22+
SLPMod_Patcher.Patch();
23+
}
1624
public override void OnLevelWasLoaded(int level)
1725
{
1826
if(GameManager.GM != null && GameManager.GM.gameObject.GetComponent<PracticeModManager>() == null)

PracticeModManager.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class PracticeModManager : MonoBehaviour
3333
float teleportTime;
3434
bool unlimitedRenderDistance;
3535
bool debugFunctions;
36+
bool triggersVisible;
37+
List<GameObject> triggerGameObjects;
3638

3739

3840
void Awake()
@@ -53,6 +55,31 @@ void Awake()
5355
base.gameObject.AddComponent<SLPMod_Console>();
5456
}
5557

58+
private void OnLevelWasLoaded(int level)
59+
{
60+
triggerGameObjects = new List<GameObject>();
61+
triggersVisible = false;
62+
}
63+
64+
public void AddTriggerGO(GameObject go)
65+
{
66+
triggerGameObjects.Add(go);
67+
}
68+
69+
public void ToggleTriggerVisibility()
70+
{
71+
if (GameManager.GM.player == null)
72+
return;
73+
74+
triggersVisible = !triggersVisible;
75+
76+
foreach (GameObject gameObject in triggerGameObjects)
77+
{
78+
gameObject.SetActive(triggersVisible);
79+
}
80+
81+
}
82+
5683
void Update()
5784
{
5885
if (Input.GetKeyDown(KeyCode.F11))
@@ -269,6 +296,9 @@ string GetPlayerTextString()
269296
if (debugFunctions)
270297
dynamicInfo += "\nDebug Functions";
271298

299+
if (triggersVisible)
300+
dynamicInfo += "\nTriggers Visible";
301+
272302
if (noClip)
273303
dynamicInfo += "\nNoClip";
274304

SLPMod_Console.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ private void ParseCommand(string command)
8787
{
8888
PracticeModManager.Instance.noClip = !PracticeModManager.Instance.noClip;
8989
}
90+
else if (commandArray[0].ToLower() == "showtriggers")
91+
{
92+
PracticeModManager.Instance.ToggleTriggerVisibility();
93+
}
94+
9095
}
9196

9297
public void Toggle()

SLPMod_Patcher.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Harmony;
7+
using System.Reflection;
8+
using MelonLoader;
9+
using UnityEngine;
10+
11+
namespace SuperliminalPracticeMod
12+
{
13+
public class SLPMod_Patcher
14+
{
15+
public static void Patch()
16+
{
17+
var harmony = HarmonyInstance.Create("com.harmonypatch.test");
18+
harmony.PatchAll(Assembly.GetExecutingAssembly());
19+
}
20+
}
21+
22+
[HarmonyPatch(typeof(VendingMachine))]
23+
[HarmonyPatch("Start")]
24+
class VendingMachinePatch
25+
{
26+
static void Prefix(VendingMachine __instance)
27+
{
28+
MelonLogger.Log("VendingMachine.Start()");
29+
__instance.HasInfinite = true;
30+
}
31+
}
32+
33+
[HarmonyPatch(typeof(MOSTTriggerEnterCollider))]
34+
[HarmonyPatch("Start")]
35+
class TriggerEnterColliderPatch
36+
{
37+
static void Prefix(MOSTTriggerEnterCollider __instance)
38+
{
39+
Bounds bounds = __instance.gameObject.GetComponent<Collider>().bounds;
40+
GameObject gameObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
41+
gameObject.transform.position = bounds.center;
42+
gameObject.transform.localScale = bounds.extents * 2f;
43+
gameObject.GetComponent<BoxCollider>().enabled = false;
44+
MeshRenderer component = gameObject.GetComponent<MeshRenderer>();
45+
component.material.shader = Shader.Find("Transparent/Diffuse");
46+
component.GetComponent<MeshRenderer>().material.color = new Color(1f, 1f, 1f, 0.3f);
47+
gameObject.SetActive(false);
48+
PracticeModManager.Instance.AddTriggerGO(gameObject);
49+
}
50+
}
51+
52+
}

SuperliminalPracticeMod.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
</Reference>
8383
</ItemGroup>
8484
<ItemGroup>
85+
<Compile Include="SLPMod_Patcher.cs" />
8586
<Compile Include="SLPMod_Console.cs" />
8687
<Compile Include="PracticeModManager.cs" />
8788
<Compile Include="Main.cs" />

0 commit comments

Comments
 (0)