using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Speedrunner's Delight")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Speedrunner's Delight")]
[assembly: AssemblyTitle("Speedrunner's Delight")]
[assembly: AssemblyVersion("1.0.0.0")]
[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;
}
}
}
namespace BigWalkPuzzleBeaconMod
{
[BepInPlugin("com.gogogadgetjustice.bigwalk.puzzlebeacon", "Big Walk Puzzle Beacons Mod", "2.5.0")]
public class PuzzleBeaconPlugin : BasePlugin
{
public static PuzzleBeaconPlugin Instance;
public static ConfigEntry<KeyCode> KeyShowMultiple { get; private set; }
public static ConfigEntry<KeyCode> KeyShowClosest { get; private set; }
public static ConfigEntry<KeyCode> KeyHideAll { get; private set; }
public static ConfigEntry<int> MaxBeaconsToShow { get; private set; }
public static ConfigEntry<float> ScanRange { get; private set; }
public static ConfigEntry<float> BeaconWidth { get; private set; }
public static ConfigEntry<float> BeaconHeight { get; private set; }
public static ConfigEntry<float> BeaconColorR { get; private set; }
public static ConfigEntry<float> BeaconColorG { get; private set; }
public static ConfigEntry<float> BeaconColorB { get; private set; }
public static ConfigEntry<float> BeaconColorA { get; private set; }
public static ConfigEntry<float> LightRange { get; private set; }
public static ConfigEntry<float> LightIntensity { get; private set; }
public static ConfigEntry<bool> EnableParticles { get; private set; }
public static ConfigEntry<int> ParticleCount { get; private set; }
public static ConfigEntry<float> ParticleSize { get; private set; }
public static ConfigEntry<float> ParticleRiseSpeed { get; private set; }
public static ConfigEntry<float> ParticleSpinSpeed { get; private set; }
public override void Load()
{
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Expected O, but got Unknown
Instance = this;
((BasePlugin)this).Log.LogInfo((object)"Puzzle Beacon Mod v2.5.0 (Scan Range Config) Loaded.");
KeyShowMultiple = ((BasePlugin)this).Config.Bind<KeyCode>("Controls", "ShowMultipleKey", (KeyCode)49, "Show beacons on closest N gourds.");
KeyShowClosest = ((BasePlugin)this).Config.Bind<KeyCode>("Controls", "ShowClosestKey", (KeyCode)50, "Show beacon ONLY on the single closest gourd.");
KeyHideAll = ((BasePlugin)this).Config.Bind<KeyCode>("Controls", "HideAllKey", (KeyCode)51, "Turn off all beacons.");
MaxBeaconsToShow = ((BasePlugin)this).Config.Bind<int>("Controls", "MaxBeacons", 5, "Number of beacons to show when pressing Key 1.");
ScanRange = ((BasePlugin)this).Config.Bind<float>("Detection", "ScanRange", 3000f, "Maximum distance in meters to scan for targets relative to player position.");
BeaconWidth = ((BasePlugin)this).Config.Bind<float>("Visuals", "BeaconWidth", 0.2f, "Width / Radius of the beacon beam noodle.");
BeaconHeight = ((BasePlugin)this).Config.Bind<float>("Visuals", "BeaconHeight", 5000f, "Height of the beacon pillar extending into the sky.");
BeaconColorR = ((BasePlugin)this).Config.Bind<float>("Visuals", "ColorRed", 0f, "Beacon Color Red channel (0.0 to 1.0).");
BeaconColorG = ((BasePlugin)this).Config.Bind<float>("Visuals", "ColorGreen", 1f, "Beacon Color Green channel (0.0 to 1.0).");
BeaconColorB = ((BasePlugin)this).Config.Bind<float>("Visuals", "ColorBlue", 1f, "Beacon Color Blue channel (0.0 to 1.0).");
BeaconColorA = ((BasePlugin)this).Config.Bind<float>("Visuals", "ColorAlpha", 0.85f, "Beacon Transparency Alpha channel (0.0 to 1.0).");
LightRange = ((BasePlugin)this).Config.Bind<float>("Light", "LightRange", 6f, "How far the glow at the base of each beacon reaches.");
LightIntensity = ((BasePlugin)this).Config.Bind<float>("Light", "LightIntensity", 0.7f, "Brightness of the glow at the base of each beacon.");
EnableParticles = ((BasePlugin)this).Config.Bind<bool>("Particles", "EnableParticles", true, "Toggle swirling particles around each beacon beam.");
ParticleCount = ((BasePlugin)this).Config.Bind<int>("Particles", "ParticleCount", 6, "How many particles swirl around each beam.");
ParticleSize = ((BasePlugin)this).Config.Bind<float>("Particles", "ParticleSize", 0.08f, "Size of each swirling particle.");
ParticleRiseSpeed = ((BasePlugin)this).Config.Bind<float>("Particles", "ParticleRiseSpeed", 0.5f, "Upward rise speed for particles.");
ParticleSpinSpeed = ((BasePlugin)this).Config.Bind<float>("Particles", "ParticleSpinSpeed", 1f, "Orbit speed around the beam.");
ClassInjector.RegisterTypeInIl2Cpp<PuzzleBeaconManager>();
GameObject val = new GameObject("PuzzleBeaconManager");
Object.DontDestroyOnLoad((Object)(object)val);
val.AddComponent<PuzzleBeaconManager>();
}
}
public class PuzzleBeaconManager : MonoBehaviour
{
private List<Transform> gourdTransforms = new List<Transform>();
private List<GameObject> activeBeaconRoots = new List<GameObject>();
private List<Light> activeLights = new List<Light>();
private Material sharedBeaconMaterial;
private MaterialPropertyBlock propBlock;
private Transform currentSingleTarget = null;
private string cachedDistanceText = "";
private GUIStyle cachedLabelStyle;
private bool styleInitialized = false;
private float updateTimer = 0f;
private const float UpdateInterval = 0.1f;
private const float RefWidth = 1920f;
public PuzzleBeaconManager(IntPtr ptr)
: base(ptr)
{
}
private void Awake()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
Shader val = Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("HDRP/Unlit") ?? Shader.Find("Unlit/Texture") ?? Shader.Find("Sprites/Default");
sharedBeaconMaterial = new Material(val);
propBlock = new MaterialPropertyBlock();
}
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(PuzzleBeaconPlugin.KeyShowMultiple.Value))
{
EnsureGourdsScanned();
ActivateBeacons(PuzzleBeaconPlugin.MaxBeaconsToShow.Value, isSingleMode: false);
}
else if (Input.GetKeyDown(PuzzleBeaconPlugin.KeyShowClosest.Value))
{
EnsureGourdsScanned();
ActivateBeacons(1, isSingleMode: true);
}
else if (Input.GetKeyDown(PuzzleBeaconPlugin.KeyHideAll.Value))
{
ClearBeacons();
}
if (activeBeaconRoots.Count > 0)
{
AnimateBeaconsAndParticles();
}
if ((Object)(object)currentSingleTarget != (Object)null && (Object)(object)Camera.main != (Object)null)
{
updateTimer += Time.deltaTime;
if (updateTimer >= 0.1f)
{
updateTimer = 0f;
float num = Vector3.Distance(((Component)Camera.main).transform.position, currentSingleTarget.position);
float value = num / 1000f;
cachedDistanceText = $"<b>CLOSEST GOURD: <color=lime>{value:F2} km</color></b> ({num:F0} m)";
}
}
}
private void EnsureGourdsScanned()
{
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Expected O, but got Unknown
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Expected O, but got Unknown
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
gourdTransforms.RemoveAll((Transform t) => (Object)(object)t == (Object)null || !((Component)t).gameObject.activeInHierarchy);
if (gourdTransforms.Count > 0)
{
return;
}
Transform[] array = Il2CppArrayBase<Transform>.op_Implicit(Object.FindObjectsOfType<Transform>());
PuzzleBeaconPlugin instance = PuzzleBeaconPlugin.Instance;
if (instance != null)
{
((BasePlugin)instance).Log.LogInfo((object)"=== [PuzzleBeacon] SCANNING SPECIFICALLY FOR 'GourdProp' ===");
}
Transform[] array2 = array;
bool flag = default(bool);
foreach (Transform val in array2)
{
if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy || (!((Object)val).name.Equals("GourdProp", StringComparison.OrdinalIgnoreCase) && !((Object)val).name.ToLower().Contains("gourdprop")))
{
continue;
}
gourdTransforms.Add(val);
PuzzleBeaconPlugin instance2 = PuzzleBeaconPlugin.Instance;
if (instance2 != null)
{
ManualLogSource log = ((BasePlugin)instance2).Log;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(38, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PuzzleBeacon] FOUND GOURDPROP: '");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' at ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector3>(val.position);
}
log.LogInfo(val2);
}
}
PuzzleBeaconPlugin instance3 = PuzzleBeaconPlugin.Instance;
if (instance3 != null)
{
ManualLogSource log2 = ((BasePlugin)instance3).Log;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(63, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("=== [PuzzleBeacon] Scan complete. Found ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(gourdTransforms.Count);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" active GourdProps. ===");
}
log2.LogInfo(val2);
}
}
private void ActivateBeacons(int count, bool isSingleMode)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
ClearBeacons();
if (gourdTransforms.Count == 0 || (Object)(object)Camera.main == (Object)null)
{
return;
}
Vector3 playerPos = ((Component)Camera.main).transform.position;
float maxDistance = PuzzleBeaconPlugin.ScanRange.Value;
List<Transform> list = gourdTransforms.FindAll((Transform t) => (Object)(object)t != (Object)null && ((Component)t).gameObject.activeInHierarchy && Vector3.Distance(playerPos, t.position) <= maxDistance);
if (list.Count == 0)
{
PuzzleBeaconPlugin instance = PuzzleBeaconPlugin.Instance;
if (instance != null)
{
ManualLogSource log = ((BasePlugin)instance).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(60, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PuzzleBeacon] No Gourds found within current ScanRange (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(maxDistance);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("m).");
}
log.LogInfo(val);
}
return;
}
list.Sort(delegate(Transform a, Transform b)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
float num4 = Vector3.Distance(playerPos, a.position);
float value = Vector3.Distance(playerPos, b.position);
return num4.CompareTo(value);
});
int num = Math.Min(count, list.Count);
for (int num2 = 0; num2 < num; num2++)
{
CreateBeacon(list[num2].position);
}
if (isSingleMode && list.Count > 0)
{
currentSingleTarget = list[0];
float num3 = Vector3.Distance(playerPos, currentSingleTarget.position);
cachedDistanceText = $"<b>CLOSEST GOURD: <color=lime>{num3 / 1000f:F2} km</color></b> ({num3:F0} m)";
}
else
{
currentSingleTarget = null;
}
}
private void CreateBeacon(Vector3 position)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Expected O, but got Unknown
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("[PuzzleBeacon] Root");
val.transform.position = position;
GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)2);
Object.Destroy((Object)(object)val2.GetComponent<Collider>());
val2.transform.SetParent(val.transform, false);
float value = PuzzleBeaconPlugin.BeaconWidth.Value;
float value2 = PuzzleBeaconPlugin.BeaconHeight.Value;
val2.transform.localScale = new Vector3(value, value2 / 2f, value);
val2.transform.localPosition = new Vector3(0f, value2 / 2f, 0f);
Color configuredColor = GetConfiguredColor();
Renderer component = val2.GetComponent<Renderer>();
component.sharedMaterial = sharedBeaconMaterial;
propBlock.SetColor("_BaseColor", configuredColor);
propBlock.SetColor("_Color", configuredColor);
component.SetPropertyBlock(propBlock);
GameObject val3 = new GameObject("[PuzzleBeacon] PointLight");
val3.transform.SetParent(val.transform, false);
val3.transform.localPosition = new Vector3(0f, 1f, 0f);
Light val4 = val3.AddComponent<Light>();
val4.type = (LightType)2;
val4.color = configuredColor;
val4.range = PuzzleBeaconPlugin.LightRange.Value;
val4.intensity = PuzzleBeaconPlugin.LightIntensity.Value;
val4.shadows = (LightShadows)0;
activeLights.Add(val4);
if (PuzzleBeaconPlugin.EnableParticles.Value)
{
int num = Mathf.Clamp(PuzzleBeaconPlugin.ParticleCount.Value, 0, 30);
for (int i = 0; i < num; i++)
{
GameObject val5 = GameObject.CreatePrimitive((PrimitiveType)0);
((Object)val5).name = "Particle_" + i;
val5.transform.SetParent(val.transform, false);
Object.Destroy((Object)(object)val5.GetComponent<Collider>());
float value3 = PuzzleBeaconPlugin.ParticleSize.Value;
val5.transform.localScale = new Vector3(value3, value3, value3);
val5.transform.localPosition = new Vector3(0f, Random.Range(0.1f, 5f), 0f);
Renderer component2 = val5.GetComponent<Renderer>();
component2.sharedMaterial = sharedBeaconMaterial;
component2.SetPropertyBlock(propBlock);
}
}
activeBeaconRoots.Add(val);
}
private void AnimateBeaconsAndParticles()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
Color configuredColor = GetConfiguredColor();
float value = PuzzleBeaconPlugin.ParticleRiseSpeed.Value;
float num = 60f * PuzzleBeaconPlugin.ParticleSpinSpeed.Value;
float num2 = 0.25f + PuzzleBeaconPlugin.BeaconWidth.Value;
int num3 = Mathf.Clamp(PuzzleBeaconPlugin.ParticleCount.Value, 0, 30);
foreach (Light activeLight in activeLights)
{
if (!((Object)(object)activeLight == (Object)null))
{
activeLight.range = PuzzleBeaconPlugin.LightRange.Value;
activeLight.intensity = PuzzleBeaconPlugin.LightIntensity.Value;
activeLight.color = configuredColor;
}
}
if (!PuzzleBeaconPlugin.EnableParticles.Value)
{
return;
}
foreach (GameObject activeBeaconRoot in activeBeaconRoots)
{
if ((Object)(object)activeBeaconRoot == (Object)null)
{
continue;
}
for (int i = 0; i < num3; i++)
{
Transform val = activeBeaconRoot.transform.Find("Particle_" + i);
if (!((Object)(object)val == (Object)null))
{
float num4 = 360f / (float)num3 * (float)i + Time.time * num;
float num5 = num4 * ((float)Math.PI / 180f);
Vector3 localPosition = val.localPosition;
localPosition.x = Mathf.Cos(num5) * num2;
localPosition.z = Mathf.Sin(num5) * num2;
localPosition.y += value * Time.deltaTime;
if (localPosition.y > 6f || localPosition.y < 0f)
{
localPosition.y = Random.Range(0.05f, 0.3f);
}
val.localPosition = localPosition;
}
}
}
}
private Color GetConfiguredColor()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
return new Color(PuzzleBeaconPlugin.BeaconColorR.Value, PuzzleBeaconPlugin.BeaconColorG.Value, PuzzleBeaconPlugin.BeaconColorB.Value, PuzzleBeaconPlugin.BeaconColorA.Value);
}
private void ClearBeacons()
{
currentSingleTarget = null;
cachedDistanceText = "";
foreach (GameObject activeBeaconRoot in activeBeaconRoots)
{
if ((Object)(object)activeBeaconRoot != (Object)null)
{
Object.Destroy((Object)(object)activeBeaconRoot);
}
}
activeBeaconRoots.Clear();
activeLights.Clear();
}
private void InitStyles()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
if (!styleInitialized)
{
cachedLabelStyle = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)4,
fontSize = 18,
fontStyle = (FontStyle)1
};
cachedLabelStyle.normal.textColor = Color.white;
styleInitialized = true;
}
}
private void OnGUI()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)currentSingleTarget == (Object)null) && !((Object)(object)Camera.main == (Object)null) && !string.IsNullOrEmpty(cachedDistanceText))
{
InitStyles();
float num = (float)Screen.width / 1920f;
Matrix4x4 matrix = GUI.matrix;
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num, num, 1f));
float num2 = 450f;
float num3 = 45f;
float num4 = 960f - num2 / 2f;
float num5 = 20f;
GUI.Box(new Rect(num4, num5, num2, num3), "");
GUI.Label(new Rect(num4, num5, num2, num3), cachedDistanceText, cachedLabelStyle);
GUI.matrix = matrix;
}
}
private void OnDestroy()
{
ClearBeacons();
}
}
}