Decompiled source of Bopl Evolution v1.0.1

Evolution.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BoplFixedMath;
using HarmonyLib;
using RandomAttributes;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[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")]
namespace Evolution;

[BepInDependency("com.dogoodogster.randomattributes", "1.1.0")]
[BepInPlugin("com.dogoodogster.evolution", "Evolution", "1.0.0")]
public class EvolutionPlugin : BaseUnityPlugin
{
	public Harmony harmony;

	public static EvolutionPlugin instance;

	public static AbilitySet[] abilitySets = new AbilitySet[4];

	public static Attributes[] previousAttributes = (Attributes[])(object)new Attributes[4];

	public static AbilitySet[] previousAbilitySets = new AbilitySet[4];

	private void Awake()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Expected O, but got Unknown
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Expected O, but got Unknown
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Expected O, but got Unknown
		instance = this;
		harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
		harmony.PatchAll(((object)this).GetType());
		MethodInfo methodInfo = AccessTools.Method(typeof(AbilitySelectController), "openCloseMenu", (Type[])null, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(((object)this).GetType(), "AbsolutelyObliterateTheAbilitySelectMidGameThingyBecauseItsAVeryUselessThingInThisModAndWeDontWantThePlayersUsingTheModToBeAbleToChangeThereAbilitiesMidGameForPorpoisPurposes", (Type[])null, (Type[])null);
		harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Cow val = new Cow("Craig", "probably a pig in a cow costume", "mooing");
		Cow val2 = new Cow("Lancy", "who knows", "nothing..?");
		Cow val3 = new Cow("Bert", "almighty frog", "executing all bopl kind");
		Cow val4 = new Cow("Nimbus", "cloud whisperer", "creating cow-shaped clouds");
		((BaseUnityPlugin)this).Logger.LogInfo((object)val.Moo());
		((BaseUnityPlugin)this).Logger.LogInfo((object)val2.Moo());
		((BaseUnityPlugin)this).Logger.LogInfo((object)val3.Moo());
		((BaseUnityPlugin)this).Logger.LogInfo((object)val4.Moo());
		RandomAttributesPlugin.OnLevelStart -= RandomAttributesPlugin.RandomizeThings;
		RandomAttributesPlugin.OnLevelStart += RandomAttributes_OnLevelStart;
	}

	[HarmonyPatch(typeof(LocalizationTable), "GetText")]
	[HarmonyPrefix]
	public static void TextThingy(ref string enText)
	{
		if (enText == "winner!!")
		{
			enText = "wiener winner wow fun!! he wons!!!";
		}
	}

	[HarmonyPatch(typeof(GameSession), "Init")]
	[HarmonyPostfix]
	public static void GameSession_Init()
	{
		//IL_000d: 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_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//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_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: 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_0091: 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_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: 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_00b4: Expected O, but got Unknown
		for (int i = 0; i < PlayerHandler.Get().NumberOfPlayers(); i++)
		{
			RandomAttributesPlugin.attributes[i] = new Attributes
			{
				scale = Updater.RandomFix((Fix)0.4, (Fix)2.5),
				speed = Updater.RandomFix((Fix)15L, (Fix)40L),
				jumpStrength = Updater.RandomFix((Fix)35L, (Fix)60L),
				color = new FixColor(Updater.RandomFix((Fix)0L, (Fix)1L), Updater.RandomFix((Fix)0L, (Fix)1L), Updater.RandomFix((Fix)0L, (Fix)1L))
			};
			abilitySets[i] = new AbilitySet(PlayerHandler.Get().GetPlayer(i + 1));
		}
	}

	[HarmonyPatch(typeof(Player), "Kill")]
	[HarmonyPostfix]
	public static void AThingthatmeansplayerGoByeByeAndGoToBoplHeavenAndGoLikeThisBecauseInThisModPorpoisPurposesSoItBeLikeThatAndItResetsTheAbilitiesAndAttributesToThePreviousRoundBecauseItCanAndFunThingsAndALsoICantKeepTypingHereBecauseICantEvenSeeWhatImTypingAnywaysIThinnkIllEndItNow(Player __instance)
	{
		if (!__instance.stillAliveThisRound)
		{
			RandomAttributesPlugin.attributes[__instance.Id - 1].CopyFrom(previousAttributes[__instance.Id - 1]);
			abilitySets[__instance.Id - 1].CopyFrom(previousAbilitySets[__instance.Id - 1]);
		}
	}

	public static bool AbsolutelyObliterateTheAbilitySelectMidGameThingyBecauseItsAVeryUselessThingInThisModAndWeDontWantThePlayersUsingTheModToBeAbleToChangeThereAbilitiesMidGameForPorpoisPurposes()
	{
		return false;
	}

	private void RandomAttributes_OnLevelStart()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: 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)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: 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_0283: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0312: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_032f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0346: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_035a: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_0366: Unknown result type (might be due to invalid IL or missing references)
		//IL_0371: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0380: Unknown result type (might be due to invalid IL or missing references)
		//IL_0382: Unknown result type (might be due to invalid IL or missing references)
		//IL_0384: Unknown result type (might be due to invalid IL or missing references)
		//IL_038f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0394: Unknown result type (might be due to invalid IL or missing references)
		//IL_0399: Unknown result type (might be due to invalid IL or missing references)
		//IL_039e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
		Fix factor = (Fix)0.15;
		Fix factor2 = (Fix)0.05;
		Fix small = (Fix)0.15;
		Fix large = (Fix)0.15;
		Fix factor3 = (Fix)3L;
		Fix factor4 = (Fix)9.1;
		Fix val = (Fix)0.15;
		for (int i = 0; i < PlayerHandler.Get().NumberOfPlayers(); i++)
		{
			previousAbilitySets[i] = abilitySets[i].Clone();
			Attributes arg = RandomAttributesPlugin.attributes[i];
			Attributes val2 = previousAttributes[i];
			if (val2 == null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Player {i} Previous attributes: null");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Player {i} Previous attributes: {val2}");
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Player {i} Current attributes: {arg}");
			int num = Updater.RandomInt(0, abilitySets[i].abilities.Count);
			for (int j = 0; j < abilitySets[i].abilities.Count; j++)
			{
				List<NamedSprite> sprites = SteamManager.instance.abilityIcons.sprites;
				if ((Object)(object)abilitySets[i].abilityIcons[j] == (Object)(object)sprites[1].associatedGameObject || (Updater.RandomFix(Fix.Zero, Fix.One) < val && j == num))
				{
					NamedSprite val3 = sprites[Updater.RandomInt(2, sprites.Count)];
					abilitySets[i].abilities[j] = val3.associatedGameObject;
					abilitySets[i].abilityIcons[j] = val3.sprite;
				}
			}
			abilitySets[i].SetToPlayer(PlayerHandler.Get().GetPlayer(i + 1));
		}
		int num2 = 0;
		Attributes[] attributes = RandomAttributesPlugin.attributes;
		Fix val5 = default(Fix);
		Fix val6 = default(Fix);
		Fix val7 = default(Fix);
		foreach (Attributes val4 in attributes)
		{
			if (val4 != null)
			{
				previousAttributes[num2] = val4.Clone();
				((FixColor)(ref val4.color)).ToHSV(ref val5, ref val6, ref val7);
				val5 += RandomFromFactor(factor);
				val6 += RandomFromFactor(factor2);
				val7 += RandomFromFactor(factor2);
				Fix val8 = RandomFromTwoFactors(small, large);
				Fix val9 = RandomFromFactor(factor3);
				Fix val10 = RandomFromFactor(factor4);
				val4.scale += val8;
				if (val8 > 0L)
				{
					val4.speed -= val8 * (Fix)5L;
				}
				else
				{
					val4.speed -= val8 * (Fix)17.5392065208;
				}
				val4.speed += val9;
				val4.jumpStrength += val10;
				val4.jumpStrength += val9 * (Fix)2L;
				val4.jumpStrength += val8 * (Fix)50L;
				val7 -= val8 * (Fix)0.5;
				val6 -= val8 * (Fix)0.15;
				val4.color = FixColor.FromHSV(val5, val6, val7);
				num2++;
				continue;
			}
			break;
		}
	}

	public static Fix RandomFromFactor(Fix factor)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: 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_0018: Unknown result type (might be due to invalid IL or missing references)
		return Updater.RandomFix(Fix.Zero, factor) - factor / (Fix)2L;
	}

	public static Fix RandomFromTwoFactors(Fix small, Fix large)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: 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_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		return Updater.RandomFix(Fix.Zero, small + large) - small;
	}
}
public class AbilitySet
{
	public List<GameObject> abilities;

	public List<Sprite> abilityIcons;

	public AbilitySet(List<GameObject> abilities, List<Sprite> abilityIcons)
	{
		this.abilities = abilities.ToArray().ToList();
		this.abilityIcons = abilityIcons.ToArray().ToList();
	}

	public AbilitySet(Player player)
	{
		abilities = player.Abilities.ToArray().ToList();
		abilityIcons = player.AbilityIcons.ToArray().ToList();
	}

	public void SetToPlayer(Player player)
	{
		player.Abilities = abilities.ToArray().ToList();
		player.AbilityIcons = abilityIcons.ToArray().ToList();
	}

	public AbilitySet Clone()
	{
		return new AbilitySet(abilities, abilityIcons);
	}

	public void CopyFrom(AbilitySet other)
	{
		abilities = other.abilities.ToArray().ToList();
		abilityIcons = other.abilityIcons.ToArray().ToList();
	}
}