-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
78 lines (66 loc) · 2.55 KB
/
Main.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
using DDSS_NewYorkElevator.Patches;
using Il2CppProps.Elevator;
using MelonLoader;
using System;
using UnityEngine;
namespace DDSS_NewYorkElevator
{
internal class MelonMain : MelonMod
{
internal static MelonLogger.Instance _logger;
public override void OnInitializeMelon()
{
_logger = LoggerInstance;
ApplyPatch<Patch_ElevatorController>();
_logger.Msg("Initialized");
}
public override void OnSceneWasInitialized(int buildIndex, string sceneName)
{
// Check for New York office Scene
if (sceneName != "Level_0")
return;
// Enable Movers
ElevatorMover[] elevatorMoverArr = Resources.FindObjectsOfTypeAll<ElevatorMover>();
foreach (ElevatorMover mover in elevatorMoverArr)
{
mover.enabled = true;
mover.gameObject.SetActive(true);
}
// Enable Controllers
ElevatorController[] elevatorControllerArr = Resources.FindObjectsOfTypeAll<ElevatorController>();
foreach (ElevatorController elevator in elevatorControllerArr)
{
// Enable the Elevator
elevator.enabled = true;
elevator.gameObject.SetActive(true);
// Enable the Doors
elevator.lowerDoor.enabled = true;
elevator.upperDoor.enabled = true;
// Fix Indicators
foreach (var indicator in elevator.minLevelIndicator)
indicator.SetRequested(false);
foreach (var indicator in elevator.maxLevelIndicator)
indicator.SetRequested(true);
// Remove Out of Service Signs
Transform signObjLower = elevator.lowerDoor.transform.Find("Plane/Service");
if (signObjLower != null)
UnityEngine.Object.Destroy(signObjLower.parent.gameObject);
Transform signObjUpper = elevator.upperDoor.transform.Find("Plane/Service");
if (signObjUpper != null)
UnityEngine.Object.Destroy(signObjUpper.parent.gameObject);
}
}
private void ApplyPatch<T>()
{
Type type = typeof(T);
try
{
HarmonyInstance.PatchAll(type);
}
catch (Exception e)
{
LoggerInstance.Error($"Exception while attempting to apply {type.Name}: {e}");
}
}
}
}