using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Configgy;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMUAM;
using TMUAM.Effects;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Video;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("TMUAM")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("The most annoying mod")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+596b635f77a051f4914932be42acf66049315544")]
[assembly: AssemblyProduct("TMUAM")]
[assembly: AssemblyTitle("TMUAM")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public class FakeDiscordPing : Effect
{
public class WAV
{
public float[] LeftChannel { get; private set; }
public int ChannelCount { get; private set; }
public int SampleCount { get; private set; }
public int Frequency { get; private set; }
public WAV(byte[] wav)
{
ChannelCount = wav[22];
Frequency = BitConverter.ToInt32(wav, 24);
int num = 12;
while (wav[num] != 100 || wav[num + 1] != 97 || wav[num + 2] != 116 || wav[num + 3] != 97)
{
num += 4;
int num2 = BitConverter.ToInt32(wav, num);
num += 4 + num2;
}
num += 8;
SampleCount = (wav.Length - num) / 2;
LeftChannel = new float[SampleCount];
for (int i = 0; i < SampleCount; i++)
{
LeftChannel[i] = (float)BitConverter.ToInt16(wav, num) / 32768f;
num += 2;
}
}
}
private AudioClip clip;
public override string Category => ConvertCategoryToText(Categories.Audio);
public override string Name => "Fake Discord";
public override bool HasOtherConfigs => false;
public override void OtherConfigs()
{
clip = LoadEmbeddedWav("TMUAM.Sound.discord_ping_sound_effect.wav");
base.OtherConfigs();
}
public override void OnSceneLoad()
{
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(RandomPings());
base.OnSceneLoad();
}
private IEnumerator RandomPings()
{
while (true)
{
yield return (object)new WaitForSeconds((float)Random.Range(1, 15));
GameObject objectlol = new GameObject("sound");
AudioSource audioSource = objectlol.AddComponent<AudioSource>();
audioSource.clip = clip;
audioSource.Play();
Object.Destroy((Object)(object)objectlol, clip.length);
}
}
public static AudioClip LoadEmbeddedWav(string resourceName)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
using Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
if (stream == null)
{
Debug.LogError((object)("Could not find the resource: " + resourceName));
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
WAV wAV = new WAV(array);
AudioClip val = AudioClip.Create(resourceName, wAV.SampleCount, wAV.ChannelCount, wAV.Frequency, false);
val.SetData(wAV.LeftChannel, 0);
return val;
}
}
namespace TMUAM
{
public abstract class Effect : MonoBehaviour
{
public ConfigEntry<bool> isEnabled;
public bool ActuallyActive = true;
public abstract string Category { get; }
public abstract string Name { get; }
public abstract bool HasOtherConfigs { get; }
private void Awake()
{
if (HasOtherConfigs)
{
isEnabled = Plugin.configFile.Bind<bool>("Effects/" + Category + "/" + Name, "Is Enabled", true, (ConfigDescription)null);
}
else
{
isEnabled = Plugin.configFile.Bind<bool>("Effects/" + Category, Name, true, (ConfigDescription)null);
}
isEnabled.SettingChanged += IsEnabled_SettingChanged;
OtherConfigs();
}
private void IsEnabled_SettingChanged(object sender, EventArgs e)
{
if (isEnabled.Value)
{
Plugin.activeEffects.Add(this);
if (ActuallyActive)
{
OnEffectEnabled();
}
}
else
{
Plugin.activeEffects.Remove(this);
if (ActuallyActive)
{
OnEffectDisabled();
}
}
}
public virtual void OnEffectDisabled()
{
}
public virtual void OnEffectEnabled()
{
}
public virtual void OtherConfigs()
{
}
public virtual void OnSceneLoad()
{
}
public string ConvertCategoryToText(Categories categories)
{
return categories.ToString().Replace("_", " ");
}
}
public enum Categories
{
Gameplay_Affecting_Effects,
Visual_Effects,
Audio
}
[BepInPlugin("TMUAM", "TMUAM", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private Harmony Harmony = new Harmony("TMUAM");
public static ConfigFile configFile;
public string targetNamespace = "TMUAM.Effects";
private static List<Effect> effects = new List<Effect>();
public static List<Effect> activeEffects = new List<Effect>();
public static List<Effect> VeryActiveEffects = new List<Effect>();
private ConfigEntry<bool> FullyEnabled;
private ConfigEntry<bool> ChooseRandomEffects;
public static string dir;
[Configgable("Effects", "Enable All Button", 0, null)]
public static ConfigButton EnableAll = new ConfigButton((Action)delegate
{
foreach (Effect effect in effects)
{
try
{
effect.isEnabled.Value = true;
}
catch (Exception ex2)
{
Debug.LogError((object)("Failed to enable effect: " + ex2.Message));
}
}
}, (string)null);
[Configgable("Effects", "Disable All Button", 0, null)]
public static ConfigButton DisableAll = new ConfigButton((Action)delegate
{
foreach (Effect effect2 in effects)
{
try
{
effect2.isEnabled.Value = false;
}
catch (Exception ex)
{
Debug.LogError((object)("Failed to enable effect: " + ex.Message));
}
}
}, (string)null);
public static ConfigBuilder configBuilder { get; private set; }
private void Awake()
{
FullyEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Global Settings", "Fully Enabled", true, (ConfigDescription)null);
ChooseRandomEffects = ((BaseUnityPlugin)this).Config.Bind<bool>("Global Settings", "Choose random effects", true, "Every scene (aka level) load it chooses random effects that will happen. Disabling this makes every effect happen every scene (aka level)");
configFile = ((BaseUnityPlugin)this).Config;
dir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
}
private void Start()
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
configBuilder = new ConfigBuilder((string)null, (string)null);
configBuilder.BuildAll();
Harmony.PatchAll();
Assembly executingAssembly = Assembly.GetExecutingAssembly();
IEnumerable<Type> enumerable = from t in executingAssembly.GetTypes()
where t.Namespace == targetNamespace && t.IsSubclassOf(typeof(Effect)) && !t.IsAbstract
select t;
foreach (Type item2 in enumerable)
{
Effect item = ((Component)this).gameObject.AddComponent(item2) as Effect;
effects.Add(item);
activeEffects.Add(item);
Debug.Log((object)("Added component: " + item2.Name));
}
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
}
public static List<Effect> GetRandomEffects(int amount)
{
Debug.Log((object)amount);
List<Effect> list = new List<Effect>();
List<Effect> list2 = new List<Effect>(activeEffects);
Debug.Log((object)list2.Count);
for (int i = 0; i < amount; i++)
{
int index = Random.Range(0, list2.Count);
Debug.Log((object)list2[index].Name);
list.Add(list2[index]);
list2.RemoveAt(index);
}
return list;
}
public bool isLevelScene(string scene)
{
return scene != "Main Menu" && scene != "Intro";
}
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
{
if (!isLevelScene(SceneHelper.CurrentScene))
{
return;
}
VeryActiveEffects.Clear();
Debug.Log((object)activeEffects.Count);
List<Effect> randomEffects = GetRandomEffects(Random.Range(0, activeEffects.Count));
VeryActiveEffects.AddRange(randomEffects);
foreach (Effect effect in effects)
{
if ((!VeryActiveEffects.Contains(effect) && ChooseRandomEffects.Value) || !FullyEnabled.Value)
{
effect.ActuallyActive = false;
}
else
{
effect.ActuallyActive = true;
}
effect.OnSceneLoad();
}
}
private void Update()
{
}
}
[HarmonyPatch(typeof(HudController), "Start")]
public class hudShake
{
public static bool Prefix(HudController __instance)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
HudShake.originalPos = ((Component)__instance).transform.position;
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "TMUAM";
public const string PLUGIN_NAME = "TMUAM";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace TMUAM.Effects
{
public class AdDisplayEffect : Effect
{
private ConfigEntry<float> minAdInterval;
private ConfigEntry<float> maxAdInterval;
private ConfigEntry<int> maxSimultaneousAds;
private float timeUntilNextAd;
private List<string> adVideoPaths = new List<string>();
private List<GameObject> currentAdObjects = new List<GameObject>();
private string jumpscareImageFolder;
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Ad Display";
public override bool HasOtherConfigs => true;
public override void OtherConfigs()
{
minAdInterval = Plugin.configFile.Bind<float>("Effects/" + Category + "/" + Name, "Min Ad Interval (seconds)", 10f, (ConfigDescription)null);
maxAdInterval = Plugin.configFile.Bind<float>("Effects/" + Category + "/" + Name, "Max Ad Interval (seconds)", 30f, (ConfigDescription)null);
maxSimultaneousAds = Plugin.configFile.Bind<int>("Effects/" + Category + "/" + Name, "Max Simultaneous Ads", 9999999, (ConfigDescription)null);
LoadAdVideoPaths();
SetNextAdTime();
}
private void LoadAdVideoPaths()
{
string path = (jumpscareImageFolder = Path.Combine(Plugin.dir, "Ads"));
if (Directory.Exists(path))
{
string[] files = Directory.GetFiles(path, "*.mp4");
adVideoPaths.AddRange(files);
}
}
private void SetNextAdTime()
{
timeUntilNextAd = Random.Range(minAdInterval.Value, maxAdInterval.Value);
}
public override void OnSceneLoad()
{
SetupFolders();
currentAdObjects.Clear();
base.OnSceneLoad();
}
private void Update()
{
if (isEnabled.Value && ActuallyActive && adVideoPaths.Count != 0)
{
timeUntilNextAd -= Time.deltaTime;
if (timeUntilNextAd <= 0f && currentAdObjects.Count < maxSimultaneousAds.Value)
{
DisplayAd();
SetNextAdTime();
}
currentAdObjects.RemoveAll((GameObject obj) => (Object)(object)obj == (Object)null);
}
}
private void DisplayAd()
{
LoadRandomVideo(adVideoPaths.ToArray(), Path.Combine(Plugin.dir, "Ads"));
}
private void LoadRandomVideo(string[] videoFiles, string folderPath)
{
if (videoFiles.Length == 0)
{
Debug.LogError((object)("No mp4 files found in folder: " + folderPath));
return;
}
string path = videoFiles[Random.Range(0, videoFiles.Length)];
Canvas val = FindCanvas();
if (!((Object)(object)val == (Object)null))
{
LoadVideo(path, val);
}
}
private Canvas FindCanvas()
{
List<Canvas> source = ((Component)((Component)MonoSingleton<NewMovement>.instance).transform).GetComponentsInChildren<Canvas>().ToList();
return ((IEnumerable<Canvas>)source).FirstOrDefault((Func<Canvas, bool>)((Canvas x) => ((Object)x).name.ToLower() == "finishcanvas")) ?? source.FirstOrDefault();
}
private void LoadVideo(string path, Canvas canvas)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_004a: 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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: 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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Expected O, but got Unknown
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Expected O, but got Unknown
GameObject adObject = new GameObject("VideoDisplay");
adObject.transform.SetParent(((Component)canvas).transform, false);
RawImage val = adObject.AddComponent<RawImage>();
RectTransform component = ((Component)val).GetComponent<RectTransform>();
Rect pixelRect = canvas.pixelRect;
float width = ((Rect)(ref pixelRect)).width;
pixelRect = canvas.pixelRect;
float num = Mathf.Min(width, ((Rect)(ref pixelRect)).height);
float num2 = Random.Range(50f, num);
float num3 = Random.Range(50f, num);
component.sizeDelta = new Vector2(num2, num3);
pixelRect = canvas.pixelRect;
float num4 = (0f - ((Rect)(ref pixelRect)).width) / 2f + num2 / 2f;
pixelRect = canvas.pixelRect;
float num5 = Random.Range(num4, ((Rect)(ref pixelRect)).width / 2f - num2 / 2f);
pixelRect = canvas.pixelRect;
float num6 = (0f - ((Rect)(ref pixelRect)).height) / 2f + num3 / 2f;
pixelRect = canvas.pixelRect;
float num7 = Random.Range(num6, ((Rect)(ref pixelRect)).height / 2f - num3 / 2f);
component.anchoredPosition = new Vector2(num5, num7);
VideoPlayer val2 = adObject.AddComponent<VideoPlayer>();
val2.url = path;
val2.targetTexture = new RenderTexture((int)num2, (int)num3, 0);
val.texture = (Texture)(object)val2.targetTexture;
val2.renderMode = (VideoRenderMode)2;
val2.playOnAwake = false;
val2.isLooping = false;
val2.loopPointReached += (EventHandler)delegate
{
OnVideoFinished(adObject);
};
val2.Play();
currentAdObjects.Add(adObject);
}
private void OnVideoFinished(GameObject adObject)
{
if ((Object)(object)adObject != (Object)null)
{
currentAdObjects.Remove(adObject);
Object.Destroy((Object)(object)adObject);
}
}
private void SetupFolders()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
bool flag = false;
if (!Directory.Exists(jumpscareImageFolder))
{
Directory.CreateDirectory(jumpscareImageFolder);
flag = true;
}
if (flag || !Directory.EnumerateFileSystemEntries(jumpscareImageFolder).Any())
{
ExtractEmbeddedResources();
}
}
private void ExtractEmbeddedResources()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
string[] array = manifestResourceNames;
foreach (string text in array)
{
if (!text.StartsWith("TMUAM.Videos."))
{
continue;
}
string path = text.Substring("TMUAM.Videos.".Length);
string path2 = Path.Combine(jumpscareImageFolder, path);
if (File.Exists(path2))
{
continue;
}
using Stream stream = executingAssembly.GetManifestResourceStream(text);
using FileStream destination = new FileStream(path2, FileMode.Create);
stream.CopyTo(destination);
}
}
}
[HarmonyPatch(typeof(Projectile), "Start")]
public class BiggerHitbox : Effect
{
public ConfigEntry<float> sizeMultipler;
public static BiggerHitbox Instance { get; private set; }
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Bigger Hitbox";
public override bool HasOtherConfigs => true;
public override void OtherConfigs()
{
Instance = this;
sizeMultipler = Plugin.configFile.Bind<float>("Effects/" + ConvertCategoryToText(Categories.Gameplay_Affecting_Effects) + "/" + Name, "sizeMultipler", 4f, "Multiplier for the projectile hitbox size.");
}
public static bool Prefix(ref Projectile __instance)
{
//IL_00a7: 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_0117: 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.isEnabled.Value)
{
return true;
}
if (!Instance.ActuallyActive)
{
return true;
}
Collider component = ((Component)__instance).gameObject.GetComponent<Collider>();
if ((Object)(object)component != (Object)null)
{
float value = Instance.sizeMultipler.Value;
SphereCollider val = (SphereCollider)(object)((component is SphereCollider) ? component : null);
if (val != null)
{
val.radius *= value;
}
else
{
BoxCollider val2 = (BoxCollider)(object)((component is BoxCollider) ? component : null);
if (val2 != null)
{
val2.size *= value;
}
else
{
CapsuleCollider val3 = (CapsuleCollider)(object)((component is CapsuleCollider) ? component : null);
if (val3 != null)
{
val3.radius *= value;
val3.height *= value;
}
else
{
MeshCollider val4 = (MeshCollider)(object)((component is MeshCollider) ? component : null);
if (val4 != null)
{
Transform transform = ((Component)val4).transform;
transform.localScale *= value;
}
else
{
CharacterController val5 = (CharacterController)(object)((component is CharacterController) ? component : null);
if (val5 != null)
{
val5.radius *= value;
val5.height *= value;
}
else
{
Debug.LogWarning((object)("Collider type " + ((object)component).GetType().Name + " not explicitly handled. Consider adding custom scaling."));
}
}
}
}
}
}
else
{
Debug.LogWarning((object)"Projectile has no collider, hitbox size could not be adjusted.");
}
return true;
}
}
[HarmonyPatch(typeof(Coin), "ReflectRevolver")]
public class CoinsOnlyDeflectAtPlayer : Effect
{
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Coins only target player";
public override bool HasOtherConfigs => false;
private static bool Prefix(Coin __instance)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
CoinsOnlyDeflectAtPlayer coinsOnlyDeflectAtPlayer = Plugin.activeEffects.Find((Effect e) => e is CoinsOnlyDeflectAtPlayer) as CoinsOnlyDeflectAtPlayer;
if ((Object)(object)coinsOnlyDeflectAtPlayer == (Object)null || !coinsOnlyDeflectAtPlayer.isEnabled.Value || !coinsOnlyDeflectAtPlayer.ActuallyActive)
{
return true;
}
Vector3 position = ((Component)MonoSingleton<PlayerTracker>.Instance.GetPlayer()).transform.position;
((Collider)((Component)__instance).GetComponent<SphereCollider>()).enabled = false;
LineRenderer component = __instance.SpawnBeam().GetComponent<LineRenderer>();
component.SetPosition(0, ((Component)__instance).transform.position);
component.SetPosition(1, position);
MonoSingleton<NewMovement>.Instance.GetHurt(10, true, 1f, false, false, 0.35f, false);
((Component)__instance).gameObject.SetActive(false);
new GameObject().AddComponent<CoinCollector>().coin = ((Component)__instance).gameObject;
((MonoBehaviour)__instance).CancelInvoke("GetDeleted");
return false;
}
}
public class DeafMode : Effect
{
public override string Category => ConvertCategoryToText(Categories.Audio);
public override string Name => "Deaf Mode";
public override bool HasOtherConfigs => false;
public override void OnEffectEnabled()
{
AudioListener.pause = true;
AudioListener.volume = 0f;
base.OnEffectEnabled();
}
public override void OnEffectDisabled()
{
AudioListener.pause = false;
AudioListener.volume = 1f;
base.OnEffectEnabled();
}
public override void OnSceneLoad()
{
AudioListener.pause = false;
AudioListener.volume = 1f;
if (isEnabled.Value && ActuallyActive)
{
AudioListener.pause = true;
AudioListener.volume = 0f;
base.OnSceneLoad();
}
}
public void ToggleDeafMode()
{
AudioListener.pause = !AudioListener.pause;
AudioListener.volume = (AudioListener.pause ? 0f : 1f);
}
}
public class DelayWeaponSwitch : Effect
{
[HarmonyPatch(typeof(GunControl), "SwitchWeapon", new Type[]
{
typeof(int),
typeof(List<GameObject>),
typeof(bool),
typeof(bool),
typeof(bool),
typeof(bool)
})]
public class PatchSwitchWeapon6
{
public static bool Prefix(GunControl __instance, int target, List<GameObject> slot, bool lastUsedSlot, bool useRetainedVariation, bool scrolled, bool isNextVarBind)
{
if (!Instance.isEnabled.Value || !Instance.ActuallyActive)
{
return true;
}
if (!isSwitchInProgress)
{
isSwitchInProgress = true;
((MonoBehaviour)__instance).StartCoroutine(DelayedSwitch(__instance, delegate
{
__instance.SwitchWeapon(target, slot, lastUsedSlot, useRetainedVariation, scrolled, isNextVarBind);
}));
return false;
}
return true;
}
}
[HarmonyPatch(typeof(GunControl), "SwitchWeapon", new Type[]
{
typeof(int),
typeof(bool)
})]
public class PatchSwitchWeapon2
{
public static bool Prefix(GunControl __instance, int target, bool isNextVarBind)
{
if (!Instance.isEnabled.Value || !Instance.ActuallyActive)
{
return true;
}
if (!isSwitchInProgress)
{
isSwitchInProgress = true;
((MonoBehaviour)__instance).StartCoroutine(DelayedSwitch(__instance, delegate
{
__instance.SwitchWeapon(target, isNextVarBind);
}));
return false;
}
return true;
}
}
[HarmonyPatch(typeof(GunControl), "SwitchVariant")]
public class PatchSwitchVariant
{
public static bool Prefix(GunControl __instance, int index)
{
if (!Instance.isEnabled.Value || !Instance.ActuallyActive)
{
return true;
}
if (!isSwitchInProgress)
{
isSwitchInProgress = true;
((MonoBehaviour)__instance).StartCoroutine(DelayedSwitch(__instance, delegate
{
__instance.SwitchVariant(index);
}));
return false;
}
return true;
}
}
private const float SWITCH_DELAY = 1f;
private static bool isSwitchInProgress;
public static DelayWeaponSwitch Instance { get; private set; }
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Delayed Weapon Switch";
public override bool HasOtherConfigs => false;
public override void OtherConfigs()
{
Instance = this;
}
private static IEnumerator DelayedSwitch(GunControl instance, Action originalMethod)
{
isSwitchInProgress = false;
yield return (object)new WaitForSeconds(1f);
isSwitchInProgress = true;
originalMethod();
isSwitchInProgress = false;
}
}
[HarmonyPatch(typeof(EnemyIdentifier), "DeliverDamage")]
public class DnDDamageEffect : Effect
{
private ConfigEntry<int> numberOfDice;
private ConfigEntry<int> diceSides;
private ConfigEntry<float> criticalFailureChance;
private ConfigEntry<float> failureChance;
private ConfigEntry<int> playerDamageOnFailure;
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "DnD Damage Roll";
public override bool HasOtherConfigs => true;
public override void OtherConfigs()
{
numberOfDice = Plugin.configFile.Bind<int>("Effects/" + Category + "/" + Name, "Number of Dice", 1, "Number of dice to roll for damage");
diceSides = Plugin.configFile.Bind<int>("Effects/" + Category + "/" + Name, "Dice Sides", 20, "Number of sides on each die");
criticalFailureChance = Plugin.configFile.Bind<float>("Effects/" + Category + "/" + Name, "Critical Failure Chance", 0.15f, "Chance of critical failure (0.0 to 1.0)");
failureChance = Plugin.configFile.Bind<float>("Effects/" + Category + "/" + Name, "Failure Chance", 0.35f, "Chance of failure (0.0 to 1.0)");
playerDamageOnFailure = Plugin.configFile.Bind<int>("Effects/" + Category + "/" + Name, "Player Damage on Failure", 10, "Damage dealt to player on failure");
}
[HarmonyPrefix]
private static bool Prefix(ref float multiplier, ref EnemyIdentifier __instance)
{
if (__instance.dead)
{
return true;
}
DnDDamageEffect dnDDamageEffect = Plugin.activeEffects.Find((Effect e) => e is DnDDamageEffect) as DnDDamageEffect;
if ((Object)(object)dnDDamageEffect == (Object)null || !dnDDamageEffect.isEnabled.Value || !dnDDamageEffect.ActuallyActive)
{
return true;
}
int num = 0;
for (int i = 0; i < dnDDamageEffect.numberOfDice.Value; i++)
{
num += Random.Range(1, dnDDamageEffect.diceSides.Value + 1);
}
float value = Random.value;
string text;
if (value < dnDDamageEffect.criticalFailureChance.Value)
{
multiplier = 0f;
DamagePlayer(dnDDamageEffect.playerDamageOnFailure.Value * 2);
text = $"Critical Failure! Player takes {dnDDamageEffect.playerDamageOnFailure.Value * 2} damage!";
}
else if (value < dnDDamageEffect.criticalFailureChance.Value + dnDDamageEffect.failureChance.Value)
{
multiplier = 0f;
DamagePlayer(dnDDamageEffect.playerDamageOnFailure.Value);
text = $"Failure! Player takes {dnDDamageEffect.playerDamageOnFailure.Value} damage!";
}
else
{
multiplier *= num;
text = $"Success! Enemy takes {num} damage!";
}
Debug.Log((object)$"DnD Damage Roll: {num} ({dnDDamageEffect.numberOfDice.Value}d{dnDDamageEffect.diceSides.Value}) - {text}");
MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage($"DnD Damage Roll: {num} ({dnDDamageEffect.numberOfDice.Value}d{dnDDamageEffect.diceSides.Value}) - {text}", "", "", 0, false);
return true;
}
private static void DamagePlayer(int damage)
{
MonoSingleton<NewMovement>.Instance.GetHurt(damage, true, 1f, false, false, 0.35f, false);
}
}
public class DreamedHealthBlocker : Effect
{
private Sprite dreamed;
private List<GameObject> dreameds = new List<GameObject>();
public override string Category => Categories.Visual_Effects.ToString().Replace("_", " ");
public override string Name => "Dreamed Blocker";
public override bool HasOtherConfigs => false;
public override void OtherConfigs()
{
dreamed = GetDreamedSprite();
}
public override void OnSceneLoad()
{
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Expected O, but got Unknown
//IL_01ad: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Expected O, but got Unknown
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
dreameds.Clear();
if (!isEnabled.Value || !ActuallyActive)
{
return;
}
List<HudController> list = Resources.FindObjectsOfTypeAll<HudController>().ToList();
list.RemoveAll((HudController x) => ((Component)x).gameObject.scene != SceneManager.GetActiveScene());
foreach (HudController item in list)
{
Debug.Log((object)item.altHud);
if (item.altHud)
{
GameObject gameObject = ((Component)((Component)item).gameObject.transform.Find("Filler")).gameObject;
GameObject val = new GameObject("Dreamed");
val.transform.parent = gameObject.transform;
val.AddComponent<Image>().sprite = dreamed;
val.transform.localPosition = new Vector3(0f, -327.1803f, 0f);
val.transform.localScale = new Vector3(9.5455f, 1.0509f, 1f);
val.transform.localRotation = Quaternion.identity;
dreameds.Add(val);
}
else
{
GameObject gunCanvas = item.gunCanvas;
GameObject val2 = new GameObject("Dreamed");
val2.transform.parent = gunCanvas.transform;
val2.AddComponent<Image>().sprite = dreamed;
val2.transform.localPosition = new Vector3(0f, 58.347f, 0f);
val2.transform.localScale = new Vector3(9.5455f, 7.2945f, 1f);
val2.transform.localRotation = Quaternion.identity;
dreameds.Add(val2);
}
}
List<Crosshair> list2 = Resources.FindObjectsOfTypeAll<Crosshair>().ToList();
list2.RemoveAll((Crosshair x) => ((Component)x).gameObject.scene != SceneManager.GetActiveScene());
foreach (Crosshair item2 in list2)
{
GameObject val3 = new GameObject("Dreamed");
val3.transform.parent = ((Component)item2).gameObject.transform;
val3.AddComponent<Image>().sprite = dreamed;
val3.transform.localPosition = Vector3.zero;
val3.transform.localScale = Vector3.one;
val3.transform.localRotation = Quaternion.identity;
dreameds.Add(val3);
}
}
public override void OnEffectEnabled()
{
if (dreameds.Count <= 0)
{
return;
}
foreach (GameObject dreamed in dreameds)
{
dreamed.SetActive(true);
}
}
public override void OnEffectDisabled()
{
if (dreameds.Count <= 0)
{
return;
}
foreach (GameObject dreamed in dreameds)
{
dreamed.SetActive(false);
}
}
public Sprite GetDreamedSprite()
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string text = "TMUAM.Images.dreamed.png";
using Stream stream = executingAssembly.GetManifestResourceStream(text);
if (stream == null)
{
Debug.LogError((object)("Could not find the embedded resource: " + text));
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, array);
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
}
}
public class DynamicPOV : Effect
{
[SerializeField]
private ConfigEntry<float> minFOV;
[SerializeField]
private ConfigEntry<float> maxFOV;
[SerializeField]
private ConfigEntry<float> velocityMultiplier;
public override string Category => ConvertCategoryToText(Categories.Visual_Effects);
public override string Name => "Dynamic FOV";
public override bool HasOtherConfigs => true;
public override void OtherConfigs()
{
minFOV = Plugin.configFile.Bind<float>("Effects/" + ConvertCategoryToText(Categories.Visual_Effects) + "/" + Name, "minFOV", 30f, (ConfigDescription)null);
maxFOV = Plugin.configFile.Bind<float>("Effects/" + ConvertCategoryToText(Categories.Visual_Effects) + "/" + Name, "maxFOV", 120f, (ConfigDescription)null);
velocityMultiplier = Plugin.configFile.Bind<float>("Effects/" + ConvertCategoryToText(Categories.Visual_Effects) + "/" + Name, "velocityMultiplier", 1f, (ConfigDescription)null);
}
private void Update()
{
//IL_0043: 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)
try
{
if (isEnabled.Value && ActuallyActive && !((Object)(object)Camera.main == (Object)null))
{
Vector3 playerVelocity = MonoSingleton<PlayerTracker>.Instance.GetPlayerVelocity(true);
float magnitude = ((Vector3)(ref playerVelocity)).magnitude;
float num = minFOV.Value + magnitude * velocityMultiplier.Value;
float fieldOfView = Mathf.Clamp(num, minFOV.Value, maxFOV.Value);
Camera.main.fieldOfView = fieldOfView;
}
}
catch (Exception)
{
}
}
}
[HarmonyPatch(typeof(EnemyIdentifier), "Death", new Type[] { typeof(bool) })]
public class EnemiesExplodeOnDeath : Effect
{
public static List<GameObject> explosives = new List<GameObject>();
private string[] explosivePaths = new string[20]
{
"Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Minos Prime.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Rocket Harmless.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Wave.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Landmine.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Big.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Ferryman.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Mindflayer.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Lightning.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Sand.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Malicious Railcannon.prefab",
"Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Wave Sisyphus.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Lightning Strike Explosive.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Sisyphus Prime.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Gutterman.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Wave Enemy.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Super.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Harmless.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Sisyphus Prime Charged.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Lightning - No Lightning.prefab"
};
private static bool assetsLoaded = false;
private static Dictionary<EnemyIdentifier, bool> hasExploded = new Dictionary<EnemyIdentifier, bool>();
public static EnemiesExplodeOnDeath Instance { get; private set; }
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Enemies Explode On Death";
public override bool HasOtherConfigs => false;
public override void OtherConfigs()
{
Instance = this;
((MonoBehaviour)this).StartCoroutine(LoadExplosives());
base.OtherConfigs();
}
private IEnumerator LoadExplosives()
{
string[] array = explosivePaths;
foreach (string path in array)
{
AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>((object)path);
yield return handle;
if ((int)handle.Status == 1)
{
explosives.Add(handle.Result);
Debug.Log((object)("Successfully loaded " + path));
}
else
{
Debug.LogError((object)("Failed to load " + path));
}
}
assetsLoaded = true;
}
public static bool Prefix(ref EnemyIdentifier __instance)
{
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
if (__instance.dead)
{
return true;
}
if (!Instance.isEnabled.Value)
{
return true;
}
if (!Instance.ActuallyActive)
{
return true;
}
if (!assetsLoaded)
{
Debug.LogWarning((object)"Explosive assets not yet loaded. Skipping explosion.");
return true;
}
if (hasExploded.ContainsKey(__instance) && hasExploded[__instance])
{
return true;
}
hasExploded[__instance] = true;
if (explosives.Count == 0)
{
return true;
}
GameObject val = explosives[Random.Range(0, explosives.Count)];
Object.Instantiate<GameObject>(val, ((Component)__instance).transform.position, Quaternion.identity);
return true;
}
}
[HarmonyPatch(typeof(EnemyIdentifier), "Start")]
public class EnemiesSpawnBehindYou : Effect
{
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Enemies Spawn Behind You";
public override bool HasOtherConfigs => false;
public static EnemiesSpawnBehindYou instance { get; set; }
public override void OtherConfigs()
{
instance = this;
base.OtherConfigs();
}
public static void Postfix(EnemyIdentifier __instance)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if (instance.isEnabled.Value && instance.ActuallyActive)
{
((Component)__instance).transform.position = ((Component)MonoSingleton<NewMovement>.instance).transform.position;
}
}
}
public class EverySoundFilter : Effect
{
private AudioLowPassFilter filter1;
private AudioHighPassFilter filter2;
private AudioEchoFilter filter3;
private AudioDistortionFilter filter4;
private AudioReverbFilter filter5;
private AudioChorusFilter filter6;
public override string Category => Categories.Audio.ToString().Replace("_", " ");
public override string Name => "Get Every Sound Filter";
public override bool HasOtherConfigs => false;
public override void OnSceneLoad()
{
if (ActuallyActive && isEnabled.Value)
{
ApplyEverySoundFilter();
}
}
public override void OnEffectDisabled()
{
Object.Destroy((Object)(object)filter1);
Object.Destroy((Object)(object)filter2);
Object.Destroy((Object)(object)filter3);
Object.Destroy((Object)(object)filter4);
Object.Destroy((Object)(object)filter5);
Object.Destroy((Object)(object)filter6);
}
public override void OnEffectEnabled()
{
ApplyEverySoundFilter();
}
private void ApplyEverySoundFilter()
{
GameObject gameObject = ((Component)Camera.main).gameObject;
filter1 = gameObject.AddComponent<AudioLowPassFilter>();
filter2 = gameObject.AddComponent<AudioHighPassFilter>();
filter3 = gameObject.AddComponent<AudioEchoFilter>();
filter4 = gameObject.AddComponent<AudioDistortionFilter>();
filter5 = gameObject.AddComponent<AudioReverbFilter>();
filter6 = gameObject.AddComponent<AudioChorusFilter>();
}
}
public class EverythingCostsStamina : Effect
{
public static EverythingCostsStamina Instance;
public static ConfigEntry<bool> IsEnabled;
public override string Category => Categories.Gameplay_Affecting_Effects.ToString().Replace("_", " ");
public override string Name => "Everything Costs Stamina";
public override bool HasOtherConfigs => false;
public override void OtherConfigs()
{
Instance = this;
IsEnabled = isEnabled;
base.OtherConfigs();
}
}
[HarmonyPatch]
public class PatchinStamina
{
[HarmonyPatch(typeof(Revolver), "Shoot")]
[HarmonyPatch(typeof(Shotgun), "Shoot")]
[HarmonyPatch(typeof(Nailgun), "Shoot")]
[HarmonyPatch(typeof(RocketLauncher), "Shoot")]
[HarmonyPatch(typeof(Railcannon), "Shoot")]
public static bool Prefix()
{
if (!EverythingCostsStamina.Instance.ActuallyActive)
{
return true;
}
if (!EverythingCostsStamina.IsEnabled.Value)
{
return true;
}
if (MonoSingleton<NewMovement>.Instance.boostCharge >= 100f)
{
NewMovement instance = MonoSingleton<NewMovement>.Instance;
instance.boostCharge -= 25f;
return true;
}
return false;
}
[HarmonyPatch(typeof(NewMovement), "Jump")]
[HarmonyPrefix]
public static bool Prefix2()
{
if (!EverythingCostsStamina.Instance.ActuallyActive)
{
return true;
}
if (!EverythingCostsStamina.IsEnabled.Value)
{
return true;
}
if (MonoSingleton<NewMovement>.Instance.boostCharge >= 100f)
{
NewMovement instance = MonoSingleton<NewMovement>.Instance;
instance.boostCharge -= 65f;
return true;
}
return false;
}
[HarmonyPatch(typeof(NewMovement), "Parry")]
[HarmonyPrefix]
public static bool Prefix3(ref NewMovement __instance, EnemyIdentifier eid = null, string customParryText = "")
{
Debug.Log((object)"hi i parried");
if (!EverythingCostsStamina.Instance.ActuallyActive)
{
return true;
}
if (!EverythingCostsStamina.IsEnabled.Value)
{
return true;
}
Debug.Log((object)"hi i parried");
if (MonoSingleton<NewMovement>.Instance.boostCharge >= 200f)
{
NewMovement instance = MonoSingleton<NewMovement>.Instance;
instance.boostCharge -= 300f;
MonoSingleton<TimeController>.Instance.ParryFlash();
__instance.exploded = false;
__instance.GetHealth(999, false, false);
if ((Object)(object)__instance.shud == (Object)null)
{
__instance.shud = MonoSingleton<StyleHUD>.Instance;
}
if (!Object.op_Implicit((Object)(object)eid) || !eid.blessed)
{
__instance.shud.AddPoints(100, (customParryText != "") ? ("<color=green>" + customParryText + "</color>") : "ultrakill.parry", (GameObject)null, (EnemyIdentifier)null, -1, "", "");
}
return false;
}
Debug.Log((object)"hi i parried");
return false;
}
[HarmonyPatch(typeof(Punch), "PunchStart")]
public static bool Prefix3()
{
if (!EverythingCostsStamina.Instance.ActuallyActive)
{
return true;
}
if (!EverythingCostsStamina.IsEnabled.Value)
{
return true;
}
if (MonoSingleton<NewMovement>.Instance.boostCharge >= 100f)
{
NewMovement instance = MonoSingleton<NewMovement>.Instance;
instance.boostCharge -= 15f;
return true;
}
return false;
}
}
[HarmonyPatch]
public class ExplodingWeaponsRandomly : Effect
{
public static List<GameObject> explosives = new List<GameObject>();
private string[] explosivePaths = new string[20]
{
"Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Minos Prime.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Rocket Harmless.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Wave.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Landmine.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Big.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Ferryman.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Mindflayer.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Lightning.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Sand.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Malicious Railcannon.prefab",
"Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Wave Sisyphus.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Lightning Strike Explosive.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Sisyphus Prime.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Gutterman.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Wave Enemy.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Super.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Harmless.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Sisyphus Prime Charged.prefab", "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Lightning - No Lightning.prefab"
};
private static bool assetsLoaded = false;
public ConfigEntry<float> ChanceToExplode;
public static ExplodingWeaponsRandomly Instance { get; private set; }
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Weapons Explode Randomly";
public override bool HasOtherConfigs => true;
private IEnumerator LoadExplosives()
{
string[] array = explosivePaths;
foreach (string path in array)
{
AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>((object)path);
yield return handle;
if ((int)handle.Status == 1)
{
explosives.Add(handle.Result);
Debug.Log((object)("Successfully loaded " + path));
}
else
{
Debug.LogError((object)("Failed to load " + path));
}
}
assetsLoaded = true;
}
public override void OtherConfigs()
{
Instance = this;
((MonoBehaviour)this).StartCoroutine(LoadExplosives());
ChanceToExplode = Plugin.configFile.Bind<float>("Effects/" + ConvertCategoryToText(Categories.Gameplay_Affecting_Effects) + "/" + Name, "Chance To Explode", 25f, (ConfigDescription)null);
base.OtherConfigs();
}
[HarmonyPatch(typeof(Revolver), "Shoot")]
[HarmonyPatch(typeof(Shotgun), "Shoot")]
[HarmonyPatch(typeof(Nailgun), "Shoot")]
[HarmonyPatch(typeof(RocketLauncher), "Shoot")]
[HarmonyPatch(typeof(Railcannon), "Shoot")]
public static bool Prefix(ref MonoBehaviour __instance)
{
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
if (!Instance.isEnabled.Value || !Instance.ActuallyActive)
{
return true;
}
float num = Random.Range(0f, 100f);
if (Instance.ChanceToExplode.Value > num)
{
GameObject val = Object.Instantiate<GameObject>(explosives[Random.Range(0, explosives.Count)], ((Component)__instance).gameObject.transform.position, Quaternion.identity);
val.GetComponentInChildren<Explosion>().canHit = (AffectedSubjects)1;
val.GetComponentInChildren<Explosion>().harmless = false;
return false;
}
return true;
}
}
public class ExtraHUDsEffect : Effect
{
private const string HUD_DIRECTORY = "HUDS";
private List<Texture2D> hudTextures = new List<Texture2D>();
private ConfigEntry<int> numberOfHUDs;
private List<RawImage> hudImages = new List<RawImage>();
private Canvas hudCanvas;
public override string Category => ConvertCategoryToText(Categories.Visual_Effects);
public override string Name => "Extra HUDs";
public override bool HasOtherConfigs => true;
public override void OtherConfigs()
{
numberOfHUDs = Plugin.configFile.Bind<int>("Effects/Visual Effects/Extra HUDs", "Number of HUDs", 5, "The number of extra HUDs to display");
}
public override void OnEffectEnabled()
{
LoadOrGenerateHUDs();
CreateHUDCanvas();
DisplayHUDs();
}
public override void OnEffectDisabled()
{
ClearHUDs();
DestroyHUDCanvas();
}
public override void OnSceneLoad()
{
LoadOrGenerateHUDs();
CreateHUDCanvas();
DisplayHUDs();
}
private void LoadOrGenerateHUDs()
{
ClearHUDs();
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "HUDS");
if (!Directory.Exists(text))
{
Directory.CreateDirectory(text);
}
if (Directory.Exists(text) && Directory.GetFiles(text, "*.png").Length != 0)
{
LoadHUDsFromDirectory(text);
}
else
{
GenerateHUDsFromEmbeddedResources(text);
}
Debug.Log((object)$"[ExtraHUDsEffect] Loaded {hudTextures.Count} HUD textures.");
}
private void ClearHUDs()
{
foreach (Texture2D hudTexture in hudTextures)
{
if ((Object)(object)hudTexture != (Object)null)
{
Object.Destroy((Object)(object)hudTexture);
}
}
hudTextures.Clear();
foreach (RawImage hudImage in hudImages)
{
if ((Object)(object)hudImage != (Object)null)
{
Object.Destroy((Object)(object)((Component)hudImage).gameObject);
}
}
hudImages.Clear();
}
private void LoadHUDsFromDirectory(string path)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
string[] files = Directory.GetFiles(path, "*.png");
string[] array = files;
foreach (string text in array)
{
try
{
Texture2D val = new Texture2D(2, 2);
byte[] array2 = File.ReadAllBytes(text);
if (ImageConversion.LoadImage(val, array2))
{
hudTextures.Add(val);
Debug.Log((object)("[ExtraHUDsEffect] Loaded texture from file: " + text));
}
else
{
Debug.LogError((object)("[ExtraHUDsEffect] Failed to load texture from file: " + text));
}
}
catch (Exception ex)
{
Debug.LogError((object)("[ExtraHUDsEffect] Error loading texture from file " + text + ": " + ex.Message));
}
}
}
private void GenerateHUDsFromEmbeddedResources(string outputPath)
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
string[] array = manifestResourceNames;
foreach (string text in array)
{
if (!text.StartsWith("TMUAM.HUDS.") || !text.EndsWith(".png"))
{
continue;
}
try
{
using Stream stream = executingAssembly.GetManifestResourceStream(text);
if (stream != null)
{
byte[] array2 = new byte[stream.Length];
stream.Read(array2, 0, array2.Length);
Texture2D val = new Texture2D(2, 2);
if (ImageConversion.LoadImage(val, array2))
{
hudTextures.Add(val);
Debug.Log((object)("[ExtraHUDsEffect] Loaded texture from embedded resource: " + text));
}
else
{
Debug.LogError((object)("[ExtraHUDsEffect] Failed to load texture from embedded resource: " + text));
}
string fileName = Path.GetFileName(text);
File.WriteAllBytes(Path.Combine(outputPath, fileName), array2);
}
}
catch (Exception ex)
{
Debug.LogError((object)("[ExtraHUDsEffect] Error loading texture from embedded resource " + text + ": " + ex.Message));
}
}
}
private void CreateHUDCanvas()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("HUDCanvas");
hudCanvas = val.AddComponent<Canvas>();
hudCanvas.renderMode = (RenderMode)0;
hudCanvas.sortingOrder = 1000;
CanvasScaler val2 = val.AddComponent<CanvasScaler>();
val2.uiScaleMode = (ScaleMode)1;
val2.referenceResolution = new Vector2(1920f, 1080f);
val.AddComponent<GraphicRaycaster>();
}
private void DestroyHUDCanvas()
{
if ((Object)(object)hudCanvas != (Object)null)
{
Object.Destroy((Object)(object)((Component)hudCanvas).gameObject);
hudCanvas = null;
}
}
private void DisplayHUDs()
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: 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)
if (isEnabled.Value && ActuallyActive && !((Object)(object)hudCanvas == (Object)null))
{
int num = Math.Min(numberOfHUDs.Value, hudTextures.Count);
for (int i = 0; i < num; i++)
{
GameObject val = new GameObject($"HUD_{i}");
val.transform.SetParent(((Component)hudCanvas).transform, false);
RawImage val2 = val.AddComponent<RawImage>();
val2.texture = (Texture)(object)hudTextures[i];
((Graphic)val2).color = new Color(1f, 1f, 1f, 1f);
RectTransform rectTransform = ((Graphic)val2).rectTransform;
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = Vector2.one;
rectTransform.sizeDelta = Vector2.zero;
rectTransform.anchoredPosition = Vector2.zero;
((Graphic)val2).raycastTarget = false;
hudImages.Add(val2);
Debug.Log((object)$"[ExtraHUDsEffect] Displayed HUD {i} with texture size: {((Texture)hudTextures[i]).width}x{((Texture)hudTextures[i]).height}");
}
}
}
private void Update()
{
if (isEnabled.Value && ActuallyActive && (Object)(object)hudCanvas != (Object)null && hudImages.Count != numberOfHUDs.Value)
{
ClearHUDs();
DisplayHUDs();
}
}
}
public class FakeCheckPoints : Effect
{
public static FakeCheckPoints Instance { get; set; }
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Fake Checkpoints";
public override bool HasOtherConfigs => false;
public override void OtherConfigs()
{
Instance = this;
base.OtherConfigs();
}
}
[HarmonyPatch(typeof(CheckPoint), "ActivateCheckPoint")]
public class FakeCheckpointsmaybe
{
public static bool Prefix(CheckPoint __instance)
{
//IL_0064: 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)
if (!FakeCheckPoints.Instance.isEnabled.Value)
{
return true;
}
if (!FakeCheckPoints.Instance.ActuallyActive)
{
return true;
}
float num = Random.Range(0, 100);
if (num > 75f)
{
Object.Instantiate<GameObject>(AddressablesExtensions.ToAsset(__instance.activateEffect), MonoSingleton<PlayerTracker>.Instance.GetPlayer().position, Quaternion.identity);
if (Object.op_Implicit((Object)(object)__instance.graphic))
{
if (__instance.multiUse)
{
__instance.graphic.SetActive(false);
}
else
{
Object.Destroy((Object)(object)((Component)__instance).gameObject);
}
}
return false;
}
return true;
}
}
public class HealthDrainWhileIdle : Effect
{
private bool wasIdle = false;
private bool DAMAGETHATPLAYER;
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Health Drain While Idle";
public override bool HasOtherConfigs => false;
private void Update()
{
if (!isEnabled.Value || !ActuallyActive || (Object)(object)MonoSingleton<StatsManager>.Instance == (Object)null || !MonoSingleton<StatsManager>.instance.levelStarted)
{
return;
}
if ((Object)(object)MonoSingleton<NewMovement>.instance != (Object)null)
{
if (((Vector3)(ref MonoSingleton<NewMovement>.instance.movementDirection)).magnitude == 0f && !wasIdle)
{
wasIdle = true;
((MonoBehaviour)this).StartCoroutine(WaitBeforeDMG());
}
else if (((Vector3)(ref MonoSingleton<NewMovement>.instance.movementDirection)).magnitude != 0f)
{
wasIdle = false;
((MonoBehaviour)this).StopAllCoroutines();
DAMAGETHATPLAYER = false;
}
}
if (DAMAGETHATPLAYER)
{
MonoSingleton<NewMovement>.instance.GetHurt(1, false, 1f, false, false, 0.35f, false);
}
}
private IEnumerator WaitBeforeDMG()
{
yield return (object)new WaitForSeconds(2f);
DAMAGETHATPLAYER = true;
}
}
public class HudShake : Effect
{
public ConfigEntry<float> shakeDuration;
public ConfigEntry<float> shakeAmount;
public ConfigEntry<float> decreaseFactor;
public static Vector3 originalPos;
public override string Category => Categories.Visual_Effects.ToString().Replace("_", " ");
public override string Name => "Hud Shake";
public override bool HasOtherConfigs => true;
public override void OtherConfigs()
{
shakeDuration = Plugin.configFile.Bind<float>("Effects/Visual Effects/Hud Shake", "shake duration", 0.5f, (ConfigDescription)null);
shakeAmount = Plugin.configFile.Bind<float>("Effects/Visual Effects/Hud Shake", "shake Amount", 0.7f, (ConfigDescription)null);
decreaseFactor = Plugin.configFile.Bind<float>("Effects/Visual Effects/Hud Shake", "decrease Factor", 1f, (ConfigDescription)null);
}
public override void OnSceneLoad()
{
((MonoBehaviour)this).StopAllCoroutines();
if (ActuallyActive && isEnabled.Value)
{
((MonoBehaviour)this).StartCoroutine(Shake());
}
}
public override void OnEffectDisabled()
{
((MonoBehaviour)this).StopAllCoroutines();
}
private IEnumerator Shake()
{
float elapsed2 = 0f;
Debug.Log((object)elapsed2);
while (!((Object)(object)HudController.Instance == (Object)null))
{
if (isEnabled.Value)
{
elapsed2 = 0f;
while (elapsed2 < shakeDuration.Value)
{
float x = Random.Range(-1f, 1f) * shakeAmount.Value;
float y = Random.Range(-1f, 1f) * shakeAmount.Value;
((Component)HudController.Instance).transform.localPosition = new Vector3(x, y, originalPos.z);
elapsed2 += Time.deltaTime;
yield return null;
}
((Component)HudController.Instance).transform.localPosition = originalPos;
yield return (object)new WaitForSeconds(0.1f);
}
}
yield return null;
}
}
public class LandMineSpawner : Effect
{
private string landminePrefabPath = "Assets/Prefabs/Attacks and Projectiles/Landmine.prefab";
private GameObject landminePrefab;
private ConfigEntry<float> spawnInterval;
private Coroutine spawnCoroutine;
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Landmine Spawner";
public override bool HasOtherConfigs => true;
private IEnumerator LoadExplosives()
{
AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>((object)landminePrefabPath);
yield return handle;
if ((int)handle.Status == 1)
{
landminePrefab = handle.Result.gameObject;
Debug.Log((object)("Successfully loaded " + landminePrefabPath));
}
else
{
Debug.LogError((object)("Failed to load " + landminePrefabPath));
}
}
public override void OtherConfigs()
{
spawnInterval = Plugin.configFile.Bind<float>("Effects/" + Category + "/" + Name, "Spawn Interval", 5f, "Time in seconds between landmine spawns");
}
public override void OnSceneLoad()
{
((MonoBehaviour)this).StopAllCoroutines();
if ((Object)(object)landminePrefab == (Object)null)
{
((MonoBehaviour)this).StartCoroutine(LoadExplosives());
Debug.LogError((object)"Failed to load Landmine prefab!");
}
else
{
spawnCoroutine = ((MonoBehaviour)this).StartCoroutine(SpawnLandmines());
}
}
public override void OnEffectEnabled()
{
if ((Object)(object)landminePrefab == (Object)null)
{
((MonoBehaviour)this).StartCoroutine(LoadExplosives());
Debug.LogError((object)"Failed to load Landmine prefab!");
}
else
{
spawnCoroutine = ((MonoBehaviour)this).StartCoroutine(SpawnLandmines());
}
}
public override void OnEffectDisabled()
{
if (spawnCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(spawnCoroutine);
spawnCoroutine = null;
}
}
private IEnumerator SpawnLandmines()
{
while (true)
{
yield return (object)new WaitForSeconds(spawnInterval.Value);
if ((Object)(object)MonoSingleton<NewMovement>.Instance != (Object)null && isEnabled.Value && ActuallyActive)
{
Vector3 spawnPosition = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
Object.Instantiate<GameObject>(landminePrefab, spawnPosition, Quaternion.identity);
}
}
}
}
[HarmonyPatch]
public class NoMoreTaunts : Effect
{
public static NoMoreTaunts Instance { get; private set; }
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "No More Cooldowns";
public override bool HasOtherConfigs => false;
public override void OtherConfigs()
{
Instance = this;
base.OtherConfigs();
}
private bool CanRunCode()
{
return isEnabled.Value && ActuallyActive;
}
[HarmonyPatch(typeof(Gabriel), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsGabe1(ref Gabriel __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.attackCooldown = 0f;
__instance.readyTaunt = false;
return true;
}
[HarmonyPatch(typeof(GabrielSecond), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsGabe2(ref GabrielSecond __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.attackCooldown = 0f;
__instance.readyTaunt = false;
return true;
}
[HarmonyPatch(typeof(SisyphusPrime), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsSisyphus(ref SisyphusPrime __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.cooldown = 0f;
__instance.tauntCheck = false;
return true;
}
[HarmonyPatch(typeof(MinosPrime), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsMinos(ref MinosPrime __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.cooldown = 0f;
return true;
}
[HarmonyPatch(typeof(Sisyphus), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsSisyphusNormal(ref Sisyphus __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.cooldown = 0f;
return true;
}
[HarmonyPatch(typeof(ZombieProjectiles), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsZombieProj(ref ZombieProjectiles __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.coolDown = 0f;
return true;
}
[HarmonyPatch(typeof(Turret), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsZombieProj(ref Turret __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.cooldown = 0f;
__instance.kickCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(EnemyCooldowns), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsEnemyCooldowns(ref EnemyCooldowns __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.ferrymanCooldown = 0f;
__instance.virtueCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(Drone), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsDrone(ref Drone __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.attackCooldown = 0f;
__instance.dodgeCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(DroneFlesh), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsDroneFlesh(ref DroneFlesh __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.cooldown = 0f;
return true;
}
[HarmonyPatch(typeof(Streetcleaner), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsStreetcleanah(ref Streetcleaner __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.cooldown = 0f;
__instance.dodgeCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(V2), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsRECONSTRUCTWHAT(ref V2 __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.shootCooldown = 0f;
__instance.altShootCooldown = 0f;
__instance.dodgeCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(Mindflayer), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsHearMeOut(ref Mindflayer __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.cooldown = 0f;
__instance.beamCooldown = false;
return true;
}
[HarmonyPatch(typeof(Gutterman), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsHeavy(ref Gutterman __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.bulletCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(Guttertank), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsGuttertank(ref Guttertank __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.mineCooldown = 0f;
__instance.punchCooldown = 0f;
__instance.shootCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(SpiderBody), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsMaurice(ref SpiderBody __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.burstCharge = 0f;
return true;
}
[HarmonyPatch(typeof(StatueBoss), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsCerberus(ref StatueBoss __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.attackCheckCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(Mass), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsMass(ref Mass __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.attackCooldown = 0f;
__instance.swingCooldown = 0f;
__instance.spearCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(Mannequin), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsMannequin(ref Mannequin __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.jumpCooldown = 0f;
__instance.meleeCooldown = 0f;
__instance.projectileCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(Minotaur), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsMinotaur(ref Minotaur __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.cooldown = 0f;
__instance.ramCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(MinotaurChase), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsMinotaurChase(ref MinotaurChase __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.cooldown = 0f;
return true;
}
[HarmonyPatch(typeof(CancerousRodent), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsHardestBoss(ref CancerousRodent __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.coolDown = 0f;
return true;
}
[HarmonyPatch(typeof(FleshPrison), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsPrison(ref FleshPrison __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.attackCooldown = 0f;
__instance.homingProjectileCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(MinosArm), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsMinosArm(ref MinosArm __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.attackCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(MinosBoss), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsMinosBoss(ref MinosBoss __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.cooldown = 0f;
__instance.blackHoleCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(LeviathanHead), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsLeviathanHead(ref LeviathanHead __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.attackCooldown = 0f;
__instance.projectileBurstCooldown = 0f;
return true;
}
[HarmonyPatch(typeof(Mandalore), "Update")]
[HarmonyPrefix]
public static bool NoCooldownsMandalore(ref Mandalore __instance)
{
if (!Instance.CanRunCode())
{
return true;
}
__instance.cooldown = 0f;
return true;
}
}
[HarmonyPatch(typeof(Projectile), "Start")]
public class ProjectileHomeAtYou : Effect
{
public ConfigEntry<int> chanceToHome;
public static ProjectileHomeAtYou instance { get; set; }
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Projectiles Home At You";
public override bool HasOtherConfigs => true;
public override void OtherConfigs()
{
instance = this;
chanceToHome = Plugin.configFile.Bind<int>("Effects/" + ConvertCategoryToText(Categories.Gameplay_Affecting_Effects) + "/" + Name, "Chance to home", 15, (ConfigDescription)null);
base.OtherConfigs();
}
public static void Postfix(Projectile __instance)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
if (instance.isEnabled.Value && instance.ActuallyActive && Random.Range(0, 100) <= instance.chanceToHome.Value && (int)__instance.homingType == 0)
{
EnemyTarget target = new EnemyTarget(MonoSingleton<PlayerTracker>.Instance.GetPlayer());
__instance.homingType = (HomingType)4;
__instance.target = target;
__instance.playerBullet = false;
__instance.friendly = false;
}
}
}
public class RandomDirectionsFire : Effect
{
public static RandomDirectionsFire Instance;
public static ConfigEntry<float> maxAngleDeviation;
public static ConfigEntry<bool> enabledthing;
public override string Category => Categories.Gameplay_Affecting_Effects.ToString().Replace("_", " ");
public override string Name => "Fire Randomly";
public override bool HasOtherConfigs => true;
public override void OtherConfigs()
{
Instance = this;
maxAngleDeviation = Plugin.configFile.Bind<float>("Effects/" + Category + "/" + Name, "Max Angle Deviation", 25f, (ConfigDescription)null);
enabledthing = isEnabled;
}
}
[HarmonyPatch(typeof(RevolverBeam), "Start")]
public class RandomDirPatch
{
public static bool Prefix(RevolverBeam __instance)
{
//IL_0057: 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)
//IL_00a5: 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)
//IL_00ac: 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_00af: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
if (!RandomDirectionsFire.Instance.ActuallyActive)
{
return true;
}
if (!RandomDirectionsFire.enabledthing.Value)
{
return true;
}
if ((Object)(object)__instance.sourceWeapon == (Object)null)
{
return true;
}
Vector3 forward = ((Component)__instance).transform.forward;
float value = RandomDirectionsFire.maxAngleDeviation.Value;
float num = Random.Range(0f, value);
float num2 = Random.Range(0f, 360f);
Quaternion val = Quaternion.Euler(Mathf.Sin(num2 * ((float)Math.PI / 180f)) * num, Mathf.Cos(num2 * ((float)Math.PI / 180f)) * num, 0f);
Vector3 val2 = val * forward;
Quaternion rotation = Quaternion.LookRotation(val2, Vector3.up);
((Component)__instance).transform.rotation = rotation;
return true;
}
}
[HarmonyPatch(typeof(Projectile), "Start")]
public class RandomDirPatchTheSecond
{
public static bool Prefix(Projectile __instance)
{
//IL_0057: 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)
//IL_00a5: 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)
//IL_00ac: 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_00af: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
if (!RandomDirectionsFire.Instance.ActuallyActive)
{
return true;
}
if (!RandomDirectionsFire.enabledthing.Value)
{
return true;
}
if ((Object)(object)__instance.sourceWeapon == (Object)null)
{
return true;
}
Vector3 forward = ((Component)__instance).transform.forward;
float value = RandomDirectionsFire.maxAngleDeviation.Value;
float num = Random.Range(0f, value);
float num2 = Random.Range(0f, 360f);
Quaternion val = Quaternion.Euler(Mathf.Sin(num2 * ((float)Math.PI / 180f)) * num, Mathf.Cos(num2 * ((float)Math.PI / 180f)) * num, 0f);
Vector3 val2 = val * forward;
Quaternion rotation = Quaternion.LookRotation(val2, Vector3.up);
((Component)__instance).transform.rotation = rotation;
return true;
}
}
[HarmonyPatch(typeof(Nail), "Start")]
public class RandomDirPatchTheTHird
{
public static bool Prefix(Nail __instance)
{
//IL_0057: 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)
//IL_00a5: 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)
//IL_00ac: 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_00af: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
if (!RandomDirectionsFire.Instance.ActuallyActive)
{
return true;
}
if (!RandomDirectionsFire.enabledthing.Value)
{
return true;
}
if ((Object)(object)__instance.sourceWeapon == (Object)null)
{
return true;
}
Vector3 forward = ((Component)__instance).transform.forward;
float value = RandomDirectionsFire.maxAngleDeviation.Value;
float num = Random.Range(0f, value);
float num2 = Random.Range(0f, 360f);
Quaternion val = Quaternion.Euler(Mathf.Sin(num2 * ((float)Math.PI / 180f)) * num, Mathf.Cos(num2 * ((float)Math.PI / 180f)) * num, 0f);
Vector3 val2 = val * forward;
Quaternion rotation = Quaternion.LookRotation(val2, Vector3.up);
((Component)__instance).transform.rotation = rotation;
return true;
}
}
[HarmonyPatch(typeof(Grenade), "Start")]
public class RandomDirPatchTheFourth
{
public static bool Prefix(Grenade __instance)
{
//IL_0057: 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)
//IL_00a5: 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)
//IL_00ac: 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_00af: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
if (!RandomDirectionsFire.Instance.ActuallyActive)
{
return true;
}
if (!RandomDirectionsFire.enabledthing.Value)
{
return true;
}
if ((Object)(object)__instance.sourceWeapon == (Object)null)
{
return true;
}
Vector3 forward = ((Component)__instance).transform.forward;
float value = RandomDirectionsFire.maxAngleDeviation.Value;
float num = Random.Range(0f, value);
float num2 = Random.Range(0f, 360f);
Quaternion val = Quaternion.Euler(Mathf.Sin(num2 * ((float)Math.PI / 180f)) * num, Mathf.Cos(num2 * ((float)Math.PI / 180f)) * num, 0f);
Vector3 val2 = val * forward;
Quaternion rotation = Quaternion.LookRotation(val2, Vector3.up);
((Component)__instance).transform.rotation = rotation;
return true;
}
}
public class RandomGravity : Effect
{
private Vector3 normalGrav;
public override string Category => Categories.Gameplay_Affecting_Effects.ToString().Replace("_", " ");
public override string Name => "Random Gravity";
public override bool HasOtherConfigs => false;
public override void OtherConfigs()
{
//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)
normalGrav = Physics.gravity;
}
public override void OnSceneLoad()
{
((MonoBehaviour)this).StopAllCoroutines();
if (ActuallyActive)
{
((MonoBehaviour)this).StartCoroutine(RandomLeGravity());
}
}
private Vector3 GetRandomVector3(float MinX, float MinY, float MinZ, float MaxX, float MaxY, float MaxZ)
{
//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_0027: Unknown result type (might be due to invalid IL or missing references)
float num = Random.Range(MinX, MaxX);
float num2 = Random.Range(MinY, MaxY);
float num3 = Random.Range(MinZ, MaxZ);
return new Vector3(num, num2, num3);
}
private Vector3 GetRandomVector3(Vector3 min, Vector3 max)
{
//IL_0001: 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_0013: 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_0025: 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)
//IL_003a: 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)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
float num = Random.Range(min.x, max.x);
float num2 = Random.Range(min.y, max.y);
float num3 = Random.Range(min.z, max.z);
return new Vector3(num, num2, num3);
}
private IEnumerator RandomLeGravity()
{
while (true)
{
yield return (object)new WaitForSeconds((float)Random.Range(1, 25));
if (isEnabled.Value)
{
Physics.gravity = GetRandomVector3(-normalGrav, normalGrav);
}
}
}
}
public class RandomJumpscares : Effect
{
private ConfigEntry<float> minTimeBetweenJumpscares;
private ConfigEntry<float> maxTimeBetweenJumpscares;
private ConfigEntry<float> jumpscareDisplayTime;
private GameObject jumpscareObject;
private Image jumpscareImage;
private AudioSource jumpscareAudio;
private string jumpscareImageFolder;
private string jumpscareAudioFolder;
private string[] imageFiles;
private string[] audioFiles;
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Random Jumpscare";
public override bool HasOtherConfigs => true;
public override void OtherConfigs()
{
minTimeBetweenJumpscares = Plugin.configFile.Bind<float>("Effects/" + Category + "/" + Name, "Min Time Between Jumpscares", 60f, "Minimum time (in seconds) between jumpscares");
maxTimeBetweenJumpscares = Plugin.configFile.Bind<float>("Effects/" + Category + "/" + Name, "Max Time Between Jumpscares", 300f, "Maximum time (in seconds) between jumpscares");
jumpscareDisplayTime = Plugin.configFile.Bind<float>("Effects/" + Category + "/" + Name, "Jumpscare Display Time", 0.5f, "How long (in seconds) the jumpscare image is displayed");
}
public override void OnSceneLoad()
{
if (ActuallyActive && isEnabled.Value)
{
SetupFolders();
LoadJumpscareFiles();
SetupJumpscareObject();
((MonoBehaviour)this).StartCoroutine(JumpscareRoutine());
}
}
private void SetupFolders()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
jumpscareImageFolder = Path.Combine(directoryName, "Jumpscares", "images");
jumpscareAudioFolder = Path.Combine(directoryName, "Jumpscares", "audio");
bool flag = false;
if (!Directory.Exists(jumpscareImageFolder))
{
Directory.CreateDirectory(jumpscareImageFolder);
flag = true;
}
if (!Directory.Exists(jumpscareAudioFolder))
{
Directory.CreateDirectory(jumpscareAudioFolder);
flag = true;
}
if (flag || !Directory.EnumerateFileSystemEntries(jumpscareImageFolder).Any() || !Directory.EnumerateFileSystemEntries(jumpscareAudioFolder).Any())
{
ExtractEmbeddedResources();
}
}
private void ExtractEmbeddedResources()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
string[] array = manifestResourceNames;
foreach (string text in array)
{
if (text.StartsWith("TMUAM.Jumpscares.images."))
{
string path = text.Substring("TMUAM.Jumpscares.images.".Length);
string path2 = Path.Combine(jumpscareImageFolder, path);
if (File.Exists(path2))
{
continue;
}
using Stream stream = executingAssembly.GetManifestResourceStream(text);
using FileStream destination = new FileStream(path2, FileMode.Create);
stream.CopyTo(destination);
}
else
{
if (!text.StartsWith("TMUAM.Jumpscares.audio."))
{
continue;
}
string path3 = text.Substring("TMUAM.Jumpscares.audio.".Length);
string path4 = Path.Combine(jumpscareAudioFolder, path3);
if (File.Exists(path4))
{
continue;
}
using Stream stream2 = executingAssembly.GetManifestResourceStream(text);
using FileStream destination2 = new FileStream(path4, FileMode.Create);
stream2.CopyTo(destination2);
}
}
}
private void LoadJumpscareFiles()
{
imageFiles = Directory.GetFiles(jumpscareImageFolder, "*.png");
audioFiles = Directory.GetFiles(jumpscareAudioFolder, "*.mp3");
}
private void SetupJumpscareObject()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
jumpscareObject = new GameObject("Jumpscare");
jumpscareObject.transform.SetParent(((Component)this).transform);
Canvas val = jumpscareObject.AddComponent<Canvas>();
val.renderMode = (RenderMode)0;
val.sortingOrder = 9999;
jumpscareImage = jumpscareObject.AddComponent<Image>();
((Graphic)jumpscareImage).color = Color.clear;
jumpscareAudio = jumpscareObject.AddComponent<AudioSource>();
jumpscareObject.SetActive(false);
}
public override void OnEffectDisabled()
{
if ((Object)(object)jumpscareObject != (Object)null)
{
jumpscareObject.SetActive(false);
}
base.OnEffectDisabled();
}
public override void OnEffectEnabled()
{
if ((Object)(object)jumpscareObject != (Object)null)
{
jumpscareObject.SetActive(true);
}
base.OnEffectDisabled();
}
private IEnumerator JumpscareRoutine()
{
while (true)
{
float waitTime = Random.Range(minTimeBetweenJumpscares.Value, maxTimeBetweenJumpscares.Value);
yield return (object)new WaitForSeconds(waitTime);
if (isEnabled.Value && ActuallyActive)
{
TriggerJumpscare();
}
}
}
private void TriggerJumpscare()
{
if (imageFiles.Length != 0 && audioFiles.Length != 0)
{
string imagePath = imageFiles[Random.Range(0, imageFiles.Length)];
string audioPath = audioFiles[Random.Range(0, audioFiles.Length)];
((MonoBehaviour)this).StartCoroutine(LoadAndShowJumpscare(imagePath, audioPath));
}
}
private IEnumerator LoadAndShowJumpscare(string imagePath, string audioPath)
{
byte[] imageData = File.ReadAllBytes(imagePath);
Texture2D texture = new Texture2D(2, 2);
ImageConversion.LoadImage(texture, imageData);
jumpscareImage.sprite = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f));
WWW www = new WWW("file://" + audioPath);
try
{
yield return www;
jumpscareAudio.clip = www.GetAudioClip();
}
finally
{
((IDisposable)www)?.Dispose();
}
if (!ActuallyActive)
{
yield return null;
}
if (!isEnabled.Value)
{
yield return null;
}
jumpscareObject.SetActive(true);
((Graphic)jumpscareImage).color = Color.white;
jumpscareAudio.Play();
((MonoBehaviour)this).StartCoroutine(HideJumpscare());
}
private IEnumerator HideJumpscare()
{
yield return (object)new WaitForSeconds(jumpscareDisplayTime.Value);
((Graphic)jumpscareImage).color = Color.clear;
jumpscareObject.SetActive(false);
}
}
public class RandomScreenEffects : Effect
{
private class InvertEffect : MonoBehaviour
{
public Material[] materials;
public Material currentMaterial;
private void OnRenderImage(RenderTexture src, RenderTexture dest)
{
if ((Object)(object)currentMaterial != (Object)null)
{
Graphics.Blit((Texture)(object)src, dest, currentMaterial);
}
else
{
Graphics.Blit((Texture)(object)src, dest);
}
}
}
public Dictionary<Material, ConfigEntry<bool>> ShaderConfigs = new Dictionary<Material, ConfigEntry<bool>>();
private Material[] shaderMaterials;
private Camera mainCamera;
private InvertEffect invertEffect;
public override string Category => Categories.Visual_Effects.ToString().Replace("_", " ");
public override string Name => "Random Screen Effects";
public override bool HasOtherConfigs => true;
public override void OtherConfigs()
{
GetScreenEffects();
Material[] array = shaderMaterials;
foreach (Material val in array)
{
ConfigEntry<bool> value = Plugin.configFile.Bind<bool>("Effects/" + Category + "/" + Name, ((Object)val).name, true, (ConfigDescription)null);
ShaderConfigs.Add(val, value);
}
}
public override void OnSceneLoad()
{
if (ActuallyActive)
{
SceneLoadScreenEffects();
}
}
private void GetScreenEffects()
{
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
Assembly executingAssembly = Assembly.GetExecutingAssembly();
AssetBundle val = AssetBundle.LoadFromStream(executingAssembly.GetManifestResourceStream("TMUAM.Bundles.tmuamshaders"));
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)"Failed to load asset bundle.");
return;
}
Debug.Log((object)"bundle loaded");
Shader[] array = val.LoadAllAssets<Shader>();
if (array == null || array.Length == 0)
{
Debug.LogError((object)"No shaders found in the bundle.");
return;
}
Debug.Log((object)"shaders loaded");
shaderMaterials = (Material[])(object)new Material[array.Length];
Debug.Log((object)"list made");
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null)
{
shaderMaterials[i] = new Material(array[i]);
((Object)shaderMaterials[i]).name = ((Object)array[i]).name.Replace("Custom/", "");
Debug.Log((object)"material made");
}
else
{
Debug.LogError((object)$"Shader {i} not found!");
}
}
}
private IEnumerator SwitchShaders()
{
while (true)
{
List<Material> validMaterials = (from entry in ShaderConfigs
where entry.Value.Value
select entry.Key).ToList();
if (validMaterials.Count > 0)
{
int randomIndex = Random.Range(0, validMaterials.Count);
invertEffect.currentMaterial = validMaterials[randomIndex];
}
yield return (object)new WaitForSeconds(30f);
}
}
public override void OnEffectDisabled()
{
if (ActuallyActive)
{
((Behaviour)invertEffect).enabled = false;
}
}
public override void OnEffectEnabled()
{
if (ActuallyActive)
{
((Behaviour)invertEffect).enabled = true;
}
}
private void SceneLoadScreenEffects()
{
if (!ActuallyActive)
{
return;
}
Debug.Log((object)"hiiiiiiiiiiiii");
mainCamera = Camera.main;
if ((Object)(object)mainCamera == (Object)null)
{
mainCamera = Object.FindObjectOfType<Camera>();
}
if ((Object)(object)mainCamera != (Object)null)
{
Debug.Log((object)isEnabled);
if ((Object)(object)((Component)mainCamera).transform.Find("Virtual Camera") != (Object)null)
{
invertEffect = ((Component)((Component)mainCamera).transform.Find("Virtual Camera")).gameObject.AddComponent<InvertEffect>();
invertEffect.materials = shaderMaterials;
}
else
{
invertEffect = ((Component)mainCamera).gameObject.AddComponent<InvertEffect>();
invertEffect.materials = shaderMaterials;
}
Debug.Log((object)((Object)((Component)invertEffect).gameObject).name);
((Behaviour)invertEffect).enabled = isEnabled.Value;
((MonoBehaviour)this).StartCoroutine(SwitchShaders());
}
else
{
Debug.LogError((object)"No camera found!");
}
}
}
[HarmonyPatch(typeof(WallCheck), "Update")]
public class TouchWallsOuchie : Effect
{
public static TouchWallsOuchie instance { get; set; }
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Touching walls hurt you";
public override bool HasOtherConfigs => false;
public override void OtherConfigs()
{
instance = this;
base.OtherConfigs();
}
public static void Postfix(WallCheck __instance)
{
if (instance.isEnabled.Value && instance.ActuallyActive && __instance.onWall)
{
MonoSingleton<NewMovement>.instance.GetHurt(1, false, 1f, false, false, 0.35f, false);
}
}
}
[HarmonyPatch(typeof(NewMovement), "GetHurt")]
internal class YeetOnHurt : Effect
{
public static YeetOnHurt instance { get; set; }
public override string Category => ConvertCategoryToText(Categories.Gameplay_Affecting_Effects);
public override string Name => "Yeet On Hurt";
public override bool HasOtherConfigs => false;
public override void OtherConfigs()
{
instance = this;
base.OtherConfigs();
}
public static void Postfix(int damage, NewMovement __instance)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (instance.isEnabled.Value && instance.ActuallyActive)
{
__instance.Launch(Vector3.up * 6f, (float)(20 * damage), false);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}