using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using GBCouchTest;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppTMPro;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(GBCouchTestMod), "GBCouchPlus", "1.3.1", "Charlie", 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]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 GBCouchTest
{
public static class ColorUtil
{
public static string LastWin = "";
private static readonly string[] Props = new string[17]
{
"_BaseColor", "_Color", "_Colour", "_BaseColour", "_Tint", "_TintColor", "_MainTint", "_ColorTint", "_AlbedoTint", "_PrimaryColor",
"_BodyColor", "_SkinColor", "_SuitColor", "_ColorA", "_Color1", "_CharacterColor", "_TeamColor"
};
public static bool TrySample(Renderer rend, out Color c)
{
//IL_0001: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_0071: 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)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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)
c = Color.white;
if ((Object)(object)rend == (Object)null)
{
return false;
}
Material val = null;
try
{
val = rend.material;
}
catch
{
}
if ((Object)(object)val == (Object)null)
{
try
{
val = rend.sharedMaterial;
}
catch
{
}
}
if ((Object)(object)val == (Object)null)
{
return false;
}
Color val2 = Color.white;
string text = null;
string[] props = Props;
foreach (string text2 in props)
{
try
{
if (val.HasProperty(text2))
{
Color color = val.GetColor(text2);
if (text == null)
{
val2 = color;
text = text2;
}
if (color.r < 0.95f || color.g < 0.95f || color.b < 0.95f)
{
val2 = color;
text = text2;
break;
}
}
}
catch
{
}
}
if (text == null)
{
try
{
val2 = val.color;
text = "(alias)";
}
catch
{
return false;
}
}
c = val2;
LastWin = text;
return true;
}
public static Color Placeholder(int i)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
return new Color(0.3f, 0.3f, 0.3f);
}
}
public static class FreezeController
{
private static List<Rigidbody> _rbs = new List<Rigidbody>();
private static List<Animator> _anims = new List<Animator>();
private static bool _engaged;
private static float _openTime;
private static bool _gaveUp;
private static readonly Dictionary<Rigidbody, bool> _kinematic = new Dictionary<Rigidbody, bool>();
public static void NotifyMenuOpened()
{
_openTime = Time.time;
_gaveUp = false;
}
public static void TickWhileOpen()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
if (!_engaged)
{
if (!_gaveUp)
{
if (Time.time - _openTime > 5f)
{
_gaveUp = true;
VerifyPanel.Mark("freeze", passed: false, "no self found in 5s (expected pre-recon)");
}
else
{
TryEngageSample();
}
}
return;
}
foreach (Rigidbody rb in _rbs)
{
if ((Object)(object)rb != (Object)null)
{
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
}
}
foreach (Animator anim in _anims)
{
if ((Object)(object)anim != (Object)null)
{
anim.speed = 0f;
}
}
}
public static bool TryEngageSample()
{
Candidate candidate = TargetManager.IdentifySelf();
if (candidate == null)
{
return false;
}
_rbs.Clear();
_anims.Clear();
_kinematic.Clear();
try
{
Il2CppArrayBase<Rigidbody> componentsInChildren = candidate.Go.GetComponentsInChildren<Rigidbody>();
if (componentsInChildren != null)
{
foreach (Rigidbody item in componentsInChildren)
{
if (!((Object)(object)item == (Object)null))
{
_rbs.Add(item);
_kinematic[item] = item.isKinematic;
item.isKinematic = true;
}
}
}
Il2CppArrayBase<Animator> componentsInChildren2 = candidate.Go.GetComponentsInChildren<Animator>();
if (componentsInChildren2 != null)
{
_anims.AddRange((IEnumerable<Animator>)componentsInChildren2);
}
}
catch
{
return false;
}
if (_rbs.Count == 0 && _anims.Count == 0)
{
return false;
}
_engaged = true;
return true;
}
public static void Release()
{
foreach (Animator anim in _anims)
{
if ((Object)(object)anim != (Object)null)
{
anim.speed = 1f;
}
}
foreach (KeyValuePair<Rigidbody, bool> item in _kinematic)
{
if ((Object)(object)item.Key != (Object)null)
{
item.Key.isKinematic = item.Value;
}
}
_rbs.Clear();
_anims.Clear();
_kinematic.Clear();
_engaged = false;
}
public static void OnMenuClosed()
{
if (_engaged)
{
Release();
VerifyPanel.Mark("unfreeze", passed: true, "released on close");
}
}
}
public class Candidate
{
public GameObject Go;
public string Name;
public Color Color;
public bool ColorSampled;
}
public static class TargetManager
{
public static List<Candidate> Candidates = new List<Candidate>();
public static int TargetIndex = -1;
private static readonly List<Ui.WButton> _selectButtons = new List<Ui.WButton>();
private static Ui.Label _countLabel;
public static int Rescan()
{
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
Candidates.Clear();
try
{
Il2CppArrayBase<GameObject> obj = Object.FindObjectsOfType<GameObject>();
int num = 0;
foreach (GameObject item in obj)
{
if ((Object)(object)item == (Object)null || !item.activeInHierarchy)
{
continue;
}
string text = ((((Object)item).name == null) ? "" : ((Object)item).name.ToLowerInvariant());
if (!text.Contains("actor [") && !text.Contains("player") && !text.Contains("beast") && !text.Contains("character") && !text.Contains("guy") && !text.Contains("fighter"))
{
continue;
}
Candidate candidate = new Candidate
{
Go = item,
Name = ((Object)item).name
};
Renderer val = item.GetComponent<Renderer>();
if ((Object)(object)val == (Object)null)
{
Il2CppArrayBase<Renderer> componentsInChildren = item.GetComponentsInChildren<Renderer>();
if (componentsInChildren != null && componentsInChildren.Length > 0)
{
val = componentsInChildren[0];
}
}
if ((Object)(object)val != (Object)null && ColorUtil.TrySample(val, out var c))
{
candidate.Color = c;
candidate.ColorSampled = true;
}
if (!candidate.ColorSampled)
{
candidate.Color = ColorUtil.Placeholder(num);
}
else if (!string.IsNullOrEmpty(ColorUtil.LastWin) && Ui.BuildNote.StartsWith("canvas ok"))
{
Ui.BuildNote = Ui.BuildNote + ", colors:" + ColorUtil.LastWin;
}
Candidates.Add(candidate);
num++;
}
}
catch (Exception ex)
{
MelonLogger.Error("[GBCouchTest] scan failed: " + ex.Message);
}
Candidates.Sort(delegate(Candidate a, Candidate b)
{
int num2 = ParseId(a.Name);
int value = ParseId(b.Name);
bool flag = a.Name.StartsWith("Actor [");
bool flag2 = b.Name.StartsWith("Actor [");
return (flag != flag2) ? ((!flag) ? 1 : (-1)) : num2.CompareTo(value);
});
if (TargetIndex >= Candidates.Count)
{
TargetIndex = Candidates.Count - 1;
}
return Candidates.Count;
}
private static int ParseId(string name)
{
try
{
int num = name.IndexOf("PlayerID:");
if (num < 0)
{
num = name.IndexOf("GangID:");
}
if (num < 0)
{
return 999;
}
int i;
for (i = num; i < name.Length && (name[i] < '0' || name[i] > '9'); i++)
{
}
int j;
for (j = i; j < name.Length && name[j] >= '0' && name[j] <= '9'; j++)
{
}
return int.Parse(name.Substring(i, j - i));
}
catch
{
return 999;
}
}
public static Candidate CurrentTarget()
{
if (TargetIndex < 0 || TargetIndex >= Candidates.Count)
{
return null;
}
return Candidates[TargetIndex];
}
public static void CycleTarget()
{
if (Candidates.Count == 0)
{
TargetIndex = -1;
return;
}
TargetIndex++;
if (TargetIndex >= Candidates.Count)
{
TargetIndex = 0;
}
}
public static Candidate IdentifySelf()
{
if (Candidates.Count == 0)
{
Rescan();
}
foreach (Candidate candidate in Candidates)
{
string text = candidate.Name.ToLowerInvariant();
if (text.Contains("p1") || text.Contains("player1") || text.Contains("player 1") || text.Contains("keyboard"))
{
return candidate;
}
}
if (Candidates.Count <= 0)
{
return null;
}
return Candidates[0];
}
public static void BuildPlayersWidgets(float y)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
_selectButtons.Clear();
Ui.AddButton(20f, y, 100f, 26f, "Rescan", delegate
{
Rescan();
MenuGui.Refresh();
});
_countLabel = Ui.AddLabel(130f, y, 480f, 26f, "", 14, Color.white, center: false);
y += 36f;
for (int num = 0; num < Candidates.Count && num < 12; num++)
{
int idx = num;
Candidate c = Candidates[num];
Ui.NewChild("swatch", image: true, 20f, y + 1f, 24f, 24f, c.Color);
Ui.AddLabel(52f, y, 330f, 26f, c.Name + (c.ColorSampled ? "" : " (no color)"), 14, Color.white, center: false);
Ui.WButton item = Ui.AddButton(400f, y, 120f, 26f, "select", delegate
{
TargetIndex = idx;
VerifyPanel.Mark("color_row", passed: true, c.Name);
});
_selectButtons.Add(item);
y += 30f;
}
}
public static void FrameWidgets()
{
//IL_0069: 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_006e: Unknown result type (might be due to invalid IL or missing references)
if (_countLabel != null)
{
_countLabel.Text = Candidates.Count + " candidates | TAB cycles target";
}
for (int i = 0; i < _selectButtons.Count; i++)
{
_selectButtons[i].Base = ((TargetIndex == i) ? new Color(0.8f, 0.6f, 0.2f) : new Color(0.28f, 0.28f, 0.33f));
}
}
}
public class GBCouchTestMod : MelonMod
{
internal static GBCouchTestMod Instance;
public override void OnInitializeMelon()
{
Instance = this;
MelonLogger.Msg("[GBCouchTest] ready. Press F2 to open the test menu.");
}
public override void OnUpdate()
{
KeyInput.Update();
Trolls.Tick();
if (KeyInput.WasPressed(113))
{
MenuGui.Toggle();
}
if (MenuGui.Open)
{
MenuGui.HandleKeys();
MenuGui.Frame();
FreezeController.TickWhileOpen();
}
else
{
FreezeController.OnMenuClosed();
}
}
}
public static class KeyInput
{
private struct POINT
{
public int X;
public int Y;
}
public const int VK_ESCAPE = 27;
public const int VK_TAB = 9;
public const int VK_RETURN = 13;
public const int VK_LEFT = 37;
public const int VK_UP = 38;
public const int VK_RIGHT = 39;
public const int VK_DOWN = 40;
public const int VK_F2 = 113;
public static Vector2 MousePos;
public static bool MouseHeld;
public static bool MouseClicked;
private static readonly Dictionary<int, bool> _down = new Dictionary<int, bool>();
private static readonly Dictionary<int, bool> _prev = new Dictionary<int, bool>();
private static bool _prevMouseHeld;
[DllImport("user32.dll")]
private static extern short GetAsyncKeyState(int vKey);
[DllImport("user32.dll")]
private static extern bool GetCursorPos(out POINT lpPoint);
public static void Update()
{
//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)
Poll(113);
Poll(27);
Poll(9);
Poll(13);
Poll(37);
Poll(38);
Poll(39);
Poll(40);
GetCursorPos(out var lpPoint);
MousePos = new Vector2((float)lpPoint.X, (float)lpPoint.Y);
bool num = (GetAsyncKeyState(1) & 0x8000) != 0;
MouseClicked = num && !_prevMouseHeld;
MouseHeld = num;
_prevMouseHeld = num;
}
private static void Poll(int vk)
{
bool value = (GetAsyncKeyState(vk) & 0x8000) != 0;
_prev[vk] = _down.ContainsKey(vk) && _down[vk];
_down[vk] = value;
}
public static bool IsDown(int vk)
{
if (_down.ContainsKey(vk))
{
return _down[vk];
}
return false;
}
public static bool WasPressed(int vk)
{
if (IsDown(vk))
{
return !_prev[vk];
}
return false;
}
}
public static class MenuGui
{
public static bool Open;
private static int _tab;
private static readonly string[] Tabs = new string[2] { "Trolls", "Players" };
private static Ui.Label _statusLabel;
private static Ui.Label _trollTargetLabel;
private static Ui.Label _trollStatusLabel;
private static Ui.Label _trollMatLabel;
public static void Toggle()
{
try
{
ToggleInner();
}
catch (Exception ex)
{
MelonLogger.Error("[GBCouchTest] Toggle failed: " + ex);
}
}
private static void ToggleInner()
{
Open = !Open;
if (Open)
{
Ui.EnsureBuilt();
if (!Ui.BuiltOk)
{
Open = false;
MelonLogger.Error("menu open aborted: UI build failed (" + Ui.BuildNote + ")");
}
else
{
Refresh();
FreezeController.NotifyMenuOpened();
VerifyPanel.Mark("open_close", passed: true, "opened");
}
}
else
{
FreezeController.OnMenuClosed();
Ui.SetVisible(visible: false);
VerifyPanel.Mark("open_close", passed: true, "closed");
}
}
public static void Refresh()
{
if (Open)
{
Ui.Rebuild();
BuildHeader();
float y = 70f;
if (_tab == 0)
{
BuildTrolls(y);
}
else
{
TargetManager.BuildPlayersWidgets(y);
}
Ui.SetVisible(visible: true);
}
}
private static void BuildHeader()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
Ui.AddLabel(12f, 5f, 250f, 20f, "GBCOUCHPLUS v1.3.1", 12, Color.white, center: false);
_statusLabel = Ui.AddLabel(260f, 6f, 368f, 18f, Ui.BuildNote, 11, new Color(0.7f, 0.7f, 0.6f), center: false);
for (int i = 0; i < Tabs.Length; i++)
{
int idx = i;
Ui.AddButton(12 + i * 124, 36f, 116f, 26f, ((_tab == idx) ? "[ " : "") + Tabs[idx] + ((_tab == idx) ? " ]" : ""), delegate
{
_tab = idx;
Refresh();
});
}
}
private static void BuildTrolls(float y)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_035e: Unknown result type (might be due to invalid IL or missing references)
_trollTargetLabel = Ui.AddLabel(20f, y, 600f, 22f, "", 14, new Color(1f, 0.85f, 0.4f), center: false);
y += 30f;
Ui.AddToggle(20f, y, 400f, 26f, "Freeze target", () => Trolls.FreezeTarget, delegate(bool v)
{
Trolls.FreezeTarget = v;
VerifyPanel.Mark("toggle", passed: true, "freezeT=" + v);
});
y += 30f;
Ui.AddToggle(20f, y, 400f, 26f, "Slippery (zero friction)", () => Trolls.Slippery, delegate(bool v)
{
Trolls.Slippery = v;
});
y += 30f;
Ui.AddToggle(20f, y, 400f, 26f, "Heavy (x5 mass)", () => Trolls.Heavy, delegate(bool v)
{
Trolls.Heavy = v;
});
y += 38f;
Ui.AddSlider(20f, y, 560f, 40f, "Target scale", 0.5f, 2f, 10, () => Trolls.Scale, delegate(float v)
{
Trolls.Scale = v;
});
y += 48f;
Ui.AddSlider(20f, y, 560f, 40f, "Yeet power", 5f, 60f, 11, () => Trolls.YeetPower, delegate(float v)
{
Trolls.YeetPower = v;
});
y += 46f;
Ui.AddButton(20f, y, 120f, 30f, "YEET", delegate
{
Trolls.Yeet();
});
Ui.AddButton(150f, y, 150f, 30f, "Beef boxes", delegate
{
Trolls.BeefBoxes(4);
});
y += 40f;
_trollStatusLabel = Ui.AddLabel(20f, y, 600f, 22f, "", 12, new Color(0.7f, 0.9f, 0.7f), center: false);
y += 26f;
Ui.AddLabel(20f, y, 600f, 22f, "KO / Revive need the recon pass (game internals) - coming later.", 11, new Color(0.6f, 0.6f, 0.6f), center: false);
y += 22f;
_trollMatLabel = Ui.AddLabel(20f, y, 600f, 20f, "", 11, new Color(0.5f, 0.7f, 0.5f), center: false);
}
public static void HandleKeys()
{
if (KeyInput.WasPressed(27))
{
Toggle();
}
if (KeyInput.WasPressed(9))
{
TargetManager.CycleTarget();
VerifyPanel.Mark("color_row", passed: true, "cycled via Tab");
}
}
public static void Frame()
{
if (Open)
{
Ui.Frame();
TargetManager.FrameWidgets();
if (_statusLabel != null)
{
_statusLabel.Text = Ui.BuildNote;
}
Candidate candidate = TargetManager.CurrentTarget();
if (_trollTargetLabel != null)
{
_trollTargetLabel.Text = "Target: " + ((candidate != null) ? candidate.Name : "(none - Rescan in Players)");
}
if (_trollStatusLabel != null)
{
_trollStatusLabel.Text = Trolls.Status;
}
if (_trollMatLabel != null)
{
_trollMatLabel.Text = Trolls.MatInfo;
}
}
}
}
public static class TestRunner
{
public static void RunAll()
{
int num = TargetManager.Rescan();
VerifyPanel.Mark("scan", num > 0, num + " candidates");
MelonLogger.Msg("[GBCouchTest] scan found " + num + " candidates");
Candidate candidate = TargetManager.IdentifySelf();
if (candidate != null)
{
VerifyPanel.Mark("self_id", passed: true, candidate.Name);
MelonLogger.Msg("[GBCouchTest] self guess: " + candidate.Name);
}
else
{
VerifyPanel.Mark("self_id", passed: false, "no match; check log");
MelonLogger.Warning("[GBCouchTest] could not identify keyboard player (expected pre-recon)");
}
bool flag = FreezeController.TryEngageSample();
VerifyPanel.Mark("freeze", flag, flag ? "velocity pinned" : "no self yet");
if (flag)
{
FreezeController.Release();
VerifyPanel.Mark("unfreeze", passed: true, "released");
}
}
}
public static class Ui
{
private enum TextMode
{
None,
TMP,
Legacy
}
public class Label
{
public TextMeshProUGUI Tmp;
public Text Legacy;
public string Text
{
set
{
if ((Object)(object)Tmp != (Object)null)
{
((TMP_Text)Tmp).text = value ?? "";
}
else if ((Object)(object)Legacy != (Object)null)
{
Legacy.text = value ?? "";
}
}
}
public void SetColor(Color c)
{
//IL_0014: 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)
if ((Object)(object)Tmp != (Object)null)
{
((Graphic)Tmp).color = c;
}
else if ((Object)(object)Legacy != (Object)null)
{
((Graphic)Legacy).color = c;
}
}
}
public abstract class W
{
public float X;
public float Y;
public float Wd;
public float Ht;
public Rect Sr => ScreenRect(X, Y, Wd, Ht);
public abstract void Frame();
}
public class WButton : W
{
public Image Img;
public Label Lbl;
public string Text;
public Action OnClick;
public Color Base = new Color(0.28f, 0.28f, 0.33f);
public override void Frame()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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_0052: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: 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)
Rect sr;
if ((Object)(object)Img != (Object)null)
{
Image img = Img;
sr = base.Sr;
((Graphic)img).color = (Color)(((Rect)(ref sr)).Contains(KeyInput.MousePos) ? new Color(0.45f, 0.45f, 0.55f) : Base);
}
if (!KeyInput.MouseClicked)
{
return;
}
sr = base.Sr;
if (((Rect)(ref sr)).Contains(KeyInput.MousePos))
{
KeyInput.MouseClicked = false;
if (OnClick != null)
{
OnClick();
}
}
}
}
public class WToggle : W
{
public Image Box;
public Label Lbl;
public string Text;
public Func<bool> Get;
public Action<bool> Set;
public override void Frame()
{
//IL_0053: 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_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
bool flag = Get != null && Get();
if ((Object)(object)Box != (Object)null)
{
((Graphic)Box).color = (flag ? new Color(0.3f, 0.8f, 0.3f) : new Color(0.55f, 0.2f, 0.2f));
}
if (Lbl != null)
{
Lbl.Text = Text + (flag ? " [ON]" : " [OFF]");
}
if (!KeyInput.MouseClicked)
{
return;
}
Rect sr = base.Sr;
if (((Rect)(ref sr)).Contains(KeyInput.MousePos))
{
KeyInput.MouseClicked = false;
if (Set != null)
{
Set(!flag);
}
}
}
}
public class WSlider : W
{
public Image Fill;
public Image Handle;
public Label Lbl;
public Label Val;
public RectTransform RtFill;
public RectTransform RtHandle;
public float TrackW;
public string Text;
public float Min;
public float Max;
public int Id;
public Func<float> Get;
public Action<float> Set;
private static int _active = -1;
public override void Frame()
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
float num = ((Get != null) ? Get() : Min);
if (Lbl != null)
{
Lbl.Text = Text;
}
if (Val != null)
{
Val.Text = num.ToString("0.0");
}
float num2 = Mathf.Clamp01((num - Min) / (Max - Min));
if ((Object)(object)RtFill != (Object)null)
{
RtFill.sizeDelta = new Vector2(TrackW * num2, 8f);
}
if ((Object)(object)RtHandle != (Object)null)
{
RtHandle.anchoredPosition = new Vector2(TrackW * num2, 0f);
}
Rect sr;
if (KeyInput.MouseClicked)
{
sr = base.Sr;
if (((Rect)(ref sr)).Contains(KeyInput.MousePos))
{
_active = Id;
}
}
if (!KeyInput.MouseHeld)
{
_active = -1;
}
if (_active == Id && Set != null)
{
float x = KeyInput.MousePos.x;
sr = base.Sr;
float num3 = Mathf.Clamp01((x - (((Rect)(ref sr)).x + 10f)) / (Wd - 20f));
Set(Min + num3 * (Max - Min));
}
}
}
public class WCycle : W
{
public Label Lbl;
public Label Val;
public string Text;
public string[] Options;
public Func<int> Get;
public Action<int> Set;
public override void Frame()
{
if (Lbl != null)
{
Lbl.Text = Text;
}
int num = ((Get != null) ? Get() : 0);
if (Val != null)
{
Val.Text = "[" + Options[num] + "]";
}
}
public void Step(int d)
{
int num = ((Get != null) ? Get() : 0);
if (Set != null)
{
Set((num + d + Options.Length) % Options.Length);
}
}
}
public class WCheck : W
{
public Image Box;
public Label Lbl;
public string Text;
public Func<bool> Get;
public Action<bool> Set;
public override void Frame()
{
//IL_0053: 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_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
bool flag = Get != null && Get();
if ((Object)(object)Box != (Object)null)
{
((Graphic)Box).color = (flag ? new Color(0.3f, 0.8f, 0.3f) : new Color(0.25f, 0.25f, 0.28f));
}
if (Lbl != null)
{
Lbl.Text = (flag ? "[PASS] " : "[ ] ") + Text;
}
if (!KeyInput.MouseClicked)
{
return;
}
Rect sr = base.Sr;
if (((Rect)(ref sr)).Contains(KeyInput.MousePos))
{
KeyInput.MouseClicked = false;
if (Set != null)
{
Set(!flag);
}
}
}
}
public const float PW = 640f;
public const float PH = 480f;
public static Canvas Canvas;
public static RectTransform Panel;
public static float PX;
public static float PY;
public static readonly List<W> Widgets = new List<W>();
public static string BuildNote = "";
private static TextMode _textMode = TextMode.None;
private static TMP_FontAsset _tmpFont;
private static Font _legacyFont;
private static bool _fontTried;
public static bool BuiltOk
{
get
{
if ((Object)(object)Canvas != (Object)null)
{
return (Object)(object)Panel != (Object)null;
}
return false;
}
}
private static RectTransform GetRT(GameObject go)
{
if ((Object)(object)go == (Object)null)
{
return null;
}
RectTransform component = go.GetComponent<RectTransform>();
if ((Object)(object)component != (Object)null)
{
return component;
}
try
{
return go.AddComponent<RectTransform>();
}
catch (Exception ex)
{
MelonLogger.Error("GetRT failed on '" + ((Object)go).name + "': " + ex.Message);
return null;
}
}
public static void EnsureBuilt()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Canvas != (Object)null && (Object)(object)Panel != (Object)null)
{
return;
}
try
{
MelonLogger.Msg("UI step: canvas go");
GameObject val = new GameObject("GBCouch_Canvas");
Object.DontDestroyOnLoad((Object)val);
Canvas = val.AddComponent<Canvas>();
Canvas.renderMode = (RenderMode)0;
Canvas.sortingOrder = 999;
RectTransform rT = GetRT(val);
if ((Object)(object)rT == (Object)null)
{
throw new Exception("canvas RectTransform cast failed");
}
rT.sizeDelta = new Vector2((float)Screen.width, (float)Screen.height);
MelonLogger.Msg("UI step: panel go");
GameObject val2 = new GameObject("GBCouch_Panel");
val2.transform.SetParent((Transform)(object)rT, false);
Panel = GetRT(val2);
if ((Object)(object)Panel == (Object)null)
{
throw new Exception("panel RectTransform cast failed");
}
Panel.anchorMin = new Vector2(0.5f, 0.5f);
Panel.anchorMax = new Vector2(0.5f, 0.5f);
Panel.pivot = new Vector2(0.5f, 0.5f);
Panel.sizeDelta = new Vector2(640f, 480f);
Panel.anchoredPosition = Vector2.zero;
Image obj = val2.AddComponent<Image>();
((Graphic)obj).color = new Color(0f, 0f, 0f, 0.88f);
((Graphic)obj).raycastTarget = false;
MelonLogger.Msg("UI step: font");
ResolveFont();
BuildNote = "canvas ok, text=" + _textMode;
MelonLogger.Msg("UI built: " + BuildNote);
}
catch (Exception ex)
{
BuildNote = "BUILD FAILED: " + ex.Message;
MelonLogger.Error("UI build failed: " + ex);
Canvas = null;
Panel = null;
}
}
private static void ResolveFont()
{
if (_fontTried)
{
return;
}
_fontTried = true;
try
{
foreach (TextMeshProUGUI item in Object.FindObjectsOfType<TextMeshProUGUI>())
{
if ((Object)(object)((TMP_Text)item).font != (Object)null)
{
_tmpFont = ((TMP_Text)item).font;
break;
}
}
}
catch
{
}
if ((Object)(object)_tmpFont == (Object)null)
{
try
{
_tmpFont = Resources.Load<TMP_FontAsset>("Fonts & Materials/LiberationSans SDF");
}
catch
{
}
if ((Object)(object)_tmpFont == (Object)null)
{
try
{
_tmpFont = Resources.Load<TMP_FontAsset>("LiberationSans SDF");
}
catch
{
}
}
}
if ((Object)(object)_tmpFont != (Object)null)
{
_textMode = TextMode.TMP;
return;
}
try
{
_legacyFont = Font.CreateDynamicFontFromOSFont(Il2CppStringArray.op_Implicit(new string[4] { "Arial", "Segoe UI", "Calibri", "Tahoma" }), 16);
}
catch
{
}
if ((Object)(object)_legacyFont != (Object)null)
{
_textMode = TextMode.Legacy;
}
}
public static void SetVisible(bool visible)
{
if ((Object)(object)Panel != (Object)null)
{
((Component)Panel).gameObject.SetActive(visible);
}
}
public static void Rebuild()
{
if ((Object)(object)Panel == (Object)null)
{
return;
}
for (int num = ((Transform)Panel).childCount - 1; num >= 0; num--)
{
Transform child = ((Transform)Panel).GetChild(num);
if (!((Object)(object)child == (Object)null))
{
((Component)child).gameObject.SetActive(false);
Object.Destroy((Object)(object)((Component)child).gameObject);
}
}
Widgets.Clear();
}
public static void Frame()
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Canvas == (Object)null) && !((Object)(object)Panel == (Object)null))
{
PX = ((float)Screen.width - 640f) / 2f;
PY = ((float)Screen.height - 480f) / 2f;
((Component)Canvas).GetComponent<RectTransform>().sizeDelta = new Vector2((float)Screen.width, (float)Screen.height);
W[] array = Widgets.ToArray();
for (int i = 0; i < array.Length; i++)
{
array[i].Frame();
}
}
}
public static RectTransform Place(GameObject go, float x, float y, float w, float h)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)go == (Object)null)
{
MelonLogger.Error("Place: null GameObject");
return null;
}
RectTransform rT = GetRT(go);
if ((Object)(object)rT == (Object)null)
{
MelonLogger.Error("Place: no RectTransform on " + ((Object)go).name);
return null;
}
if ((Object)(object)Panel == (Object)null)
{
MelonLogger.Error("Place: Panel is null");
return null;
}
((Transform)rT).SetParent((Transform)(object)Panel, false);
rT.anchorMin = new Vector2(0f, 1f);
rT.anchorMax = new Vector2(0f, 1f);
rT.pivot = new Vector2(0f, 1f);
rT.anchoredPosition = new Vector2(x, 0f - y);
rT.sizeDelta = new Vector2(w, h);
return rT;
}
public static Rect ScreenRect(float x, float y, float w, float h)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
return new Rect(PX + x, PY + y, w, h);
}
public static GameObject NewChild(string name, bool image, float x, float y, float w, float h, Color c)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(name);
Place(val, x, y, w, h);
if (image)
{
Image obj = val.AddComponent<Image>();
((Graphic)obj).color = c;
((Graphic)obj).raycastTarget = false;
}
return val;
}
public static Label CreateLabel(GameObject parent, float x, float y, float w, float h, string text, int size, Color c, bool center)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0029: 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_0053: 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_006e: 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_0105: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("lbl");
RectTransform rT = GetRT(val);
((Transform)rT).SetParent((Transform)(object)GetRT(parent), false);
rT.anchorMin = new Vector2(0f, 1f);
rT.anchorMax = new Vector2(0f, 1f);
rT.pivot = new Vector2(0f, 1f);
rT.anchoredPosition = new Vector2(x, 0f - y);
rT.sizeDelta = new Vector2(w, h);
Label label = new Label();
if (_textMode == TextMode.TMP)
{
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)val2).text = text;
((TMP_Text)val2).fontSize = size;
((Graphic)val2).color = c;
((TMP_Text)val2).font = _tmpFont;
((TMP_Text)val2).alignment = (TextAlignmentOptions)(center ? 514 : 513);
((TMP_Text)val2).enableWordWrapping = false;
((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
((Graphic)val2).raycastTarget = false;
label.Tmp = val2;
}
else if (_textMode == TextMode.Legacy)
{
Text val3 = val.AddComponent<Text>();
val3.text = text;
val3.fontSize = size;
((Graphic)val3).color = c;
val3.font = _legacyFont;
val3.alignment = (TextAnchor)(center ? 4 : 3);
val3.horizontalOverflow = (HorizontalWrapMode)1;
val3.verticalOverflow = (VerticalWrapMode)1;
((Graphic)val3).raycastTarget = false;
label.Legacy = val3;
}
return label;
}
public static WButton AddButton(float x, float y, float w, float h, string text, Action onClick)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
GameObject val = NewChild("btn", image: true, x, y, w, h, new Color(0.28f, 0.28f, 0.33f));
WButton wButton = new WButton
{
X = x,
Y = y,
Wd = w,
Ht = h,
Img = val.GetComponent<Image>(),
Text = text,
OnClick = onClick
};
wButton.Lbl = CreateLabel(val, 0f, 0f, w, h, text, 14, Color.white, center: true);
Widgets.Add(wButton);
return wButton;
}
public static WToggle AddToggle(float x, float y, float w, float h, string text, Func<bool> get, Action<bool> set)
{
//IL_0012: 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_005e: Unknown result type (might be due to invalid IL or missing references)
NewChild("tlbl", image: false, x, y, 0f, 0f, Color.white);
GameObject val = NewChild("tbox", image: true, x + 300f, y + 3f, 60f, h - 6f, Color.white);
Label lbl = CreateLabel(((Component)Panel).gameObject, x, y, 290f, h, text, 14, Color.white, center: false);
WToggle wToggle = new WToggle
{
X = x,
Y = y,
Wd = 370f,
Ht = h,
Box = val.GetComponent<Image>(),
Lbl = lbl,
Text = text,
Get = get,
Set = set
};
Widgets.Add(wToggle);
return wToggle;
}
private static RectTransform AnchorChild(GameObject go, GameObject parent, float ax, float ay, float px, float py, Vector2 pos, Vector2 size)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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_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)
RectTransform rT = GetRT(go);
((Transform)rT).SetParent((Transform)(object)GetRT(parent), false);
rT.anchorMin = new Vector2(ax, ay);
rT.anchorMax = new Vector2(ax, ay);
rT.pivot = new Vector2(px, py);
rT.anchoredPosition = pos;
rT.sizeDelta = size;
return rT;
}
public static WSlider AddSlider(float x, float y, float w, float h, string text, float min, float max, int id, Func<float> get, Action<float> set)
{
//IL_0022: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
float num = w - 20f;
Label lbl = CreateLabel(((Component)Panel).gameObject, x, y, 300f, 22f, text, 14, Color.white, center: false);
Label val = CreateLabel(((Component)Panel).gameObject, x + w - 90f, y, 90f, 22f, "", 14, Color.white, center: false);
GameObject parent = NewChild("strack", image: true, x + 10f, y + 25f, num, 8f, new Color(0.2f, 0.2f, 0.22f));
GameObject val2 = NewChild("sfill", image: true, 0f, 0f, 0f, 8f, new Color(0.4f, 0.6f, 0.9f));
GameObject val3 = NewChild("shandle", image: true, 0f, 0f, 12f, 20f, new Color(0.9f, 0.9f, 0.95f));
RectTransform rtFill = AnchorChild(val2, parent, 0f, 0.5f, 0f, 0.5f, Vector2.zero, new Vector2(0f, 8f));
RectTransform rtHandle = AnchorChild(val3, parent, 0f, 0.5f, 0.5f, 0.5f, Vector2.zero, new Vector2(12f, 20f));
WSlider wSlider = new WSlider
{
X = x,
Y = y,
Wd = w,
Ht = 40f,
Fill = val2.GetComponent<Image>(),
Handle = val3.GetComponent<Image>(),
RtFill = rtFill,
RtHandle = rtHandle,
TrackW = num,
Lbl = lbl,
Val = val,
Text = text,
Min = min,
Max = max,
Id = id,
Get = get,
Set = set
};
Widgets.Add(wSlider);
return wSlider;
}
public static WCycle AddCycle(float x, float y, float w, float h, string text, string[] options, Func<int> get, Action<int> set)
{
//IL_001c: 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)
Label lbl = CreateLabel(((Component)Panel).gameObject, x, y, 150f, h, text, 14, Color.white, center: false);
Label val = CreateLabel(((Component)Panel).gameObject, x + 170f, y, 220f, h, "", 14, Color.white, center: true);
WCycle wd = new WCycle
{
X = x,
Y = y,
Wd = w,
Ht = h,
Lbl = lbl,
Val = val,
Text = text,
Options = options,
Get = get,
Set = set
};
AddButton(x + 400f, y, 34f, h, "<", delegate
{
wd.Step(-1);
});
AddButton(x + 440f, y, 34f, h, ">", delegate
{
wd.Step(1);
});
Widgets.Add(wd);
return wd;
}
public static WCheck AddCheck(float x, float y, float w, float h, string text, Func<bool> get, Action<bool> set)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
GameObject val = NewChild("cbox", image: true, x, y + 2f, 20f, 20f, Color.white);
Label lbl = CreateLabel(((Component)Panel).gameObject, x + 28f, y, w - 28f, h, text, 14, Color.white, center: false);
WCheck wCheck = new WCheck
{
X = x,
Y = y,
Wd = w,
Ht = h,
Box = val.GetComponent<Image>(),
Lbl = lbl,
Text = text,
Get = get,
Set = set
};
Widgets.Add(wCheck);
return wCheck;
}
public static Label AddLabel(float x, float y, float w, float h, string text, int size, Color c, bool center)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
return CreateLabel(((Component)Panel).gameObject, x, y, w, h, text, size, c, center);
}
}
public static class VerifyPanel
{
public class Item
{
public string Id;
public string Label;
public string Note = "";
public bool Passed;
public Ui.Label NoteLabel;
}
public static List<Item> Items = new List<Item>
{
new Item
{
Id = "open_close",
Label = "Menu opens and closes with F2"
},
new Item
{
Id = "toggle",
Label = "Toggle flips and holds state"
},
new Item
{
Id = "slider",
Label = "Slider moves and applies value"
},
new Item
{
Id = "dropdown",
Label = "Cycle-dropdown changes selection"
},
new Item
{
Id = "color_row",
Label = "Player color rows render and select"
},
new Item
{
Id = "scan",
Label = "Scene scan finds beast candidates"
},
new Item
{
Id = "self_id",
Label = "Keyboard player identified (best effort)"
},
new Item
{
Id = "freeze",
Label = "Freeze engages on you while menu open"
},
new Item
{
Id = "unfreeze",
Label = "Freeze releases on menu close"
},
new Item
{
Id = "controller",
Label = "Controllers unaffected (manual confirm)"
},
new Item
{
Id = "no_errors",
Label = "MelonLoader log clean after session (manual)"
}
};
public static void Mark(string id, bool passed, string note)
{
Item item = Items.Find((Item x) => x.Id == id);
if (item != null)
{
item.Passed = passed;
if (!string.IsNullOrEmpty(note))
{
item.Note = note;
}
}
}
public static void BuildWidgets(float y)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
Ui.AddLabel(20f, y, 300f, 22f, "VERIFICATION", 14, Color.white, center: false);
y += 28f;
foreach (Item it in Items)
{
Ui.AddCheck(20f, y, 380f, 22f, it.Label, () => it.Passed, delegate(bool v)
{
it.Passed = v;
});
it.NoteLabel = Ui.AddLabel(400f, y, 220f, 22f, "", 12, new Color(0.8f, 0.8f, 0.6f), center: false);
y += 26f;
}
y += 6f;
Ui.AddButton(20f, y, 400f, 30f, "RUN TESTS (scan, identify you, freeze sample)", delegate
{
TestRunner.RunAll();
});
}
public static void FrameNotes()
{
foreach (Item item in Items)
{
if (item.NoteLabel != null)
{
item.NoteLabel.Text = item.Note;
}
}
}
}
public static class Trolls
{
public static bool FreezeTarget;
public static bool Slippery;
public static bool Heavy;
public static float Scale = 1f;
public static float YeetPower = 30f;
public static string Status = "";
private static GameObject _appliedTo;
private static readonly Dictionary<Collider, PhysicMaterial> _origMats = new Dictionary<Collider, PhysicMaterial>();
private static PhysicMaterial _slick;
private static readonly Dictionary<Rigidbody, bool> _frozenKin = new Dictionary<Rigidbody, bool>();
private static readonly Dictionary<Rigidbody, float> _origMass = new Dictionary<Rigidbody, float>();
private static Vector3 _origScale;
private static bool _scaleInit;
private static readonly List<KeyValuePair<GameObject, float>> _debris = new List<KeyValuePair<GameObject, float>>();
private static Material _worldMat;
public static string MatInfo = "mat:?";
private static Material WorldMat()
{
if ((Object)(object)_worldMat != (Object)null)
{
return _worldMat;
}
try
{
Il2CppArrayBase<MeshRenderer> val = Object.FindObjectsOfType<MeshRenderer>();
foreach (MeshRenderer item in val)
{
if ((Object)(object)item == (Object)null)
{
continue;
}
Material sharedMaterial = ((Renderer)item).sharedMaterial;
if ((Object)(object)sharedMaterial == (Object)null)
{
continue;
}
string text = null;
try
{
if ((Object)(object)sharedMaterial.shader != (Object)null)
{
text = ((Object)sharedMaterial.shader).name;
}
}
catch
{
}
if (text != null && (text.Contains("Universal") || text.Contains("Lit") || text.Contains("Standard") || text.Contains("Simple")))
{
_worldMat = sharedMaterial;
return sharedMaterial;
}
}
foreach (MeshRenderer item2 in val)
{
if ((Object)(object)item2 != (Object)null && (Object)(object)((Renderer)item2).sharedMaterial != (Object)null)
{
_worldMat = ((Renderer)item2).sharedMaterial;
return _worldMat;
}
}
}
catch
{
}
return null;
}
private static void Dress(GameObject go, Color c)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
try
{
Material val = WorldMat();
MaterialPropertyBlock val2 = new MaterialPropertyBlock();
val2.SetColor("_BaseColor", c);
val2.SetColor("_Color", c);
foreach (Renderer componentsInChild in go.GetComponentsInChildren<Renderer>())
{
if (!((Object)(object)componentsInChild == (Object)null))
{
if ((Object)(object)val != (Object)null)
{
componentsInChild.sharedMaterial = val;
}
componentsInChild.SetPropertyBlock(val2);
}
}
if ((Object)(object)val != (Object)null)
{
try
{
MatInfo = "mat:" + ((Object)val.shader).name;
return;
}
catch
{
MatInfo = "mat:?";
return;
}
}
MatInfo = "mat:NOT FOUND (invisible)";
}
catch
{
}
}
private static GameObject TargetGo()
{
return TargetManager.CurrentTarget()?.Go;
}
private static void RestoreAll()
{
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
foreach (KeyValuePair<Collider, PhysicMaterial> origMat in _origMats)
{
if ((Object)(object)origMat.Key != (Object)null)
{
try
{
origMat.Key.material = origMat.Value;
}
catch
{
}
}
}
_origMats.Clear();
foreach (KeyValuePair<Rigidbody, bool> item in _frozenKin)
{
if ((Object)(object)item.Key != (Object)null)
{
try
{
item.Key.isKinematic = item.Value;
}
catch
{
}
}
}
_frozenKin.Clear();
foreach (KeyValuePair<Rigidbody, float> item2 in _origMass)
{
if ((Object)(object)item2.Key != (Object)null)
{
try
{
item2.Key.mass = item2.Value;
}
catch
{
}
}
}
_origMass.Clear();
if ((Object)(object)_appliedTo != (Object)null && _scaleInit)
{
try
{
_appliedTo.transform.localScale = _origScale;
}
catch
{
}
}
_scaleInit = false;
}
public static void Tick()
{
GameObject val = TargetGo();
if ((Object)(object)val == (Object)null)
{
if ((Object)(object)_appliedTo != (Object)null)
{
RestoreAll();
_appliedTo = null;
}
}
else if ((Object)(object)_appliedTo != (Object)(object)val)
{
RestoreAll();
_appliedTo = val;
}
if ((Object)(object)val != (Object)null)
{
ApplyFreeze(val);
ApplySlippery(val);
ApplyHeavy(val);
ApplyScale(val);
}
TickDebris();
}
private static void ApplyFreeze(GameObject go)
{
Il2CppArrayBase<Rigidbody> componentsInChildren = go.GetComponentsInChildren<Rigidbody>();
if (FreezeTarget)
{
foreach (Rigidbody item in componentsInChildren)
{
if (!((Object)(object)item == (Object)null) && !_frozenKin.ContainsKey(item))
{
_frozenKin[item] = item.isKinematic;
item.isKinematic = true;
}
}
return;
}
if (_frozenKin.Count <= 0)
{
return;
}
foreach (KeyValuePair<Rigidbody, bool> item2 in _frozenKin)
{
if ((Object)(object)item2.Key != (Object)null)
{
item2.Key.isKinematic = item2.Value;
}
}
_frozenKin.Clear();
}
private static void ApplySlippery(GameObject go)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
if (Slippery)
{
if ((Object)(object)_slick == (Object)null)
{
_slick = new PhysicMaterial();
_slick.dynamicFriction = 0.02f;
_slick.staticFriction = 0.02f;
_slick.frictionCombine = (PhysicMaterialCombine)2;
_slick.bounciness = 0f;
}
{
foreach (Collider componentsInChild in go.GetComponentsInChildren<Collider>())
{
if (!((Object)(object)componentsInChild == (Object)null) && !_origMats.ContainsKey(componentsInChild))
{
try
{
_origMats[componentsInChild] = componentsInChild.material;
componentsInChild.material = _slick;
}
catch
{
}
}
}
return;
}
}
if (_origMats.Count <= 0)
{
return;
}
foreach (KeyValuePair<Collider, PhysicMaterial> origMat in _origMats)
{
if ((Object)(object)origMat.Key != (Object)null)
{
try
{
origMat.Key.material = origMat.Value;
}
catch
{
}
}
}
_origMats.Clear();
}
private static void ApplyHeavy(GameObject go)
{
Il2CppArrayBase<Rigidbody> componentsInChildren = go.GetComponentsInChildren<Rigidbody>();
if (Heavy)
{
foreach (Rigidbody item in componentsInChildren)
{
if (!((Object)(object)item == (Object)null) && !_origMass.ContainsKey(item))
{
_origMass[item] = item.mass;
item.mass *= 5f;
}
}
return;
}
if (_origMass.Count <= 0)
{
return;
}
foreach (KeyValuePair<Rigidbody, float> item2 in _origMass)
{
if ((Object)(object)item2.Key != (Object)null)
{
item2.Key.mass = item2.Value;
}
}
_origMass.Clear();
}
private static void ApplyScale(GameObject go)
{
//IL_0023: 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_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)
if (!_scaleInit)
{
_origScale = go.transform.localScale;
_scaleInit = true;
}
go.transform.localScale = _origScale * Scale;
}
public static void Yeet()
{
//IL_0046: 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)
GameObject val = TargetGo();
if ((Object)(object)val == (Object)null)
{
Status = "no target";
return;
}
FreezeTarget = false;
foreach (Rigidbody componentsInChild in val.GetComponentsInChildren<Rigidbody>())
{
if (!((Object)(object)componentsInChild == (Object)null))
{
componentsInChild.isKinematic = false;
componentsInChild.AddForce(Vector3.up * YeetPower, (ForceMode)1);
}
}
Status = "YEET x" + YeetPower.ToString("0");
}
public static void BeefBoxes(int n)
{
//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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
GameObject val = TargetGo();
if ((Object)(object)val == (Object)null)
{
Status = "no target";
return;
}
Vector3 position = val.transform.position;
for (int i = 0; i < n; i++)
{
try
{
GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
((Object)val2).name = "GBCouch_BeefBox";
val2.transform.position = position + new Vector3((Random.value - 0.5f) * 5f, 10f + Random.value * 5f, (Random.value - 0.5f) * 5f);
float num = 1.2f + Random.value * 1f;
val2.transform.localScale = new Vector3(num, num, num);
val2.transform.rotation = Random.rotation;
val2.AddComponent<Rigidbody>().mass = 30f;
Dress(val2, new Color(0.55f, 0.35f, 0.25f));
_debris.Add(new KeyValuePair<GameObject, float>(val2, Time.time + 15f));
}
catch (Exception ex)
{
Status = "box fail: " + ex.Message;
}
}
Status = "beef boxes x" + n;
}
private static void TickDebris()
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
for (int num = _debris.Count - 1; num >= 0; num--)
{
KeyValuePair<GameObject, float> keyValuePair = _debris[num];
bool flag = Time.time > keyValuePair.Value || (Object)(object)keyValuePair.Key == (Object)null;
if (!flag)
{
try
{
flag = keyValuePair.Key.transform.position.y < -60f;
}
catch
{
flag = true;
}
}
if (flag)
{
if ((Object)(object)keyValuePair.Key != (Object)null)
{
Object.Destroy((Object)(object)keyValuePair.Key);
}
_debris.RemoveAt(num);
}
}
}
}
}