-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntroPatch.cs
110 lines (91 loc) · 4.39 KB
/
IntroPatch.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
using HarmonyLib;
using System;
using TormentedSoulsVR.cam;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace TormentedSoulsVR
{
[HarmonyPatch]
internal class IntroPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(ActorEvent_PuzzleIllumination), "Start")]
private static void PositionIntroCanvasAndCam(ActorEvent_PuzzleIllumination __instance)
{
if (__instance.gameObject.name != "IntroScene_Actor_GameObject")
return;
GameObject[] rootObjects = SceneManager.GetActiveScene().GetRootGameObjects();
foreach (GameObject gameObj in rootObjects)
{
if (gameObj.name == "Canvas")
{
Canvas canvas = gameObj.GetComponent<Canvas>();
canvas.renderMode = RenderMode.WorldSpace;
gameObj.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
gameObj.transform.position = new Vector3(0, 0, 10);
break;
}
}
CamFix.vrCamera.backgroundColor = new Color(0.1284f, 0.1792f, 0.1333f, 1);
CamFix.camHolder.transform.localPosition = CamFix.vrCamera.transform.position * -1;
CamFix.menus.transform.localPosition = new Vector3(0,0,0.3f);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UnityEngine.Playables.PlayableDirector), "Play", new Type[] { })]
private static void PositionIntroCinematic(UnityEngine.Playables.PlayableDirector __instance)
{
if (SceneManager.GetActiveScene().name == "IntroScene") {
Canvas cinematicCanvas = __instance.transform.parent.GetChild(1).GetComponent<Canvas>();
if (cinematicCanvas != null)
{
cinematicCanvas.renderMode = RenderMode.WorldSpace;
cinematicCanvas.transform.localScale = new Vector3(0.001f, 0.001f, 0.001f);
cinematicCanvas.transform.position = new Vector3(0f, 0f, 2.1f);
}
}
else {
CamFix.inCinematic = true;
CamFix.camHolder.transform.localPosition = CamFix.vrCamera.transform.localPosition * -1;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UnityEngine.Playables.PlayableDirector), "SendOnPlayableDirectorStop", new Type[] { })]
private static void ResetVarOnCinematicEnd(UnityEngine.Playables.PlayableDirector __instance)
{
CamFix.inCinematic = false;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ItemObsClick), "Setup")]
private static void DisableColliderMesh(ItemObsClick __instance)
{
if (__instance.name == "DireccionCollider" || __instance.name == "AbrirCollider" || __instance.name == "TextoCollider" || __instance.name == "FotoCollider")
{
UnityEngine.MeshFilter filter = __instance.GetComponent<MeshFilter>();
// The colliders for the intro letter are visible for some reason so hide them with this
filter.mesh.subMeshCount = 0;
if (CamFix.camRoot.transform.childCount >= 2)
{
Transform gui3dObject = CamFix.camRoot.transform.GetChild(1).GetChild(2);
// Re-enable the 3D object inspector lights and reflection probe just for this scene
gui3dObject.GetChild(2).gameObject.SetActive(true);
gui3dObject.GetChild(2).GetComponent<UnityEngine.Light>().intensity = 1.25f;
gui3dObject.GetChild(5).gameObject.SetActive(true);
CamFix.inIntro = true;
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ItemObservationBase), "OnLetterCommentaryClick")]
private static void SetCameraBackgroundToBlackAgain(ItemObservationBase __instance, string id)
{
if (id == "maintext") {
CamFix.vrCamera.backgroundColor = Color.black;
Transform gui3dObject = CamFix.camRoot.transform.GetChild(1).GetChild(2);
gui3dObject.GetChild(2).gameObject.SetActive(false);
gui3dObject.GetChild(5).gameObject.SetActive(false);
CamFix.inIntro = false;
CamFix.headsetPos = CamFix.vrCamera.transform.localPosition;
}
}
}
}