Skip to content
This repository was archived by the owner on Mar 12, 2022. It is now read-only.

Commit dd06322

Browse files
authored
Merge pull request #1 from d-mageek/master
vai pra puta que pariu vai pra casa do caralho vai se foder vai tomar no cu vai se arrombar vai da essa bunda vai chupar uma rola vai pro quinto dos inferno mamar a piroca do capeta vai pra porra vai pra merda vai engolir uma pica vai sugar um caralho vai cair de boca num piru
2 parents 570b2d2 + 88b6cd6 commit dd06322

7 files changed

Lines changed: 220 additions & 82 deletions

File tree

Properties/AssemblyInfo.cs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,13 @@
33
using System.Runtime.InteropServices;
44
using TrackingRotator;
55

6-
// General Information about an assembly is controlled through the following
7-
// set of attributes. Change these attribute values to modify the information
8-
// associated with an assembly.
6+
[assembly: ComVisible(false)]
7+
[assembly: Guid("652febb3-e7bd-4f5c-8ac4-51e36b19bc9d")]
98
[assembly: AssemblyTitle(ModBuildInfo.Name)]
10-
[assembly: AssemblyDescription("")]
11-
[assembly: AssemblyConfiguration("")]
12-
[assembly: AssemblyCompany("")]
139
[assembly: AssemblyProduct(ModBuildInfo.Name)]
1410
[assembly: AssemblyCopyright("Created by " + ModBuildInfo.Author)]
15-
[assembly: AssemblyTrademark("")]
16-
[assembly: AssemblyCulture("")]
17-
18-
// Setting ComVisible to false makes the types in this assembly not visible
19-
// to COM components. If you need to access a type in this assembly from
20-
// COM, set the ComVisible attribute to true on that type.
21-
[assembly: ComVisible(false)]
22-
23-
// The following GUID is for the ID of the typelib if this project is exposed to COM
24-
[assembly: Guid("652febb3-e7bd-4f5c-8ac4-51e36b19bc9d")]
25-
26-
// Version information for an assembly consists of the following four values:
27-
//
28-
// Major Version
29-
// Minor Version
30-
// Build Number
31-
// Revision
32-
//
33-
// You can specify all the values or you can default the Build and Revision Numbers
34-
// by using the '*' as shown below:
35-
// [assembly: AssemblyVersion("1.0.*")]
3611
[assembly: AssemblyVersion(ModBuildInfo.Version)]
3712
[assembly: AssemblyFileVersion(ModBuildInfo.Version)]
3813
[assembly: MelonInfo(typeof(TrackingRotatorMod), ModBuildInfo.Name, ModBuildInfo.Version, ModBuildInfo.Author, ModBuildInfo.DownloadLink)]
3914
[assembly: MelonGame(ModBuildInfo.GameDeveloper, ModBuildInfo.Game)]
40-
[assembly: MelonOptionalDependencies("UIExpansionKit")]
15+
[assembly: MelonOptionalDependencies("UIExpansionKit", "ActionMenuApi")]

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66
Video preview soon.
77

