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

Commit

Permalink
Merge pull request #1 from d-mageek/master
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nitrog0d authored May 29, 2021
2 parents 570b2d2 + 88b6cd6 commit dd06322
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 82 deletions.
31 changes: 3 additions & 28 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,13 @@
using System.Runtime.InteropServices;
using TrackingRotator;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: ComVisible(false)]
[assembly: Guid("652febb3-e7bd-4f5c-8ac4-51e36b19bc9d")]
[assembly: AssemblyTitle(ModBuildInfo.Name)]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct(ModBuildInfo.Name)]
[assembly: AssemblyCopyright("Created by " + ModBuildInfo.Author)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("652febb3-e7bd-4f5c-8ac4-51e36b19bc9d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(ModBuildInfo.Version)]
[assembly: AssemblyFileVersion(ModBuildInfo.Version)]
[assembly: MelonInfo(typeof(TrackingRotatorMod), ModBuildInfo.Name, ModBuildInfo.Version, ModBuildInfo.Author, ModBuildInfo.DownloadLink)]
[assembly: MelonGame(ModBuildInfo.GameDeveloper, ModBuildInfo.Game)]
[assembly: MelonOptionalDependencies("UIExpansionKit")]
[assembly: MelonOptionalDependencies("UIExpansionKit", "ActionMenuApi")]
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
Video preview soon.

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

* **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.

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

## Installation
* **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!).**
* Download the [latest version](https://github.com/nitrog0d/TrackingRotator/releases/latest/download/TrackingRotator.dll) of the mod.
* **Install the mod [UIExpansionKit](https://github.com/knah/VRCMods) by [knah](https://github.com/knah), it is required.**
* **Install (at least one is required):**
* [UIExpansionKit](https://github.com/knah/VRCMods) by [knah](https://github.com/knah), or/and
* [ActionMenuApi](https://github.com/gompocp/ActionMenuApi) by [gompo](https://github.com/gompocp).
* Drag/copy the DLL files that you have downloaded into the Mods folder.
* That's it! Now just run the game and the mod should be installed!

Expand Down
11 changes: 10 additions & 1 deletion TrackingRotator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<MelonLoaderPath>C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader</MelonLoaderPath>
<MelonLoaderPath>D:\Jogos\SteamLibrary\steamapps\common\VRChat\MelonLoader</MelonLoaderPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -32,10 +32,15 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Utils\AMAPIManager.cs" />
<Compile Include="TrackingRotatorMod.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\UIXManager.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="ActionMenuApi">
<HintPath>$(MelonLoaderPath)\..\Mods\ActionMenuApi.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>$(MelonLoaderPath)\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
Expand All @@ -51,9 +56,13 @@
<Reference Include="UnhollowerBaseLib">
<HintPath>$(MelonLoaderPath)\Managed\UnhollowerBaseLib.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule">
<HintPath>$(MelonLoaderPath)\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(MelonLoaderPath)\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<EmbeddedResource Include="trackingrotator" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
Expand Down
130 changes: 79 additions & 51 deletions TrackingRotatorMod.cs
Original file line number Diff line number Diff line change
@@ -1,97 +1,125 @@
using MelonLoader;
using UIExpansionKit.API;
using UnityEngine;
using System.Linq;
using UnhollowerRuntimeLib;
using System.Collections;
using TrackingRotator.Utils;
using Il2CppSystem.Reflection;

namespace TrackingRotator {

namespace TrackingRotator
{
public static class ModBuildInfo {
public const string Name = "TrackingRotator";
public const string Author = "nitro.";
public const string Version = "1.0.1";
public const string Author = "Davi & nitro."; // <3
public const string Version = "1.0.2";
public const string DownloadLink = "https://github.com/nitrog0d/TrackingRotator/releases/latest/download/TrackingRotator.dll";
public const string GameDeveloper = "VRChat";
public const string Game = "VRChat";
}

public class TrackingRotatorMod : MelonMod {
public class TrackingRotatorMod : MelonMod
{

private const string ModCategory = "TrackingRotator";
private const string UIXIntegration = "UIXIntegration";
private const string AMAPIIntegration = "AMAPIIntegration";
private const string RotationValuePref = "RotationValue";
private const string HighPrecisionRotationValuePref = "HighPrecisionRotationValue";
private const string ResetRotationOnSceneChangePref = "ResetRotationOnSceneChange";

private static float rotationValue = 0f;
private static float highPrecisionRotationValue = 0f;
private static bool highPrecision = false;
private static bool resetRotationOnSceneChange = false;
private static bool resetRotationOnSceneChange, IsUsingUIX, IsUsingAMAPI = false;
private static bool UIXintegration, AMAPIintegration = true;

private static Transform cameraTransform = null;
private static Quaternion originalRotation;
public static bool highPrecision = false;
public static Transform transform;
public static Transform cameraTransform;
public static Quaternion originalRotation;

public override void OnApplicationStart() {
MelonLogger.Msg("Mod loaded.");
public override void OnApplicationStart()
{
MelonPreferences.CreateCategory(ModCategory, "Tracking Rotator");
MelonPreferences.CreateEntry(ModCategory, UIXIntegration, true, "Integrate with UiExpansionKit?");
MelonPreferences.CreateEntry(ModCategory, AMAPIIntegration, true, "Integrate with Action Menu?");
MelonPreferences.CreateEntry(ModCategory, RotationValuePref, 22.5f, "Rotation value");
MelonPreferences.CreateEntry(ModCategory, HighPrecisionRotationValuePref, 1f, "High precision rotation value");
MelonPreferences.CreateEntry(ModCategory, ResetRotationOnSceneChangePref, false, "Reset rotation when a new world loads");
ExpansionKitApi.GetExpandedMenu(ExpandedMenu.QuickMenu).AddSimpleButton("Tracking rotation", ShowRotationMenu);
OnPreferencesSaved();
}

public override void OnSceneWasLoaded(int buildIndex, string sceneName) {
if (resetRotationOnSceneChange && cameraTransform) cameraTransform.localRotation = originalRotation;
Integrations();

MelonLogger.Msg("Mod loaded.");
}

public override void OnPreferencesSaved() {
public override void OnPreferencesSaved()
{
UIXintegration = MelonPreferences.GetEntryValue<bool>(ModCategory, UIXIntegration);
AMAPIintegration = MelonPreferences.GetEntryValue<bool>(ModCategory, AMAPIIntegration);
rotationValue = MelonPreferences.GetEntryValue<float>(ModCategory, RotationValuePref);
highPrecisionRotationValue = MelonPreferences.GetEntryValue<float>(ModCategory, HighPrecisionRotationValuePref);
resetRotationOnSceneChange = MelonPreferences.GetEntryValue<bool>(ModCategory, ResetRotationOnSceneChangePref);
}

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

private static ICustomShowableLayoutedMenu rotationMenu = null;
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
if (resetRotationOnSceneChange && cameraTransform) cameraTransform.localRotation = originalRotation;
}

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

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

var transform = Camera.main.transform;
if (IsUsingAMAPI) typeof(AMAPIManager).GetMethod("ActionMenuIntegration").Invoke(null, null);
}

rotationMenu.AddSpacer();
rotationMenu.AddSimpleButton("Forward", () => Move(transform.right));
rotationMenu.AddSpacer();
rotationMenu.AddSpacer();
public static void Move(Vector3 direction)
{
cameraTransform.Rotate(direction, highPrecision ? highPrecisionRotationValue : rotationValue, Space.World);
}

rotationMenu.AddSimpleButton("Tilt Left", () => Move(transform.forward));
rotationMenu.AddSimpleButton("Reset", () => cameraTransform.localRotation = originalRotation);
rotationMenu.AddSimpleButton("Tilt Right", () => Move(-transform.forward));
rotationMenu.AddSpacer();
private static void Integrations()
{
if (AMAPIintegration)
{
if (MelonHandler.Mods.Any(x => x.Info.Name.Equals("ActionMenuApi")))
{
Assets.OnApplicationStart();
IsUsingAMAPI = true;
}
else MelonLogger.Warning("For a better experience, please consider using ActionMenuApi.");
}
else MelonLogger.Warning("Integration with ActionMenuApi has been deactivated on Settings.");

if (UIXintegration)
{
if (MelonHandler.Mods.Any(x => x.Info.Name.Equals("UI Expansion Kit")))
{
typeof(UIXManager).GetMethod("OnApplicationStart").Invoke(null, null);
IsUsingUIX = true;
}
else MelonLogger.Warning("For a better experience, please consider using UIExpansionKit.");
}
else MelonLogger.Warning("Integration with UIExpansionKit has been deactivated on Settings.");

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

rotationMenu.AddToggleButton("High precision", b => highPrecision = b, () => highPrecision);
rotationMenu.AddSpacer();
rotationMenu.AddSpacer();
rotationMenu.AddSimpleButton("Back", rotationMenu.Hide);
if (!IsUsingAMAPI && !IsUsingUIX)
{
MelonLogger.Error("Failed to load both integrations with UIExpansionKit and ActionMenuApi! The mod will not be loaded.");
}

rotationMenu.Show();
else MelonCoroutines.Start(WaitForUiInit());
}
}
}
}
80 changes: 80 additions & 0 deletions Utils/AMAPIManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using UnityEngine;
using ActionMenuApi.Api;
using UnhollowerRuntimeLib;
using System.Collections;
using MelonLoader;
using System.IO;
using System.Reflection;
using static TrackingRotator.TrackingRotatorMod;

namespace TrackingRotator.Utils
{
internal static class AMAPIManager
{
public static void ActionMenuIntegration()
{
VRCActionMenuPage.AddSubMenu(ActionMenuPage.Main, "<color=#00a2ff>Tracking Rotator</color>", () =>
{
CustomSubMenu.AddButton("Forward", () => Move(transform.right), Assets.Forward); //X+
CustomSubMenu.AddButton("Backward", () => Move(-transform.right), Assets.Backward); //X-
CustomSubMenu.AddButton("Tilt Left", () => Move(transform.forward), Assets.TLeft); //Z+
CustomSubMenu.AddButton("Tilt Right", () => Move(-transform.forward), Assets.TRight); //Z-
CustomSubMenu.AddButton("Left", () => Move(-transform.up), Assets.Left); //Y-
CustomSubMenu.AddButton("Right", () => Move(transform.up), Assets.Right); //Y+
CustomSubMenu.AddSubMenu("Other", () =>
{
CustomSubMenu.AddButton("Reset", () => cameraTransform.localRotation = originalRotation, Assets.Reset);
CustomSubMenu.AddToggle("High precision", highPrecision, b => highPrecision = b, Assets.HP);
}, Assets.Other);
}, Assets.Main);
}
}

// The code below was based on Lily's...
// https://github.com/KortyBoi/VRChat-TeleporterVR/blob/main/Utils/ResourceManager.cs
// And also knah's!
// https://github.com/knah/VRCMods/blob/master/UIExpansionKit
internal static class Assets
{
private static AssetBundle Bundle;
public static Texture2D Main, Forward, Backward, TLeft, TRight, Left, Right, Other, Reset, HP;

public static void OnApplicationStart() { MelonCoroutines.Start(LoadAssets()); }

private static IEnumerator LoadAssets()
{
try
{
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TrackingRotator.trackingrotator"))
{
using (var memoryStream = new MemoryStream((int)stream.Length))
{
stream.CopyTo(memoryStream);
Bundle = AssetBundle.LoadFromMemory_Internal(memoryStream.ToArray(), 0);
Bundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;
try { Main = LoadTexture("Main.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Main.png"); }
try { Forward = LoadTexture("Forward.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Forward.png"); }
try { Backward = LoadTexture("Backward.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Backward.png"); }
try { TLeft = LoadTexture("TLeft.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: TLeft.png"); }
try { TRight = LoadTexture("TRight.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: TRight.png"); }
try { Left = LoadTexture("Left.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Left.png"); }
try { Right = LoadTexture("Right.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Right.png"); }
try { Other = LoadTexture("Other.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Other.png"); }
try { Reset = LoadTexture("Reset.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: Reset.png"); }
try { HP = LoadTexture("HP.png"); } catch { MelonLogger.Error("Failed to load image from asset bundle: HP.png"); }
}
}
} catch { MelonLogger.Warning("Failed to load AssetBundle! ActionMenuApi will have its icons completely broken."); }
yield break;
}

private static Texture2D LoadTexture(string Texture)
{
Texture2D Texture2 = Bundle.LoadAsset_Internal(Texture, Il2CppType.Of<Texture2D>()).Cast<Texture2D>();
Texture2.hideFlags |= HideFlags.DontUnloadUnusedAsset;
Texture2.hideFlags = HideFlags.HideAndDontSave;
return Texture2;
}
}
}
Loading

0 comments on commit dd06322

Please sign in to comment.