using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("FlashlightAngleFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+33c1a048af9063aa6c469eed976d1de333b561cb")]
[assembly: AssemblyProduct("Fix your angles")]
[assembly: AssemblyTitle("FlashlightAngleFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[BepInPlugin("com.oworope.flashlightanglefix", "FlashlightAngleFix", "1.0.0")]
public class FlashlightAngleFixPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(CL_Lamp), "Awake")]
private static class CLLampAwakePatch
{
private static void Postfix(CL_Lamp __instance)
{
if (((Object)((Component)__instance).gameObject).name.Contains("Headlamp_Lamp"))
{
__instance.angle = HeadlampAngle.Value;
}
else
{
__instance.angle = FlashlightAngle.Value;
}
}
}
[HarmonyPatch(typeof(Item_Object_Flashlight), "Start")]
private static class FlashlightStartPatch
{
private static void Postfix(Item_Object_Flashlight __instance)
{
if ((Object)(object)__instance.lamp != (Object)null)
{
__instance.lamp.angle = FlashlightAngle.Value;
}
}
}
public static FlashlightAngleFixPlugin Instance { get; private set; }
public static ConfigEntry<float> HeadlampAngle { get; private set; }
public static ConfigEntry<float> FlashlightAngle { get; private set; }
private void Awake()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
HeadlampAngle = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Headlamp Angle", 300f, new ConfigDescription("Target angle for the Headlamp_Lamp object.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 360f), Array.Empty<object>()));
FlashlightAngle = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Flashlight Angle", 300f, new ConfigDescription("Target angle for all flashlights.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 360f), Array.Empty<object>()));
new Harmony("com.oworope.flashlightanglefix").PatchAll();
((MonoBehaviour)this).StartCoroutine(EnforceAnglesLoop());
HeadlampAngle.SettingChanged += delegate
{
ApplyAngles();
};
FlashlightAngle.SettingChanged += delegate
{
ApplyAngles();
};
((BaseUnityPlugin)this).Logger.LogInfo((object)"FlashlightAngleFix loaded! Press F1 to open ConfigurationManager.");
}
private IEnumerator EnforceAnglesLoop()
{
while (true)
{
ApplyAngles();
yield return (object)new WaitForSeconds(1f);
}
}
private void ApplyAngles()
{
CL_Lamp[] array = Object.FindObjectsOfType<CL_Lamp>(true);
if (array.Length == 0)
{
return;
}
CL_Lamp[] array2 = array;
foreach (CL_Lamp val in array2)
{
if (!((Object)(object)val == (Object)null))
{
float num = (((Object)((Component)val).gameObject).name.Contains("Headlamp_Lamp") ? HeadlampAngle.Value : FlashlightAngle.Value);
if (Mathf.Abs(val.angle - num) > 0.01f)
{
val.angle = num;
}
}
}
}
}
namespace FlashlightAngleFix
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "FlashlightAngleFix";
public const string PLUGIN_NAME = "Fix your angles";
public const string PLUGIN_VERSION = "1.0.1";
}
}