Decompiled source of 95 Gextradus v4.0.4

GextradusSpawns.dll

Decompiled a day ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MyMoonsModifier")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MyMoonsModifier")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eaa62af8-c1b0-4457-a5e0-f0409b7b50a6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.mrkixcat.gextradusspawns", "GextradusSpawns", "1.0.0")]
public class GextradusSpawnsInjector : BaseUnityPlugin
{
	public static GextradusSpawnsInjector Instance;

	private const string TARGET_MOON = "Gextradus";

	private const string TARGET_ENEMY = "Bunker Spider";

	private const int CLONE_COUNT = 8;

	private const int MAX_COUNT = 6;

	private const float PROB_MULTIPLIER = 8f;

	private const int RARITY = 200;

	private void Awake()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		Instance = this;
		Harmony val = new Harmony("com.mrkixcat.gextradusspawns");
		val.PatchAll();
	}

	public void ApplyToLevel(SelectableLevel level)
	{
		if (!((Object)(object)level == (Object)null) && !(level.PlanetName != "Gextradus"))
		{
			ReplaceInList(level.Enemies, level.PlanetName, "Enemies");
		}
	}

	private void ReplaceInList(List<SpawnableEnemyWithRarity> list, string moonName, string zoneName)
	{
		//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_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Expected O, but got Unknown
		SpawnableEnemyWithRarity val = null;
		foreach (SpawnableEnemyWithRarity item in list)
		{
			if (item?.enemyType?.enemyName == "Bunker Spider")
			{
				val = item;
				break;
			}
		}
		if (val == null)
		{
			return;
		}
		list.RemoveAll((SpawnableEnemyWithRarity s) => s?.enemyType?.enemyName == "Bunker Spider");
		for (int i = 0; i < 8; i++)
		{
			EnemyType val2 = Object.Instantiate<EnemyType>(val.enemyType);
			((Object)val2).name = string.Format("{0}_{1}_Clone_{2}", "Bunker Spider", moonName, i);
			val2.MaxCount = 6;
			if (val2.probabilityCurve != null)
			{
				val2.probabilityCurve = MultiplyCurve(val2.probabilityCurve, 8f);
			}
			list.Add(new SpawnableEnemyWithRarity
			{
				enemyType = val2,
				rarity = 200
			});
		}
	}

	private AnimationCurve MultiplyCurve(AnimationCurve original, float multiplier)
	{
		//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_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		Keyframe[] keys = original.keys;
		Keyframe[] array = (Keyframe[])(object)new Keyframe[keys.Length];
		for (int i = 0; i < keys.Length; i++)
		{
			array[i] = new Keyframe(((Keyframe)(ref keys[i])).time, ((Keyframe)(ref keys[i])).value * multiplier, ((Keyframe)(ref keys[i])).inTangent, ((Keyframe)(ref keys[i])).outTangent);
		}
		return new AnimationCurve(array);
	}
}
[HarmonyPatch(typeof(StartOfRound), "openingDoorsSequence")]
internal class Patch_InjectGextradus
{
	private static void Prefix(StartOfRound __instance)
	{
		if (((NetworkBehaviour)__instance).IsHost)
		{
			SelectableLevel currentLevel = __instance.currentLevel;
			if (!((Object)(object)currentLevel == (Object)null))
			{
				GextradusSpawnsInjector.Instance?.ApplyToLevel(currentLevel);
			}
		}
	}
}