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

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArion authored Mar 11, 2021
1 parent 05b20e8 commit 1a809d5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 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.2";
internal const string Version = "1.4.3";

internal const string Description = "";

Expand Down
15 changes: 12 additions & 3 deletions Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ internal static float userVolumePeak
}
}
}
internal static bool isInstantiated => CurrentUser != null && IsInWorld && uInstance != null;

internal static bool isInstantiated
{
get
{
if (CurrentUser == null || !IsInWorld) return false;
return uInstance != null; // Im guessing having it complete the check above ^ first, prevents uInstance from throwing a null ref at the CurrentUser level and checks if uspeaker is present.
}
}
internal static IEnumerator WorldJoinedCoroutine()
{
for (;;)
Expand All @@ -67,7 +75,8 @@ internal static IEnumerator WorldJoinedCoroutine()
{
yield return new WaitForSeconds(1);
{
SensitivitySetup();
if (!UseMod) yield break;
userVolumeThreshold = SensitivityValue; userVolumePeak = SensitivityValue * 2;
}
sw.Stop();
yield break;
Expand All @@ -78,7 +87,7 @@ internal static IEnumerator WorldJoinedCoroutine()
MelonLogger.Warning("WorldJoinedCoroutine took too long and was stopped.");
yield break;
}
yield return new WaitForSeconds(1);
yield return new WaitForSeconds(1); // IEnumerator Speed Control
}
}
private static Il2CppSystem.Object FindInstance(Type WhereLooking, Type WhatLooking) // Credits to Teo
Expand Down
22 changes: 10 additions & 12 deletions MicSensitivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,23 @@ public override void OnSceneWasLoaded(int buildIndex, string sceneName) // World
public override void OnPreferencesSaved()
{
InternalConfigRefresh();
SensitivitySetup();
if (UseMod) return;
userVolumeThreshold = DefaultPeak; //Defaulted if Mod is not used.
userVolumePeak = DefaultThreshold; //Defaulted if Mod is not used.
if (UseMod && isInstantiated)
{
userVolumeThreshold = SensitivityValue; userVolumePeak = SensitivityValue * 2;
}
else if (!UseMod && isInstantiated) // This is most likely due to the need to update to 1.4.3, People who don't use the Mod get a null ref if another mod calls the method.
{
userVolumeThreshold = DefaultPeak; //Defaulted if Mod is not used.
userVolumePeak = DefaultThreshold; //Defaulted if Mod is not used.
}
}

#endregion
#region The Actual Mod
internal static bool UseMod;
internal static bool UseMod = false;
internal static float SensitivityValue = 0;
private const float DefaultThreshold = 0.01f;
private const float DefaultPeak = 0.02f;

internal static void SensitivitySetup()
{
if (!UseMod) return;
if (!isInstantiated) return;
userVolumeThreshold = SensitivityValue; userVolumePeak = SensitivityValue * 2;
}
#endregion
}
}

0 comments on commit 1a809d5

Please sign in to comment.