using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BeastSizeChangerV2;
using HarmonyLib;
using Il2Cpp;
using Il2CppFemur;
using Il2CppGB.Game.Critters;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Mod), "BeastSizeChanger", "2.1", "konradKG25", null)]
[assembly: MelonGame("Boneloaf", "Gang Beasts")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("0.0.0.0")]
[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 BeastSizeChangerV2
{
public class Mod : MelonMod
{
public static class BuildInfo
{
public const string Name = "BeastSizeChanger";
public const string Author = "konradKG25";
public const string Version = "2.1";
public const string DownloadLink = null;
}
[CompilerGenerated]
private sealed class <MakeDataDelayed>d__24 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Actor actor;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <MakeDataDelayed>d__24(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.2f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
ActorPosRotSettingsList.Add(new ActorPosRotSettings(actor));
StoreOldRigidbodiesMassesB(Il2CppArrayBase<Rigidbody>.op_Implicit(((Component)actor).GetComponentsInChildren<Rigidbody>(true)));
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private bool showMenu = false;
private string inputSize = "1.0";
private static float beastSize = 1f;
public Vector3 MegaladonSize = new Vector3(2f, 2f, 2f);
public Vector3 FishSize = new Vector3(0.2f, 0.2f, 0.2f);
public Vector3 NormalSize = new Vector3(1f, 1f, 1f);
public static bool SharksToMegalodons;
public static bool SharksToFishes;
public static bool Players = false;
public static bool Birds = false;
public static List<ActorPosRotSettings> ActorPosRotSettingsList = new List<ActorPosRotSettings>();
public static List<BirdPosRotSettings> BirdPosRotSettingsList = new List<BirdPosRotSettings>();
public static List<SharkPosRotSettings> SharkPosRotSettingsList = new List<SharkPosRotSettings>();
public static float yourPlayerIDForRequestedPerson;
public static float yourWantedPlayerSize;
public static Dictionary<Rigidbody, float> masses = new Dictionary<Rigidbody, float>();
public static Instance Logger => Melon<Mod>.Logger;
public override void OnInitializeMelon()
{
((MelonBase)this).LoggerInstance.Msg(ConsoleColor.Green, "Mod Beast Size Changer initialized!");
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
ActorPosRotSettingsList.Clear();
BirdPosRotSettingsList.Clear();
SharkPosRotSettingsList.Clear();
masses.Clear();
StoreOldRigidbodiesMasses();
}
public override void OnUpdate()
{
if (((ButtonControl)Keyboard.current.f8Key).wasReleasedThisFrame)
{
showMenu = !showMenu;
}
}
public override void OnFixedUpdate()
{
//IL_0033: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
foreach (SharkPosRotSettings sharkPosRotSettings in SharkPosRotSettingsList)
{
if (SharksToMegalodons)
{
if (((Component)sharkPosRotSettings.SShark).transform.localScale != MegaladonSize)
{
((Component)sharkPosRotSettings.SShark).gameObject.SetActive(false);
((Component)sharkPosRotSettings.SShark).transform.localScale = Vector3.one;
sharkPosRotSettings.SharkToSettings();
((Component)sharkPosRotSettings.SShark).transform.localScale = MegaladonSize;
sharkPosRotSettings.SharkMassesToOrginal();
((Component)sharkPosRotSettings.SShark).gameObject.SetActive(true);
}
}
else if (SharksToFishes)
{
if (!(((Component)sharkPosRotSettings.SShark).transform.localScale != FishSize))
{
continue;
}
((Component)sharkPosRotSettings.SShark).gameObject.SetActive(false);
((Component)sharkPosRotSettings.SShark).transform.localScale = Vector3.one;
sharkPosRotSettings.SharkToSettings();
((Component)sharkPosRotSettings.SShark).transform.localScale = FishSize;
sharkPosRotSettings.SharkMassesToOrginal();
foreach (Rigidbody rigidbody in sharkPosRotSettings.rigidbodies)
{
rigidbody.mass = 20f;
}
((Component)sharkPosRotSettings.SShark).gameObject.SetActive(true);
}
else if (!SharksToFishes && !SharksToMegalodons && ((Component)sharkPosRotSettings.SShark).transform.localScale != NormalSize)
{
((Component)sharkPosRotSettings.SShark).gameObject.SetActive(false);
((Component)sharkPosRotSettings.SShark).transform.localScale = Vector3.one;
sharkPosRotSettings.SharkToSettings();
((Component)sharkPosRotSettings.SShark).transform.localScale = NormalSize;
sharkPosRotSettings.SharkMassesToOrginal();
((Component)sharkPosRotSettings.SShark).gameObject.SetActive(true);
}
}
}
public override void OnGUI()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
if (!showMenu)
{
return;
}
GUI.Box(new Rect(100f, 100f, 250f, 250f), "Beast Size Changer V2");
GUI.Label(new Rect(120f, 140f, 200f, 30f), "Enter Size:");
inputSize = GUI.TextField(new Rect(120f, 170f, 200f, 30f), inputSize);
SharksToMegalodons = GUI.Toggle(new Rect(120f, 210f, 200f, 30f), SharksToMegalodons, "Sharks To Megalodons");
SharksToFishes = GUI.Toggle(new Rect(120f, 240f, 200f, 30f), SharksToFishes, "Sharks To Fishes");
Players = GUI.Toggle(new Rect(120f, 270f, 200f, 30f), Players, "Players");
Birds = GUI.Toggle(new Rect(120f, 300f, 200f, 30f), Birds, "Birds");
if (GUI.Button(new Rect(120f, 330f, 200f, 30f), "Change Size"))
{
if (float.TryParse(inputSize, out var result))
{
beastSize = result;
MelonLogger.Msg($"Beast Size changed to: {beastSize}");
MelonLogger.Msg($"Sharks To Megalodons: {SharksToMegalodons}");
MelonLogger.Msg($"Players: {Players}");
ChangeBeastSize();
}
else
{
MelonLogger.Warning("Invalid number entered!");
}
}
}
[IteratorStateMachine(typeof(<MakeDataDelayed>d__24))]
public static IEnumerator MakeDataDelayed(Actor actor)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <MakeDataDelayed>d__24(0)
{
actor = actor
};
}
public static void ChangeBeastSize()
{
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: 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_0078: Invalid comparison between Unknown and I4
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Invalid comparison between Unknown and I4
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Invalid comparison between Unknown and I4
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Invalid comparison between Unknown and I4
MelonLogger.Msg("Beast Size has been changed!");
Vector3 localScale = default(Vector3);
((Vector3)(ref localScale))..ctor(beastSize, beastSize, beastSize);
BirdActor[] array = Il2CppArrayBase<BirdActor>.op_Implicit(Object.FindObjectsOfType<BirdActor>());
if (!Birds)
{
foreach (ActorPosRotSettings actorPosRotSettings in ActorPosRotSettingsList)
{
if (((Component)actorPosRotSettings.AActor).gameObject.active && (int)actorPosRotSettings.AActor.ControlledBy == 2 && Players && !actorPosRotSettings.AActor.statusHandeler.dying)
{
((Component)actorPosRotSettings.AActor).gameObject.SetActive(false);
((Component)actorPosRotSettings.AActor).transform.localScale = Vector3.one;
actorPosRotSettings.ActorToSettings();
((Component)actorPosRotSettings.AActor).transform.localScale = localScale;
((Component)actorPosRotSettings.AActor).gameObject.SetActive(true);
}
else if (((Component)actorPosRotSettings.AActor).gameObject.active && (int)actorPosRotSettings.AActor.ControlledBy != 2 && !Players && !actorPosRotSettings.AActor.statusHandeler.dying)
{
((Component)actorPosRotSettings.AActor).gameObject.SetActive(false);
((Component)actorPosRotSettings.AActor).transform.localScale = Vector3.one;
actorPosRotSettings.ActorToSettings();
((Component)actorPosRotSettings.AActor).transform.localScale = localScale;
((Component)actorPosRotSettings.AActor).gameObject.SetActive(true);
}
}
}
else
{
foreach (BirdPosRotSettings birdPosRotSettings in BirdPosRotSettingsList)
{
((Component)birdPosRotSettings.BBird).gameObject.SetActive(false);
((Component)birdPosRotSettings.BBird).transform.localScale = Vector3.one;
birdPosRotSettings.BirdToSettings();
((Component)birdPosRotSettings.BBird).transform.localScale = localScale;
((Component)birdPosRotSettings.BBird).gameObject.SetActive(true);
}
}
if (beastSize > 1f)
{
Rigidbody[] array2 = Il2CppArrayBase<Rigidbody>.op_Implicit(Object.FindObjectsOfType<Rigidbody>(true));
ReturnBackToOldMasses();
Rigidbody[] array3 = array2;
foreach (Rigidbody val in array3)
{
Enumerator<Actor> enumerator3 = Actor.CachedActors.GetEnumerator();
while (enumerator3.MoveNext())
{
Actor current3 = enumerator3.Current;
if ((((Component)val).transform.IsChildOf(((Component)current3).transform) && Players && (int)current3.ControlledBy == 2) || (((Component)val).transform.IsChildOf(((Component)current3).transform) && !Players && (int)current3.ControlledBy == 1) || !((Object)(object)((Component)val).transform.parent != (Object)null) || !((Object)(object)((Component)((Component)val).transform.parent).GetComponent<BirdActor>() != (Object)null) || !((Component)val).gameObject.active)
{
continue;
}
if ((double)beastSize > 2.5 && beastSize < 11f)
{
val.mass /= beastSize * 5f;
}
else if (beastSize > 11f)
{
val.mass /= 10f;
}
else if ((double)beastSize < 2.5)
{
val.mass = 30f;
if (((Object)((Component)val).gameObject).name != "shark")
{
val.mass = 20f;
}
}
}
}
return;
}
foreach (SharkPosRotSettings sharkPosRotSettings in SharkPosRotSettingsList)
{
sharkPosRotSettings.SharkMassesToOrginal();
}
ReturnBackToOldMasses();
}
public static void StoreOldRigidbodiesMasses()
{
foreach (Rigidbody item in Object.FindObjectsOfType<Rigidbody>(true))
{
masses.Add(item, item.mass);
}
}
public static void StoreOldRigidbodiesMassesB(Rigidbody[] rigidbodies)
{
foreach (Rigidbody val in rigidbodies)
{
masses.Add(val, val.mass);
}
}
public static void ReturnBackToOldMasses()
{
foreach (KeyValuePair<Rigidbody, float> mass in masses)
{
if ((Object)(object)mass.Key != (Object)null && !((Object)((Component)mass.Key).gameObject).name.Contains("tie"))
{
mass.Key.mass = mass.Value;
}
}
}
public static void ChangeSizePlayerID(float playerID, float size)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
Vector3 localScale = default(Vector3);
((Vector3)(ref localScale))..ctor(beastSize, beastSize, beastSize);
foreach (ActorPosRotSettings actorPosRotSettings in ActorPosRotSettingsList)
{
if ((float)actorPosRotSettings.AActor.playerID == playerID)
{
((Component)actorPosRotSettings.AActor).gameObject.SetActive(false);
((Component)actorPosRotSettings.AActor).transform.localScale = Vector3.one;
actorPosRotSettings.ActorToSettings();
((Component)actorPosRotSettings.AActor).transform.localScale = localScale;
((Component)actorPosRotSettings.AActor).gameObject.SetActive(true);
}
}
}
}
public class ActorPosRotSettings
{
public Actor AActor;
public Transform[] ActorColliderList;
public List<Vector3> ActorCollidersPositions = new List<Vector3>();
public List<Quaternion> ActorColliderRotations = new List<Quaternion>();
public ActorPosRotSettings(Actor actor)
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
AActor = actor;
ActorColliderList = Il2CppArrayBase<Transform>.op_Implicit(((Component)((Component)AActor).transform.Find("colliders")).GetComponentsInChildren<Transform>(true));
Transform[] actorColliderList = ActorColliderList;
foreach (Transform val in actorColliderList)
{
ActorCollidersPositions.Add(val.localPosition);
ActorColliderRotations.Add(val.rotation);
}
}
public void ActorToSettings()
{
//IL_001c: 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)
int num = 0;
Transform[] actorColliderList = ActorColliderList;
foreach (Transform val in actorColliderList)
{
val.localPosition = ActorCollidersPositions[num];
val.rotation = ActorColliderRotations[num];
num++;
}
}
}
public class BirdPosRotSettings
{
public BirdActor BBird;
public List<Transform> BirdColliderList = new List<Transform>();
public List<Vector3> BirdCollidersPositions = new List<Vector3>();
public List<Quaternion> BirdColliderRotations = new List<Quaternion>();
public BirdPosRotSettings(BirdActor bird)
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
BBird = bird;
BirdColliderList = ((IEnumerable<Transform>)((Component)((Component)BBird).transform).GetComponentsInChildren<Transform>(true)).ToList();
foreach (Transform birdCollider in BirdColliderList)
{
BirdCollidersPositions.Add(birdCollider.localPosition);
BirdColliderRotations.Add(birdCollider.rotation);
}
}
public void BirdToSettings()
{
//IL_0023: 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)
int num = 0;
foreach (Transform birdCollider in BirdColliderList)
{
birdCollider.localPosition = BirdCollidersPositions[num];
birdCollider.rotation = BirdColliderRotations[num];
num++;
}
}
}
public class SharkPosRotSettings
{
public SharkActor SShark;
public List<Transform> SharkColliderList = new List<Transform>();
public List<Vector3> SharkCollidersPositions = new List<Vector3>();
public List<Quaternion> SharkColliderRotations = new List<Quaternion>();
public List<float> originalMasses = new List<float>();
public List<Rigidbody> rigidbodies = new List<Rigidbody>();
public SharkPosRotSettings(SharkActor shark)
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
SShark = shark;
SharkColliderList = ((IEnumerable<Transform>)((Component)((Component)SShark).transform).GetComponentsInChildren<Transform>(true)).ToList();
foreach (Transform sharkCollider in SharkColliderList)
{
SharkCollidersPositions.Add(sharkCollider.localPosition);
SharkColliderRotations.Add(sharkCollider.rotation);
if ((Object)(object)((Component)sharkCollider).gameObject.GetComponent<Rigidbody>() != (Object)null)
{
rigidbodies.Add(((Component)sharkCollider).gameObject.GetComponent<Rigidbody>());
originalMasses.Add(((Component)sharkCollider).gameObject.GetComponent<Rigidbody>().mass);
}
}
}
public void SharkToSettings()
{
//IL_0023: 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)
int num = 0;
foreach (Transform sharkCollider in SharkColliderList)
{
sharkCollider.localPosition = SharkCollidersPositions[num];
sharkCollider.rotation = SharkColliderRotations[num];
num++;
}
}
public void SharkMassesToOrginal()
{
int num = 0;
foreach (Rigidbody rigidbody in rigidbodies)
{
rigidbody.mass = originalMasses[num];
num++;
}
}
}
[HarmonyPatch(typeof(Actor), "Awake")]
public class ActorPatch
{
public static void Postfix(Actor __instance)
{
MelonCoroutines.Start(Mod.MakeDataDelayed(__instance));
MelonLogger.Msg("Registered for size changing Beast: " + __instance.playerID + " " + __instance.gangID);
}
}
[HarmonyPatch(typeof(BirdActor), "Start")]
public class BirdActorPatch
{
public static void Postfix(BirdActor __instance)
{
Mod.BirdPosRotSettingsList.Add(new BirdPosRotSettings(__instance));
}
}
[HarmonyPatch(typeof(SharkActor), "Start")]
public class SharkActorPatch
{
public static void Postfix(SharkActor __instance)
{
Mod.SharkPosRotSettingsList.Add(new SharkPosRotSettings(__instance));
}
}
public class OnlineChangeBeastSizeMessage : MessageBase
{
private float size = Mod.yourWantedPlayerSize;
private float playerID = Mod.yourPlayerIDForRequestedPerson;
public OnlineChangeBeastSizeMessage(IntPtr ptr)
: base(ptr)
{
}
public OnlineChangeBeastSizeMessage()
: base(ClassInjector.DerivedConstructorPointer<OnlineChangeBeastSizeMessage>())
{
ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(size);
writer.Write(playerID);
}
}
}