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 System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using ExitGames.Client.Photon;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("CorruptPEAK")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("CorruptPEAK")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c8c2184997c36cda6dcc33270a5f8f443cee17da")]
[assembly: AssemblyProduct("CorruptPEAK")]
[assembly: AssemblyTitle("CorruptPEAK")]
[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;
}
}
}
namespace CorruptPEAK
{
public class CustomPropCheck : MonoBehaviourPunCallbacks
{
public override void OnJoinedRoom()
{
((MonoBehaviourPunCallbacks)this).OnJoinedRoom();
Player[] playerListOthers = PhotonNetwork.PlayerListOthers;
foreach (Player val in playerListOthers)
{
if (((Dictionary<object, object>)(object)val.CustomProperties).ContainsKey((object)"CRPTPEAK") && !PhotonNetwork.IsMasterClient)
{
if (val.IsMasterClient)
{
Notifications.SendOnce("<color=blue>[ CorruptPEAK ] : The host is using CorruptPEAK!</color>");
}
else
{
Notifications.SendOnce("<color=blue>[ CorruptPEAK ] : Another player is using CorruptPEAK!</color>");
}
}
if (((Dictionary<object, object>)(object)val.CustomProperties).ContainsKey((object)"CRPTPEAK") && PhotonNetwork.IsMasterClient)
{
Notifications.SendOnce("<color=blue>[ CorruptPEAK ] : Another user is using CorruptPEAK!</color>");
}
}
}
}
internal class Notifications
{
private static readonly HashSet<string> sentMessages = new HashSet<string>();
public static void SendOnce(string message)
{
if (!sentMessages.Contains(message) && TrySend(message))
{
sentMessages.Add(message);
}
}
public static void Reset(string message)
{
sentMessages.Remove(message);
}
public static void ResetAll()
{
sentMessages.Clear();
}
private static bool TrySend(string message)
{
PlayerConnectionLog val = Object.FindFirstObjectByType<PlayerConnectionLog>();
if ((Object)(object)val == (Object)null)
{
return false;
}
MethodInfo method = typeof(PlayerConnectionLog).GetMethod("AddMessage", BindingFlags.Instance | BindingFlags.NonPublic);
if (method != null)
{
method.Invoke(val, new object[1] { message });
return true;
}
Debug.LogWarning((object)"AddMessage method not found on PlayerConnectionLog.");
return false;
}
}
[BepInPlugin("com.zbytek.CorruptPEAK", "CorruptPEAK", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
public static bool readyToPlay = false;
public static ConfigEntry<bool> AntiCrashEnabled;
public static float CorruptionIntensity = 0.0001f;
public static ConfigEntry<float> CorruptionIncreaseRate;
public static ConfigEntry<float> AntiCrashLimit;
public static ConfigEntry<bool> CorruptRenderers;
public static ConfigEntry<bool> CorruptAudio;
public static ConfigEntry<bool> CorruptParticles;
public static ConfigEntry<bool> CorruptTransforms;
public static ConfigEntry<bool> CorruptMeshes;
public static ConfigEntry<bool> ShouldCorruptLightmaps;
public static ConfigEntry<bool> CorruptRandomValues;
public static ConfigEntry<bool> WelcomeAccepted;
public static bool corruptionStarted = false;
public static bool litthecampfiresostopcorruption = false;
private List<AudioClip> AllAudioClips = new List<AudioClip>();
private bool Init;
public bool alreadysent = false;
private Random rng = new Random();
private void Awake()
{
AntiCrashEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AntiCrashEnabled", true, "makes ur game quit before it dies");
AntiCrashLimit = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AntiCrashLimit", 20f, "corruption intensity to quit your game at");
CorruptionIncreaseRate = ((BaseUnityPlugin)this).Config.Bind<float>("Corruption", "CorruptionIncreaseRate", 0.0001f, "how fast the corruption increases");
CorruptRenderers = ((BaseUnityPlugin)this).Config.Bind<bool>("Corruption Options", "CorruptRenderers", true, "makes it so that colors break");
CorruptAudio = ((BaseUnityPlugin)this).Config.Bind<bool>("Corruption Options", "CorruptAudio", true, "makes it so that audio values change");
CorruptParticles = ((BaseUnityPlugin)this).Config.Bind<bool>("Corruption Options", "CorruptParticles", true, "changes particle system values");
CorruptTransforms = ((BaseUnityPlugin)this).Config.Bind<bool>("Corruption Options", "CorruptTransforms", false, "makes it so things randomly get bigger or smaller");
CorruptMeshes = ((BaseUnityPlugin)this).Config.Bind<bool>("Corruption Options", "CorruptMeshes", true, "makes it so any editable mesh can be edited randomly");
ShouldCorruptLightmaps = ((BaseUnityPlugin)this).Config.Bind<bool>("Corruption Options", "CorruptLightmaps", true, "makes it so the lighting breaks");
CorruptRandomValues = ((BaseUnityPlugin)this).Config.Bind<bool>("Dangerous", "CorruptRandomValues", false, "THIS IS DANGEROUS, PLEASE USE AT YOUR OWN WILL!!! randomizes values in basically any object in the scene, might go faster than the increase rate cuz i suck at coding");
}
private void Update()
{
if (readyToPlay && corruptionStarted)
{
CorruptionIntensity = Mathf.Clamp(CorruptionIntensity + CorruptionIncreaseRate.Value * Time.deltaTime, 0f, 500f);
}
if (CorruptionIntensity > AntiCrashLimit.Value && AntiCrashEnabled.Value)
{
MessageBox(IntPtr.Zero, "Hey your game is about to crash so its also about to quit so bye", "AntiCrash", 0u);
Application.Quit();
}
}
public void LateUpdate()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
if (PhotonNetwork.InRoom)
{
corruptionStarted = true;
readyToPlay = true;
}
if (readyToPlay && corruptionStarted && PhotonNetwork.InRoom)
{
if (!alreadysent)
{
Hashtable val = new Hashtable();
val[(object)"CRPTPEAK"] = true;
PhotonNetwork.LocalPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
Notifications.SendOnce("<color=blue>[ CorruptPEAK ] : Corruption Has Begun. </color>");
alreadysent = true;
}
if (!Init && (Object)(object)Player.localPlayer != (Object)null)
{
FindAllAudioClips();
Init = true;
}
if (Random.value < CorruptionIntensity * 0.1f)
{
CorruptScene();
}
}
}
private void FindAllAudioClips()
{
AudioClip[] array = Resources.FindObjectsOfTypeAll<AudioClip>();
foreach (AudioClip item in array)
{
if (!AllAudioClips.Contains(item))
{
AllAudioClips.Add(item);
}
}
}
private void CorruptScene()
{
if (CorruptRenderers.Value)
{
Renderer[] array = Object.FindObjectsOfType<Renderer>();
foreach (Renderer renderer in array)
{
if (Random.value < CorruptionIntensity)
{
CorruptRenderer(renderer);
}
}
}
if (CorruptAudio.Value)
{
AudioSource[] array2 = Object.FindObjectsOfType<AudioSource>();
foreach (AudioSource src in array2)
{
if (Random.value < CorruptionIntensity)
{
CorruptAudioSource(src);
}
}
}
if (CorruptParticles.Value)
{
ParticleSystem[] array3 = Object.FindObjectsOfType<ParticleSystem>();
foreach (ParticleSystem ps in array3)
{
if (Random.value < CorruptionIntensity)
{
CorruptParticleSystem(ps);
}
}
}
if (CorruptTransforms.Value)
{
Transform[] array4 = Object.FindObjectsOfType<Transform>();
foreach (Transform tr in array4)
{
if (Random.value < CorruptionIntensity)
{
CorruptTransform(tr);
}
}
}
if (!CorruptRandomValues.Value)
{
return;
}
MonoBehaviour[] array5 = Object.FindObjectsOfType<MonoBehaviour>();
List<MonoBehaviour> list = new List<MonoBehaviour>();
MonoBehaviour[] array6 = array5;
foreach (MonoBehaviour val in array6)
{
string text = ((object)val).GetType().Name.ToLowerInvariant();
if (!text.Contains("photon"))
{
list.Add(val);
}
}
int num = Math.Min(127, list.Count);
for (int n = 0; n < num; n++)
{
int index = rng.Next(list.Count);
MonoBehaviour obj = list[index];
CorruptFields(obj);
list.RemoveAt(index);
}
}
private void CorruptFields(MonoBehaviour obj)
{
Type type = ((object)obj).GetType();
FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
FieldInfo[] array = fields;
foreach (FieldInfo fieldInfo in array)
{
if (fieldInfo.IsInitOnly)
{
continue;
}
Type fieldType = fieldInfo.FieldType;
try
{
if (fieldType == typeof(int))
{
fieldInfo.SetValue(obj, rng.Next(-1000, 1000));
}
else if (fieldType == typeof(float))
{
float num = (float)(rng.NextDouble() * 2000.0 - 1000.0);
if (rng.NextDouble() < 0.1)
{
num = float.NaN;
}
fieldInfo.SetValue(obj, num);
}
else if (fieldType == typeof(bool))
{
fieldInfo.SetValue(obj, rng.Next(2) == 0);
}
else if (fieldType == typeof(string))
{
fieldInfo.SetValue(obj, RandomString(rng.Next(3, 10)));
}
}
catch
{
}
}
}
private string RandomString(int length)
{
char[] array = new char[length];
for (int i = 0; i < length; i++)
{
array[i] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!?"[rng.Next("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!?".Length)];
}
return new string(array);
}
private void CorruptRenderer(Renderer renderer)
{
//IL_0018: 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)
Material material = renderer.material;
if (material.HasProperty("_Color"))
{
material.color = Random.ColorHSV();
}
if (material.HasProperty("_MainTex") && (Object)(object)material.mainTexture != (Object)null)
{
material.mainTextureScale = new Vector2(Random.Range(0.5f, 2f), Random.Range(0.5f, 2f));
}
MeshFilter component = ((Component)renderer).GetComponent<MeshFilter>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.mesh) && component.mesh.isReadable)
{
CorruptMesh(component.mesh);
}
}
private void CorruptAudioSource(AudioSource src)
{
src.pitch = Random.Range(0f, 100f);
src.volume = Random.Range(0f, 1f);
if (AllAudioClips.Count > 0)
{
src.clip = AllAudioClips[Random.Range(0, AllAudioClips.Count)];
}
}
private void CorruptParticleSystem(ParticleSystem ps)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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)
MainModule main = ps.main;
((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(Random.Range(0.1f, 5f));
((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Random.ColorHSV());
}
private void CorruptTransform(Transform tr)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: 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)
tr.position += Random.insideUnitSphere * CorruptionIntensity * 2f;
tr.rotation = Quaternion.Euler(Random.Range(0f, 360f), Random.Range(0f, 360f), Random.Range(0f, 360f));
tr.localScale = new Vector3(tr.localScale.x * Random.Range(0.5f, 1.5f), tr.localScale.y * Random.Range(0.5f, 1.5f), tr.localScale.z * Random.Range(0.5f, 1.5f));
}
private void CorruptMesh(Mesh mesh)
{
//IL_0025: 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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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)
Vector3[] vertices = mesh.vertices;
for (int i = 0; i < vertices.Length; i++)
{
if (Random.value < CorruptionIntensity)
{
ref Vector3 reference = ref vertices[i];
reference += Random.insideUnitSphere * CorruptionIntensity;
}
}
mesh.vertices = vertices;
mesh.RecalculateNormals();
mesh.RecalculateBounds();
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int MessageBox(IntPtr hWnd, string text, string caption, uint type);
}
}