88
A mod that lets you rotate your tracking, it was made with "play while laying down" in mind.
9+
* UIExpansionKit Integration, first releases and actual algorithm by [nitro.](https://github.com/nitrog0d)
10+
* AssetBundle, AMAPI Integration and Integrations' Management/Organization by [Davi](https://github.com/d-mageek).
911

1012
* **Warning:** The VRChat team is not very keen on modding or reverse engineering the game, while the mod does not include anything that would ruin the fun for others, using it may still be a bannable offence.
1113

12-
* **USE IT AT YOUR OWN RISK**, I am not responsible for any bans or any punishments you may get by using this mod!
14+
* **USE IT AT YOUR OWN RISK**, we are not responsible for any bans or any punishments you may get by using this mod!
1315

1416
## Installation
1517
* **Make sure you have run the [MelonLoader Installer](https://github.com/LavaGang/MelonLoader.Installer/releases/latest/download/MelonLoader.Installer.exe) by [LavaGang](https://github.com/LavaGang) first (feel free to join the [VRChat Modding Group Discord](https://discord.gg/jgvc9Fd) for help!).**
1618
* Download the [latest version](https://github.com/nitrog0d/TrackingRotator/releases/latest/download/TrackingRotator.dll) of the mod.
17-
* **Install the mod [UIExpansionKit](https://github.com/knah/VRCMods) by [knah](https://github.com/knah), it is required.**
19+
* **Install (at least one is required):**
20+
* [UIExpansionKit](https://github.com/knah/VRCMods) by [knah](https://github.com/knah), or/and
21+
* [ActionMenuApi](https://github.com/gompocp/ActionMenuApi) by [gompo](https://github.com/gompocp).
1822
* Drag/copy the DLL files that you have downloaded into the Mods folder.
1923
* That's it! Now just run the game and the mod should be installed!
2024

TrackingRotator.csproj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<Deterministic>true</Deterministic>
15-
<MelonLoaderPath>C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader</MelonLoaderPath>
15+
<MelonLoaderPath>D:\Jogos\SteamLibrary\steamapps\common\VRChat\MelonLoader</MelonLoaderPath>
1616
</PropertyGroup>
1717
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1818
<DebugSymbols>true</DebugSymbols>
@@ -32,10 +32,15 @@
3232
<WarningLevel>4</WarningLevel>
3333
</PropertyGroup>
3434
<ItemGroup>
35+
<Compile Include="Utils\AMAPIManager.cs" />
3536
<Compile Include="TrackingRotatorMod.cs" />
3637
<Compile Include="Properties\AssemblyInfo.cs" />
38+
<Compile Include="Utils\UIXManager.cs" />
3739
</ItemGroup>
3840
<ItemGroup>
41+
<Reference Include="ActionMenuApi">
42+
<HintPath>$(MelonLoaderPath)\..\Mods\ActionMenuApi.dll</HintPath>
43+
</Reference>
3944
<Reference Include="Assembly-CSharp">
4045
<HintPath>$(MelonLoaderPath)\Managed\Assembly-CSharp.dll</HintPath>
4146
</Reference>
@@ -51,9 +56,13 @@
5156
<Reference Include="UnhollowerBaseLib">
5257
<HintPath>$(MelonLoaderPath)\Managed\UnhollowerBaseLib.dll</HintPath>
5358
</Reference>
59+
<Reference Include="UnityEngine.AssetBundleModule">
60+
<HintPath>$(MelonLoaderPath)\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
61+
</Reference>
5462
<Reference Include="UnityEngine.CoreModule">
5563
<HintPath>$(MelonLoaderPath)\Managed\UnityEngine.CoreModule.dll</HintPath>
5664
</Reference>
65+
<EmbeddedResource Include="trackingrotator" />
5766
</ItemGroup>
5867
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
5968
<PropertyGroup>

TrackingRotatorMod.cs

Lines changed: 79 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,125 @@
11
using MelonLoader;
2-
using UIExpansionKit.API;
32
using UnityEngine;
43
using System.Linq;
54
using UnhollowerRuntimeLib;
5+
using System.Collections;
6+
using TrackingRotator.Utils;
67
using Il2CppSystem.Reflection;
78

8-
namespace TrackingRotator {
9-
9+
namespace TrackingRotator
10+
{
1011
public static class ModBuildInfo {
1112
public const string Name = "TrackingRotator";
12-
public const string Author = "nitro.";
13-
public const string Version = "1.0.1";
13+
public const string Author = "Davi & nitro."; // <3
14+
public const string Version = "1.0.2";
1415
public const string DownloadLink = "https://github.com/nitrog0d/TrackingRotator/releases/latest/download/TrackingRotator.dll";
1516
public const string GameDeveloper = "VRChat";
1617
public const string Game = "VRChat";
1718
}
1819

19-
public class TrackingRotatorMod : MelonMod {
20+
public class TrackingRotatorMod : MelonMod
21+
{
22+
2023
private const string ModCategory = "TrackingRotator";
24+
private const string UIXIntegration = "UIXIntegration";
25+
private const string AMAPIIntegration = "AMAPIIntegration";
2126
private const string RotationValuePref = "RotationValue";
2227
private const string HighPrecisionRotationValuePref = "HighPrecisionRotationValue";
2328
private const string ResetRotationOnSceneChangePref = "ResetRotationOnSceneChange";
2429

2530
private static float rotationValue = 0f;
2631
private static float highPrecisionRotationValue = 0f;
27-
private static bool highPrecision = false;
28-
private static bool resetRotationOnSceneChange = false;
32+
private static bool resetRotationOnSceneChange, IsUsingUIX, IsUsingAMAPI = false;
33+
private static bool UIXintegration, AMAPIintegration = true;
2934

30-
private static Transform cameraTransform = null;
31-
private static Quaternion originalRotation;
35+
public static bool highPrecision = false;
36+
public static Transform transform;
37+
public static Transform cameraTransform;
38+
public static Quaternion originalRotation;
3239

33-
public override void OnApplicationStart() {
34-
MelonLogger.Msg("Mod loaded.");
40+
public override void OnApplicationStart()
41+
{
3542
MelonPreferences.CreateCategory(ModCategory, "Tracking Rotator");
43+
MelonPreferences.CreateEntry(ModCategory, UIXIntegration, true, "Integrate with UiExpansionKit?");
44+
MelonPreferences.CreateEntry(ModCategory, AMAPIIntegration, true, "Integrate with Action Menu?");
3645
MelonPreferences.CreateEntry(ModCategory, RotationValuePref, 22.5f, "Rotation value");
3746
MelonPreferences.CreateEntry(ModCategory, HighPrecisionRotationValuePref, 1f, "High precision rotation value");
3847
MelonPreferences.CreateEntry(ModCategory, ResetRotationOnSceneChangePref, false, "Reset rotation when a new world loads");
39-
ExpansionKitApi.GetExpandedMenu(ExpandedMenu.QuickMenu).AddSimpleButton("Tracking rotation", ShowRotationMenu);
4048
OnPreferencesSaved();
41-
}
4249

43-
public override void OnSceneWasLoaded(int buildIndex, string sceneName) {
44-
if (resetRotationOnSceneChange && cameraTransform) cameraTransform.localRotation = originalRotation;
50+
Integrations();
51+
52+
MelonLogger.Msg("Mod loaded.");
4553
}
4654

47-
public override void OnPreferencesSaved() {
55+
public override void OnPreferencesSaved()
56+
{
57+
UIXintegration = MelonPreferences.GetEntryValue<bool>(ModCategory, UIXIntegration);
58+
AMAPIintegration = MelonPreferences.GetEntryValue<bool>(ModCategory, AMAPIIntegration);
4859
rotationValue = MelonPreferences.GetEntryValue<float>(ModCategory, RotationValuePref);
4960
highPrecisionRotationValue = MelonPreferences.GetEntryValue<float>(ModCategory, HighPrecisionRotationValuePref);
5061
resetRotationOnSceneChange = MelonPreferences.GetEntryValue<bool>(ModCategory, ResetRotationOnSceneChangePref);
5162
}
5263

53-
public override void VRChat_OnUiManagerInit() {
54-
var camera = Object.FindObjectOfType<VRCVrCamera>();
55-
var transform = camera.GetIl2CppType().GetFields(BindingFlags.Public | BindingFlags.Instance).Where(f => f.FieldType == Il2CppType.Of<Transform>()).ToArray()[0];
56-
cameraTransform = transform.GetValue(camera).Cast<Transform>();
57-
originalRotation = cameraTransform.localRotation;
58-
}
5964

60-
private static ICustomShowableLayoutedMenu rotationMenu = null;
65+
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
66+
{
67+
if (resetRotationOnSceneChange && cameraTransform) cameraTransform.localRotation = originalRotation;
68+
}
6169

62-
// Based on knah's ViewPointTweaker mod, https://github.com/knah/VRCMods/blob/master/ViewPointTweaker
63-
private void ShowRotationMenu() {
64-
if (rotationMenu == null) {
65-
rotationMenu = ExpansionKitApi.CreateCustomQuickMenuPage(LayoutDescription.QuickMenu4Columns);
70+
public static IEnumerator WaitForUiInit()
71+
{
72+
while (Object.FindObjectOfType<VRCVrCamera>() == null)
73+
yield return null;
6674

67-
void Move(Vector3 direction) {
68-
cameraTransform.Rotate(direction, highPrecision ? highPrecisionRotationValue : rotationValue, Space.World);
69-
}
75+
var camera = Object.FindObjectOfType<VRCVrCamera>();
76+
var Transform = camera.GetIl2CppType().GetFields(BindingFlags.Public | BindingFlags.Instance).Where(f => f.FieldType == Il2CppType.Of<Transform>()).ToArray()[0];
77+
cameraTransform = Transform.GetValue(camera).Cast<Transform>();
78+
originalRotation = cameraTransform.localRotation;
79+
transform = Camera.main.transform;
7080

71-
var transform = Camera.main.transform;
81+
if (IsUsingAMAPI) typeof(AMAPIManager).GetMethod("ActionMenuIntegration").Invoke(null, null);
82+
}
7283

73-
rotationMenu.AddSpacer();
74-
rotationMenu.AddSimpleButton("Forward", () => Move(transform.right));
75-
rotationMenu.AddSpacer();
76-
rotationMenu.AddSpacer();
84+
public static void Move(Vector3 direction)
85+
{
86+
cameraTransform.Rotate(direction, highPrecision ? highPrecisionRotationValue : rotationValue, Space.World);
87+
}
7788

78-
rotationMenu.AddSimpleButton("Tilt Left", () => Move(transform.forward));
79-
rotationMenu.AddSimpleButton("Reset", () => cameraTransform.localRotation = originalRotation);
80-
rotationMenu.AddSimpleButton("Tilt Right", () => Move(-transform.forward));
81-
rotationMenu.AddSpacer();
89+
private static void Integrations()
90+
{
91+
if (AMAPIintegration)
92+
{
93+
if (MelonHandler.Mods.Any(x => x.Info.Name.Equals("ActionMenuApi")))
94+
{
95+
Assets.OnApplicationStart();
96+
IsUsingAMAPI = true;
97+
}
98+
else MelonLogger.Warning("For a better experience, please consider using ActionMenuApi.");
99+
}
100+
else MelonLogger.Warning("Integration with ActionMenuApi has been deactivated on Settings.");
101+
102+
if (UIXintegration)
103+
{
104+
if (MelonHandler.Mods.Any(x => x.Info.Name.Equals("UI Expansion Kit")))
105+
{
106+
typeof(UIXManager).GetMethod("OnApplicationStart").Invoke(null, null);
107+
IsUsingUIX = true;
108+
}
109+
else MelonLogger.Warning("For a better experience, please consider using UIExpansionKit.");
110+
}
111+
else MelonLogger.Warning("Integration with UIExpansionKit has been deactivated on Settings.");
82112

83-
rotationMenu.AddSpacer();
84-
rotationMenu.AddSimpleButton("Backward", () => Move(-transform.right));
85-
rotationMenu.AddSimpleButton("Left", () => Move(-transform.up));
86-
rotationMenu.AddSimpleButton("Right", () => Move(transform.up));
113+
if (!AMAPIintegration && !UIXintegration)
114+
MelonLogger.Warning("Both integrations (Action Menu and UiExpansionKit) have been deactivated. " +
115+
"The mod cannot run without those, therefore, expect it to fail. If this was not intended, " +
116+
"please consider activating at least one of the integrations on Settings.");
87117

88-
rotationMenu.AddToggleButton("High precision", b => highPrecision = b, () => highPrecision);
89-
rotationMenu.AddSpacer();
90-
rotationMenu.AddSpacer();
91-
rotationMenu.AddSimpleButton("Back", rotationMenu.Hide);
118+
if (!IsUsingAMAPI && !IsUsingUIX)
119+
{
120+
MelonLogger.Error("Failed to load both integrations with UIExpansionKit and ActionMenuApi! The mod will not be loaded.");
92121
}
93-
94-
rotationMenu.Show();
122+
else MelonCoroutines.Start(WaitForUiInit());
95123
}
96124
}
97-
}
125+
}

Utils/AMAPIManager.cs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using UnityEngine;
2+
using ActionMenuApi.Api;
3+
using UnhollowerRuntimeLib;
4+
using System.Collections;
5+
using MelonLoader;
6+
using System.IO;
7+
using System.Reflection;
8+
using static TrackingRotator.TrackingRotatorMod;
9+
10+
namespace TrackingRotator.Utils
11+
{
12+
internal static class AMAPIManager
13+
{
14+
public static void ActionMenuIntegration()
15+
{
16+
VRCActionMenuPage.AddSubMenu(ActionMenuPage.Main, "<color=#00a2ff>Tracking Rotator</color>", () =>
17+
{
18+
CustomSubMenu.AddButton("Forward", () => Move(transform.right), Assets.Forward); //X+
19+
CustomSubMenu.AddButton("Backward", () => Move(-transform.right), Assets.Backward); //X-
20+
CustomSubMenu.AddButton("Tilt Left", () => Move(transform.forward), Assets.TLeft); //Z+
21+
CustomSubMenu.AddButton("Tilt Right", () => Move(-transform.forward), Assets.TRight); //Z-
22+
CustomSubMenu.AddButton("Left", () => Move(-transform.up), Assets.Left); //Y-
23+
CustomSubMenu.AddButton("Right", () => Move(transform.up), Assets.Right); //Y+
24+
25+
CustomSubMenu.AddSubMenu("Other", () =>
26+
{
27+
CustomSubMenu.AddButton("Reset", () => cameraTransform.localRotation = originalRotation, Assets.Reset);
28+
CustomSubMenu.AddToggle("High precision", highPrecision, b => highPrecision = b, Assets.HP);
29+
}, Assets.Other);
30+
}, Assets.Main);
31+
}
32+
}
33+
34+
// The code below was based on Lily's...
35+
// https://github.com/KortyBoi/VRChat-TeleporterVR/blob/main/Utils/ResourceManager.cs
36+
// And also knah's!
37+
// https://github.com/knah/VRCMods/blob/master/UIExpansionKit
38+
internal static class Assets
39+
{
40+
private static AssetBundle Bundle;
41+
public static Texture2D Main, Forward, Backward, TLeft, TRight, Left, Right, Other, Reset, HP;
42+
43+
public static void OnApplicationStart() { MelonCoroutines.Start(LoadAssets()); }
44+
45+
private static IEnumerator LoadAssets()
46+
{
47+
try
48+
{
49+
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TrackingRotator.trackingrotator"))
50+
{
51+
using (var memoryStream = new MemoryStream((int)stream.Length))
52+
{
53+
stream.CopyTo(memoryStream);
54+
Bundle = AssetBundle.LoadFromMemory_Internal(memoryStream.ToArray(), 0);
55+
Bundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;
56+
try { Main = LoadTexture("Main.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Main.png"); }
57+
try { Forward = LoadTexture("Forward.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Forward.png"); }
58+
try { Backward = LoadTexture("Backward.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Backward.png"); }
59+
try { TLeft = LoadTexture("TLeft.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: TLeft.png"); }
60+
try { TRight = LoadTexture("TRight.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: TRight.png"); }
61+
try { Left = LoadTexture("Left.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Left.png"); }
62+
try { Right = LoadTexture("Right.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Right.png"); }
63+
try { Other = LoadTexture("Other.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Other.png"); }
64+
try { Reset = LoadTexture("Reset.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Reset.png"); }
65+
try { HP = LoadTexture("HP.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: HP.png"); }
66+
}
67+
}
68+
} catch { MelonLogger.Warning("Failed to load AssetBundle! ActionMenuApi will have its icons completely broken."); }
69+
yield break;
70+
}
71+
72+
private static Texture2D LoadTexture(string Texture)
73+
{
74+
Texture2D Texture2 = Bundle.LoadAsset_Internal(Texture, Il2CppType.Of<Texture2D>()).Cast<Texture2D>();
75+
Texture2.hideFlags |= HideFlags.DontUnloadUnusedAsset;
76+
Texture2.hideFlags = HideFlags.HideAndDontSave;
77+
return Texture2;
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)