using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using AimAssist;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Enemy;
using Equipment;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RunnerUtils.Components;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RunnerUtils")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RunnerUtils")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a79cd55a-b3b1-464f-af67-38bb052b77bb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace RunnerUtils
{
public class InGameLog
{
private class CircularArray<T>
{
private int len = 0;
private T[] array = new T[length];
private int startIndex;
public T this[int idx]
{
get
{
return array[GetIdx(idx)];
}
set
{
array[GetIdx(idx)] = value;
}
}
public int Length
{
get
{
return len;
}
set
{
if (value > len)
{
for (int i = len; i < value; i++)
{
array[i] = default(T);
}
}
len = value;
}
}
public int MaxLength
{
get
{
return array.Length;
}
set
{
if (value > 0 && value != this.array.Length)
{
T[] array = new T[value];
int num = Math.Min(value, this.array.Length);
for (int i = 0; i < num; i++)
{
array[i] = this.array[GetIdx(i)];
}
startIndex = 0;
this.array = array;
}
}
}
public CircularArray(int length)
{
}
private int GetIdx(int index)
{
return (startIndex + index) % array.Length;
}
public void Push(T value)
{
array[GetIdx(len)] = value;
if (len == array.Length)
{
startIndex++;
if (startIndex == array.Length)
{
startIndex = 0;
}
}
else
{
len++;
}
}
public T Pop()
{
return array[GetIdx(--len)];
}
public void ForEach(Action<T, int> callback)
{
for (int i = 0; i < len; i++)
{
callback(this[i], i);
}
}
public void ReverseForEach(Action<T, int> callback)
{
for (int num = len - 1; num >= 0; num--)
{
callback(this[num], num);
}
}
}
private int m_bufferLen = 15;
private bool m_shouldBeVisible = true;
private int fadeLen;
public Vector2 anchoredPos = new Vector2(-925f, 535f);
public Vector2 sizeDelta = new Vector2(500f, 250f);
public TextAlignmentOptions textAlignment = (TextAlignmentOptions)257;
private GameObject m_gameObj;
private string m_name;
private CircularArray<string> buffer;
public TextMeshProUGUI TextComponent { get; private set; }
public int Length
{
get
{
return m_bufferLen;
}
set
{
m_bufferLen = value;
buffer.MaxLength = value;
}
}
public InGameLog(string name = "Unnamed Log", int bufferLength = 15, int fadeLength = 4)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
m_name = name;
m_bufferLen = bufferLength;
fadeLen = fadeLength;
buffer = new CircularArray<string>(m_bufferLen);
}
public void ToggleVisibility()
{
((Behaviour)TextComponent).enabled = !((Behaviour)TextComponent).enabled;
m_shouldBeVisible = ((Behaviour)TextComponent).enabled;
}
public void Show()
{
((Behaviour)TextComponent).enabled = true;
m_shouldBeVisible = true;
}
public void Hide()
{
((Behaviour)TextComponent).enabled = false;
m_shouldBeVisible = false;
}
public void LogLine(string message)
{
if (!Object.op_Implicit((Object)(object)TextComponent))
{
throw new InvalidOperationException("Log not initialized! call Setup() before using.");
}
buffer.Push(message + "\n");
FlushBuffer();
}
public void Log(string message)
{
if (!Object.op_Implicit((Object)(object)TextComponent))
{
throw new InvalidOperationException("Log not initialized! call Setup() before using.");
}
buffer.Push(message);
FlushBuffer();
}
public void PushBufferLine(string message)
{
if (!Object.op_Implicit((Object)(object)TextComponent))
{
throw new InvalidOperationException("Log not initialized! call Setup() before using.");
}
buffer.Push(message + "\n");
}
public void PushBuffer(string message)
{
if (!Object.op_Implicit((Object)(object)TextComponent))
{
throw new InvalidOperationException("Log not initialized! call Setup() before using.");
}
buffer.Push(message);
}
public void Clear()
{
while (buffer.Length > 0)
{
buffer.Pop();
}
FlushBuffer();
}
public void SetBufferLine(int idx, string message)
{
if (idx >= buffer.Length)
{
buffer.Length = idx + 1;
}
buffer[idx] = message + "\n";
}
public void FlushBuffer()
{
if (Object.op_Implicit((Object)(object)TextComponent))
{
((TMP_Text)TextComponent).text = m_name + "\n";
buffer.ForEach(delegate(string val, int i)
{
TextMeshProUGUI textComponent = TextComponent;
((TMP_Text)textComponent).text = ((TMP_Text)textComponent).text + ((i < m_bufferLen - fadeLen) ? val : ($"<alpha=#{255 * (m_bufferLen - i) / fadeLen:X2}>" + val));
});
}
}
public void Setup()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
HUDGPS gPS = GameManager.instance.player.GetHUD().GetGPS();
if (Object.op_Implicit((Object)(object)m_gameObj))
{
if (!m_gameObj.activeInHierarchy)
{
m_gameObj = Object.Instantiate<GameObject>(new GameObject(), ((Component)((Component)gPS).transform.parent).gameObject.transform);
}
}
else
{
m_gameObj = Object.Instantiate<GameObject>(new GameObject(), ((Component)((Component)gPS).transform.parent).gameObject.transform);
}
((Object)m_gameObj).name = m_name + " (Ingame Log)";
RectTransform val = m_gameObj.GetComponent<RectTransform>();
if (!Object.op_Implicit((Object)(object)val))
{
val = m_gameObj.AddComponent<RectTransform>();
}
val.anchoredPosition = anchoredPos;
val.sizeDelta = sizeDelta;
TextMeshProUGUI componentInChildren = ((Component)((Component)gPS).transform.parent).GetComponentInChildren<TextMeshProUGUI>();
TextComponent = m_gameObj.GetComponent<TextMeshProUGUI>();
if (!Object.op_Implicit((Object)(object)TextComponent))
{
TextComponent = m_gameObj.AddComponent<TextMeshProUGUI>();
}
((TMP_Text)TextComponent).alignment = textAlignment;
((TMP_Text)TextComponent).font = ((TMP_Text)componentInChildren).font;
((TMP_Text)TextComponent).fontSize = 24f;
((Behaviour)TextComponent).enabled = m_shouldBeVisible;
FlushBuffer();
}
}
[BepInPlugin("kestrel.iamyourbeast.runnerutils", "Runner Utils", "2.4.2")]
public class Mod : BaseUnityPlugin
{
[HarmonyPatch(typeof(Player))]
public class PatchPlayer
{
[HarmonyPatch("Initialize")]
[HarmonyPostfix]
public static void PlayerInitPostfix()
{
ShowTriggers.RegisterAll();
Igl.Setup();
ThrowCam.Reset();
FairPlay.Init();
MovementDebug.Init();
}
}
[HarmonyPatch(typeof(PlayerMovement))]
public class PatchPlayerMovement
{
[HarmonyPatch("Initialize")]
[HarmonyPostfix]
public static void MovementInitPostfix(CharacterController ___controller)
{
if (walkabilityOverlay.Value)
{
Terrain[] activeTerrains = Terrain.activeTerrains;
foreach (Terrain val in activeTerrains)
{
TerrainData data = val.terrainData;
WalkabilityOverlay.MakeWalkabilityTex(ref data, ___controller.slopeLimit);
val.terrainData = data;
}
}
}
}
[HarmonyPatch(typeof(HUDLevelTimer), "Update")]
public class The
{
[HarmonyPostfix]
public static void Postfix(ref TMP_Text ___gradeText)
{
___gradeText.text = " " + ___gradeText.text;
}
}
public const string pluginGuid = "kestrel.iamyourbeast.runnerutils";
public const string pluginName = "Runner Utils";
public const string pluginVersion = "2.4.2";
internal static ManualLogSource Logger;
private static bool shouldResetScale;
public static ConfigEntry<float> throwCam_rangeScalar;
public static ConfigEntry<bool> throwCam_unlockCamera;
public static ConfigEntry<bool> throwCam_autoSwitch;
public static ConfigEntry<bool> walkabilityOverlay;
public static ConfigEntry<bool> saveLocation_verbose;
public static ConfigEntry<bool> snowmanPercent;
private static string loadBearingColonThree = ":3";
public static Mod Instance { get; private set; }
private static RUInputManager InputManager { get; set; } = new RUInputManager();
public static InGameLog Igl { get; private set; } = new InGameLog("Runner Utils~Ingame Log (v2.4.2)");
public void Awake()
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
if (loadBearingColonThree != ":3")
{
Application.Quit();
}
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
InputManager.BindToConfig(((BaseUnityPlugin)this).Config);
throwCam_unlockCamera = ((BaseUnityPlugin)this).Config.Bind<bool>("Throw Cam", "Unlock Camera", false, "Unlock the camera when in throw cam");
throwCam_rangeScalar = ((BaseUnityPlugin)this).Config.Bind<float>("Throw Cam", "Camera Range", 0.2f, new ConfigDescription("Follow range of the throw cam", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 3f), Array.Empty<object>()));
throwCam_autoSwitch = ((BaseUnityPlugin)this).Config.Bind<bool>("Throw Cam", "Auto Switch", false, "Automatically switch to throw cam when a projectile is thrown");
walkabilityOverlay = ((BaseUnityPlugin)this).Config.Bind<bool>("Walkability Overlay", "Enable", false, "Makes all walkable surfaces appear snowy, and all unwalkable surfaces appear black");
saveLocation_verbose = ((BaseUnityPlugin)this).Config.Bind<bool>("Location Save", "Verbose", false, "Log the exact location and rotation when a save or load is performed");
snowmanPercent = ((BaseUnityPlugin)this).Config.Bind<bool>("Snowman%", "Enable", true, "Displays your time upon destroying a snowman, to time the (silly) category snowman%");
new Harmony("kestrel.iamyourbeast.runnerutils").PatchAll();
Logger.LogInfo((object)"Hiiiiiiiiiiii :3");
}
private void OnEnable()
{
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void Update()
{
InputManager.Update();
if (GameManager.instance.timeManager != null && shouldResetScale)
{
PauseTime.Reset();
shouldResetScale = false;
}
if (GameManager.instance.player != null)
{
FairPlay.Update();
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)mode == 1)
{
ShowTriggers.ExtendRegistry();
}
shouldResetScale = true;
ViewCones.OnSceneLoad();
}
}
}
namespace RunnerUtils.Components
{
public static class AutoJump
{
[HarmonyPatch(typeof(PlayerMovement), "UpdateJumpCheck")]
public static class PatchAutoJump
{
[HarmonyPrefix]
public static bool Prefix(ref PlayerMovement __instance)
{
if (!Enabled)
{
return true;
}
bool flag = (bool)AccessTools.Method(typeof(PlayerMovement), "BlockPerchDetachment", (Type[])null, (Type[])null).Invoke(__instance, null);
if (__instance.CanJump() && !flag && GameManager.instance.inputManager.jump.Held())
{
AccessTools.Method(typeof(PlayerMovement), "Jump", (Type[])null, (Type[])null).Invoke(__instance, null);
}
return false;
}
}
public static bool Enabled { get; private set; }
public static void Toggle()
{
Enabled = !Enabled;
}
}
public static class FairPlay
{
private static InGameLog igl = new InGameLog(" ", 10);
public static bool triggersModified = false;
public static bool infiniteAmmo = false;
public static bool locationSaved = false;
public static bool timePaused = false;
public static bool autoJump = false;
public static bool hfOverlay = false;
public static bool viewCones = false;
public static void Init()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//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_003d: Unknown result type (might be due to invalid IL or missing references)
igl.anchoredPos = new Vector2(800f, 567f);
igl.sizeDelta = new Vector2(750f, 250f);
igl.textAlignment = (TextAlignmentOptions)260;
igl.Setup();
}
public static void Update()
{
if (Object.op_Implicit((Object)(object)igl.TextComponent))
{
igl.Clear();
if (triggersModified)
{
igl.LogLine("Triggers");
}
if (infiniteAmmo)
{
igl.LogLine("Ammo");
}
if (locationSaved)
{
igl.LogLine("Location Saved" + (Mod.saveLocation_verbose.Value ? (" (" + LocationSave.StringLoc + ")") : ""));
}
if (timePaused)
{
igl.LogLine("Time Paused");
}
if (autoJump)
{
igl.LogLine("Auto Jump");
}
if (hfOverlay)
{
igl.LogLine("HF Overlay");
}
if (viewCones)
{
igl.LogLine("View Cones");
}
}
}
}
public static class InfiniteAmmo
{
[HarmonyPatch(typeof(HUDAmmoIndicator), "LoadInSlots")]
public class PatchColorAmmoSlots
{
[HarmonyPostfix]
public static void Postfix(ref List<HUDAmmoIndicatorSlot> ___spawnedSlots)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < ___spawnedSlots.Count; i++)
{
if (m_enabled)
{
ColorAmmoSlots(ref ___spawnedSlots, Color.red);
continue;
}
ColorAmmoSlots(ref ___spawnedSlots, Color.white);
AccessTools.Field(typeof(HUDAmmoIndicatorSlot), "lowAmmoColor").SetValue(___spawnedSlots[i], Color.yellow);
}
}
}
[HarmonyPatch(typeof(DebugManager), "GetInfiniteAmmo")]
public class PatchInfiniteAmmo
{
[HarmonyPrefix]
public static bool Prefix(ref bool __result)
{
if (m_enabled)
{
__result = true;
return false;
}
return true;
}
}
private static bool m_enabled;
public static bool Enabled => m_enabled;
public static void Enable()
{
m_enabled = true;
GameManager.instance.player.GetHUD().GetAmmoIndicator().LoadInSlots(GameManager.instance.player.GetArmScript().GetEquippedWeapon());
}
public static void Disable()
{
m_enabled = false;
GameManager.instance.player.GetHUD().GetAmmoIndicator().LoadInSlots(GameManager.instance.player.GetArmScript().GetEquippedWeapon());
}
public static void Toggle()
{
m_enabled = !m_enabled;
try
{
GameManager.instance.player.GetHUD().GetAmmoIndicator().LoadInSlots(GameManager.instance.player.GetArmScript().GetEquippedWeapon());
}
catch
{
}
}
private static void ColorAmmoSlots(ref List<HUDAmmoIndicatorSlot> slots, Color color)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
foreach (HUDAmmoIndicatorSlot slot in slots)
{
AccessTools.Field(typeof(HUDAmmoIndicatorSlot), "lowAmmoColor").SetValue(slot, color);
slot.LowAmmo();
}
}
}
public class RUInputManager
{
public struct DefaultBindingInfo
{
public Action action;
public string identifier;
public string description;
public KeyCode key;
public DefaultBindingInfo(string identifier, Action action, string description = "", KeyCode key = 0)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
this.action = action;
this.identifier = identifier;
this.description = description;
this.key = key;
}
}
private Dictionary<ConfigEntry<KeyCode>, Action> bindings = new Dictionary<ConfigEntry<KeyCode>, Action>();
private static List<DefaultBindingInfo> DefaultBindings { get; } = new List<DefaultBindingInfo>(18)
{
new DefaultBindingInfo("Log Visibility Toggle", delegate
{
Mod.Igl.ToggleVisibility();
Mod.Igl.LogLine("Toggled log visibility");
}, "", (KeyCode)107),
new DefaultBindingInfo("Clear Log", delegate
{
Mod.Igl.Clear();
Mod.Igl.LogLine("Cleared Log");
}, "", (KeyCode)106),
new DefaultBindingInfo("Force Trigger Visibility On", delegate
{
ShowTriggers.ShowAll();
Mod.Igl.LogLine("Enabled all triggers' visibility");
FairPlay.triggersModified = true;
}, "", (KeyCode)111),
new DefaultBindingInfo("Force Trigger Visibility Off", delegate
{
ShowTriggers.HideAll();
Mod.Igl.LogLine("Disabled all triggers' visibility");
FairPlay.triggersModified = false;
}, "", (KeyCode)105),
new DefaultBindingInfo("Toggle Infinite Ammo", delegate
{
if (Object.op_Implicit((Object)(object)GameManager.instance.player.GetHUD()))
{
InfiniteAmmo.Toggle();
Mod.Igl.LogLine("Toggled infinite ammo");
FairPlay.infiniteAmmo = InfiniteAmmo.Enabled;
}
}, "", (KeyCode)108),
new DefaultBindingInfo("Toggle Throw Cam", delegate
{
if (ThrowCam.cameraAvailable)
{
ThrowCam.ToggleCam();
Mod.Igl.LogLine("Toggled throw cam");
}
else
{
Mod.Igl.LogLine("Unable to switch to throw cam ~ no thrown weapons are in the air");
}
}, "", (KeyCode)59),
new DefaultBindingInfo("Toggle auto jump", delegate
{
AutoJump.Toggle();
Mod.Igl.LogLine("Toggled auto jump");
FairPlay.autoJump = AutoJump.Enabled;
}, "", (KeyCode)109),
new DefaultBindingInfo("Toggle hard fall overlay", delegate
{
MovementDebug.Toggle();
Mod.Igl.LogLine("Toggled hf overlay");
FairPlay.hfOverlay = !FairPlay.hfOverlay;
}, "", (KeyCode)117),
new DefaultBindingInfo("Toggle timestop", delegate
{
PauseTime.Toggle();
Mod.Igl.LogLine("Toggled timestop");
FairPlay.timePaused = PauseTime.Enabled;
}, "", (KeyCode)303),
new DefaultBindingInfo("Save Location", delegate
{
LocationSave.SaveLocation();
Mod.Igl.LogLine("Saved location " + (Mod.saveLocation_verbose.Value ? LocationSave.StringLoc : ""));
FairPlay.locationSaved = true;
}, "", (KeyCode)91),
new DefaultBindingInfo("Load Location", delegate
{
Vector3? savedPosition = LocationSave.savedPosition;
if (savedPosition.HasValue)
{
LocationSave.RestoreLocation();
Mod.Igl.LogLine("Loaded previous location " + (Mod.saveLocation_verbose.Value ? LocationSave.StringLoc : ""));
}
else
{
Mod.Igl.LogLine("No location saved!");
}
}, "", (KeyCode)93),
new DefaultBindingInfo("Clear Location", delegate
{
LocationSave.ClearLocation();
Mod.Igl.LogLine("Cleared saved location");
FairPlay.locationSaved = false;
}, "", (KeyCode)112),
new DefaultBindingInfo("Toggle view cones visibility", delegate
{
ViewCones.Toggle();
Mod.Igl.LogLine("Toggled view cones' visibility");
FairPlay.viewCones = !FairPlay.viewCones;
}, "", (KeyCode)121),
new DefaultBindingInfo("Trigger Visibility Toggle", delegate
{
ShowTriggers.ToggleAll();
Mod.Igl.LogLine("Toggled all triggers' visibility");
FairPlay.triggersModified = true;
}, "", (KeyCode)0),
new DefaultBindingInfo("OOB Box Visibility Toggle", delegate
{
ShowTriggers.ToggleAllOf<PlayerOutOfBoundsBox>();
Mod.Igl.LogLine("Toggled OOB boxes' visibility");
FairPlay.triggersModified = true;
}, "", (KeyCode)0),
new DefaultBindingInfo("Start Trigger Visibility Toggle", delegate
{
ShowTriggers.ToggleAllOf<PlayerTimerStartBox>();
Mod.Igl.LogLine("Toggled start triggers' visibility");
FairPlay.triggersModified = true;
}, "", (KeyCode)0),
new DefaultBindingInfo("Spawner Visibility Toggle", delegate
{
ShowTriggers.ToggleAllOf<EnemySpawner>();
Mod.Igl.LogLine("Toggled spawners' visibility");
FairPlay.triggersModified = true;
}, "", (KeyCode)0),
new DefaultBindingInfo("Toggle advanced movement info", delegate
{
MovementDebug.ToggleAdvanced();
Mod.Igl.LogLine("Toggled movement info");
}, "", (KeyCode)0)
};
public void BindToConfig(ConfigFile config)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
foreach (DefaultBindingInfo defaultBinding in DefaultBindings)
{
ConfigEntry<KeyCode> key = config.Bind<KeyCode>(((int)defaultBinding.key != 0) ? "Keybinds" : "Keybinds.Optional", defaultBinding.identifier, defaultBinding.key, defaultBinding.description);
bindings[key] = defaultBinding.action;
}
}
public void Update()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
if (GameManager.instance.levelController == null || GameManager.instance.levelController.IsLevelPaused())
{
return;
}
foreach (KeyValuePair<ConfigEntry<KeyCode>, Action> binding in bindings)
{
if (Input.GetKeyDown(binding.Key.Value))
{
binding.Value?.Invoke();
}
}
}
}
public static class ViewCones
{
[HarmonyPatch(typeof(EnemyHuman))]
public class EnemyHumanPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void CreateViewCone(EnemyHuman __instance)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
if (__instance.GetSniperScanZone() == null)
{
GameObject val = new GameObject();
MeshRenderer val2 = val.AddComponent<MeshRenderer>();
((Renderer)val2).material = ShowTriggers.mat;
((Renderer)val2).material.color = defaultColor;
((Object)val).name = "View Cone";
val.AddComponent<MeshFilter>();
val.transform.up = __instance.GetHeadAnchor().forward;
val.transform.position = __instance.GetHeadAnchor().position;
val.transform.parent = ((Component)__instance).gameObject.transform;
ViewCone viewCone = val.AddComponent<ViewCone>();
}
}
[HarmonyPatch("OnPlayerSeen")]
[HarmonyPostfix]
public static void RecolorConeOnSeen(EnemyHuman __instance)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (__instance.GetSniperScanZone() == null)
{
Transform val = ((Component)__instance).transform.Find("View Cone");
if (val != null)
{
((Component)val).GetComponent<ViewCone>().SetColor(seenColor);
}
}
}
[HarmonyPatch("RefreshPlayerInView")]
[HarmonyPrefix]
public static void UpdateViewConeVisibility(EnemyHuman __instance)
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
if (__instance.GetSniperScanZone() != null)
{
return;
}
Transform val = ((Component)__instance).transform.Find("View Cone");
if (val == null)
{
return;
}
ViewCone component = ((Component)val).GetComponent<ViewCone>();
if (component.ForceDisable)
{
return;
}
Vector3 targetCenter = GameManager.instance.player.GetTargetCenter(0f);
bool visibility = Vector3.Distance(targetCenter, __instance.GetHeadAnchor().position) < __instance.GetDetectionRadius() * 2f;
component.SetVisibility(visibility);
if (!__instance.GetHasPersonallySeenPlayer())
{
if (!__instance.PositionSightlineClear(targetCenter))
{
component.SetColor(noSightlineColor);
}
else
{
component.SetColor(defaultColor);
}
}
}
}
[HarmonyPatch(typeof(Enemy))]
public class EnemyPatch
{
[HarmonyPatch("Kill")]
[HarmonyPostfix]
public static void DestroyViewCone(Enemy __instance)
{
if (__instance is EnemyHuman)
{
Transform val = ((Component)__instance).transform.Find("View Cone");
if (val != null)
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
}
}
[RequireComponent(typeof(MeshRenderer))]
[RequireComponent(typeof(MeshFilter))]
public class ViewCone : MonoBehaviour
{
private static Dictionary<(float, float), Mesh> cachedMeshes = new Dictionary<(float, float), Mesh>();
private const int subdivisions = 25;
private MeshRenderer m_renderer;
private bool m_forceDisable;
public bool ForceDisable
{
get
{
return m_forceDisable;
}
set
{
m_forceDisable = value;
((Renderer)m_renderer).enabled = !value;
}
}
public void SetVisibility(bool value)
{
if (!ForceDisable)
{
((Renderer)((Component)this).GetComponent<MeshRenderer>()).enabled = value;
}
}
public void Start()
{
EnemyHuman component = ((Component)((Component)this).transform.parent).gameObject.GetComponent<EnemyHuman>();
float detectionRadius = component.GetDetectionRadius();
float detectionAngle = component.GetDetectionAngle();
Mesh val;
if (cachedMeshes.ContainsKey((detectionRadius, detectionAngle)))
{
val = cachedMeshes[(detectionRadius, detectionAngle)];
}
else
{
val = CreateConeMesh(25, detectionRadius, detectionAngle);
cachedMeshes[(detectionRadius, detectionAngle)] = val;
}
((Component)this).GetComponent<MeshFilter>().sharedMesh = val;
m_renderer = ((Component)this).GetComponent<MeshRenderer>();
cones.Add(this);
ForceDisable = !FairPlay.viewCones;
}
public void SetColor(Color col)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
((Renderer)m_renderer).material.color = col;
}
public void OnDestroy()
{
cones.Remove(this);
}
private static Mesh CreateConeMesh(int subdivisions, float height, float angle)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
Mesh val = new Mesh();
float num = height * Mathf.Tan(0.5f * angle * ((float)Math.PI / 180f));
Vector3[] array = (Vector3[])(object)new Vector3[subdivisions + 2];
Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
int[] array3 = new int[subdivisions * 2 * 3];
array[0] = new Vector3(0f, height, 0f);
array2[0] = new Vector2(0.5f, 0f);
for (int i = 0; i < subdivisions; i++)
{
float num2 = (float)i / (float)(subdivisions - 1);
float num3 = num2 * ((float)Math.PI * 2f);
float num4 = Mathf.Cos(num3) * num;
float num5 = Mathf.Sin(num3) * num;
array[i + 1] = new Vector3(num4, height, num5);
array2[i + 1] = new Vector2(num2, 0f);
}
array[subdivisions + 1] = Vector3.zero;
array2[subdivisions + 1] = new Vector2(0.5f, 1f);
for (int j = 0; j < subdivisions - 1; j++)
{
int num6 = j * 3;
array3[num6] = 0;
array3[num6 + 1] = j + 1;
array3[num6 + 2] = j + 2;
}
int num7 = subdivisions * 3;
for (int k = 0; k < subdivisions - 1; k++)
{
int num8 = k * 3 + num7;
array3[num8] = k + 1;
array3[num8 + 1] = subdivisions + 1;
array3[num8 + 2] = k + 2;
}
val.vertices = array;
val.uv = array2;
val.triangles = array3;
val.RecalculateBounds();
val.RecalculateNormals();
return val;
}
}
private static List<ViewCone> cones = new List<ViewCone>();
private static Color seenColor = new Color(1f, 0f, 0f, 0.25f);
private static Color defaultColor = new Color(0.5f, 0f, 0.5f, 0.4f);
private static Color noSightlineColor = new Color(0f, 0.5f, 0.5f, 0.25f);
public static void Enable()
{
foreach (ViewCone cone in cones)
{
cone.ForceDisable = false;
}
}
public static void Disable()
{
foreach (ViewCone cone in cones)
{
cone.ForceDisable = true;
}
}
public static void Toggle()
{
foreach (ViewCone cone in cones)
{
cone.ForceDisable = !cone.ForceDisable;
}
}
public static void OnSceneLoad()
{
cones.Clear();
}
}
public static class LocationSave
{
public static Vector3? savedPosition;
public static Vector3? savedRotation;
public static string StringLoc => $"<color=red>l{savedPosition}<color=white>@<color=blue>r{savedRotation}</color>";
public static void SaveLocation()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
Player player = GameManager.instance.player;
savedPosition = ((player != null) ? new Vector3?(player.GetPosition()) : null);
Player player2 = GameManager.instance.player;
savedRotation = ((player2 != null) ? new Vector3?(player2.GetLookScript().GetBaseRotation()) : null);
if (savedPosition.HasValue && savedRotation.HasValue)
{
}
}
public static void ClearLocation()
{
savedPosition = null;
savedRotation = null;
}
public static void RestoreLocation()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
if (savedPosition.HasValue)
{
Player player = GameManager.instance.player;
if (player != null)
{
player.GetMovementScript().Teleport(savedPosition.Value);
}
}
if (savedRotation.HasValue)
{
Player player2 = GameManager.instance.player;
if (player2 != null)
{
player2.GetLookScript().SetBaseRotation(savedRotation.Value);
}
}
}
}
public static class MovementDebug
{
[HarmonyPatch(typeof(PlayerMovement), "Update")]
public class LogMovement
{
[HarmonyPostfix]
public static void Postfix(PlayerMovement __instance, ref int ___dropOnEnemyFrames, ref int ___fallLevel, ref float ___coyoteTimer, ref float ___vMomentum)
{
m_obj.SetActive(m_simple);
if (m_simple)
{
((TMP_Text)m_text).text = (__instance.IsHardFalling() ? "<color=#FF0000>HF" : "<color=#ED424240>HF");
}
if (m_advanced)
{
igl.SetBufferLine(0, $"Hard falling: {__instance.IsHardFalling()}");
igl.SetBufferLine(1, $"Drop frames: {___dropOnEnemyFrames}");
igl.SetBufferLine(2, $"Fall level: {___fallLevel}");
igl.SetBufferLine(3, $"Coyote: {___coyoteTimer:0.00}");
igl.SetBufferLine(4, $"vMomentum: {___vMomentum:0.00}");
igl.FlushBuffer();
}
}
}
private static bool m_advanced = false;
private static bool m_simple = false;
private static GameObject m_obj;
private static TextMeshProUGUI m_text;
private static InGameLog igl = new InGameLog("Runner Utils~Movement Info", 10);
public static void Init()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
igl.anchoredPos = new Vector2(-425f, 535f);
igl.Setup();
if (!m_advanced)
{
igl.Hide();
}
SetupIndicator();
}
private static void SetupIndicator()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
HUDGPS gPS = GameManager.instance.player.GetHUD().GetGPS();
m_obj = Object.Instantiate<GameObject>(new GameObject(), ((Component)((Component)gPS).transform.parent).gameObject.transform);
TMP_FontAsset font = ((TMP_Text)((Component)((Component)gPS).transform.parent).GetComponentInChildren<TextMeshProUGUI>()).font;
((Object)m_obj).name = "RunnerUtils~HF Indicator";
m_text = m_obj.AddComponent<TextMeshProUGUI>();
((TMP_Text)m_text).fontSize = 35f;
((TMP_Text)m_text).font = font;
((TMP_Text)m_text).alignment = (TextAlignmentOptions)1025;
RectTransform val = m_obj.GetComponent<RectTransform>();
if (!Object.op_Implicit((Object)(object)val))
{
val = m_obj.AddComponent<RectTransform>();
}
val.anchoredPosition = new Vector2(-1085f, -645f);
}
public static void ToggleAdvanced()
{
m_advanced = !m_advanced;
igl.ToggleVisibility();
}
public static void Toggle()
{
m_simple = !m_simple;
}
}
public static class PauseTime
{
private static TimeScale m_timeScale;
public static bool Enabled { get; private set; }
public static void Toggle()
{
m_timeScale.SetScale(Mathf.Abs(m_timeScale.GetScale() - 1f));
Enabled = !Enabled;
}
public static void Reset()
{
m_timeScale = GameManager.instance.timeManager.CreateTimeScale(1f);
Enabled = false;
}
}
public static class SnowmanPercent
{
[HarmonyPatch(typeof(Snowman), "Kill")]
public class PatchSnowman
{
[HarmonyPostfix]
public static void Postfix()
{
if (Mod.snowmanPercent.Value)
{
float time = GameManager.instance.levelController.GetCombatTimer().GetTime(true);
GameManager.instance.player.GetHUD().GetNotificationPopUp().TriggerPopUp($"Snowman%: {time:0.00}", (ThreatLevel)2);
}
}
}
}
public static class ThrowCam
{
[HarmonyPatch(typeof(PlayerWeaponToss))]
public static class WeaponToss
{
[HarmonyPatch("Initialize", new Type[]
{
typeof(WeaponPickup),
typeof(AimTarget)
})]
[HarmonyPostfix]
public static void InitPostfix(ref TossedEquipment ___tossedEquipment)
{
if (cameraAvailable)
{
Reset();
}
SetupCam();
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void UpdatePostfix(ref bool ___hitSurface, ref Transform ___tiltAnchor, ref Transform ___spinAnchor)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (!___hitSurface && cameraAvailable)
{
UpdatePos(___tiltAnchor, m_velocity);
}
}
[HarmonyPatch("OnCollisionEnter")]
[HarmonyPostfix]
public static void CollisionEnterPostfix()
{
Reset();
}
[HarmonyPatch("FixedUpdate")]
[HarmonyPostfix]
public static void FixedUpdatePostfix(float ___speed, float ___gravity, Transform ___tiltAnchor)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((Component)___tiltAnchor.parent).transform.forward * ___speed;
val += Vector3.down * ___gravity;
m_velocity = val;
}
}
[HarmonyPatch(typeof(TossedEquipment))]
public static class EquipmentToss
{
[HarmonyPatch("Initialize")]
[HarmonyPostfix]
public static void InitPostfix()
{
if (cameraAvailable)
{
Reset();
}
SetupCam();
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void UpdatePostfix(ref bool ___collided, ref Rigidbody ___rb)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
if (!___collided && cameraAvailable)
{
UpdatePos(((Component)___rb).gameObject.transform, ___rb.velocity);
}
}
[HarmonyPatch("OnCollisionEnter")]
[HarmonyPostfix]
public static void CollisionEnterPostfix()
{
Reset();
}
}
private static Camera m_cam;
private static Camera m_oldCam;
private static GameObject m_obj;
private static Vector3 m_velocity;
public static bool cameraAvailable;
private static void UpdatePos(Transform anchor, Vector3 velocity)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
m_obj.transform.position = anchor.position - velocity * Mod.throwCam_rangeScalar.Value;
if (Mod.throwCam_unlockCamera.Value)
{
m_obj.transform.rotation = ((Component)GameManager.instance.cameraManager.GetArmCamera()).transform.rotation;
}
else
{
m_obj.transform.LookAt(anchor);
}
}
public static void Reset()
{
cameraAvailable = false;
((Component)GameManager.instance.player.GetHUD().GetReticle()).gameObject.SetActive(true);
if (Object.op_Implicit((Object)(object)m_cam))
{
((Behaviour)m_cam).enabled = false;
((Behaviour)m_oldCam).enabled = true;
Object.Destroy((Object)(object)m_obj);
}
}
public static void ToggleCam()
{
((Behaviour)m_oldCam).enabled = !((Behaviour)m_oldCam).enabled;
((Behaviour)m_cam).enabled = !((Behaviour)m_cam).enabled;
GameObject gameObject = ((Component)GameManager.instance.player.GetHUD().GetReticle()).gameObject;
gameObject.SetActive(!gameObject.activeInHierarchy);
}
private static void SetupCam()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
m_oldCam = GameManager.instance.cameraManager.GetManagersCamera();
m_obj = new GameObject();
m_cam = m_obj.AddComponent<Camera>();
CameraExtensions.GetUniversalAdditionalCameraData(m_cam).cameraStack.Add(CameraExtensions.GetUniversalAdditionalCameraData(m_oldCam).cameraStack[1]);
((Behaviour)m_cam).enabled = false;
cameraAvailable = true;
if (Mod.throwCam_autoSwitch.Value)
{
ToggleCam();
}
}
}
public static class WalkabilityOverlay
{
private static Dictionary<TerrainData, float[,,]> cachedMaps = new Dictionary<TerrainData, float[,,]>();
public static void MakeWalkabilityTex(ref TerrainData data, float maxWalkableAngle)
{
if (cachedMaps.TryGetValue(data, out var value))
{
data.SetAlphamaps(0, 0, value);
return;
}
data.terrainLayers[1].diffuseTexture = Texture2D.blackTexture;
data.terrainLayers[1].diffuseTexture.Apply(true);
float[,,] array = new float[data.alphamapWidth, data.alphamapHeight, data.alphamapLayers];
for (int i = 0; i < data.alphamapHeight; i++)
{
for (int j = 0; j < data.alphamapWidth; j++)
{
float num = (float)j * 1f / (float)(data.alphamapWidth - 1);
float num2 = (float)i * 1f / (float)(data.alphamapHeight - 1);
float steepness = data.GetSteepness(num2, num);
if (steepness < maxWalkableAngle)
{
array[j, i, 0] = 1f;
continue;
}
float num3 = steepness - 45f;
array[j, i, 0] = (1f - num3 / 45f) * 0.25f;
array[j, i, 1] = num3 / 45f * 4f;
}
}
cachedMaps.Add(data, array);
data.SetAlphamaps(0, 0, array);
}
}
public static class ShowTriggers
{
[HarmonyPatch(typeof(EnemySpawner))]
public class ShowSpawners
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPostfix(EnemySpawner __instance)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
MeshRenderer val = default(MeshRenderer);
if (((Component)__instance).gameObject.TryGetComponent<MeshRenderer>(ref val))
{
((Renderer)val).material.SetColor(baseColor, spawnerColor);
}
((Component)__instance).gameObject.SetActive(true);
registry.Add(((Component)__instance).gameObject);
}
[HarmonyPatch("SpawnEnemy")]
[HarmonyPostfix]
public static void SpawnPostfix(EnemySpawner __instance, ref bool __state)
{
((Component)__instance).gameObject.SetActive(true);
}
}
[HarmonyPatch(typeof(PlacedEquipment), "Initialize")]
public class ShowEquipment
{
[HarmonyPostfix]
public static void PlacedPostfix(ref PlacedEquipment __instance)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
MakeVisible(((Component)__instance).gameObject, placedEquipmentColor);
registry.Add(((Component)__instance).gameObject);
}
}
private static Texture2D tex;
public static Material mat;
private static Color spawnerColor;
private static Color placedEquipmentColor;
private static Dictionary<Type, Color> triggerColors;
private static Dictionary<string, Color> extraColors;
private static List<GameObject> registry;
private static readonly int mainTex;
private static readonly int baseColor;
static ShowTriggers()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0020: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
tex = new Texture2D(1, 1);
mat = new Material(Shader.Find("Sprites/Default"));
spawnerColor = Color.magenta;
placedEquipmentColor = new Color(1f, 0f, 0.5f, 0.5f);
triggerColors = new Dictionary<Type, Color>();
extraColors = new Dictionary<string, Color>();
registry = new List<GameObject>();
mainTex = Shader.PropertyToID("_MainTex");
baseColor = Shader.PropertyToID("_BaseColor");
mat.SetTexture(mainTex, (Texture)(object)tex);
triggerColors.Add(typeof(PlayerOutOfBoundsBox), new Color(1f, 0.5f, 0f, 0.5f));
triggerColors.Add(typeof(PlayerTimerStartBox), new Color(0.5f, 0f, 1f, 0.5f));
triggerColors.Add(typeof(KillPlayerEventTrigger), new Color(1f, 0f, 0f, 0.5f));
extraColors.Add("Spawn", new Color(1f, 1f, 0f, 0.5f));
extraColors.Add("SpawnEnemy", new Color(1f, 1f, 0f, 0.5f));
}
public static void ShowAllOf<T>() where T : MonoBehaviour
{
T val = default(T);
for (int num = registry.Count - 1; num >= 0; num--)
{
if (!Object.op_Implicit((Object)(object)registry[num]))
{
registry.RemoveAt(num);
}
else if (registry[num].TryGetComponent<T>(ref val))
{
((Renderer)registry[num].GetComponent<MeshRenderer>()).enabled = true;
}
}
}
public static void HideAllOf<T>() where T : MonoBehaviour
{
T val = default(T);
for (int num = registry.Count - 1; num >= 0; num--)
{
if (!Object.op_Implicit((Object)(object)registry[num]))
{
registry.RemoveAt(num);
}
else if (registry[num].TryGetComponent<T>(ref val))
{
((Renderer)registry[num].GetComponent<MeshRenderer>()).enabled = false;
}
}
}
public static void ToggleAllOf<T>() where T : MonoBehaviour
{
T val = default(T);
for (int num = registry.Count - 1; num >= 0; num--)
{
if (!Object.op_Implicit((Object)(object)registry[num]))
{
registry.RemoveAt(num);
}
else if (registry[num].TryGetComponent<T>(ref val))
{
MeshRenderer component = registry[num].GetComponent<MeshRenderer>();
((Renderer)component).enabled = !((Renderer)component).enabled;
}
}
}
public static void ShowAll()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
for (int num = registry.Count - 1; num >= 0; num--)
{
if (!Object.op_Implicit((Object)(object)registry[num]))
{
registry.RemoveAt(num);
}
else
{
foreach (Transform item in registry[num].transform)
{
Transform val = item;
if (((Object)((Component)val).gameObject).name == "SpawnerTrace")
{
((Component)val).gameObject.SetActive(true);
}
}
((Renderer)registry[num].GetComponent<MeshRenderer>()).enabled = true;
}
}
}
public static void HideAll()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
for (int num = registry.Count - 1; num >= 0; num--)
{
if (!Object.op_Implicit((Object)(object)registry[num]))
{
registry.RemoveAt(num);
}
else
{
foreach (Transform item in registry[num].transform)
{
Transform val = item;
if (((Object)((Component)val).gameObject).name == "SpawnerTrace")
{
((Component)val).gameObject.SetActive(false);
}
}
((Renderer)registry[num].GetComponent<MeshRenderer>()).enabled = false;
}
}
}
public static void ToggleAll()
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
for (int num = registry.Count - 1; num >= 0; num--)
{
if (!Object.op_Implicit((Object)(object)registry[num]))
{
registry.RemoveAt(num);
}
else
{
MeshRenderer component = registry[num].GetComponent<MeshRenderer>();
foreach (Transform item in registry[num].transform)
{
Transform val = item;
if (((Object)((Component)val).gameObject).name == "SpawnerTrace")
{
((Component)val).gameObject.SetActive(!((Component)val).gameObject.activeInHierarchy);
}
}
((Renderer)component).enabled = !((Renderer)component).enabled;
}
}
}
public static void RegisterAllOf<T>() where T : MonoBehaviour
{
registry.Clear();
EventTriggerBoxPlayer[] array = Object.FindObjectsOfType<EventTriggerBoxPlayer>(true);
foreach (EventTriggerBoxPlayer val in array)
{
if (Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<T>()))
{
RegisterObj(val);
}
}
}
public static void RegisterAllExcluding(Type[] Ts)
{
registry.Clear();
EventTriggerBoxPlayer[] array = Object.FindObjectsOfType<EventTriggerBoxPlayer>(true);
foreach (EventTriggerBoxPlayer val in array)
{
bool flag = true;
foreach (Type type in Ts)
{
if (Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent(type)))
{
flag = false;
break;
}
}
if (flag)
{
RegisterObj(val);
}
}
}
public static void RegisterAll()
{
registry.Clear();
EventTriggerBoxPlayer[] array = Object.FindObjectsOfType<EventTriggerBoxPlayer>(true);
foreach (EventTriggerBoxPlayer obj in array)
{
RegisterObj(obj);
}
}
public static void ExtendRegistry()
{
EventTriggerBoxPlayer[] array = Object.FindObjectsOfType<EventTriggerBoxPlayer>(true);
foreach (EventTriggerBoxPlayer val in array)
{
if (!registry.Contains(((Component)val).gameObject))
{
RegisterObj(val);
}
}
}
private static void MakeVisible(GameObject obj, Color boxColor)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
BoxCollider val = default(BoxCollider);
if (obj.TryGetComponent<BoxCollider>(ref val))
{
MeshRenderer val2 = obj.AddComponent<MeshRenderer>();
MeshFilter val3 = default(MeshFilter);
if (!obj.TryGetComponent<MeshFilter>(ref val3))
{
val3 = obj.AddComponent<MeshFilter>();
}
GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3);
Mesh sharedMesh = val4.GetComponent<MeshFilter>().sharedMesh;
Object.Destroy((Object)(object)val4);
Mesh val5 = Object.Instantiate<Mesh>(sharedMesh);
Vector3[] vertices = val5.vertices;
for (int i = 0; i < vertices.Length; i++)
{
vertices[i] = Vector3.Scale(vertices[i], val.size) + val.center;
}
val5.vertices = vertices;
val5.RecalculateBounds();
val3.mesh = val5;
((Renderer)val2).material = mat;
((Renderer)val2).enabled = false;
((Renderer)val2).material.color = boxColor;
}
}
private static void RegisterObj(EventTriggerBoxPlayer obj)
{
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
Color boxColor = default(Color);
((Color)(ref boxColor))..ctor(0f, 1f, 0f, 0.25f);
object? value = AccessTools.Field(typeof(EventTriggerBoxPlayer), "onTrigger").GetValue(obj);
UnityEvent val = (UnityEvent)((value is UnityEvent) ? value : null);
int num = ((val != null) ? ((UnityEventBase)val).GetPersistentEventCount() : 0);
for (int i = 0; i < num; i++)
{
string text = ((val != null) ? ((UnityEventBase)val).GetPersistentMethodName(i) : null);
if ((text == "Spawn" || text == "SpawnEnemy") ? true : false)
{
Object persistentTarget = ((UnityEventBase)val).GetPersistentTarget(i);
if (!Object.op_Implicit(persistentTarget))
{
continue;
}
GameObject gameObject;
try
{
gameObject = ((Component)(MonoBehaviour)persistentTarget).gameObject;
}
catch
{
continue;
}
List<EnemySpawner> list = new List<EnemySpawner>(gameObject.GetComponentsInChildren<EnemySpawner>(true));
foreach (EnemySpawner item in list)
{
GameObject val2 = new GameObject("SpawnerTrace");
val2.transform.SetParent(((Component)obj).gameObject.transform);
LineRenderer val3 = val2.AddComponent<LineRenderer>();
((Renderer)val3).material = mat;
val3.startColor = extraColors[text];
val3.endColor = spawnerColor;
val3.positionCount = 2;
val3.SetPosition(0, ((Component)obj).gameObject.transform.position);
val3.SetPosition(1, ((Component)item).gameObject.transform.position);
val2.SetActive(false);
}
}
if (text != null && extraColors.TryGetValue(text, out var value2))
{
boxColor = value2;
}
}
foreach (KeyValuePair<Type, Color> triggerColor in triggerColors)
{
if (Object.op_Implicit((Object)(object)((Component)obj).gameObject.GetComponent(triggerColor.Key)))
{
boxColor = triggerColor.Value;
}
}
MakeVisible(((Component)obj).gameObject, boxColor);
registry.Add(((Component)obj).gameObject);
}
}
}