-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSLPMod_Console.cs
More file actions
114 lines (100 loc) · 2.9 KB
/
SLPMod_Console.cs
File metadata and controls
114 lines (100 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using Rewired;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using MelonLoader;
using UnityEngine.SceneManagement;
namespace SuperliminalPracticeMod
{
class SLPMod_Console : MonoBehaviour
{
public static SLPMod_Console instance;
public bool active;
string input;
private void Awake()
{
instance = this;
active = false;
input = "";
}
private void OnGUI()
{
if (GameManager.GM.player != false && PracticeModManager.Instance.pauseMenu.isInMenu == false)
GameManager.GM.PM.canControl = !active;
if (!active)
return;
float y = 0f;
if (Event.current.type == EventType.KeyDown && Event.current.character == '\n')
{
ParseCommand(input);
input = "";
active = false;
return;
}
if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.F11 || Event.current.keyCode == KeyCode.Escape)
{
active = false;
return;
}
GUI.Box(new Rect(0, y, Screen.width, 30), "");
GUI.backgroundColor = new Color(0, 0, 0, 0);
GUI.SetNextControlName("SLP_Console");
input = GUI.TextField(new Rect(10f, y + 5f, Screen.width - 20f, 20f), input);
GUI.FocusControl("SLP_Console");
}
private void ParseCommand(string command)
{
MelonLogger.Log("Trying to parse \"" + command + "\"");
string[] commandArray = command.Split(' ');
if(commandArray[0].ToLower() == "teleport" && commandArray.Length >= 4)
{
float x, y, z;
if (!float.TryParse(commandArray[1], out x) || !float.TryParse(commandArray[2], out y) || !float.TryParse(commandArray[3], out z))
return;
MelonLogger.Log("Trying to teleport to "+x+", "+y+", "+z);
PracticeModManager.Instance.Teleport(new Vector3(x, y, z));
}
else if(commandArray[0].ToLower() == "scale" && commandArray.Length >= 2)
{
float newScale;
if (float.TryParse(commandArray[1], out newScale))
PracticeModManager.Instance.Scale(Math.Abs(newScale));
}
else if(commandArray[0].ToLower() == "load" && commandArray.Length >= 2)
{
int sceneIndex;
if (!int.TryParse(commandArray[1], out sceneIndex))
return;
if(sceneIndex >= 0)
{
SceneManager.LoadScene(sceneIndex % SceneManager.sceneCountInBuildSettings);
}
}
else if(commandArray[0].ToLower() == "noclip")
{
PracticeModManager.Instance.noClip = !PracticeModManager.Instance.noClip;
}
else if (commandArray[0].ToLower() == "showtriggers")
{
PracticeModManager.Instance.ToggleTriggerVisibility();
}
else if (commandArray[0].ToLower() == "mousemin" && commandArray.Length >= 2)
{
float mouseMinY;
MelonLogger.Log("test");
if (float.TryParse(commandArray[1], out mouseMinY))
{
MelonLogger.Log(mouseMinY.ToString());
PracticeModManager.Instance.SetMouseMinY(mouseMinY);
}
}
}
public void Toggle()
{
active = !active;
}
}
}