-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTheMod.cs
347 lines (301 loc) · 11.6 KB
/
TheMod.cs
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MelonLoader;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Reflection;
namespace StanleyParableUltraModDeluxe
{
public class TheMod : MelonMod
{
bool menuShown = true;
public AchievementID achievementToUnlock = AchievementID.Tuesday;
public AchievementID achievementToUnlock1 = AchievementID.SpeedRun;
public AchievementID achievementToUnlock2 = AchievementID.SettingsWorldChampion;
private Rect windoPosition = new Rect(20, 20, 500, 420);
private string TextArea = "";
private float hSliderValue = 0.0f;
public int noclipUse;
public bool tempBucket;
public override void OnGUI()
{
if (menuShown == true)
{
windoPosition = GUI.Window(0, windoPosition, WindowFunction, "The Stanley Parable Ultra Mod Delux Menu");
}
}
private void WindowFunction(int id)
{
//x,y w,h
TextArea = GUI.TextArea(new Rect(200, 65, 100, 30), TextArea);
GUI.Label(new Rect(20, 30, 350, 50), "Current number of scene(s): " + SceneManager.sceneCountInBuildSettings.ToString());
GUI.Label(new Rect(20, 120, 250, 20), "Keybinds: ");
GUI.Label(new Rect(20, 140, 250, 20), "K - Get current scene info to Melon Console");
GUI.Label(new Rect(20, 160, 250, 20), "T - Unlock All Door in scene");
GUI.Label(new Rect(20, 180, 250, 20), "L - Enable Jumping");
GUI.Label(new Rect(20, 200, 250, 20), "P - Achievement Giver");
GUI.Label(new Rect(20, 220, 250, 20), "O - Show hidden Achievemet menu");
GUI.Label(new Rect(20, 240, 250, 20), "I - Toggle Menu");
GUI.Label(new Rect(20, 260, 250, 20), "LeftAlt - Toggle Cursor Lock");
GUI.Label(new Rect(20, 280, 450, 20), "LeftBracket ( [ ) - Remove occlusion culling");
GUI.Label(new Rect(20, 300, 450, 20), "RightBracket ( ] ) - Open all doors (Use door unlocker first)");
GUI.Label(new Rect(20, 320, 450, 20), "PageUp/Down - Increase/Decrease movement speed");
GUI.Label(new Rect(20, 340, 450, 20), "N - Noclip");
/*For Later Use
hSliderValue = GUI.HorizontalSlider(new Rect(25, 25, 100, 30), hSliderValue, 0.0f, 10.0f);
*/
if (GUI.Button(new Rect(20, 70, 150, 20), "Load Selected Scene"))
{
try
{
int temp = int.Parse(TextArea);
SceneManager.LoadScene(temp);
//For later use
//StanleyController.Instance.UnfreezeMotionAndView();
}
catch (Exception exc)
{
//For when people screw up
}
}
/* currently unused
if (GUI.Button(new Rect(20, 120, 150, 20), "Level 2"))
{
}
*/
GUI.DragWindow(new Rect(0, 0, 10000, 10000));
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
LoggerInstance.Msg("Scene was loaded. Name: " + sceneName + " int: " + buildIndex);
}
public override void OnUpdate()
{
GameObject obj2 = GameObject.FindGameObjectWithTag("Player");
GameObject obj3 = GameObject.Find("Main Camera");
bool HASBUCKET = BucketController.HASBUCKET;
StanleyController controller = UnityEngine.Object.FindObjectOfType<StanleyController>();
bool motionFrozen = controller.motionFrozen;
Rigidbody component = obj2.GetComponent<Rigidbody>();
float num = 0.03f;
if (Input.GetKeyDown(KeyCode.T))
{
UnlockAllDoors();
}
if (Input.GetKeyDown(KeyCode.P))
{
AcheivementThing();
}
if (Input.GetKeyDown(KeyCode.L))
{
JumpingThing();
}
if (Input.GetKeyDown(KeyCode.O))
{
ShowAcheivementMenu();
}
if (Input.GetKeyDown(KeyCode.I))
{
ToggleMenu();
}
if (Input.GetKeyDown(KeyCode.LeftBracket))
{
ToggleOcclusionCull();
}
if (Input.GetKeyDown(KeyCode.RightBracket))
{
OpenAllDoors();
}
if (Input.GetKeyDown(KeyCode.PageUp))
{
FasterWalkingSpeed();
}
if (Input.GetKeyDown(KeyCode.PageDown))
{
SlowerWalkingSpeed();
}
if (Input.GetKeyDown(KeyCode.LeftAlt))
{
if (Cursor.visible == false)
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
if (Input.GetKeyDown(KeyCode.K))
{
int sceneCount = SceneManager.sceneCountInBuildSettings;
LoggerInstance.Msg("Scene Count: " + sceneCount);
//LoggerInstance.Msg("Scene was loaded. Name: " + S + " int: " + buildIndex);
}
if (Input.GetKeyDown(KeyCode.N))
{
int noclipUse = this.noclipUse;
if (noclipUse == 0)
{
this.noclipUse = 1;
controller.motionFrozen = true;
if (HASBUCKET)
{
this.tempBucket = true;
HASBUCKET = false;
}
component.useGravity = false;
}
else if (noclipUse != 1)
{
MelonLogger.Msg("ERROR");
}
else
{
this.noclipUse = 0;
controller.motionFrozen = false;
if (this.tempBucket)
{
this.tempBucket = false;
HASBUCKET = true;
}
component.useGravity = true;
}
}
num = !Input.GetKey(KeyCode.LeftShift) ? 0.03f : 0.05f;
if (this.noclipUse == 1)
{
if (Input.GetKey(KeyCode.W))
{
obj2.transform.Translate(Vector3.forward * num, obj3.transform);
}
if (Input.GetKey(KeyCode.S))
{
obj2.transform.Translate(Vector3.back * num, obj3.transform);
}
if (Input.GetKey(KeyCode.A))
{
obj2.transform.Translate(Vector3.left * num, obj3.transform);
}
if (Input.GetKey(KeyCode.D))
{
obj2.transform.Translate(Vector3.right * num, obj3.transform);
}
if (Input.GetKey(KeyCode.Space))
{
obj2.transform.Translate(Vector3.up * num);
}
if (Input.GetKey(KeyCode.LeftControl))
{
obj2.transform.Translate(Vector3.down * num);
}
}
}
public void ToggleMenu()
{
menuShown = !menuShown;
}
public void FasterWalkingSpeed()
{
GameObject[] allObjects = UnityEngine.Object.FindObjectsOfType<GameObject>();
float speed = 0;
foreach (GameObject go in allObjects)
{
if (go.GetComponent<StanleyController>() != null)
{
StanleyController PlayerController = go.GetComponent<StanleyController>();
speed = PlayerController.WalkingSpeedMultiplier;
speed++;
PlayerController.SetMovementSpeedMultiplier(speed);
}
}
LoggerInstance.Msg("Speed increased to" + speed);
}
public void SlowerWalkingSpeed()
{
GameObject[] allObjects = UnityEngine.Object.FindObjectsOfType<GameObject>();
float speed = 0;
foreach (GameObject go in allObjects)
{
if (go.GetComponent<StanleyController>() != null)
{
StanleyController PlayerController = go.GetComponent<StanleyController>();
speed = PlayerController.WalkingSpeedMultiplier;
speed--;
PlayerController.SetMovementSpeedMultiplier(speed);
}
}
LoggerInstance.Msg("Speed decreased to" + speed);
}
public void OpenAllDoors()
{
GameObject[] allObjects = UnityEngine.Object.FindObjectsOfType<GameObject>();
foreach (GameObject go in allObjects)
{
if (go.GetComponent<RotatingDoor>() != null)
{
RotatingDoor Doorscript = go.GetComponent<RotatingDoor>();
Doorscript.Input_Open();
}
}
LoggerInstance.Msg("Doors Opened");
}
public void ToggleOcclusionCull()
{
GameObject Cameraobject = GameObject.Find("Main Camera");
Camera TheCameraComponent = Cameraobject.GetComponent<Camera>();
TheCameraComponent.useOcclusionCulling = false;
TheCameraComponent.farClipPlane = 10000;
}
public void AcheivementThing()
{
PlatformAchievements.UnlockAchievement(this.achievementToUnlock);
PlatformAchievements.UnlockAchievement(this.achievementToUnlock1);
PlatformAchievements.UnlockAchievement(this.achievementToUnlock2);
LoggerInstance.Msg("Achievements Given");
}
public void JumpingThing()
{
foreach (BooleanConfigurable go in Resources.FindObjectsOfTypeAll(typeof(BooleanConfigurable)) as BooleanConfigurable[])
{
if (go.name == "CONFIGURABLE_STANLEYCANJUMP")
{
go.SetValue(true);
}
}
LoggerInstance.Msg("Jumping Enabled");
}
public void ShowAcheivementMenu()
{
foreach (BooleanConfigurable go in Resources.FindObjectsOfTypeAll(typeof(BooleanConfigurable)) as BooleanConfigurable[])
{
if (go.name == "CONFIGURABLE_ACHIEVEMENTS_UI_ENABLED_BOOL")
{
go.SetValue(true);
}
}
//StanleyController.Instance.UnfreezeMotionAndView();
LoggerInstance.Msg("Show Achievment Menu");
}
public void UnlockAllDoors()
{
GameObject[] allObjects = UnityEngine.Object.FindObjectsOfType<GameObject>();
foreach (GameObject go in allObjects)
{
if (go.GetComponent<RotatingDoor>() != null)
{
RotatingDoor Doorscript = go.GetComponent<RotatingDoor>();
Doorscript.isLocked = false;
}
}
LoggerInstance.Msg("Doors Unlocked");
}
}
}