using System;
using System.Collections;
using System.Collections.Generic;
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 PxntxrezStudio.RepoFlashlightRework;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("PxntxrezStudio")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Flashlight Rework")]
[assembly: AssemblyTitle("Flashlight Rework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.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("PxntxrezStudio.RepoFlashlightRework", "REPO Flashlight Rework", "1.2.0")]
public class FlashlightReworkPlugin : BaseUnityPlugin
{
private Harmony _harmony;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
FlashlightConfig.Init(((BaseUnityPlugin)this).Config);
_harmony = new Harmony("PxntxrezStudio.RepoFlashlightRework");
_harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
}
[HarmonyPatch(typeof(FlashlightController), "Hidden")]
internal static class Patch_FlashlightController_Hidden
{
private static bool Prefix(FlashlightController __instance)
{
return !__instance.PlayerAvatar.isLocal;
}
}
[HarmonyPatch(typeof(FlashlightController), "Idle")]
internal static class Patch_FlashlightController_Idle
{
private static bool Prefix(FlashlightController __instance)
{
if (__instance.PlayerAvatar.isLocal && __instance.LightActive && (__instance.PlayerAvatar.isCrouching || __instance.PlayerAvatar.isTumbling || __instance.PlayerAvatar.isSliding))
{
return false;
}
return true;
}
}
public static class Patch_FlashlightController_Start
{
[HarmonyPatch(typeof(FlashlightController), "Start")]
public static class Patch
{
public static void Postfix(FlashlightController __instance)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (__instance.PlayerAvatar.isLocal)
{
if (!originalColors.ContainsKey(__instance))
{
originalColors[__instance] = __instance.spotlight.color;
}
TryStartFlicker(__instance);
}
}
}
[CompilerGenerated]
private sealed class <FlickerCoroutine>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public FlashlightController flashlight;
private int <flicks>5__2;
private int <i>5__3;
private float <totalTime>5__4;
private float <timer>5__5;
private float <wait>5__6;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FlickerCoroutine>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Expected O, but got Unknown
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Expected O, but got Unknown
//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
//IL_03cd: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Expected O, but got Unknown
//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
//IL_04d7: Expected O, but got Unknown
//IL_051c: Unknown result type (might be due to invalid IL or missing references)
//IL_0526: Expected O, but got Unknown
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_0377: Unknown result type (might be due to invalid IL or missing references)
//IL_0381: Expected O, but got Unknown
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Expected O, but got Unknown
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Expected O, but got Unknown
//IL_0420: Unknown result type (might be due to invalid IL or missing references)
//IL_042a: Expected O, but got Unknown
Collider[] array;
float num;
bool flag;
Collider[] array2;
float num3;
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0046;
case 1:
<>1__state = -1;
goto IL_0046;
case 2:
<>1__state = -1;
goto IL_0046;
case 3:
<>1__state = -1;
((Behaviour)flashlight.spotlight).enabled = true;
flashlight.halo.enabled = true;
goto IL_022a;
case 4:
<>1__state = -1;
goto IL_0046;
case 5:
<>1__state = -1;
((Behaviour)flashlight.spotlight).enabled = true;
flashlight.halo.enabled = true;
<>2__current = (object)new WaitForSeconds(Random.Range(0.04f, 0.12f));
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
<i>5__3++;
goto IL_0328;
case 7:
<>1__state = -1;
((Behaviour)flashlight.spotlight).enabled = true;
flashlight.halo.enabled = true;
goto IL_03b3;
case 8:
<>1__state = -1;
goto IL_0046;
case 9:
<>1__state = -1;
((Behaviour)flashlight.spotlight).enabled = true;
flashlight.halo.enabled = true;
goto IL_045d;
case 10:
<>1__state = -1;
<timer>5__5 += <wait>5__6;
break;
case 11:
{
<>1__state = -1;
goto IL_0046;
}
IL_0046:
if (!FlashlightConfig.EnableFlicker.Value || !flashlight.LightActive)
{
((Behaviour)flashlight.spotlight).enabled = flashlight.LightActive;
flashlight.halo.enabled = flashlight.LightActive;
<>2__current = (object)new WaitForSeconds(0.2f);
<>1__state = 1;
return true;
}
array = Physics.OverlapSphere(((Component)flashlight).transform.position, 15f);
num = 15f;
flag = false;
array2 = array;
foreach (Collider val in array2)
{
EnemyChecklist componentInParent = ((Component)val).GetComponentInParent<EnemyChecklist>();
if ((Object)(object)componentInParent != (Object)null)
{
float num2 = Vector3.Distance(((Component)flashlight).transform.position, ((Component)val).transform.position);
if (num2 < num)
{
num = num2;
flag = true;
}
}
}
if (!flag)
{
if (!((Behaviour)flashlight.spotlight).enabled)
{
((Behaviour)flashlight.spotlight).enabled = true;
flashlight.halo.enabled = true;
}
<>2__current = (object)new WaitForSeconds(0.3f);
<>1__state = 2;
return true;
}
num3 = Mathf.Clamp01((15f - num) / 15f);
if (num3 < 0.3f)
{
if (Random.value < num3)
{
((Behaviour)flashlight.spotlight).enabled = false;
flashlight.halo.enabled = false;
<>2__current = (object)new WaitForSeconds(Random.Range(0.05f, 0.1f));
<>1__state = 3;
return true;
}
goto IL_022a;
}
if (num3 < 0.7f)
{
<flicks>5__2 = Random.Range(3, 6);
<i>5__3 = 0;
goto IL_0328;
}
if (Random.value < 0.6f)
{
((Behaviour)flashlight.spotlight).enabled = false;
flashlight.halo.enabled = false;
<>2__current = (object)new WaitForSeconds(Random.Range(1.5f, 3f));
<>1__state = 9;
return true;
}
goto IL_045d;
IL_0328:
if (<i>5__3 < <flicks>5__2)
{
((Behaviour)flashlight.spotlight).enabled = false;
flashlight.halo.enabled = false;
<>2__current = (object)new WaitForSeconds(Random.Range(0.03f, 0.07f));
<>1__state = 5;
return true;
}
if (Random.value < 0.3f)
{
((Behaviour)flashlight.spotlight).enabled = false;
flashlight.halo.enabled = false;
<>2__current = (object)new WaitForSeconds(Random.Range(0.8f, 1.4f));
<>1__state = 7;
return true;
}
goto IL_03b3;
IL_045d:
<totalTime>5__4 = Random.Range(1.2f, 2.5f);
<timer>5__5 = 0f;
break;
IL_03b3:
<>2__current = (object)new WaitForSeconds(Random.Range(0.1f, 0.25f));
<>1__state = 8;
return true;
IL_022a:
<>2__current = (object)new WaitForSeconds(Random.Range(0.15f, 0.25f));
<>1__state = 4;
return true;
}
if (<timer>5__5 < <totalTime>5__4)
{
bool enabled = Random.value > 0.2f;
((Behaviour)flashlight.spotlight).enabled = enabled;
flashlight.halo.enabled = enabled;
<wait>5__6 = Random.Range(0.015f, 0.07f);
<>2__current = (object)new WaitForSeconds(<wait>5__6);
<>1__state = 10;
return true;
}
<>2__current = (object)new WaitForSeconds(Random.Range(0.05f, 0.2f));
<>1__state = 11;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static readonly Dictionary<FlashlightController, Color> originalColors = new Dictionary<FlashlightController, Color>();
private static readonly Dictionary<FlashlightController, Coroutine> activeFlickers = new Dictionary<FlashlightController, Coroutine>();
public static void TryStartFlicker(FlashlightController flashlight)
{
if (!FlashlightConfig.EnableFlicker.Value)
{
StopFlicker(flashlight);
}
else if (!activeFlickers.ContainsKey(flashlight))
{
Coroutine value = ((MonoBehaviour)flashlight).StartCoroutine(FlickerCoroutine(flashlight));
activeFlickers[flashlight] = value;
}
}
public static void StopFlicker(FlashlightController flashlight)
{
if (activeFlickers.TryGetValue(flashlight, out Coroutine value))
{
((MonoBehaviour)flashlight).StopCoroutine(value);
activeFlickers.Remove(flashlight);
}
if (!flashlight.LightActive)
{
((Behaviour)flashlight.spotlight).enabled = false;
flashlight.halo.enabled = false;
}
else
{
((Behaviour)flashlight.spotlight).enabled = true;
flashlight.halo.enabled = true;
}
}
[IteratorStateMachine(typeof(<FlickerCoroutine>d__5))]
public static IEnumerator FlickerCoroutine(FlashlightController flashlight)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FlickerCoroutine>d__5(0)
{
flashlight = flashlight
};
}
public static void OnFlickerSettingChanged()
{
FlashlightController[] array = Object.FindObjectsOfType<FlashlightController>();
foreach (FlashlightController val in array)
{
if (val.PlayerAvatar.isLocal)
{
if (FlashlightConfig.EnableFlicker.Value)
{
TryStartFlicker(val);
}
else
{
StopFlicker(val);
}
}
}
}
}
[HarmonyPatch(typeof(FlashlightController), "Update")]
internal static class Patch_FlashlightController_Update
{
private static readonly FieldInfo fiCurrentState = AccessTools.Field(typeof(FlashlightController), "currentState");
private static readonly FieldInfo fiStateTimer = AccessTools.Field(typeof(FlashlightController), "stateTimer");
private static readonly FieldInfo fiIntroRotLerp = AccessTools.Field(typeof(FlashlightController), "introRotLerp");
private static readonly FieldInfo fiIntroYLerp = AccessTools.Field(typeof(FlashlightController), "introYLerp");
private static readonly FieldInfo fiClick = AccessTools.Field(typeof(FlashlightController), "click");
private static readonly Dictionary<FlashlightController, float> lastToggle = new Dictionary<FlashlightController, float>();
private const float toggleCooldown = 1.3f;
private static bool Prefix(FlashlightController __instance)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.PlayerAvatar.isLocal)
{
return true;
}
float value;
bool flag = !lastToggle.TryGetValue(__instance, out value) || Time.time - value >= 1.3f;
if (Input.GetKeyDown(FlashlightConfig.GetKeyCode()) && flag)
{
lastToggle[__instance] = Time.time;
if (!__instance.LightActive)
{
fiCurrentState.SetValue(__instance, Enum.Parse(fiCurrentState.FieldType, "Intro"));
fiStateTimer.SetValue(__instance, 1f);
fiIntroRotLerp.SetValue(__instance, 0f);
fiIntroYLerp.SetValue(__instance, 0f);
fiClick.SetValue(__instance, true);
}
else
{
fiCurrentState.SetValue(__instance, Enum.Parse(fiCurrentState.FieldType, "LightOff"));
fiStateTimer.SetValue(__instance, 0.25f);
fiClick.SetValue(__instance, true);
__instance.lightOffAudio.Play(((Component)__instance).transform.position, 1f, 1f, 1f, 1f);
}
}
return true;
}
private static void Postfix(FlashlightController __instance)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.PlayerAvatar.isLocal)
{
return;
}
AccessTools.Field(typeof(FlashlightController), "active").SetValue(__instance, __instance.LightActive);
if (!__instance.LightActive)
{
return;
}
Color value;
if (FlashlightConfig.UseCustomRGB.Value)
{
Color color = FlashlightConfig.GetColor();
__instance.spotlight.color = color;
Light component = ((Component)__instance.halo).GetComponent<Light>();
if ((Object)(object)component != (Object)null)
{
component.color = color;
}
}
else if (Patch_FlashlightController_Start.originalColors.TryGetValue(__instance, out value))
{
__instance.spotlight.color = value;
Light component2 = ((Component)__instance.halo).GetComponent<Light>();
if ((Object)(object)component2 != (Object)null)
{
component2.color = value;
}
}
}
}
namespace PxntxrezStudio.RepoFlashlightRework
{
public static class FlashlightConfig
{
public static ConfigEntry<int> LightColorRed;
public static ConfigEntry<int> LightColorGreen;
public static ConfigEntry<int> LightColorBlue;
public static ConfigEntry<bool> UseCustomRGB;
public static ConfigEntry<string> FlashlightToggleKey;
public static ConfigEntry<bool> EnableFlicker;
private static ConfigFile config;
public static void Init(ConfigFile cfg)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Expected O, but got Unknown
config = cfg;
UseCustomRGB = cfg.Bind<bool>("Light Color", "Use Custom RGB Color", false, "Enable or disable RGB color override");
LightColorRed = cfg.Bind<int>("Light Color", "Red", 255, new ConfigDescription("Light Color Red", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
LightColorGreen = cfg.Bind<int>("Light Color", "Green", 255, new ConfigDescription("Light Color Green", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
LightColorBlue = cfg.Bind<int>("Light Color", "Blue", 255, new ConfigDescription("Light Color Blue", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
FlashlightToggleKey = cfg.Bind<string>("Controls", "Toggle Key", "F", new ConfigDescription("Flashlight toggle key", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[20]
{
"F", "R", "T", "Y", "U", "I", "O", "P", "G", "H",
"J", "K", "L", "Z", "X", "C", "V", "B", "N", "M"
}), Array.Empty<object>()));
EnableFlicker = cfg.Bind<bool>("Flicker Settings", "Enable Flicker", true, "Enable flickering when enemy is nearby");
cfg.SettingChanged += OnConfigChanged;
}
private static void OnConfigChanged(object sender, SettingChangedEventArgs e)
{
if (e.ChangedSetting.Definition.Key == "Enable Flicker")
{
Patch_FlashlightController_Start.OnFlickerSettingChanged();
}
}
public static KeyCode GetKeyCode()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
string value = FlashlightToggleKey.Value.ToUpper();
if (Enum.TryParse<KeyCode>(value, out KeyCode result))
{
return result;
}
return (KeyCode)102;
}
public static Color GetColor()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
return new Color((float)LightColorRed.Value / 255f, (float)LightColorGreen.Value / 255f, (float)LightColorBlue.Value / 255f);
}
}
}