Decompiled source of WaveFriends v1.0.1

Mods/WaveFriends.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using Il2Cpp;
using Il2CppCostumes;
using Il2CppFemur;
using Il2CppGB.UI;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using WaveFriends;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "WaveFriends", "1.0.0", "Konrad", null)]
[assembly: MelonGame("Boneloaf", "Gang Beasts")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("WaveFriends")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3dce02b73fe601cdf34e33b7523d703be431772e")]
[assembly: AssemblyProduct("WaveFriends")]
[assembly: AssemblyTitle("WaveFriends")]
[assembly: NeutralResourcesLanguage("en-US")]
[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 WaveFriends
{
	public class Core : MelonMod
	{
		[HarmonyPatch(typeof(MenuHandlerGamemodes), "Start")]
		public class GetCostumes
		{
			public static void Postfix(GameModeHandeler __instance)
			{
				if (!((Object)(object)CostumePool.I == (Object)null) && !((Object)(object)CostumePool.I.m_CostumePresetDatabase == (Object)null))
				{
					Enumerator<CostumePreset> enumerator = CostumePool.I.m_CostumePresetDatabase.CostumePresets.GetEnumerator();
					while (enumerator.MoveNext())
					{
						CostumePreset current = enumerator.Current;
						MelonLogger.Msg(current.CostumeSaveEntry.Name);
						costumes.Add(current);
					}
				}
			}
		}

		public static List<CostumePreset> costumes = new List<CostumePreset>();

		public static GameObject Medium;

		public static GameObject Small;

		public static GameObject Big;

		public static bool isFootballOn;

		public static bool isZombiesOn;

		public static bool STOP;

		public static bool isAlreadySpawned;

		public static int Seconds;

		private static string SceneName;

		public static Color RandomColour()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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 new Color(RandomHSVColorFloat(), RandomHSVColorFloat(), RandomHSVColorFloat());
		}

		public static float RandomHSVColorFloat()
		{
			return Random.RandomRange(0.0001f, 1f);
		}

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
		}

		public static CostumePreset GetRandomCostume()
		{
			return costumes[Random.RandomRangeInt(0, costumes.Count)];
		}

		public override void OnUpdate()
		{
			if (((ButtonControl)Keyboard.current.iKey).wasReleasedThisFrame)
			{
				SpawnAIFriend();
			}
			else if (((ButtonControl)Keyboard.current.oKey).wasReleasedThisFrame)
			{
				SpawnAIFriendBig();
			}
			else if (((ButtonControl)Keyboard.current.pKey).wasReleasedThisFrame)
			{
				SpawnAIFriendSmall();
			}
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			SceneName = sceneName;
			Medium = CostumePool.I.BeastResources.GetData<GameObject>("Medium");
			Big = CostumePool.I.BeastResources.GetData<GameObject>("Big");
			Small = CostumePool.I.BeastResources.GetData<GameObject>("Tiny");
		}

		public static void SpawnAIFriend()
		{
			//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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!(SceneName == "Menu"))
			{
				GameObject val = Object.Instantiate<GameObject>(Medium, MouseRayHitPosition(Camera.main), Quaternion.identity);
				val.SetActive(false);
				Actor component = val.GetComponent<Actor>();
				((Behaviour)((Component)component).GetComponent<ActorCostume>()).enabled = false;
				component.gangID = GetPlayer().gangID;
				component._gangID = GetPlayer().gangID;
				component.primaryColor = RandomColour();
				component._primaryColor = component.primaryColor;
				((Object)component).name = ((Object)GetPlayer()).name + "'s Wave Friend";
				val.SetActive(true);
				component.ControlledBy = (ControlledTypes)1;
			}
		}

		public static void SpawnAIFriendBig()
		{
			//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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!(SceneName == "Menu"))
			{
				GameObject val = Object.Instantiate<GameObject>(Big, MouseRayHitPosition(Camera.main), Quaternion.identity);
				val.SetActive(false);
				Actor component = val.GetComponent<Actor>();
				((Behaviour)((Component)component).GetComponent<ActorCostume>()).enabled = false;
				component.gangID = GetPlayer().gangID;
				component._gangID = GetPlayer().gangID;
				component.primaryColor = RandomColour();
				component._primaryColor = component.primaryColor;
				((Object)component).name = ((Object)GetPlayer()).name + "'s Wave Friend";
				val.SetActive(true);
				component.ControlledBy = (ControlledTypes)1;
				component._punchForceModifer = 10f;
			}
		}

		public static void SpawnAIFriendSmall()
		{
			//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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!(SceneName == "Menu"))
			{
				GameObject val = Object.Instantiate<GameObject>(Small, MouseRayHitPosition(Camera.main), Quaternion.identity);
				val.SetActive(false);
				Actor component = val.GetComponent<Actor>();
				((Behaviour)((Component)component).GetComponent<ActorCostume>()).enabled = false;
				component.gangID = GetPlayer().gangID;
				component._gangID = GetPlayer().gangID;
				component.primaryColor = RandomColour();
				component._primaryColor = component.primaryColor;
				((Object)component).name = ((Object)GetPlayer()).name + "'s Wave Friend";
				val.SetActive(true);
				component.ControlledBy = (ControlledTypes)1;
			}
		}

		public static Actor GetPlayer()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			Enumerator<Actor> enumerator = Actor.CachedActors.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Actor current = enumerator.Current;
				if ((int)current.ControlledBy == 2)
				{
					return current;
				}
			}
			return null;
		}

		public static Vector3 MouseRayHitPosition(Camera camera, float maxDistance = 1000f, int layerMask = -5)
		{
			//IL_0020: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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)
			//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_0050: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			if (Mouse.current == null)
			{
				return Vector3.zero;
			}
			Vector2 val = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
			Ray val2 = camera.ScreenPointToRay(Vector2.op_Implicit(val));
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(val2, ref val3, maxDistance, layerMask))
			{
				return ((RaycastHit)(ref val3)).point;
			}
			return ((Ray)(ref val2)).origin + ((Ray)(ref val2)).direction * 10f;
		}
	}
}