using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CybeRNG_LiFE;
using CybeRNG_LiFE.RNG;
using CybeRNG_LiFE.Util;
using GameConsole;
using GameConsole.CommandTree;
using GreyAnnouncer;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.AI.Navigation;
using UnityEngine;
using plog;
using plog.Models;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CybeRNG_LiFE")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+237966dceaa694a571d61b248921b0eb3bcb3fb6")]
[assembly: AssemblyProduct("CybeRNG_LiFE")]
[assembly: AssemblyTitle("CybeRNG_LiFE")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 GreyAnnouncer
{
public static class PathManager
{
public static string GetCurrentPluginPath(string filePath = null)
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
return CleanPath(Path.Combine(directoryName, filePath ?? string.Empty));
}
public static string GetGamePath(string filePath)
{
string gameRootPath = Paths.GameRootPath;
return CleanPath(Path.Combine(gameRootPath, filePath));
}
[Description("Reference : (因win程序员想偷懒! 竟在剪切板插入隐藏字符) https://www.bilibili.com/video/BV1ebLczjEWZ (Accessed in 24/4/2025)")]
public static string CleanPath(string path)
{
if (string.IsNullOrEmpty(path))
{
return path;
}
char[] trimChars = new char[5] { '\u202a', '\u202b', '\u202c', '\u202d', '\u202e' };
string text = path.TrimStart(trimChars);
if (!path.Equals(text))
{
Plugin.Logger.LogInfo((object)("Path cleaned: Original='" + path + "', Cleaned='" + text + "'"));
}
return text;
}
[Description("Reference : (C# 判断操作系统是 Windows 还是 Linux - 青叶煮酒 - 博客园, 11/1/2022) https://www.cnblogs.com/dhqy/p/15787463.html (Accessed in 25/4/2025)")]
public static void OpenDirectory(string path)
{
if (!string.IsNullOrEmpty(path) && Directory.Exists(path))
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Process.Start("explorer.exe", path);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("xdg-open", path);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", path);
}
else
{
Plugin.Logger.LogWarning((object)"Unsupported OS platform.");
}
}
else
{
Plugin.Logger.LogWarning((object)"The path is not valid or the directory does not exist.");
}
}
public static string GetFileWithExtension(string filePath, string fileName)
{
string searchPattern = fileName + ".*";
string[] files = Directory.GetFiles(filePath, searchPattern);
if (files.Length != 0)
{
return files[0];
}
return null;
}
internal static string FindExecutable(string envVariable, string fallbackPath = null)
{
string environmentVariable = Environment.GetEnvironmentVariable(envVariable);
if (!string.IsNullOrEmpty(environmentVariable) && Directory.Exists(environmentVariable))
{
string path = Path.Combine(environmentVariable, envVariable + ".exe");
if (File.Exists(path))
{
return environmentVariable;
}
}
string environmentVariable2 = Environment.GetEnvironmentVariable("PATH");
if (!string.IsNullOrEmpty(environmentVariable2))
{
string[] array = environmentVariable2.Split(';');
string[] array2 = array;
foreach (string text in array2)
{
if (!string.IsNullOrWhiteSpace(text))
{
string path2 = Path.Combine(text, envVariable + ".exe");
if (File.Exists(path2))
{
return text;
}
}
}
}
if (!string.IsNullOrEmpty(fallbackPath) && Directory.Exists(fallbackPath))
{
return fallbackPath;
}
return null;
}
}
}
namespace CybeRNG_LiFE
{
[HarmonyPatch(typeof(EndlessGrid))]
public class EndlessGridPatch
{
private static readonly MethodInfo IRNGRangeIntMI = AccessTools.Method(typeof(RandomManager), "RangeInt", new Type[3]
{
typeof(int),
typeof(int),
typeof(RNGScope)
}, (Type[])null);
private static readonly MethodInfo IRNGRangeFloatMI = AccessTools.Method(typeof(RandomManager), "RangeFloat", new Type[3]
{
typeof(float),
typeof(float),
typeof(RNGScope)
}, (Type[])null);
private static readonly MethodInfo UnityRangeIntMI = AccessTools.Method(typeof(Random), "Range", new Type[2]
{
typeof(int),
typeof(int)
}, (Type[])null);
private static readonly MethodInfo UnityRangeFloatMI = AccessTools.Method(typeof(Random), "Range", new Type[2]
{
typeof(float),
typeof(float)
}, (Type[])null);
private static void RandomizePatternFromEndlessGridStart(EndlessGrid endlessGrid)
{
for (int i = 0; i < endlessGrid.CurrentPatternPool.Length; i++)
{
ArenaPattern val = endlessGrid.CurrentPatternPool[i];
int num = RandomManager.patternRNG.Range(i, endlessGrid.CurrentPatternPool.Length);
endlessGrid.CurrentPatternPool[i] = endlessGrid.CurrentPatternPool[num];
endlessGrid.CurrentPatternPool[num] = val;
}
endlessGrid.ShuffleDecks();
}
[HarmonyPrefix]
[HarmonyPatch("OnTriggerEnter")]
public static void TryToGenerateRandomizer(ref Collider other)
{
if (((Component)other).CompareTag("Player"))
{
RandomManager.TryToInitializeRNG();
}
}
[HarmonyTranspiler]
[HarmonyPatch("OnTriggerEnter")]
public static IEnumerable<CodeInstruction> OnTriggerEnterTranspiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Expected O, but got Unknown
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Expected O, but got Unknown
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Expected O, but got Unknown
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Expected O, but got Unknown
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Expected O, but got Unknown
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(EndlessGrid), "currentWave"), (string)null)
}).Advance(1).Insert((CodeInstruction[])(object)new CodeInstruction[6]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(EndlessGridPatch), "RandomizePatternFromEndlessGridStart", (Type[])null, (Type[])null)),
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(EndlessGrid), "ShuffleDecks", (Type[])null, (Type[])null)),
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MiniEndlessGridManager), "InitializeMiniEndlessGrid", (Type[])null, (Type[])null)),
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RandomManager), "DisplayCurrentSetting", (Type[])null, (Type[])null))
})
.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(EndlessGrid), "maxPoints"), (string)null)
})
.Advance(1)
.Insert((CodeInstruction[])(object)new CodeInstruction[2]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MiniEndlessGridManager), "RoundCurrentPattern", (Type[])null, (Type[])null))
})
.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(EndlessGrid), "ShuffleDecks", (Type[])null, (Type[])null), (string)null)
})
.Advance(-1)
.RemoveInstructions(2)
.Insert((CodeInstruction[])(object)new CodeInstruction[2]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MiniEndlessGridManager), "ApplyAntiBufferAndOLoggingToEndlessGrid", (Type[])null, (Type[])null))
});
return val.InstructionEnumeration();
}
[HarmonyPrefix]
[HarmonyPatch("NextWave")]
public static void NextWave_Prefix()
{
RandomManager.FreshRNG();
}
[HarmonyPrefix]
[HarmonyPatch("Start")]
public static bool RuinStartShuffling(EndlessGrid __instance)
{
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
RandomManager.InitializeState();
if (!RandomManager.seeded)
{
return true;
}
__instance.nms = ((Component)__instance).GetComponent<NavMeshSurface>();
__instance.anw = ((Component)__instance).GetComponent<ActivateNextWave>();
__instance.gz = GoreZone.ResolveGoreZone(((Component)__instance).transform);
__instance.cubes = new EndlessCube[16][];
for (int i = 0; i < 16; i++)
{
__instance.cubes[i] = (EndlessCube[])(object)new EndlessCube[16];
for (int j = 0; j < 16; j++)
{
GameObject val = Object.Instantiate<GameObject>(__instance.gridCube, ((Component)__instance).transform, true);
val.SetActive(true);
val.transform.localPosition = new Vector3((float)i * __instance.offset, 0f, (float)j * __instance.offset);
__instance.cubes[i][j] = val.GetComponent<EndlessCube>();
__instance.cubes[i][j].positionOnGrid = new Vector2Int(i, j);
}
}
__instance.crorea = MonoSingleton<CrowdReactions>.Instance;
if ((Object)(object)__instance.crorea != (Object)null)
{
__instance.crowdReactions = true;
}
PresenceController.UpdateCyberGrindWave(0);
__instance.mats = ((Renderer)((Component)__instance).GetComponentInChildren<MeshRenderer>()).sharedMaterials;
Material[] mats = __instance.mats;
Material[] array = mats;
foreach (Material val2 in array)
{
val2.SetColor(UKShaderProperties.EmissiveColor, Color.blue);
val2.SetFloat(UKShaderProperties.EmissiveIntensity, 0.2f * __instance.glowMultiplier);
val2.SetFloat("_PCGamerMode", 0f);
val2.SetFloat("_GradientScale", 2f);
val2.SetFloat("_GradientFalloff", 5f);
val2.SetFloat("_GradientSpeed", 10f);
val2.SetVector("_WorldOffset", new Vector4(0f, 0f, 62.5f, 0f));
__instance.targetColor = Color.blue;
}
__instance.TrySetupStaticGridMesh();
int? highestWaveForDifficulty = WaveUtils.GetHighestWaveForDifficulty(MonoSingleton<PrefsManager>.Instance.GetInt("difficulty", 0));
int @int = MonoSingleton<PrefsManager>.Instance.GetInt("cyberGrind.startingWave", 0);
__instance.startWave = (WaveUtils.IsWaveSelectable(@int, highestWaveForDifficulty.GetValueOrDefault()) ? @int : 0);
Plugin.Logger.LogInfo((object)"Removed ShuffleDeck and randomization on Endlessgrid::Start().");
return false;
}
[HarmonyTranspiler]
[HarmonyPatch("ShuffleDecks")]
public static IEnumerable<CodeInstruction> ShuffleDecks_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
while (val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)UnityRangeIntMI, (string)null)
}).IsValid)
{
val.Set(OpCodes.Call, (object)IRNGRangeIntMI).Insert((CodeInstruction[])(object)new CodeInstruction[1] { RandomManager.GetCodeInstructionOfRNGScope(RNGScope.Pattern) });
}
val.Start();
while (val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)UnityRangeFloatMI, (string)null)
}).IsValid)
{
val.Set(OpCodes.Call, (object)IRNGRangeFloatMI).Insert((CodeInstruction[])(object)new CodeInstruction[1] { RandomManager.GetCodeInstructionOfRNGScope(RNGScope.Pattern) });
}
return val.InstructionEnumeration();
}
[HarmonyTranspiler]
[HarmonyPatch("GetEnemies")]
public static IEnumerable<CodeInstruction> GetEnemies_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Expected O, but got Unknown
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
int num = 0;
while (val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)UnityRangeIntMI, (string)null)
}).IsValid)
{
if (num < 2)
{
val.Set(OpCodes.Call, (object)IRNGRangeIntMI).Insert((CodeInstruction[])(object)new CodeInstruction[1] { RandomManager.GetCodeInstructionOfRNGScope(RNGScope.CubePosition) });
num++;
}
else
{
val.Set(OpCodes.Call, (object)IRNGRangeIntMI).Insert((CodeInstruction[])(object)new CodeInstruction[1] { RandomManager.GetCodeInstructionOfRNGScope(RNGScope.EnemySpawn) });
}
}
val.Start();
while (val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)UnityRangeFloatMI, (string)null)
}).IsValid)
{
val.Set(OpCodes.Call, (object)IRNGRangeFloatMI).Insert((CodeInstruction[])(object)new CodeInstruction[1] { RandomManager.GetCodeInstructionOfRNGScope(RNGScope.EnemySpawn) });
}
return val.InstructionEnumeration();
}
[HarmonyTranspiler]
[HarmonyPatch("GetNextEnemy")]
public static IEnumerable<CodeInstruction> GetNextEnemy_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
while (val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)UnityRangeIntMI, (string)null)
}).IsValid)
{
val.Set(OpCodes.Call, (object)IRNGRangeIntMI).Insert((CodeInstruction[])(object)new CodeInstruction[1] { RandomManager.GetCodeInstructionOfRNGScope(RNGScope.EnemySpawn) });
}
val.Start();
while (val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)UnityRangeFloatMI, (string)null)
}).IsValid)
{
val.Set(OpCodes.Call, (object)IRNGRangeFloatMI).Insert((CodeInstruction[])(object)new CodeInstruction[1] { RandomManager.GetCodeInstructionOfRNGScope(RNGScope.EnemySpawn) });
}
return val.InstructionEnumeration();
}
[HarmonyTranspiler]
[HarmonyPatch("SpawnUncommons")]
public static IEnumerable<CodeInstruction> SpawnUncommons_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
while (val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)UnityRangeIntMI, (string)null)
}).IsValid)
{
val.Set(OpCodes.Call, (object)IRNGRangeIntMI).Insert((CodeInstruction[])(object)new CodeInstruction[1] { RandomManager.GetCodeInstructionOfRNGScope(RNGScope.EnemySpawn) });
}
val.Start();
while (val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)UnityRangeFloatMI, (string)null)
}).IsValid)
{
val.Set(OpCodes.Call, (object)IRNGRangeFloatMI).Insert((CodeInstruction[])(object)new CodeInstruction[1] { RandomManager.GetCodeInstructionOfRNGScope(RNGScope.EnemySpawn) });
}
return val.InstructionEnumeration();
}
}
public struct MiniEndlessGrid
{
public int currentWave;
public int massAntiBuffer;
public float uncommonAntiBuffer;
public int specialAntiBuffer;
public int meleePositionsCount;
public int projectilePositionsCount;
public int hideousMassPositionCount;
public int usedMeleePosition;
public int usedProjectilePosition;
public int hideousMassSpawned;
public int uncommonSpawned;
public int specialSpawned;
public List<EnemyTypeTracker> spawnedEnemyTypes;
public int baseSpawnPoint;
public int points;
public MiniEndlessGrid(int massAntiBuffer, float uncommonAntiBuffer, int specialAntiBuffer, int points)
{
meleePositionsCount = 0;
projectilePositionsCount = 0;
hideousMassPositionCount = 0;
currentWave = 0;
usedMeleePosition = 0;
usedProjectilePosition = 0;
hideousMassSpawned = 0;
uncommonSpawned = 0;
specialSpawned = 0;
spawnedEnemyTypes = new List<EnemyTypeTracker>();
baseSpawnPoint = 0;
this.massAntiBuffer = massAntiBuffer;
this.uncommonAntiBuffer = uncommonAntiBuffer;
this.specialAntiBuffer = specialAntiBuffer;
this.points = points;
}
public void ClearForNextWave()
{
meleePositionsCount = 0;
projectilePositionsCount = 0;
hideousMassPositionCount = 0;
baseSpawnPoint = 0;
hideousMassSpawned = 0;
uncommonSpawned = 0;
specialSpawned = 0;
usedMeleePosition = 0;
usedProjectilePosition = 0;
spawnedEnemyTypes.Clear();
}
public void SetPositionCount(int meleePositionsCount, int projectilePositionsCount, int hideousMassPositionCount)
{
this.meleePositionsCount = meleePositionsCount;
this.projectilePositionsCount = projectilePositionsCount;
this.hideousMassPositionCount = hideousMassPositionCount;
}
public void PredetermineSpawn(EndlessGrid endlessGrid)
{
Plugin.Logger.LogDebug((object)$"[PredetermineSpawn] Wave: {currentWave}");
Plugin.Logger.LogDebug((object)$"{hideousMassPositionCount}, {meleePositionsCount}, {projectilePositionsCount}");
PredetermineHideous();
PredetermineUncommonAndSpecial(endlessGrid);
Plugin.Logger.LogDebug((object)$"H: {hideousMassSpawned} U: {uncommonSpawned} S: {specialSpawned}");
Plugin.Logger.LogDebug((object)$"AH: {massAntiBuffer} AU: {uncommonAntiBuffer} AS: {specialAntiBuffer}");
ClearForNextWave();
}
public int GetIndexOfEnemyType(EnemyType target)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//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)
if (spawnedEnemyTypes.Count > 0)
{
for (int i = 0; i < spawnedEnemyTypes.Count; i++)
{
if (spawnedEnemyTypes[i].type == target)
{
return i;
}
}
}
spawnedEnemyTypes.Add(new EnemyTypeTracker(target));
return spawnedEnemyTypes.Count - 1;
}
private void PredetermineHideous()
{
int num = 0;
for (int i = 0; i < hideousMassPositionCount; i++)
{
if (massAntiBuffer == 0 && currentWave >= (num + 1) * 10 && points > 70)
{
num++;
points -= 45;
}
}
hideousMassSpawned = num;
massAntiBuffer = Math.Max(0, massAntiBuffer += ((hideousMassSpawned > 0) ? (hideousMassSpawned * 2) : (-1)));
}
public bool DetermineSpawnRadiant(EndlessEnemy target, int indexOfEnemyType)
{
float num = target.spawnWave * 2 + 25;
float num2 = target.spawnCost;
if (target.spawnCost < 10)
{
num2 += 1f;
}
if (target.spawnCost > 10)
{
num2 = num2 / 2f + 5f;
}
return (float)currentWave >= num + (float)spawnedEnemyTypes[indexOfEnemyType].amount * num2;
}
public bool DetermineUncommonSpawn(int target, int amount, EndlessGrid endlessGrid)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Invalid comparison between Unknown and I4
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
amount = endlessGrid.CapUncommonsAmount(target, amount);
bool result = false;
for (int i = 0; i < amount; i++)
{
EndlessEnemy val = endlessGrid.prefabs.uncommonEnemies[target];
bool flag = (int)val.enemyType != 12 && (int)val.enemyType != 34 && RandomManager.enemySpawnRNG.Range(0f, 1f) > 0.5f;
if (flag && projectilePositionsCount <= 0)
{
flag = false;
}
if (meleePositionsCount <= 0)
{
break;
}
int indexOfEnemyType = GetIndexOfEnemyType(val.enemyType);
int num = val.costIncreasePerSpawn * spawnedEnemyTypes[indexOfEnemyType].amount;
bool flag2 = DetermineSpawnRadiant(val, indexOfEnemyType);
points -= val.spawnCost * ((!flag2) ? 1 : 3) + num;
EnemyTypeTracker obj = spawnedEnemyTypes[indexOfEnemyType];
obj.amount++;
if (flag)
{
projectilePositionsCount--;
}
else
{
meleePositionsCount--;
}
result = true;
uncommonSpawned++;
if (flag2)
{
amount -= 2;
}
}
return result;
}
private void PredetermineUncommonAndSpecial(EndlessGrid endlessGrid)
{
//IL_039b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Invalid comparison between Unknown and I4
//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Invalid comparison between Unknown and I4
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Invalid comparison between Unknown and I4
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Invalid comparison between Unknown and I4
baseSpawnPoint = currentWave / 10;
baseSpawnPoint -= hideousMassSpawned;
if (baseSpawnPoint <= 0 || currentWave <= 11)
{
return;
}
if (uncommonAntiBuffer < 1f && baseSpawnPoint > 0)
{
int num = RandomManager.enemySpawnRNG.Range(0, currentWave / 10 + 1);
if (uncommonAntiBuffer <= -0.5f && num < 1)
{
num = 1;
}
if (num > 0 && meleePositionsCount > 0)
{
int num2 = RandomManager.enemySpawnRNG.Range(0, endlessGrid.prefabs.uncommonEnemies.Length);
int num3 = RandomManager.enemySpawnRNG.Range(0, endlessGrid.prefabs.uncommonEnemies.Length);
int num4 = 0;
while (num2 >= 0 && currentWave < endlessGrid.prefabs.uncommonEnemies[num2].spawnWave)
{
num2--;
}
while (num3 >= 0 && (currentWave < endlessGrid.prefabs.uncommonEnemies[num3].spawnWave || num3 == num2))
{
if (num3 == 0)
{
num4 = -1;
break;
}
num3--;
}
if (num2 >= 0)
{
if (currentWave > 16)
{
if (currentWave < 25)
{
num++;
}
else if (num4 != -1)
{
num4 = num;
}
}
bool flag = DetermineUncommonSpawn(num2, num, endlessGrid);
bool flag2 = false;
if (num4 > 0)
{
flag2 = DetermineUncommonSpawn(num3, num4, endlessGrid);
}
if (flag || flag2)
{
if (uncommonAntiBuffer < 0f)
{
uncommonAntiBuffer = 0f;
}
if (flag)
{
uncommonAntiBuffer += (((int)endlessGrid.prefabs.uncommonEnemies[num2].enemyType == 12 || (int)endlessGrid.prefabs.uncommonEnemies[num2].enemyType == 21) ? 1f : 0.5f);
}
if (flag2)
{
uncommonAntiBuffer += (((int)endlessGrid.prefabs.uncommonEnemies[num3].enemyType == 12 || (int)endlessGrid.prefabs.uncommonEnemies[num3].enemyType == 21) ? 1f : 0.5f);
}
baseSpawnPoint -= ((!(flag && flag2)) ? 1 : 2);
}
}
}
}
else
{
uncommonAntiBuffer -= 1f;
}
if (currentWave <= 15)
{
return;
}
bool flag3 = false;
if (specialAntiBuffer <= 0 && baseSpawnPoint > 0)
{
int num5 = RandomManager.enemySpawnRNG.Range(0, baseSpawnPoint + 1);
if (specialAntiBuffer <= -2 && num5 < 1)
{
num5 = 1;
}
if (num5 > 0 && meleePositionsCount > 0)
{
for (int i = 0; i < num5; i++)
{
int num6 = RandomManager.enemySpawnRNG.Range(0, endlessGrid.prefabs.specialEnemies.Length);
int indexOfEnemyType = GetIndexOfEnemyType(endlessGrid.prefabs.specialEnemies[num6].enemyType);
float num7 = 0f;
while (num6 >= 0 && meleePositionsCount > 0)
{
if (currentWave >= endlessGrid.prefabs.specialEnemies[num6].spawnWave && (float)points >= (float)endlessGrid.prefabs.specialEnemies[num6].spawnCost + num7)
{
bool flag4 = DetermineSpawnRadiant(endlessGrid.prefabs.specialEnemies[num6], indexOfEnemyType);
points -= Mathf.RoundToInt((float)(endlessGrid.prefabs.specialEnemies[num6].spawnCost * ((!flag4) ? 1 : 3)) + num7);
num7 += (float)(endlessGrid.prefabs.specialEnemies[num6].costIncreasePerSpawn * ((!flag4) ? 1 : 3));
EnemyTypeTracker obj = spawnedEnemyTypes[indexOfEnemyType];
obj.amount++;
meleePositionsCount--;
if (specialAntiBuffer < 0)
{
specialAntiBuffer = 0;
}
specialAntiBuffer++;
specialSpawned++;
flag3 = true;
break;
}
num6--;
if (num6 >= 0)
{
indexOfEnemyType = GetIndexOfEnemyType(endlessGrid.prefabs.specialEnemies[num6].enemyType);
}
}
}
}
}
if (!flag3)
{
specialAntiBuffer--;
}
}
}
public static class MiniEndlessGridManager
{
public static MiniEndlessGrid miniEndlessGrid;
public static void RoundCurrentPattern(EndlessGrid endlessGrid)
{
endlessGrid.currentPatternNum++;
RandomManager.FreshRNG();
if (endlessGrid.currentPatternNum >= endlessGrid.CurrentPatternPool.Length)
{
endlessGrid.ShuffleDecks();
}
miniEndlessGrid.currentWave++;
PredetermineSpawn(endlessGrid);
}
public static void ApplyAntiBufferAndOLoggingToEndlessGrid(EndlessGrid endlessGrid)
{
endlessGrid.massAntiBuffer += miniEndlessGrid.massAntiBuffer;
endlessGrid.uncommonAntiBuffer += miniEndlessGrid.uncommonAntiBuffer;
endlessGrid.specialAntiBuffer += miniEndlessGrid.specialAntiBuffer;
Plugin.Logger.LogDebug((object)$"Added antibuffer to endlessgrid: H: {miniEndlessGrid.massAntiBuffer}, U: {miniEndlessGrid.uncommonAntiBuffer}, S: {miniEndlessGrid.specialAntiBuffer}");
RandomManager.WriteSeedToText(endlessGrid.startWave);
}
public static void InitializeMiniEndlessGrid()
{
miniEndlessGrid = new MiniEndlessGrid(0, 0f, 0, 0);
}
private static void PredetermineSpawn(EndlessGrid endlessGrid)
{
miniEndlessGrid.points = endlessGrid.maxPoints;
var (meleePositionsCount, projectilePositionsCount, hideousMassPositionCount) = ParsingPattern(endlessGrid.CurrentPatternPool[endlessGrid.currentPatternNum]);
miniEndlessGrid.SetPositionCount(meleePositionsCount, projectilePositionsCount, hideousMassPositionCount);
miniEndlessGrid.PredetermineSpawn(endlessGrid);
}
private static (int Mcount, int Pcount, int Hcount) ParsingPattern(ArenaPattern currentPattern)
{
if ((Object)(object)currentPattern == (Object)null || string.IsNullOrEmpty(currentPattern.prefabs))
{
Plugin.Logger.LogError((object)"Fuck Parser");
return (0, 0, 0);
}
string[] array = currentPattern.prefabs.Split('\n');
if (array.Length != 16)
{
return (0, 0, 0);
}
int item = array.Where((string r) => r.Length == 16).Sum((string r) => r.Count((char c) => c == 'n'));
int item2 = array.Where((string r) => r.Length == 16).Sum((string r) => r.Count((char c) => c == 'p'));
int item3 = array.Where((string r) => r.Length == 16).Sum((string r) => r.Count((char c) => c == 'H'));
return (item, item2, item3);
}
}
[BepInPlugin("CybeRNG_LiFE", "CybeRNG_LiFE", "0.0.1")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
internal static Harmony harmony = new Harmony("CybeRNG_LiFE");
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
harmony.PatchAll();
Logger.LogInfo((object)"Plugin CybeRNG_LiFE is loaded!");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "CybeRNG_LiFE";
public const string PLUGIN_NAME = "CybeRNG_LiFE";
public const string PLUGIN_VERSION = "0.0.1";
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "CybeRNG_LiFE";
public const string PLUGIN_NAME = "CybeRNG_LiFE";
public const string PLUGIN_VERSION = "0.0.1";
}
}
namespace CybeRNG_LiFE.Util
{
public static class TextIO
{
public static void WriteTextToFile(string title, string content)
{
try
{
File.AppendAllText(PathManager.GetCurrentPluginPath(title), content);
}
catch (Exception ex)
{
Plugin.Logger.LogWarning((object)("Error while write text to file: " + ex.Message));
}
}
}
public static class TimeUtil
{
public static string GetLocalTimeWithUtcOffset(string format = "yyyy-MM-dd HH:mm:ss zzz")
{
return DateTimeOffset.Now.ToString(format);
}
}
}
namespace CybeRNG_LiFE.RNG
{
public interface IRandomNumberGenerator
{
int Range(int min, int max);
float Range(float min, float max);
uint NextUInt();
}
public struct PCG32 : IRandomNumberGenerator
{
private ulong state;
private readonly ulong increment;
private const ulong Multiplier = 6364136223846793005uL;
private const ulong Baseincrement = 1442695040888963407uL;
public PCG32(int seed, int stream = 1)
{
state = 0uL;
increment = (ulong)((1442695040888963407L + ((long)stream << 1)) | 1);
state += (uint)seed;
NextUInt();
}
public uint NextUInt()
{
ulong num = state;
state = num * 6364136223846793005L + increment;
uint num2 = (uint)(((num >> 18) ^ num) >> 27);
int num3 = (int)(num >> 59);
return (num2 >> num3) | (num2 << (-num3 & 0x1F));
}
public int NextInt(int max)
{
if (max <= 0)
{
return 0;
}
uint num = (uint)(0L - (long)(uint)max) % (uint)max;
uint num2;
do
{
num2 = NextUInt();
}
while (num2 < num);
return (int)(num2 % (uint)max);
}
public int Range(int min, int max)
{
if (min >= max)
{
return min;
}
return min + NextInt(max - min);
}
public float NextFloat()
{
return (float)(NextUInt() >> 8) * 5.9604645E-08f;
}
public float Range(float min, float max)
{
return min + (max - min) * NextFloat();
}
}
public class RandomManager
{
public static int seed = -1;
internal static bool seeded = false;
internal static bool testMode = false;
internal static bool fixedSeed = false;
public static IRandomNumberGenerator patternRNG;
public static IRandomNumberGenerator waveRNG;
public static IRandomNumberGenerator cubePositionRNG;
public static IRandomNumberGenerator enemySpawnRNG;
public static IRandomNumberGenerator enemyBehaviorRNG;
public static void InitializeState()
{
seeded = CheatsManager.KeepCheatsEnabled && MonoSingleton<PrefsManager>.Instance.GetBool("cheat.cyberng_life.customrng", false);
if (!fixedSeed)
{
seed = Random.Range(0, int.MaxValue);
}
}
public static void TryToInitializeRNG()
{
if (testMode)
{
seed = 114514;
}
if (seed == -1)
{
Plugin.Logger.LogDebug((object)"seed not initialized yet, randomly geenrate a seed");
seed = Random.Range(0, int.MaxValue);
}
waveRNG = new PCG32(seed);
patternRNG = new PCG32(seed, 2);
FreshRNG();
}
public static void DisplayCurrentSetting()
{
MonoSingleton<SubtitleController>.Instance.DisplaySubtitle($"current seed: {seed}", (AudioSource)null, false);
}
public static void FreshRNG()
{
GenerateRNG((int)waveRNG.NextUInt());
}
public static void GenerateRNG(int seed)
{
cubePositionRNG = new Xoshiro128StarStar(seed);
enemySpawnRNG = new Xoshiro128StarStar(seed);
}
public static int RangeInt(int min, int max, RNGScope scope)
{
if (!seeded)
{
return Random.Range(min, max);
}
if (scope == RNGScope.Default)
{
ShowFuckUpSubtitle();
}
if (1 == 0)
{
}
int result = scope switch
{
RNGScope.Pattern => patternRNG.Range(min, max),
RNGScope.CubePosition => cubePositionRNG.Range(min, max),
RNGScope.EnemySpawn => enemySpawnRNG.Range(min, max),
RNGScope.EnemyBehavior => enemyBehaviorRNG.Range(min, max),
_ => Random.Range(min, max),
};
if (1 == 0)
{
}
return result;
}
public static float RangeFloat(float min, float max, RNGScope scope)
{
if (!seeded)
{
return Random.Range(min, max);
}
if (scope == RNGScope.Default)
{
ShowFuckUpSubtitle();
}
if (1 == 0)
{
}
float result = scope switch
{
RNGScope.Pattern => patternRNG.Range(min, max),
RNGScope.CubePosition => cubePositionRNG.Range(min, max),
RNGScope.EnemySpawn => enemySpawnRNG.Range(min, max),
RNGScope.EnemyBehavior => enemyBehaviorRNG.Range(min, max),
_ => Random.Range(min, max),
};
if (1 == 0)
{
}
return result;
}
private static void ShowFuckUpSubtitle()
{
MonoSingleton<SubtitleController>.Instance.DisplaySubtitle("If you are reading this it means this mod is fucked up. Fuck infinite-state Machine", (AudioSource)null, false);
}
public static void WriteSeedToText(int startWave)
{
TextIO.WriteTextToFile("Log.txt", $"{TimeUtil.GetLocalTimeWithUtcOffset()}, Seed: {seed}, Start Wave: {startWave}\n");
}
public static CodeInstruction GetCodeInstructionOfRNGScope(RNGScope scope)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
return new CodeInstruction(OpCodes.Ldc_I4, (object)(int)scope);
}
}
public enum RNGScope
{
Pattern,
EnemySpawn,
EnemyBehavior,
CubePosition,
Default
}
public struct XorShift32 : IRandomNumberGenerator
{
private uint state;
public XorShift32(int seed)
{
state = ((seed == 0) ? 1831565813u : ((uint)seed));
}
public uint NextUInt()
{
uint num = state;
num ^= num << 13;
num ^= num >> 17;
return state = num ^ (num << 5);
}
public int NextInt(int max)
{
if (max <= 0)
{
return 0;
}
uint num = uint.MaxValue - uint.MaxValue % (uint)max;
uint num2;
do
{
num2 = NextUInt();
}
while (num2 >= num);
return (int)(num2 % (uint)max);
}
public int Range(int min, int max)
{
if (min >= max)
{
return min;
}
return min + NextInt(max - min);
}
public float NextFloat()
{
return (float)(NextUInt() >> 8) * 5.9604645E-08f;
}
public float Range(float min, float max)
{
return min + (max - min) * NextFloat();
}
}
public struct Xoshiro128StarStar : IRandomNumberGenerator
{
private uint s0;
private uint s1;
private uint s2;
private uint s3;
public Xoshiro128StarStar(int seed)
{
uint x = (uint)seed;
s0 = SplitMix32(ref x);
s1 = SplitMix32(ref x);
s2 = SplitMix32(ref x);
s3 = SplitMix32(ref x);
if ((s0 | s1 | s2 | s3) == 0)
{
s0 = 2654435769u;
}
}
public uint NextUInt()
{
uint result = RotL(s1 * 5, 7) * 9;
uint num = s1 << 9;
s2 ^= s0;
s3 ^= s1;
s1 ^= s2;
s0 ^= s3;
s2 ^= num;
s3 = RotL(s3, 11);
return result;
}
public int NextInt(int max)
{
if (max <= 0)
{
return 0;
}
uint num = uint.MaxValue - uint.MaxValue % (uint)max;
uint num2;
do
{
num2 = NextUInt();
}
while (num2 >= num);
return (int)(num2 % (uint)max);
}
public int Range(int min, int max)
{
if (min >= max)
{
return min;
}
return min + NextInt(max - min);
}
public float NextFloat()
{
return (float)(NextUInt() >> 8) * 5.9604645E-08f;
}
public float Range(float min, float max)
{
return min + (max - min) * NextFloat();
}
private static uint RotL(uint x, int k)
{
return (x << k) | (x >> 32 - k);
}
private static uint SplitMix32(ref uint x)
{
x += 2654435769u;
uint num = x;
num = (num ^ (num >> 16)) * 2246822507u;
num = (num ^ (num >> 13)) * 3266489909u;
return num ^ (num >> 16);
}
}
}
namespace CybeRNG_LiFE.Commands
{
public sealed class CommandsToRegister : CommandRoot, IConsoleLogger
{
public override string Name => "cybernglife";
public override string Description => "a mod for f";
public Logger Log { get; } = new Logger("cybernglife");
public CommandsToRegister(Console con)
: base(con)
{
}//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
public override Branch BuildTree(Console con)
{
return CommandRoot.Branch(((CommandRoot)this).Name, (Node[])(object)new Node[4]
{
(Node)GetBranches(),
(Node)SetBranches(),
(Node)CommandRoot.Leaf("help", (Action)delegate
{
ListCommands();
}, false),
(Node)CommandRoot.Leaf("reference", (Action)delegate
{
ListReference();
}, false)
});
}
private Branch GetBranches()
{
return CommandRoot.Branch("get", (Node[])(object)new Node[3]
{
(Node)CommandRoot.Leaf("seed", (Action)delegate
{
Log.Info($"{RandomManager.seed}", (IEnumerable<Tag>)null, (string)null, (object)null);
}, false),
(Node)CommandRoot.Leaf("testmode", (Action)delegate
{
Log.Info($"{RandomManager.testMode}", (IEnumerable<Tag>)null, (string)null, (object)null);
}, false),
(Node)CommandRoot.Leaf("fixedseed", (Action)delegate
{
Log.Info($"{RandomManager.fixedSeed}", (IEnumerable<Tag>)null, (string)null, (object)null);
}, false)
});
}
private Branch SetBranches()
{
return CommandRoot.Branch("set", (Node[])(object)new Node[3]
{
(Node)CommandRoot.Leaf<int>("seed", (Action<int>)delegate(int seed)
{
RandomManager.seed = seed;
}, false),
(Node)CommandRoot.Leaf<bool>("testmode", (Action<bool>)delegate(bool testmode)
{
RandomManager.testMode = testmode;
}, false),
(Node)CommandRoot.Leaf<bool>("fixedseed", (Action<bool>)delegate(bool fixedSeed)
{
RandomManager.fixedSeed = fixedSeed;
}, false)
});
}
private void ListCommands()
{
Log.Info("CybeRNG_LiFE Commands", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info("========================", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info("Available commands:", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" get", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" └─ seed Get global seed", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" └─ testmode Get testmode status", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" └─ fixedseed Get fixedseed status", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" set", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" └─ seed <int> Set global seed", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" └─ testmode <bool> Enable testmode (using a const seed /114514/)", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" └─ fixedseed <bool> Seed will not change after restart the cybergrind", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" help List all commands", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" reference List all references ", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info("Examples:", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" cybernglife get seed", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info(" cybernglife set seed 1114", (IEnumerable<Tag>)null, (string)null, (object)null);
}
private void ListReference()
{
Log.Info("10_days_till_xmas. (2025) cyberseedsetter, Available at: https://github.com/10-days-till-xmas/CyberSeedSetter (Accessed: 28 Dec 2025).", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info("M.E. O'Neill. (2018) PCG, A Family of Better Random Number Generators, Available at: https://www.pcg-random.org/ (Accessed: 21 Dec 2025).", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info("David Blackman and Sebastiano Vigna. (2018) xoshiro128starstar.c, Available at: https://xoshiro.di.unimi.it/xoshiro128starstar.c (Accessed: 19 Dec 2025)", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info("Docs.rs. (IDK) Struct Xoshiro128StarStar, Available at: https://docs.rs/xoshiro/latest/xoshiro/struct.Xoshiro128StarStar.html (Accessed: 19 Dec 2025)", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info("Wikipedia. (2025) Xorshift, Available at: https://en.wikipedia.org/wiki/Xorshift", (IEnumerable<Tag>)null, (string)null, (object)null);
Log.Info("Wikipedia. (2025) Permuted congruential generator, Available at: https://en.wikipedia.org/wiki/Permuted_congruential_generator (Accessed: 21 Dec 2025).", (IEnumerable<Tag>)null, (string)null, (object)null);
}
}
[HarmonyPatch(typeof(Console))]
public class ConsolePatcher
{
[HarmonyPrefix]
[HarmonyPatch("Awake")]
public static void AddConsoleCommands(Console __instance)
{
CommandsToRegister commandsToRegister = new CommandsToRegister(__instance);
__instance.RegisterCommand((ICommand)(object)commandsToRegister);
}
}
}
namespace CybeRNG_LiFE.Cheats
{
[HarmonyPatch(typeof(CheatsManager))]
public static class CheatsManagerPatcher
{
[HarmonyTranspiler]
[HarmonyPatch("Start")]
private static IEnumerable<CodeInstruction> StartTranspiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.Start().MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"meta", (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(CheatsManager), "RegisterCheat", (Type[])null, (Type[])null), (string)null)
}).Insert((CodeInstruction[])(object)new CodeInstruction[2]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
CodeInstruction.Call((Expression<Action>)(() => RegisterCheats(null)))
});
return val.InstructionEnumeration();
}
private static void RegisterCheats(CheatsManager __instance)
{
if (!(SceneHelper.CurrentScene != "Endless"))
{
__instance.RegisterCheat((ICheat)(object)new UsingCustomRNGCheat(), "meta");
Plugin.Logger.LogInfo((object)"Registed Custom RNG");
}
}
}
public sealed class UsingCustomRNGCheat : ICheat
{
public const string IDENTIFIER = "cyberng_life.customrng";
public string LongName => "Using Custom RNG";
public string Identifier => "cyberng_life.customrng";
public string ButtonEnabledOverride => null;
public string ButtonDisabledOverride => null;
public string Icon => "warning";
public bool DefaultState => false;
public StatePersistenceMode PersistenceMode => (StatePersistenceMode)1;
public bool IsActive { get; private set; }
public void Enable(CheatsManager manager)
{
IsActive = true;
MonoSingleton<PrefsManager>.Instance.SetBool("cheat.ultrakill.keep-enabled", true);
MonoSingleton<SubtitleController>.Instance.DisplaySubtitle("Restart the level with keep cheats enabled to apply the seed", (AudioSource)null, false);
}
public void Disable()
{
IsActive = false;
MonoSingleton<SubtitleController>.Instance.DisplaySubtitle("Restart the level to play without the seed", (AudioSource)null, false);
}
}
}