20
20
#include " UnityEngine/Resources.hpp"
21
21
#include " UnityEngine/Camera.hpp"
22
22
#include " UnityEngine/GameObject.hpp"
23
+ #include " UnityEngine/Matrix4x4.hpp"
23
24
24
25
#include " Play3rdPerViewController.hpp"
25
26
@@ -42,6 +43,28 @@ Logger& getLogger() {
42
43
return *logger;
43
44
}
44
45
46
+ UnityEngine::Matrix4x4 TranslateMatrix (UnityEngine::Vector3 vector)
47
+ {
48
+ UnityEngine::Matrix4x4 result;
49
+ result.m00 = 1 ;
50
+ result.m01 = 0 ;
51
+ result.m02 = 0 ;
52
+ result.m03 = vector.x ;
53
+ result.m10 = 0 ;
54
+ result.m11 = 1 ;
55
+ result.m12 = 0 ;
56
+ result.m13 = vector.y ;
57
+ result.m20 = 0 ;
58
+ result.m21 = 0 ;
59
+ result.m22 = 1 ;
60
+ result.m23 = vector.z ;
61
+ result.m30 = 0 ;
62
+ result.m31 = 0 ;
63
+ result.m32 = 0 ;
64
+ result.m33 = 1 ;
65
+ return result;
66
+ }
67
+
45
68
MAKE_HOOK_OFFSETLESS (LightManager_OnWillRenderObject, void , LightManager* self, UnityEngine::Camera* camera) {
46
69
// Do stuff when this function is called
47
70
LightManager_OnWillRenderObject (self, camera);
@@ -51,13 +74,29 @@ MAKE_HOOK_OFFSETLESS(LightManager_OnWillRenderObject, void, LightManager* self,
51
74
UnityEngine::Vector3 rot = c->get_transform ()->get_eulerAngles ();
52
75
UnityEngine::Vector3 pos = c->get_transform ()->get_position ();
53
76
54
- pos.x += getConfig ().config [" XOffset" ].GetFloat ();
55
- pos.y += getConfig ().config [" YOffset" ].GetFloat ();
56
- pos.z += getConfig ().config [" ZOffset" ].GetFloat ();
77
+ typedef function_ptr_t <void , UnityEngine::Camera*, UnityEngine::Matrix4x4> type;
78
+ auto method = *reinterpret_cast <type>(il2cpp_functions::resolve_icall (" UnityEngine.Camera::set_cullingMatrix_Injected" ));
79
+
80
+ method (c, UnityEngine::Matrix4x4::Ortho (-99999 , 99999 , -99999 , 99999 , 0 .001f , 99999 ) * TranslateMatrix (UnityEngine::Vector3::get_forward () * -99999 / 2 ) * c->get_worldToCameraMatrix ());
81
+
82
+ if (getConfig ().config [" Fixed" ].GetBool ()) {
83
+ pos.x = getConfig ().config [" XOffset" ].GetFloat ();
84
+ pos.y = getConfig ().config [" YOffset" ].GetFloat ();
85
+ pos.z = getConfig ().config [" ZOffset" ].GetFloat ();
86
+
87
+ rot.x = getConfig ().config [" XRot" ].GetFloat ();
88
+ rot.y = getConfig ().config [" YRot" ].GetFloat ();
89
+ rot.z = getConfig ().config [" ZRot" ].GetFloat ();
90
+ } else {
91
+ pos.x += getConfig ().config [" XOffset" ].GetFloat ();
92
+ pos.y += getConfig ().config [" YOffset" ].GetFloat ();
93
+ pos.z += getConfig ().config [" ZOffset" ].GetFloat ();
57
94
58
- rot.x += getConfig ().config [" XRot" ].GetFloat ();
59
- rot.y += getConfig ().config [" YRot" ].GetFloat ();
60
- rot.z += getConfig ().config [" ZRot" ].GetFloat ();
95
+ rot.x += getConfig ().config [" XRot" ].GetFloat ();
96
+ rot.y += getConfig ().config [" YRot" ].GetFloat ();
97
+ rot.z += getConfig ().config [" ZRot" ].GetFloat ();
98
+ }
99
+
61
100
62
101
63
102
c->get_transform ()->set_position (pos);
@@ -81,6 +120,10 @@ void createDefaultConfig() {
81
120
getConfig ().config .AddMember (" ZRot" , rapidjson::Value ().SetFloat (0 ), allocator);
82
121
}
83
122
123
+ if (getConfig ().config .HasMember (" Active" ) && !(getConfig ().config .HasMember (" Fixed" ))) {
124
+ getConfig ().config .AddMember (" Fixed" , rapidjson::Value ().SetBool (false ), allocator);
125
+ }
126
+
84
127
if (getConfig ().config .HasMember (" Active" )) {return ;}
85
128
86
129
// Add all the default options
@@ -93,6 +136,7 @@ void createDefaultConfig() {
93
136
// Add a member to the config, using the allocator
94
137
95
138
getConfig ().config .AddMember (" Active" , rapidjson::Value ().SetBool (true ), allocator);
139
+ getConfig ().config .AddMember (" Fixed" , rapidjson::Value ().SetBool (false ), allocator);
96
140
getConfig ().config .AddMember (" XOffset" , rapidjson::Value ().SetFloat (2.0 ), allocator);
97
141
getConfig ().config .AddMember (" YOffset" , rapidjson::Value ().SetFloat (1.0 ), allocator);
98
142
getConfig ().config .AddMember (" ZOffset" , rapidjson::Value ().SetFloat (-2.0 ), allocator);
0 commit comments