Skip to content

Commit 16662ee

Browse files
committed
Add project files.
1 parent d6ea685 commit 16662ee

File tree

5 files changed

+426
-0
lines changed

5 files changed

+426
-0
lines changed

Main.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using MelonLoader;
7+
using UnityEngine;
8+
[assembly: MelonInfo(typeof(SuperliminalPracticeMod.Main), "Superliminal Practice Mod", "0.1.0", "Micrologist#2351")]
9+
[assembly: MelonGame("PillowCastle", "Superliminal")]
10+
11+
namespace SuperliminalPracticeMod
12+
{
13+
public class Main : MelonMod
14+
{
15+
public override void OnLevelWasLoaded(int level)
16+
{
17+
if(GameManager.GM != null && GameManager.GM.gameObject.GetComponent<PracticeModManager>() == null)
18+
GameManager.GM.gameObject.AddComponent<PracticeModManager>();
19+
}
20+
}
21+
}

PracticeModManager.cs

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
using FMOD;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using UnityEngine;
8+
using UnityEngine.UI;
9+
using UnityEngine.SceneManagement;
10+
11+
namespace SuperliminalPracticeMod
12+
{
13+
class PracticeModManager : MonoBehaviour
14+
{
15+
public static PracticeModManager Instance;
16+
public bool noClip;
17+
public float noClipSpeed;
18+
public float defaultFarClipPlane;
19+
public GameObject player;
20+
public GameObject flashLight;
21+
public CharacterMotor playerMotor;
22+
public Camera playerCamera;
23+
public Text playerText;
24+
25+
Vector3 storedPosition;
26+
Quaternion storedRotation;
27+
float storedScale;
28+
int storedMap;
29+
float storeTime;
30+
float teleportTime;
31+
32+
33+
void Awake()
34+
{
35+
PracticeModManager.Instance = this;
36+
noClip = false;
37+
noClipSpeed = 10.0f;
38+
defaultFarClipPlane = 999f;
39+
40+
storedPosition = Vector3.zero;
41+
storedRotation = Quaternion.identity;
42+
storedScale = 1.0f;
43+
storedMap = -1;
44+
}
45+
46+
void Update()
47+
{
48+
49+
50+
if (Input.GetKeyDown(KeyCode.K))
51+
{
52+
noClip = !noClip;
53+
noClipSpeed = 10.0f;
54+
}
55+
56+
if (GameManager.GM.player == null)
57+
return;
58+
59+
if (player != GameManager.GM.player)
60+
{
61+
player = GameManager.GM.player;
62+
playerMotor = player.GetComponent<CharacterMotor>();
63+
playerCamera = player.GetComponentInChildren<Camera>();
64+
defaultFarClipPlane = playerCamera.farClipPlane;
65+
if(player.transform.Find("Flashlight") == null)
66+
{
67+
flashLight = new GameObject("Flashlight");
68+
flashLight.SetActive(false);
69+
this.flashLight.transform.parent = player.transform;
70+
this.flashLight.transform.localPosition = new Vector3(0f, playerCamera.transform.localPosition.y, 0f);
71+
Light light = this.flashLight.AddComponent<Light>();
72+
light.range = 10000f;
73+
light.intensity = 0.5f;
74+
}
75+
else
76+
{
77+
flashLight = player.transform.Find("Flashlight").gameObject;
78+
}
79+
80+
if (GameObject.Find("PlayerText") == null && GameObject.Find("UI_PAUSE_MENU") != null)
81+
{
82+
playerText = NewPlayerText();
83+
}
84+
}
85+
86+
87+
playerMotor.enabled = !noClip;
88+
89+
if (Input.GetKeyDown(KeyCode.F))
90+
{
91+
flashLight.gameObject.SetActive(!flashLight.gameObject.activeSelf);
92+
}
93+
94+
95+
if (noClip)
96+
{
97+
playerCamera.GetComponent<CameraSettingsLayer>().enabled = false;
98+
playerCamera.farClipPlane = 10000f;
99+
this.noClipSpeed += Input.mouseScrollDelta.y;
100+
this.noClipSpeed = Mathf.Max(0f, this.noClipSpeed);
101+
Vector3 directionVector = new Vector3(GameManager.GM.playerInput.GetAxisRaw("Move Horizontal"), 0f, GameManager.GM.playerInput.GetAxisRaw("Move Vertical"));
102+
if (Input.GetKey(KeyCode.Space))
103+
{
104+
directionVector.y += 1f;
105+
}
106+
if (Input.GetKey(KeyCode.C) || Input.GetKey(KeyCode.LeftControl))
107+
{
108+
directionVector.y -= 1f;
109+
}
110+
playerMotor.transform.Translate(directionVector.normalized * Time.deltaTime * this.noClipSpeed);
111+
}
112+
else
113+
{
114+
playerCamera.GetComponent<CameraSettingsLayer>().enabled = false;
115+
}
116+
117+
if(playerText != null)
118+
{
119+
playerText.text = GetPlayerTextString();
120+
}
121+
122+
if (Input.GetKeyDown(KeyCode.F5))
123+
StorePosition();
124+
125+
if (Input.GetKeyDown(KeyCode.F6))
126+
TeleportPosition();
127+
128+
if (Input.GetKeyDown(KeyCode.F7))
129+
ReloadCheckpoint();
130+
131+
if (Input.GetKeyDown(KeyCode.F8))
132+
RestartMap();
133+
}
134+
135+
void LateUpdate()
136+
{
137+
if (noClip)
138+
{
139+
playerCamera.farClipPlane = 10000f;
140+
}
141+
else
142+
{
143+
playerCamera.farClipPlane = defaultFarClipPlane;
144+
}
145+
}
146+
147+
Text NewPlayerText()
148+
{
149+
Text newText;
150+
GameObject gameObject = new GameObject("PlayerText");
151+
gameObject.transform.parent = GameObject.Find("UI_PAUSE_MENU").transform.Find("Canvas");
152+
gameObject.AddComponent<CanvasGroup>().interactable = false;
153+
newText = gameObject.AddComponent<Text>();
154+
RectTransform component = newText.GetComponent<RectTransform>();
155+
component.sizeDelta = new Vector2((float)(Screen.currentResolution.width / 3), (float)(Screen.currentResolution.height / 3));
156+
component.pivot = new Vector2(0f, 1f);
157+
component.anchorMin = new Vector2(0f, 1f);
158+
component.anchorMax = new Vector2(0f, 1f);
159+
component.anchoredPosition = new Vector2(25f, -25f);
160+
foreach (Font font in Resources.FindObjectsOfTypeAll<Font>())
161+
{
162+
if (font.name == "BebasNeue Bold")
163+
{
164+
newText.font = font;
165+
}
166+
}
167+
newText.text = "hello world";
168+
newText.fontSize = 30;
169+
170+
return newText;
171+
}
172+
173+
string GetPlayerTextString()
174+
{
175+
Vector3 position = playerMotor.transform.localPosition;
176+
Vector3 velocity = playerMotor.GetComponent<CharacterController>().velocity;
177+
Vector3 rotation = playerMotor.transform.localRotation.eulerAngles;
178+
float scale = playerMotor.transform.localScale.x;
179+
string dynamicInfo = "";
180+
181+
if (noClip)
182+
dynamicInfo += "\nNoClip";
183+
184+
if (flashLight.activeSelf)
185+
dynamicInfo += "\nFlashlight";
186+
187+
if (Time.time - this.storeTime <= 1f)
188+
dynamicInfo += "\nPosition Stored";
189+
190+
if (Time.time - this.teleportTime <= 1f)
191+
dynamicInfo += "\nTeleport";
192+
193+
194+
return string.Concat(new object[]
195+
{
196+
"Position: ",
197+
position.x.ToString("0.000"),
198+
", ",
199+
position.y.ToString("0.000"),
200+
", ",
201+
position.z.ToString("0.000"),
202+
"\n",
203+
"Rotation: ",
204+
playerCamera.transform.rotation.x.ToString("0.000"),
205+
", ",
206+
rotation.y.ToString("0.000"),
207+
", ",
208+
rotation.z.ToString("0.000"),
209+
"\n",
210+
"Scale: ",
211+
scale.ToString("0.0000")+"x",
212+
"\n",
213+
"Horizontal Velocity: ",
214+
Mathf.Sqrt(velocity.x * velocity.x + velocity.z * velocity.z).ToString("0.000")+" m/s",
215+
"\n",
216+
"Vertical Velocity: ",
217+
velocity.y.ToString("0.000")+" m/s",
218+
"\n",
219+
dynamicInfo
220+
});
221+
222+
223+
}
224+
225+
void StorePosition()
226+
{
227+
storedPosition = playerMotor.transform.position;
228+
storedRotation = playerMotor.transform.rotation;
229+
storedScale = playerMotor.transform.localScale.x;
230+
storedMap = SceneManager.GetActiveScene().buildIndex;
231+
storeTime = Time.time;
232+
}
233+
234+
void TeleportPosition()
235+
{
236+
if(storedMap == SceneManager.GetActiveScene().buildIndex)
237+
{
238+
playerMotor.transform.position = storedPosition;
239+
playerMotor.transform.rotation = storedRotation;
240+
playerMotor.transform.localScale = new Vector3(storedScale, storedScale, storedScale);
241+
teleportTime = Time.time;
242+
}
243+
}
244+
245+
void ReloadCheckpoint()
246+
{
247+
GameManager.GM.TriggerScenePreUnload();
248+
GameManager.GM.GetComponent<SaveAndCheckpointManager>().ResetToLastCheckpoint();
249+
}
250+
251+
void RestartMap()
252+
{
253+
GameManager.GM.TriggerScenePreUnload();
254+
GameManager.GM.GetComponent<SaveAndCheckpointManager>().RestartLevel();
255+
}
256+
257+
}
258+
}

Properties/AssemblyInfo.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("SuperliminalPracticeMod")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("SuperliminalPracticeMod")]
13+
[assembly: AssemblyCopyright("Copyright © 2021")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("b9e7ccf8-762d-463c-82c7-114ce88fb066")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)