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

Commit

Permalink
Rare case bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Arion-Kun authored and Arion-Kun committed Feb 23, 2021
1 parent 3bfac69 commit e7d061e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class AssemblyInfo
{
internal const string Name = "MicSensitivity";

internal const string Version = "1.4";
internal const string Version = "1.4.1";

internal const string Description = "";

Expand Down
13 changes: 7 additions & 6 deletions Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace Dawn
{
internal static class Core
{
internal static ApiWorld currentRoom => FindInstance(typeof(RoomManager), typeof(ApiWorld)).TryCast<ApiWorld>();
private static ApiWorld currentRoom => FindInstance(typeof(RoomManager), typeof(ApiWorld)).TryCast<ApiWorld>();

internal static ApiWorldInstance currentWorldInstance => FindInstance(typeof(RoomManager), typeof(ApiWorldInstance)).TryCast<ApiWorldInstance>();
private static ApiWorldInstance currentWorldInstance => FindInstance(typeof(RoomManager), typeof(ApiWorldInstance)).TryCast<ApiWorldInstance>();

internal static bool IsInWorld => currentRoom != null || currentWorldInstance != null;
private static bool IsInWorld => currentRoom != null || currentWorldInstance != null;
private static float infoIndex;
internal static float userVolumeThreshold
{
Expand Down Expand Up @@ -65,6 +65,7 @@ internal static IEnumerator WorldJoinedCoroutine()
{
yield return new WaitForSeconds(1);
{
if (uInstance == null) yield return new WaitForSeconds(1); // 1 Extra check for the rare case scenario that uInstance is not set up fast enough from CurrentUser -> uInstance.
SensitivitySetup();
}
sw.Stop();
Expand All @@ -79,7 +80,7 @@ internal static IEnumerator WorldJoinedCoroutine()
yield return new WaitForSeconds(1);
}
}
internal static Il2CppSystem.Object FindInstance(Type WhereLooking, Type WhatLooking) // Credits to Teo
private static Il2CppSystem.Object FindInstance(Type WhereLooking, Type WhatLooking) // Credits to Teo
{
try
{
Expand All @@ -106,7 +107,7 @@ private static PropertyInfo GetInfo(string originalValue)

private static PropertyInfo VolumePeakInfo;
private static PropertyInfo VolumeThreasholdInfo;
internal static USpeaker uInstance => CurrentUser.field_Private_USpeaker_0;
private static USpeaker uInstance => CurrentUser.field_Private_USpeaker_0;
internal static void InternalConfigRefresh() //The Divide by 10k sets it back to a managable float number
{
SensitivityValue = MelonPreferences.GetEntryValue<float>("MicSensitivity", "Mic - Microphone Sensitivity") / 10000;
Expand All @@ -127,7 +128,7 @@ internal static void Log(object obj)
/// <summary>
/// Returns the Current User aka the Player object.
/// </summary>
internal static VRCPlayer CurrentUser
private static VRCPlayer CurrentUser
{
get
{
Expand Down
6 changes: 3 additions & 3 deletions MicSensitivity.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Harmony;
using MelonLoader;
using MelonLoader;
using static Dawn.Core;

namespace Dawn.Mic
{
internal class MicSensitivity : MelonMod
internal sealed class MicSensitivity : MelonMod
{
#region MelonMod Native
public override void OnApplicationStart()
Expand All @@ -15,6 +14,7 @@ public override void OnApplicationStart()
InternalConfigRefresh();
} //Settings Registration and Refresh


public override void OnSceneWasLoaded(int buildIndex, string sceneName) // World Join
{
switch (buildIndex) //Prevents being called 3x
Expand Down

0 comments on commit e7d061e

Please sign in to comment.