using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityStandardAssets.ImageEffects;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LittleThings")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LittleThings")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6b716e1f-7543-4ea4-8732-6179e3408e0c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace LittleThings
{
[BepInPlugin("Distance.LittleThings", "Little Things", "4.1")]
public sealed class Mod : BaseUnityPlugin
{
private const string modGUID = "Distance.LittleThings";
private const string modName = "Little Things";
private const string modVersion = "4.1";
public static string ActiveCompassKey = "Permanent Compass";
public static string EnableLowpassKey = "Enable Custom Lowpass Filter";
public static string EnableGPSKey = "Enable GPS in Arcade";
public static string EnableHeadLightsKey = "Enables Headlights";
public static string EnableQuarantineKey = "Enables Quarantine Zones in Arcade";
private static readonly Harmony harmony = new Harmony("Distance.LittleThings");
public static ManualLogSource Log = new ManualLogSource("Little Things");
public static Mod Instance;
public static ConfigEntry<bool> ActiveCompass { get; set; }
public static ConfigEntry<bool> EnableCustomLowpass { get; set; }
public static ConfigEntry<bool> EnableGPSInArcade { get; set; }
public static ConfigEntry<bool> EnableHeadLights { get; set; }
public static ConfigEntry<bool> EnableQuarantineInArcade { get; set; }
public AudioManager audioManager { get; set; }
private void Awake()
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Expected O, but got Unknown
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Expected O, but got Unknown
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
Log = Logger.CreateLogSource("Distance.LittleThings");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Thanks for using Little Things!");
ActiveCompass = ((BaseUnityPlugin)this).Config.Bind<bool>("General", ActiveCompassKey, false, new ConfigDescription("The compass will always stay active on the carscreen and never change", (AcceptableValueBase)null, new object[0]));
EnableCustomLowpass = ((BaseUnityPlugin)this).Config.Bind<bool>("General", EnableLowpassKey, false, new ConfigDescription("Toggles whether or not lowpass filters get applied to custom music.", (AcceptableValueBase)null, new object[0]));
EnableGPSInArcade = ((BaseUnityPlugin)this).Config.Bind<bool>("General", EnableGPSKey, false, new ConfigDescription("Toggles whether Minimap will become available to use in Arcade Mode. (GPS Triggers will also activate in arcade)", (AcceptableValueBase)null, new object[0]));
EnableHeadLights = ((BaseUnityPlugin)this).Config.Bind<bool>("General", EnableHeadLightsKey, false, new ConfigDescription("Toggles whether head lights are always active on the car, just like the Beta days!", (AcceptableValueBase)null, new object[0]));
EnableQuarantineInArcade = ((BaseUnityPlugin)this).Config.Bind<bool>("General", EnableQuarantineKey, false, new ConfigDescription("Toggles whether Quarantine zones will activate in arcade mode", (AcceptableValueBase)null, new object[0]));
ActiveCompass.SettingChanged += OnConfigChanged;
EnableCustomLowpass.SettingChanged += OnConfigChanged;
EnableGPSInArcade.SettingChanged += OnConfigChanged;
EnableHeadLights.SettingChanged += OnConfigChanged;
EnableQuarantineInArcade.SettingChanged += OnConfigChanged;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading...");
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded!");
}
private void OnConfigChanged(object sender, EventArgs e)
{
SettingChangedEventArgs val = (SettingChangedEventArgs)(object)((e is SettingChangedEventArgs) ? e : null);
if (val != null)
{
}
}
public IEnumerator CustomMusicDSP(float lowpassEnd, float timer)
{
if (!((Object)(object)audioManager == (Object)null) && audioManager.sampleAggregator_ != null && audioManager.audioSettings_.AffectedByGameplay_ && !GUtils.ApproxEquals(audioManager.lowPassFreq_, lowpassEnd))
{
float startLowFreq = (float)Math.Log10(audioManager.lowPassFreq_);
float endLowFreq = (float)Math.Log10(lowpassEnd);
float time = 0f;
while (time < timer)
{
audioManager.lowPassFreq_ = (float)Math.Pow(10.0, Mathf.Lerp(startLowFreq, endLowFreq, time / timer));
audioManager.SetCustomMusicDSP(audioManager.lowPassFreq_, audioManager.highPassFreq_, false);
time += Time.deltaTime;
yield return null;
}
audioManager.SetCustomMusicDSP((float)Math.Pow(10.0, endLowFreq), -1f, false);
}
}
public IEnumerator EMPCusmtomMusicDSP()
{
if (!((Object)(object)audioManager == (Object)null) && audioManager.sampleAggregator_ != null && audioManager.audioSettings_.AffectedByGameplay_)
{
float startLowFreq = (float)Math.Log10(audioManager.lowPassFreq_);
float midLowFreq = (float)Math.Log10(0.01);
float time1 = 0f;
float time2 = 0f;
while (time1 < 0.5f)
{
audioManager.lowPassFreq_ = (float)Math.Pow(10.0, Mathf.Lerp(startLowFreq, midLowFreq, time1 / 0.5f));
audioManager.SetCustomMusicDSP(audioManager.lowPassFreq_, audioManager.highPassFreq_, false);
time1 += Time.deltaTime;
yield return null;
}
while (time2 < 2f)
{
audioManager.lowPassFreq_ = (float)Math.Pow(10.0, Mathf.Lerp(midLowFreq, 22000f, time2 / 2f));
audioManager.SetCustomMusicDSP(audioManager.lowPassFreq_, audioManager.highPassFreq_, false);
time2 += Time.deltaTime;
yield return null;
}
audioManager.SetCustomMusicDSP((float)Math.Pow(10.0, 22000.0), -1f, false);
}
}
}
}
namespace LittleThings.Patches
{
[HarmonyPatch(typeof(AudioManager), "PostEvent", new Type[] { typeof(string) })]
internal class AudioManager__PostEvent1
{
[HarmonyPostfix]
internal static void CheckCustomDSP(string eventName)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Invalid comparison between Unknown and I4
if (!Mod.EnableCustomLowpass.Value || !((Object)(object)Mod.Instance.audioManager != (Object)null))
{
return;
}
AudioManager audioManager = Mod.Instance.audioManager;
if ((int)audioManager.currentMusicState_ != 1)
{
return;
}
if (eventName == "Set_Master_Low_Pass_Fade_In")
{
if (audioManager.customMusicLowPass_ != null)
{
((MonoBehaviour)audioManager).StopCoroutine(audioManager.customMusicLowPass_);
}
audioManager.customMusicLowPass_ = ((MonoBehaviour)audioManager).StartCoroutine(Mod.Instance.EMPCusmtomMusicDSP());
}
else if (eventName == "Set_Car_Low_Pass_Filter_Off")
{
if (audioManager.customMusicLowPass_ != null)
{
((MonoBehaviour)audioManager).StopCoroutine(audioManager.customMusicLowPass_);
}
audioManager.SetCustomMusicDSP(22000f, 30f, false);
}
}
}
[HarmonyPatch(typeof(AudioManager), "PostEvent", new Type[]
{
typeof(string),
typeof(GameObject)
})]
internal class AudioManager__PostEvent2
{
[HarmonyPostfix]
internal static void CheckCustomDSP(string eventName)
{
}
}
[HarmonyPatch(typeof(AudioManager), "SetCustomMusicDSP", new Type[]
{
typeof(float),
typeof(float),
typeof(bool)
})]
internal class AudioManaher__SetCustomMusicDSP
{
[HarmonyPostfix]
internal static void CheckingIfItIsCalled(float lowPassFreq, float highPassFreq, bool forceUpdate)
{
}
}
[HarmonyPatch(typeof(AudioManager), "SetRTPCValue", new Type[]
{
typeof(string),
typeof(float)
})]
internal class AudioManager__SetRTPCValue
{
[HarmonyPostfix]
internal static void AdjustCustomRTPC(string rtpcName, float value)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Invalid comparison between Unknown and I4
if (!Mod.EnableCustomLowpass.Value || !((Object)(object)Mod.Instance.audioManager != (Object)null))
{
return;
}
AudioManager audioManager = Mod.Instance.audioManager;
if ((int)audioManager.currentMusicState_ != 1 || !(rtpcName == "TunnelHorror"))
{
return;
}
if (value != 0f)
{
audioManager.SetCustomMusicDSP(22000f / (float)Math.Pow(10.0, value), 30f, false);
return;
}
if (audioManager.customMusicLowPass_ != null)
{
((MonoBehaviour)audioManager).StopCoroutine(audioManager.customMusicLowPass_);
}
audioManager.customMusicLowPass_ = ((MonoBehaviour)audioManager).StartCoroutine(Mod.Instance.CustomMusicDSP(22000f, 0.75f));
}
}
[HarmonyPatch(typeof(AudioManager), "SetState", new Type[]
{
typeof(string),
typeof(string)
})]
internal class AudioManager__SetState
{
[HarmonyPostfix]
internal static void CustomAudioCheck(string stateGroup, string state)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Invalid comparison between Unknown and I4
if (!Mod.EnableCustomLowpass.Value || !((Object)(object)Mod.Instance.audioManager != (Object)null))
{
return;
}
AudioManager audioManager = Mod.Instance.audioManager;
if ((int)audioManager.currentMusicState_ != 1)
{
return;
}
if (state == "Under_Water")
{
if (audioManager.customMusicLowPass_ != null)
{
((MonoBehaviour)audioManager).StopCoroutine(audioManager.customMusicLowPass_);
}
audioManager.customMusicLowPass_ = ((MonoBehaviour)audioManager).StartCoroutine(Mod.Instance.CustomMusicDSP(230f, 0.75f));
return;
}
if (state == "NoGravity")
{
if (audioManager.customMusicLowPass_ != null)
{
((MonoBehaviour)audioManager).StopCoroutine(audioManager.customMusicLowPass_);
}
audioManager.customMusicLowPass_ = ((MonoBehaviour)audioManager).StartCoroutine(Mod.Instance.CustomMusicDSP(2000f, 0.75f));
}
if (state == "Normal" && (stateGroup == "Water_States" || stateGroup == "GravityLowPass"))
{
if (audioManager.customMusicLowPass_ != null)
{
((MonoBehaviour)audioManager).StopCoroutine(audioManager.customMusicLowPass_);
}
audioManager.customMusicLowPass_ = ((MonoBehaviour)audioManager).StartCoroutine(Mod.Instance.CustomMusicDSP(22000f, 0.75f));
}
}
}
[HarmonyPatch(typeof(AudioManager), "Update")]
internal class AudioManager__Update
{
[HarmonyPostfix]
internal static void LiterallyJustGettingTheAudioManager(AudioManager __instance)
{
Mod.Instance.audioManager = __instance;
}
}
[HarmonyPatch(typeof(CarScreenLogic), "OnEventGo")]
internal class CarScreenLogic__OnEventGo
{
[HarmonyPrefix]
internal static bool DisablePlacementText(CarScreenLogic __instance)
{
if (Mod.ActiveCompass.Value)
{
__instance.ModeWidgetVisible_ = true;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(CarScreenLogic), "UpdateBeforeRender")]
internal class CarScreenLogic__UpdateBeforeRender
{
[HarmonyPostfix]
internal static void KeepCompassActive(CarScreenLogic __instance)
{
if (Mod.ActiveCompass.Value)
{
__instance.SetCurrentModeVisual(__instance.compass_);
}
}
}
[HarmonyPatch(typeof(GPSTrigger), "Start")]
internal class GPSTrigger__Start
{
[HarmonyPrefix]
internal static bool GPSCheck()
{
if (Mod.EnableGPSInArcade.Value)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(LocalPlayerControlledCar), "CheckInput")]
internal class LocalPlayerControlledCar__CheckInput
{
[HarmonyPrefix]
internal static bool GPSCheck(LocalPlayerControlledCar __instance, InputStates inputStates, float dt)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Unknown result type (might be due to invalid IL or missing references)
//IL_0393: Unknown result type (might be due to invalid IL or missing references)
//IL_039a: Invalid comparison between Unknown and I4
if (Mod.EnableGPSInArcade.Value)
{
if ((Object)(object)__instance.playerDataLocal_ == (Object)null || !__instance.playerDataLocal_.CarInputEnabled_)
{
return false;
}
CarDirectives carDirectives_ = __instance.carLogic_.CarDirectives_;
carDirectives_.ZeroThis();
float num = (carDirectives_.Gas_ = inputStates.GetState((InputAction)0).value_);
if (__instance.BoostEnabled_)
{
InputState state = inputStates.GetState((InputAction)4);
bool invertBoost_ = __instance.playerDataLocal_.Profile_.InvertBoost_;
float num2 = ((!invertBoost_) ? state.value_ : (1f - state.value_));
bool boost_ = ((!invertBoost_) ? state.isPressed_ : (!state.isPressed_));
if ((double)num > 0.0 && (double)num == (double)num2)
{
carDirectives_.Gas_ = Mathf.Min(num * 2f, 1f);
carDirectives_.Boost_ = (double)num2 > 0.899999976158142;
}
else
{
carDirectives_.Boost_ = boost_;
if (carDirectives_.Boost_)
{
carDirectives_.Gas_ = 1f;
}
}
}
carDirectives_.Brake_ = inputStates.GetState((InputAction)1).value_;
if (!__instance.WingsActive_ && __instance.JetsEnabled_)
{
carDirectives_.Yaw_ = 0f;
if (inputStates.GetState((InputAction)18).isPressed_)
{
carDirectives_.Grip_ = true;
}
if (carDirectives_.Grip_ || (__instance.carStats_.WheelsContacting_ == 0 && !__instance.JumpPossible_))
{
carDirectives_.Pitch_ = inputStates.GetDualAxis((InputActionPair)21);
carDirectives_.Roll_ = inputStates.GetDualAxis((InputActionPair)19);
if ((inputStates.GetPressed((InputAction)19) && inputStates.GetPressed((InputAction)20)) || (inputStates.GetPressed((InputAction)21) && inputStates.GetPressed((InputAction)22)))
{
carDirectives_.Grip_ = true;
}
}
carDirectives_.Pitch_ += inputStates.GetDualAxis((InputActionPair)16);
carDirectives_.Roll_ += inputStates.GetDualAxis((InputActionPair)14);
if ((inputStates.GetPressed((InputAction)14) && inputStates.GetPressed((InputAction)15)) || (inputStates.GetPressed((InputAction)16) && inputStates.GetPressed((InputAction)17)))
{
carDirectives_.Grip_ = true;
}
float num3 = MathEx.Sq(carDirectives_.Pitch_) + MathEx.Sq(carDirectives_.Roll_);
if ((double)num3 > 1.0)
{
float num4 = 1f / Mathf.Sqrt(num3);
carDirectives_.Pitch_ *= num4;
carDirectives_.Roll_ *= num4;
}
}
float num5 = __instance.playerDataLocal_.Profile_.TurningSensitivity_ + 0.5f;
carDirectives_.Steer_ = inputStates.GetDualAxis((InputActionPair)2) * num5;
if (!__instance.ignoreSteeringAdjustments_)
{
carDirectives_.Steer_ *= __instance.CalcVelocityBasedSteeringMultiplier();
}
if (__instance.playerDataLocal_.EnableShowScores_ && inputStates.GetState((InputAction)25).isPressed_ && __instance.gameMan_.IsModeCreated_)
{
__instance.ShowPlacementText();
if ((Object)(object)((PlayerDataBase)__instance.playerDataLocal_).CarScreenLogic_ != (Object)null)
{
((PlayerDataBase)__instance.playerDataLocal_).CarScreenLogic_.ShowMinimap((MinimapMode)0, 0f, true, 0f, (int)G.Sys.GameManager_.ModeID_ == 15);
}
}
__instance.UpdateGasBrake(dt);
if (!__instance.gameMan_.SoloAndNotOnline_)
{
return false;
}
if (inputStates.GetPressed((InputAction)24))
{
__instance.resetHoldTimer_ += dt;
if ((double)__instance.resetHoldTimer_ <= (double)__instance.resetHoldTime_)
{
return false;
}
__instance.gameMan_.RestartLevel();
}
else
{
__instance.resetHoldTimer_ = 0f;
}
return false;
}
return true;
}
}
[HarmonyPatch(typeof(LocalPlayerControlledCar), "Start")]
internal class LocalPlayerControlledCar__Start
{
[HarmonyPostfix]
internal static void HeadlightsCheck(LocalPlayerControlledCar __instance)
{
if (Mod.EnableHeadLights.Value)
{
__instance.carLogic_.carVisuals_.SetHeadlightsValues(1f, 100f, 150f, 0.5f, false);
}
}
}
[HarmonyPatch(typeof(QuarantineTrigger), "Start")]
internal class QuarantineTrigger__Start
{
[HarmonyPrefix]
internal static bool StartRewrite(QuarantineTrigger __instance)
{
if (Mod.EnableQuarantineInArcade.Value)
{
Bloom componentInChildren = ((Component)__instance.cameraPrefab_).GetComponentInChildren<Bloom>();
if ((Object)(object)componentInChildren == (Object)null)
{
return false;
}
__instance.originalBloomIntensity_ = componentInChildren.bloomIntensity;
return false;
}
return true;
}
}
}