Skip to content

Commit 08cdcab

Browse files
IDK WHY I DID THIS
1 parent 88b5661 commit 08cdcab

9 files changed

Lines changed: 64 additions & 27 deletions

File tree

WorldBoxMod.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@ namespace NeoModLoader;
1616
/// Main class
1717
/// </summary>
1818
[MelonLoader.RegisterTypeInIl2Cpp]
19-
public class WorldBoxMod : MonoBehaviour
19+
public class WorldBoxMod : BaseBehaviour
2020
{
21-
#if IL2CPP
2221
public WorldBoxMod(IntPtr ptr) : base(ptr)
2322
{
2423
}
25-
2624
public WorldBoxMod() : base(ClassInjector.DerivedConstructorPointer<WorldBoxMod>())
2725
{
2826
ClassInjector.DerivedConstructorBody(this);
2927
}
30-
#endif
3128
/// <summary>
3229
/// All successfully loaded mods.
3330
/// </summary>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#if IL2CPP
22
global using ObjectArray = Il2CppInterop.Runtime.InteropTypes.Arrays.Il2CppReferenceArray<UnityEngine.Object>;
33
global using SysType = Il2CppSystem.Type;
4+
global using BaseBehaviour = UnityEngine.MonoBehaviour;
45
#else
56
global using ObjectArray = UnityEngine.Object[];
67
global using SysType = System.Type;
8+
global using BaseBehaviour = NeoModLoader.AndroidCompatibilityModule.BehaviourStub;
79
#endif

android_compatibility_module/Helpers.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,7 @@ public static Rect Window(int id, Rect clientRect, Action<int> func, GUIContent
3737
{
3838
return GUIStubs.DoWindow(id, clientRect, func, text, GUI.skin.window, options);
3939
}
40-
#endif
41-
public static Rect Window(int id, Rect clientRect, GUI.WindowFunction func, string text, params GUILayoutOption[] options)
42-
{
43-
return GUILayout.Window(id, clientRect, func, text, options);
44-
}
45-
public static Rect Window(int id, Rect clientRect, GUI.WindowFunction func, GUIContent text, params GUILayoutOption[] options)
46-
{
47-
return GUILayout.Window(id, clientRect, func, text, options);
48-
}
49-
public static GUILayoutOption MinWidth(float minWidth) //cuz the original functions dont fucking work for the most BS reason
40+
public static GUILayoutOption MinWidth(float minWidth) //cuz the original functions dont fucking work for the most BS reason
5041
{
5142
return new GUILayoutOption(GUILayoutOption.Type.minWidth, minWidth);
5243
}
@@ -75,6 +66,15 @@ public static GUILayoutOption ExpandHeight(bool expand)
7566
{
7667
return new GUILayoutOption(GUILayoutOption.Type.stretchHeight, (expand ? 1 : 0));
7768
}
69+
#endif
70+
public static Rect Window(int id, Rect clientRect, GUI.WindowFunction func, string text, params GUILayoutOption[] options)
71+
{
72+
return GUILayout.Window(id, clientRect, func, text, options);
73+
}
74+
public static Rect Window(int id, Rect clientRect, GUI.WindowFunction func, GUIContent text, params GUILayoutOption[] options)
75+
{
76+
return GUILayout.Window(id, clientRect, func, text, options);
77+
}
7878
}
7979
#if IL2CPP
8080
public static Rect Window(int id, Rect clientRect, Action<int> func, string text)

android_compatibility_module/IL2CPP/Wrappers/Il2CPPBehaviour.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ public void OnDestroy()
4848

4949
public void Update()
5050
{
51-
if (WrappedBehaviour == null)
52-
{
53-
return;
54-
}
5551
WrappedBehaviour.HandleInvokations(Time.deltaTime);
5652
update?.Invoke(WrappedBehaviour);
5753
}
@@ -71,7 +67,7 @@ WrappedAction GetWrappedMethod(string Method)
7167
return WrappedMethodCollection.Get(WrappedType)[Method];
7268
}
7369
[HideFromIl2Cpp]
74-
internal B SetWrappedBehaviour<B>(B Behaviour) where B : WrappedBehaviour
70+
public B SetWrappedBehaviour<B>(B Behaviour) where B : WrappedBehaviour
7571
{
7672
WrappedBehaviour = Behaviour;
7773
WrappedType = Behaviour.GetType();
@@ -92,12 +88,12 @@ internal B SetWrappedBehaviour<B>(B Behaviour) where B : WrappedBehaviour
9288
return Behaviour;
9389
}
9490
[HideFromIl2Cpp]
95-
internal WrappedBehaviour CreateWrapperIfNull(Type WrappedType)
91+
public WrappedBehaviour CreateWrapperIfNull(Type WrappedType)
9692
{
9793
return WrappedBehaviour ?? SetWrappedBehaviour((WrappedBehaviour)Activator.CreateInstance(WrappedType));
9894
}
9995
[HideFromIl2Cpp]
100-
internal W CreateWrapper<W>() where W : WrappedBehaviour
96+
public W CreateWrapper<W>() where W : WrappedBehaviour
10197
{
10298
return SetWrappedBehaviour(Activator.CreateInstance<W>());
10399
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using UnityEngine;
2+
3+
namespace NeoModLoader.AndroidCompatibilityModule;
4+
5+
public class BehaviourStub : MonoBehaviour
6+
{
7+
public BehaviourStub(nint ptr) //stub
8+
{
9+
10+
}
11+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Il2CppInterop.Runtime.Attributes;
2+
using UnityEngine;
3+
namespace NeoModLoader.AndroidCompatibilityModule;
4+
5+
public class IL2CPPBehaviour : MonoBehaviour
6+
{
7+
[HideFromIl2Cpp]
8+
public B SetWrappedBehaviour<B>(B Behaviour) where B : WrappedBehaviour
9+
{
10+
throw new PlatformNotSupportedException();
11+
}
12+
[HideFromIl2Cpp]
13+
public WrappedBehaviour CreateWrapperIfNull(Type WrappedType)
14+
{
15+
throw new PlatformNotSupportedException();
16+
}
17+
[HideFromIl2Cpp]
18+
public W CreateWrapper<W>() where W : WrappedBehaviour
19+
{
20+
throw new PlatformNotSupportedException();
21+
}
22+
}

android_compatibility_module/Mono/Stubs/Il2CPPInterop.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,16 @@ public class HideFromIl2CppAttribute : Attribute
1010

1111
namespace Il2CppInterop.Runtime.Injection
1212
{
13-
13+
public class ClassInjector
14+
{
15+
public static nint DerivedConstructorPointer<T>()
16+
{
17+
return 67;
18+
}
19+
20+
public static void DerivedConstructorBody(object obj)
21+
{
22+
23+
}
24+
}
1425
}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
2-
using UnityEngine;
31
namespace NeoModLoader.AndroidCompatibilityModule;
4-
public class WrappedBehaviour : MonoBehaviour{
5-
public MonoBehaviour Wrapper => this;
2+
public class WrappedBehaviour : IL2CPPBehaviour{
3+
public IL2CPPBehaviour Wrapper => this;
64
}

resources/commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b69252bcaed66f281b35d7bd0d4c51bf193288cd
1+
88b56610b6875216d6525397b96959517e6ce325

0 commit comments

Comments
 (0)