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 BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using HurricaneVR.Framework.Core.Player;
using HurricaneVR.Framework.Weapons.Guns;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using InfimaGames.LowPolyShooterPack;
using LeastSquares;
using RootMotion.Dynamics;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("CheatsTabPlus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CheatsTabPlus")]
[assembly: AssemblyTitle("CheatsTabPlus")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CheatsTabPlus;
internal static class BigHeads
{
private sealed class Grown
{
internal ANBBasicNPC Npc;
internal Transform Head;
internal Vector3 HeadScale;
internal readonly List<Action> Undo = new List<Action>();
internal bool HitboxDone;
internal int Attempts;
}
[HarmonyPatch(typeof(ANBBasicNPC), "UpdateExec")]
internal static class NpcUpdate
{
private static void Postfix(ANBBasicNPC __instance)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
if (failed)
{
return;
}
try
{
if (!CheatState.BigHeadsActive)
{
if (grown.Count > 0)
{
Restore();
}
}
else if (__instance.isEnemy && !__instance.isCivilian)
{
if (!grown.TryGetValue(((Il2CppObjectBase)__instance).Pointer, out var value))
{
value = Grow(__instance);
}
if (value != null && !value.HitboxDone)
{
GrowHitbox(value);
}
}
}
catch (Exception ex)
{
failed = true;
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(57, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CheatsTabPlus Big Heads stopped, heads are normal again: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
logger.LogWarning(val);
}
try
{
Restore();
}
catch (Exception)
{
}
}
}
}
internal static readonly Type[] Patches = new Type[1] { typeof(NpcUpdate) };
private const float Scale = 2.5f;
private const int HitboxAttempts = 300;
private static readonly Dictionary<IntPtr, Grown> grown = new Dictionary<IntPtr, Grown>();
private static bool failed;
private static Grown Grow(ANBBasicNPC npc)
{
//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_0061: 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)
Animator animator = npc.animator;
Transform val = (((Object)(object)animator != (Object)null && animator.isHuman) ? animator.GetBoneTransform((HumanBodyBones)10) : null);
if ((Object)(object)val == (Object)null)
{
return null;
}
Grown grown = new Grown
{
Npc = npc,
Head = val,
HeadScale = val.localScale
};
BigHeads.grown[((Il2CppObjectBase)npc).Pointer] = grown;
val.localScale = Vector3.one * 2.5f;
CheatState.MarkBigHeadsUsed();
if (BigHeads.grown.Count > 512)
{
Prune();
}
return grown;
}
private static void GrowHitbox(Grown entry)
{
ANBBasicNPC npc = entry.Npc;
PuppetMaster val = ((npc.usePuppetMaster && (Object)(object)npc.ANBPM != (Object)null) ? npc.ANBPM.puppetMaster : null);
if ((Object)(object)val == (Object)null)
{
entry.HitboxDone = true;
return;
}
Il2CppReferenceArray<Muscle> muscles = val.muscles;
if (muscles != null)
{
foreach (Muscle item in (Il2CppArrayBase<Muscle>)(object)muscles)
{
if (item == null || (Object)(object)item.joint == (Object)null || (Object)(object)item.target == (Object)null || ((Il2CppObjectBase)item.target).Pointer != ((Il2CppObjectBase)entry.Head).Pointer)
{
continue;
}
foreach (Collider componentsInChild in ((Component)item.joint).GetComponentsInChildren<Collider>(true))
{
ConfigurableJoint componentInParent = ((Component)componentsInChild).GetComponentInParent<ConfigurableJoint>(true);
if (!((Object)(object)componentInParent == (Object)null) && !(((Il2CppObjectBase)componentInParent).Pointer != ((Il2CppObjectBase)item.joint).Pointer))
{
Enlarge(componentsInChild, entry.Undo);
}
}
entry.HitboxDone = true;
return;
}
}
if (++entry.Attempts >= 300)
{
entry.HitboxDone = true;
}
}
private static void Enlarge(Collider collider, List<Action> undo)
{
//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_003a: 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_0047: 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)
//IL_00a8: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: 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)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: 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_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
SphereCollider sphere = ((Il2CppObjectBase)collider).TryCast<SphereCollider>();
Vector3 center;
if (sphere != null)
{
center = sphere.center;
float radius = sphere.radius;
float radius2 = radius;
Vector3 center2 = center;
sphere.center = center2 * 2.5f;
sphere.radius = radius2 * 2.5f;
undo.Add(delegate
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)sphere != (Object)null)
{
sphere.center = center2;
sphere.radius = radius2;
}
});
return;
}
CapsuleCollider capsule = ((Il2CppObjectBase)collider).TryCast<CapsuleCollider>();
if (capsule != null)
{
center = capsule.center;
float radius = capsule.radius;
float height = capsule.height;
float height2 = height;
float radius3 = radius;
Vector3 center3 = center;
capsule.center = center3 * 2.5f;
capsule.radius = radius3 * 2.5f;
capsule.height = height2 * 2.5f;
undo.Add(delegate
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)capsule != (Object)null)
{
capsule.center = center3;
capsule.radius = radius3;
capsule.height = height2;
}
});
return;
}
BoxCollider box = ((Il2CppObjectBase)collider).TryCast<BoxCollider>();
if (box == null)
{
return;
}
center = box.center;
Vector3 size = box.size;
Vector3 size2 = size;
Vector3 center4 = center;
box.center = center4 * 2.5f;
box.size = size2 * 2.5f;
undo.Add(delegate
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)box != (Object)null)
{
box.center = center4;
box.size = size2;
}
});
}
internal static void Restore()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
foreach (Grown value in grown.Values)
{
if ((Object)(object)value.Head != (Object)null)
{
value.Head.localScale = value.HeadScale;
}
foreach (Action item in value.Undo)
{
item();
}
}
grown.Clear();
}
private static void Prune()
{
foreach (IntPtr item in (from pair in grown
where (Object)(object)pair.Value.Npc == (Object)null
select pair.Key).ToList())
{
grown.Remove(item);
}
}
}
internal static class CheatIntegrity
{
[HarmonyPatch(typeof(ANBGameLogic), "CheckForCheats")]
internal static class Check
{
private static void Postfix(ref bool __result)
{
if (CheatState.UsedThisRun || CheatState.Enabled)
{
__result = true;
}
}
}
[HarmonyPatch(typeof(ANBHighscores), "startHighscoreStats")]
internal static class RunStart
{
private static void Prefix(ANBHighscores __instance, out bool __state)
{
__state = __instance.highscoreCounterStart;
}
private static void Postfix(bool __state)
{
if (!__state && !FromCheckpoint())
{
CheatState.UsedThisRun = false;
}
}
}
[HarmonyPatch(typeof(ANBHighscores), "resetHighScores")]
internal static class RunReset
{
private static void Postfix(ANBHighscores __instance)
{
if (!__instance.highscoreCounterStart && !FromCheckpoint())
{
CheatState.UsedThisRun = false;
}
}
}
private static bool FromCheckpoint()
{
ANBGameLogic aNBmain = ANBStaticGameManager.ANBmain;
if ((Object)(object)aNBmain != (Object)null)
{
return aNBmain.CD_checkpoint > 0;
}
return false;
}
}
internal static class CheatRows
{
private sealed class Watch
{
internal ANBSaveItem Item;
internal Transform Anchor;
internal string Key;
internal Group Group;
internal int State = -1;
}
private sealed class Row
{
internal string Id;
internal string Title;
internal string Info;
internal Func<CheatState.Switch> Setting;
internal Func<bool> Visible = () => true;
internal Action Changed;
}
private sealed class Group
{
internal string Id;
internal string[] AnchorKeys;
internal bool NewCategory;
internal bool FollowsPrevious;
internal Row[] Rows;
}
[HarmonyPatch(typeof(ANBUIManager), "OpenCheats")]
internal static class Open
{
private static void Postfix(ANBUIManager __instance)
{
Guard(delegate
{
Build(__instance.CheatScreen);
});
}
}
[HarmonyPatch(typeof(ANBUIManager), "SettingsToCheats")]
internal static class FromSettings
{
private static void Postfix(ANBUIManager __instance)
{
Guard(delegate
{
Build(__instance.SettingsCheatsScreen);
});
}
}
[HarmonyPatch(typeof(ANBSaveItem), "Update")]
internal static class LockWatch
{
private static void Postfix(ANBSaveItem __instance)
{
if (failed || !watched.TryGetValue(((Il2CppObjectBase)__instance).Pointer, out var watch) || (Object)(object)watch.Item == (Object)null)
{
return;
}
Toggle toggleComponent = __instance.toggleComponent;
int num = (int)((__instance.isLocked() ? 1u : 0u) | (uint)(((Object)(object)toggleComponent != (Object)null && ((Component)toggleComponent).gameObject.activeSelf) ? 2 : 0)) | (((Object)(object)__instance.Lock != (Object)null && __instance.Lock.activeSelf) ? 4 : 0);
if (num != watch.State)
{
watch.State = num;
Guard(delegate
{
Refresh(watch.Anchor, watch.Key, watch.Group);
});
}
}
}
private const string Prefix = "CheatsTabPlus_";
private static bool failed;
private static bool described;
private static readonly Dictionary<IntPtr, Watch> watched = new Dictionary<IntPtr, Watch>();
private static readonly Group[] Groups = new Group[4]
{
new Group
{
Id = "Weapons",
AnchorKeys = new string[2] { "cheats_unlimitedammo", "cheats_unlimitedmag" },
Rows = new Row[3]
{
new Row
{
Id = "NoRecoil",
Title = "No Recoil",
Info = "no gun kick and no camera bump when you shoot",
Setting = () => CheatState.NoRecoil
},
new Row
{
Id = "NoSpread",
Title = "No Spread",
Info = "every bullet goes exactly where you aim",
Setting = () => CheatState.NoSpread
},
new Row
{
Id = "NoSpreadShotguns",
Title = "Also Apply No Spread for Shotguns",
Info = "every shotgun pellet goes exactly to the centre",
Setting = () => CheatState.NoSpreadShotguns,
Visible = () => CheatState.NoSpread.On
}
}
},
new Group
{
Id = "Movement",
AnchorKeys = new string[1] { "cheats_slomo" },
NewCategory = true,
Rows = new Row[2]
{
new Row
{
Id = "DoubleSpeed",
Title = "Double Speed",
Info = "move twice as fast",
Setting = () => CheatState.DoubleSpeed
},
new Row
{
Id = "Noclip",
Title = "Noclip",
Info = "fly where you look, straight through walls",
Setting = () => CheatState.Noclip
}
}
},
new Group
{
Id = "Misc",
AnchorKeys = new string[1] { "cheats_slomo" },
NewCategory = true,
FollowsPrevious = true,
Rows = new Row[2]
{
new Row
{
Id = "BigHeads",
Title = "Big Heads",
Info = "You know what it does.",
Setting = () => CheatState.BigHeads,
Changed = delegate
{
if (!CheatState.BigHeads.On)
{
BigHeads.Restore();
}
}
},
new Row
{
Id = "OneHitEnemies",
Title = "One Hit Enemies",
Info = "Makes all enemies die from one hit.",
Setting = () => CheatState.OneHitEnemies
}
}
},
new Group
{
Id = "Health",
AnchorKeys = new string[1] { "cheats_HP" },
Rows = new Row[1]
{
new Row
{
Id = "Ohko",
Title = "OHKO",
Info = "Any hit is lethal, goodluck.",
Setting = () => CheatState.Ohko
}
}
}
};
private static void Guard(Action action)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
if (failed)
{
return;
}
try
{
action();
}
catch (Exception ex)
{
failed = true;
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(44, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CheatsTabPlus could not add its cheat rows: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
logger.LogWarning(val);
}
}
}
private static void Build(GameObject screen)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
if ((Object)(object)screen == (Object)null)
{
return;
}
Transform val = null;
Group[] groups = Groups;
bool flag = default(bool);
foreach (Group obj in groups)
{
var (val2, key) = FindAnchor(screen, obj.AnchorKeys);
if ((Object)(object)val2 == (Object)null)
{
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(46, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CheatsTabPlus found no '");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(obj.AnchorKeys[0]);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' row for its ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(obj.Id);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" cheats.");
}
logger.LogWarning(val3);
}
continue;
}
Describe(val2, key);
Transform parent = val2.parent;
int num = ((obj.FollowsPrevious && (Object)(object)val != (Object)null) ? val : val2).GetSiblingIndex() + 1;
if (obj.NewCategory)
{
Transform val4 = parent.Find("CheatsTabPlus_" + obj.Id + "_Divider") ?? CopyDivider(val2, obj);
if ((Object)(object)val4 != (Object)null)
{
val4.SetSiblingIndex(num++);
}
}
Row[] rows = obj.Rows;
foreach (Row row in rows)
{
Transform obj2 = parent.Find("CheatsTabPlus_" + row.Id) ?? Create(val2, key, obj, row);
obj2.SetSiblingIndex(num++);
val = obj2;
}
Refresh(val2, key, obj);
ANBSaveItem component = ((Component)val2).GetComponent<ANBSaveItem>();
if (component != null)
{
watched[((Il2CppObjectBase)component).Pointer] = new Watch
{
Item = component,
Anchor = val2,
Key = key,
Group = obj
};
}
}
}
private static Transform CopyDivider(Transform anchor, Group group)
{
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
Transform parent = anchor.parent;
bool flag = default(bool);
ManualLogSource logger;
for (int num = anchor.GetSiblingIndex() - 1; num >= 0; num--)
{
Transform child = parent.GetChild(num);
if (!((Object)child).name.StartsWith("CheatsTabPlus_") && !((Object)(object)((Component)child).GetComponent<ANBSaveItem>() != (Object)null) && ((Component)child).gameObject.activeSelf && !((Object)(object)((Component)child).GetComponentInChildren<TMP_Text>(true) != (Object)null))
{
GameObject obj = Object.Instantiate<GameObject>(((Component)child).gameObject, parent, false);
((Object)obj).name = "CheatsTabPlus_" + group.Id + "_Divider";
logger = Plugin.Logger;
if (logger != null)
{
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(50, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CheatsTabPlus copied divider '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)child).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' for its ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(group.Id);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" category.");
}
logger.LogInfo(val);
}
return obj.transform;
}
}
logger = Plugin.Logger;
if (logger != null)
{
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(59, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CheatsTabPlus found no divider to start its ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(group.Id);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" category with.");
}
logger.LogWarning(val2);
}
return null;
}
private static Transform Create(Transform anchor, string key, Group group, Row row)
{
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected O, but got Unknown
GameObject val = Object.Instantiate<GameObject>(((Component)anchor).gameObject, anchor.parent, false);
((Object)val).name = "CheatsTabPlus_" + row.Id;
ANBSaveItem component = val.GetComponent<ANBSaveItem>();
if ((Object)(object)component != (Object)null)
{
Object.DestroyImmediate((Object)(object)component);
}
foreach (ANBLanguageText componentsInChild in val.GetComponentsInChildren<ANBLanguageText>(true))
{
((Behaviour)componentsInChild).enabled = false;
}
Label(val.transform, key, row);
Toggle componentInChildren = val.GetComponentInChildren<Toggle>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
CheatState.Switch setting = row.Setting();
componentInChildren.onValueChanged = new ToggleEvent();
componentInChildren.SetIsOnWithoutNotify(setting.On);
((UnityEvent<bool>)(object)componentInChildren.onValueChanged).AddListener(UnityAction<bool>.op_Implicit((Action<bool>)delegate(bool on)
{
setting.On = on;
row.Changed?.Invoke();
Guard(delegate
{
Refresh(anchor, key, group);
});
}));
}
return val.transform;
}
private static void Refresh(Transform anchor, string key, Group group)
{
Transform parent = anchor.parent;
ANBSaveItem component = ((Component)anchor).GetComponent<ANBSaveItem>();
bool flag = (((Object)(object)component != (Object)null) ? component.isLocked() : (!CheatState.Allowed()));
Row[] rows = group.Rows;
foreach (Row row in rows)
{
Transform val = parent.Find("CheatsTabPlus_" + row.Id);
if ((Object)(object)val == (Object)null)
{
continue;
}
((Component)val).gameObject.SetActive(row.Visible());
Label(val, key, row);
if ((Object)(object)component != (Object)null)
{
Mirror(anchor, val, component.Lock);
Mirror(anchor, val, component.cheatLockText);
Mirror(anchor, val, component.cheatUnlockText);
if ((Object)(object)component.toggleComponent != (Object)null)
{
Mirror(anchor, val, ((Component)component.toggleComponent).gameObject);
}
}
Toggle componentInChildren = ((Component)val).GetComponentInChildren<Toggle>(true);
if (!((Object)(object)componentInChildren == (Object)null))
{
((Selectable)componentInChildren).interactable = !flag;
componentInChildren.SetIsOnWithoutNotify(row.Setting().On);
}
}
}
private static void Label(Transform copy, string key, Row row)
{
foreach (ANBLanguageText componentsInChild in ((Component)copy).GetComponentsInChildren<ANBLanguageText>(true))
{
TextMeshProUGUI txtField = componentsInChild.txtField;
if (!((Object)(object)txtField == (Object)null))
{
if (componentsInChild.TextID == key)
{
((TMP_Text)txtField).text = row.Title;
}
else if (componentsInChild.TextID == key + "_info")
{
((TMP_Text)txtField).text = row.Info;
}
}
}
}
private static void Mirror(Transform anchor, Transform copy, GameObject stockChild)
{
if ((Object)(object)stockChild == (Object)null)
{
return;
}
List<string> list = new List<string>();
Transform val = stockChild.transform;
while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)anchor)
{
list.Insert(0, ((Object)val).name);
val = val.parent;
}
if (!((Object)(object)val != (Object)(object)anchor) && list.Count != 0)
{
Transform val2 = copy.Find(string.Join("/", list));
if ((Object)(object)val2 != (Object)null)
{
((Component)val2).gameObject.SetActive(stockChild.activeSelf);
}
}
}
private static (Transform Row, string Key) FindAnchor(GameObject screen, string[] keys)
{
Transform val = null;
string item = null;
foreach (ANBLanguageText componentsInChild in screen.GetComponentsInChildren<ANBLanguageText>(true))
{
if (Array.IndexOf(keys, componentsInChild.TextID) < 0)
{
continue;
}
Transform val2 = ((Component)componentsInChild).transform;
while ((Object)(object)val2 != (Object)null)
{
if (!((Object)(object)((Component)val2).GetComponent<ANBSaveItem>() == (Object)null))
{
if ((Object)(object)val == (Object)null || val2.GetSiblingIndex() > val.GetSiblingIndex())
{
val = val2;
item = componentsInChild.TextID;
}
break;
}
val2 = val2.parent;
}
}
return (Row: val, Key: item);
}
private static void Describe(Transform anchor, string key)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
if (described)
{
return;
}
described = true;
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CheatsTabPlus inserting under '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)anchor).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(key);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") in '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)anchor.parent).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
}
logger.LogInfo(val);
}
}
}
internal static class CheatState
{
internal sealed class Switch
{
internal bool On;
}
[HarmonyPatch(typeof(ANBGameLogic), "ResetCheats")]
internal static class Reset
{
private static void Postfix()
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
bool flag = (NoRecoil.On = (NoSpread.On = (NoSpreadShotguns.On = (DoubleSpeed.On = (Noclip.On = (BigHeads.On = (OneHitEnemies.On = (Ohko.On = false))))))));
try
{
CheatsTabPlus.BigHeads.Restore();
}
catch (Exception ex)
{
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(52, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CheatsTabPlus could not shrink heads back on reset: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
logger.LogWarning(val);
}
}
}
}
internal static readonly Switch NoRecoil = new Switch();
internal static readonly Switch NoSpread = new Switch();
internal static readonly Switch NoSpreadShotguns = new Switch();
internal static readonly Switch DoubleSpeed = new Switch();
internal static readonly Switch Noclip = new Switch();
internal static readonly Switch BigHeads = new Switch();
internal static readonly Switch OneHitEnemies = new Switch();
internal static readonly Switch Ohko = new Switch();
internal static bool UsedThisRun;
internal static bool Enabled
{
get
{
if (NoRecoil.On || NoSpread.On || DoubleSpeed.On || Noclip.On || BigHeads.On || OneHitEnemies.On || Ohko.On)
{
return Allowed();
}
return false;
}
}
internal static bool OneHitEnemiesOn
{
get
{
if (OneHitEnemies.On)
{
return Use();
}
return false;
}
}
internal static bool OhkoOn
{
get
{
if (Ohko.On)
{
return Use();
}
return false;
}
}
internal static bool OhkoActive
{
get
{
if (Ohko.On)
{
return Allowed();
}
return false;
}
}
internal static bool NoRecoilOn
{
get
{
if (NoRecoil.On)
{
return Use();
}
return false;
}
}
internal static bool DoubleSpeedOn
{
get
{
if (DoubleSpeed.On)
{
return Use();
}
return false;
}
}
internal static bool NoclipOn
{
get
{
if (Noclip.On)
{
return Use();
}
return false;
}
}
internal static bool BigHeadsActive
{
get
{
if (BigHeads.On)
{
return Allowed();
}
return false;
}
}
internal static bool NoclipActive
{
get
{
if (Noclip.On)
{
return Allowed();
}
return false;
}
}
internal static bool NoRecoilCameraOn
{
get
{
if (NoRecoil.On)
{
return Allowed();
}
return false;
}
}
internal static bool Allowed()
{
ANBGameLogic aNBmain = ANBStaticGameManager.ANBmain;
if ((Object)(object)aNBmain != (Object)null)
{
return !aNBmain.cheatsBlocked();
}
return false;
}
internal static void MarkBigHeadsUsed()
{
Use();
}
internal static bool NoSpreadFor(bool shotgun)
{
if (NoSpread.On && (!shotgun || NoSpreadShotguns.On))
{
return Use();
}
return false;
}
private static bool Use()
{
if (!Allowed())
{
return false;
}
UsedThisRun = true;
return true;
}
}
internal static class HealthCheats
{
[HarmonyPatch]
internal static class EnemyHit
{
private static IEnumerable<MethodBase> TargetMethods()
{
return new string[7] { "TakeDamage", "TakeMeleeDamage", "TakeBluntWeaponDamage", "TakeKnifeSlashDamage", "TakeStabDamage", "ExplosionDamage", "GenericDamage" }.Select((string name) => AccessTools.Method(typeof(ANBBasicNPC), name, (Type[])null, (Type[])null));
}
private static void Prefix(ANBBasicNPC __instance)
{
Safe(delegate
{
if (IsLiveEnemy(__instance) && __instance.health > 0.001f && CheatState.OneHitEnemiesOn)
{
__instance.health = 0.001f;
}
return true;
}, fallback: true);
}
}
[HarmonyPatch(typeof(ANBBasicNPC), "TakeArmorDamage")]
internal static class ArmorHit
{
private static bool Prefix(ANBBasicNPC __instance, Vector3 location, Vector3 direction, float damage, Collider bodyPart, ANBHVRGunBase originGun, float bulletForce)
{
//IL_000d: 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_0014: 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)
return Safe(delegate
{
//IL_001d: 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)
if (!IsLiveEnemy(__instance) || !CheatState.OneHitEnemiesOn)
{
return true;
}
__instance.TakeDamage(location, direction, Mathf.Max(damage, 1f), bodyPart, originGun, bulletForce, false, "", (ANBKnife)null);
return false;
}, fallback: true);
}
}
[HarmonyPatch(typeof(ANBGameLogic), "Update")]
internal static class OhkoTick
{
private static ANBGameLogic owner;
private static float max;
private static float recharge;
private static void Postfix(ANBGameLogic __instance)
{
Safe(delegate
{
ANBGameLogic val = __instance;
if (CheatState.OhkoOn)
{
val.heartBeatPulseCurrent = 0f;
if (val.playerHitPointsMax == 1f && val.playerHitPoints <= 1f)
{
return true;
}
if (val.playerHitPointsMax != 1f)
{
owner = val;
max = val.playerHitPointsMax;
recharge = val.playerHitPointsMaxRecharge;
}
float playerHitPointsMax = (val.playerHitPointsMaxRecharge = 1f);
val.playerHitPointsMax = playerHitPointsMax;
if (val.playerHitPoints > 1f)
{
val.playerHitPoints = 1f;
}
val.checkHealth();
}
else if ((Object)(object)owner != (Object)null)
{
if (((Il2CppObjectBase)owner).Pointer == ((Il2CppObjectBase)val).Pointer)
{
val.playerHitPointsMax = max;
val.playerHitPointsMaxRecharge = recharge;
if (val.playerHitPoints > 0f)
{
val.playerHitPoints = max;
}
val.checkHealth();
}
owner = null;
}
return true;
}, fallback: true);
}
}
[HarmonyPatch(typeof(ANBGameLogic), "HurtPlayer")]
internal static class OhkoHit
{
private static void Prefix(ref float dmg)
{
if (dmg > 0f && Safe(() => CheatState.OhkoOn, fallback: false))
{
dmg = 1000000f;
}
}
}
[HarmonyPatch(typeof(ANBSFXPlayerManager), "VoiceLowhealth")]
internal static class OhkoVoice
{
private static bool Prefix()
{
return Safe(() => !CheatState.OhkoActive, fallback: true);
}
}
[HarmonyPatch(typeof(ANBWristHud), "checkHealth")]
internal static class OhkoHud
{
private static void Postfix(ANBWristHud __instance)
{
Safe(delegate
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
ANBGameLogic aNBmain = ANBStaticGameManager.ANBmain;
if (!CheatState.OhkoActive || (Object)(object)aNBmain == (Object)null || aNBmain.playerHitPoints <= 0f || __instance.allHealthPoints == null)
{
return true;
}
foreach (Image item in (Il2CppArrayBase<Image>)(object)__instance.allHealthPoints)
{
if ((Object)(object)item != (Object)null && ((Component)item).gameObject.activeSelf)
{
((Graphic)item).color = __instance.healthColor;
}
}
return true;
}, fallback: true);
}
}
internal static readonly Type[] Patches = new Type[6]
{
typeof(EnemyHit),
typeof(ArmorHit),
typeof(OhkoTick),
typeof(OhkoHit),
typeof(OhkoVoice),
typeof(OhkoHud)
};
private const float Sliver = 0.001f;
private static bool failed;
private static T Safe<T>(Func<T> body, T fallback)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
if (failed)
{
return fallback;
}
try
{
return body();
}
catch (Exception ex)
{
failed = true;
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(60, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CheatsTabPlus health cheats stopped, health is stock again: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
logger.LogWarning(val);
}
return fallback;
}
}
private static bool IsLiveEnemy(ANBBasicNPC npc)
{
if ((Object)(object)npc != (Object)null && npc.isEnemy && !npc.isCivilian)
{
return !npc.isDead;
}
return false;
}
}
internal static class MovementCheats
{
[HarmonyPatch(typeof(HVRPlayerController), "FixedUpdate")]
internal static class VrTick
{
internal sealed class Saved
{
internal float Move;
internal float Run;
internal float Accel;
internal float SprintAccel;
}
private static HVRPlayerController rig;
private static int headMask;
private static bool pushesBack;
private static bool limitsHead;
private static bool fadesFromLean;
internal static bool Flying => (Object)(object)rig != (Object)null;
private static void Prefix(HVRPlayerController __instance, out Saved __state)
{
__state = Safe(delegate
{
if (CheatState.DoubleSpeedOn)
{
HVRPlayerController val = __instance;
Saved result = new Saved
{
Move = val.MoveSpeed,
Run = val.RunSpeed,
Accel = val.Acceleration,
SprintAccel = val.SprintAcceleration
};
val.MoveSpeed *= 2f;
val.RunSpeed *= 2f;
val.Acceleration *= 2f;
val.SprintAcceleration *= 2f;
return result;
}
return (Saved)null;
}, null);
}
private static void Postfix(HVRPlayerController __instance)
{
Safe(delegate
{
HVRPlayerController val = __instance;
bool flag = (Object)(object)rig != (Object)null && ((Il2CppObjectBase)rig).Pointer == ((Il2CppObjectBase)val).Pointer;
if (CheatState.NoclipOn)
{
Fly(val, !flag);
}
else if (flag)
{
Land(val);
}
return true;
}, fallback: true);
}
private static Exception Finalizer(Exception __exception, HVRPlayerController __instance, Saved __state)
{
if (__state != null && (Object)(object)__instance != (Object)null)
{
__instance.MoveSpeed = __state.Move;
__instance.RunSpeed = __state.Run;
__instance.Acceleration = __state.Accel;
__instance.SprintAcceleration = __state.SprintAccel;
}
return __exception;
}
private static void Fly(HVRPlayerController c, bool entering)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
if (entering)
{
rig = c;
pushesBack = c.HeadCollisionPushesBack;
limitsHead = c.LimitHeadDistance;
fadesFromLean = c.FadeFromLean;
bool flag = (c.FadeFromLean = false);
bool headCollisionPushesBack = (c.LimitHeadDistance = flag);
c.HeadCollisionPushesBack = headCollisionPushesBack;
if ((Object)(object)c.HeadCollision != (Object)null)
{
LayerMask layerMask = c.HeadCollision.LayerMask;
headMask = ((LayerMask)(ref layerMask)).value;
((LayerMask)(ref layerMask)).value = 0;
c.HeadCollision.LayerMask = layerMask;
}
}
if ((Object)(object)c.CharacterController != (Object)null)
{
((Collider)c.CharacterController).enabled = false;
}
Vector2 input = (((Object)(object)c.Inputs != (Object)null) ? c.Inputs.MovementAxis : Vector2.zero);
Transform look = (((Object)(object)c.Camera != (Object)null) ? c.Camera : ((Component)c).transform);
Transform transform = ((Component)c).transform;
transform.position += Flight(look, input, c.RunSpeed, Time.fixedDeltaTime);
if (c.CanRotate())
{
c.HandleRotation();
}
}
internal static void LandIfFlying()
{
if ((Object)(object)rig != (Object)null)
{
Land(rig);
}
}
private static void Land(HVRPlayerController c)
{
//IL_0065: 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_0040: 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)
rig = null;
c.HeadCollisionPushesBack = pushesBack;
c.LimitHeadDistance = limitsHead;
c.FadeFromLean = fadesFromLean;
if ((Object)(object)c.HeadCollision != (Object)null)
{
LayerMask layerMask = c.HeadCollision.LayerMask;
((LayerMask)(ref layerMask)).value = headMask;
c.HeadCollision.LayerMask = layerMask;
}
c.yVelocity = 0f;
c.xzVelocity = Vector3.zero;
Settle(((Component)c).transform);
if ((Object)(object)c.CharacterController != (Object)null)
{
((Collider)c.CharacterController).enabled = true;
}
}
}
[HarmonyPatch(typeof(Movement), "MoveCharacter")]
internal static class FlatMove
{
private static Movement body;
private const float BoostMultiplier = 3f;
internal static bool Flying => (Object)(object)body != (Object)null;
private static bool Prefix(Movement __instance, out float[] __state)
{
float[] saved = null;
bool result = Safe(delegate
{
Movement val = __instance;
if (CheatState.DoubleSpeedOn)
{
saved = new float[4] { val.speedWalking, val.speedAiming, val.speedCrouching, val.speedRunning };
val.speedWalking *= 2f;
val.speedAiming *= 2f;
val.speedCrouching *= 2f;
val.speedRunning *= 2f;
}
if (CheatState.NoclipOn)
{
Fly(val);
return false;
}
if ((Object)(object)body != (Object)null && ((Il2CppObjectBase)body).Pointer == ((Il2CppObjectBase)val).Pointer)
{
Land(val);
}
return true;
}, fallback: true);
__state = saved;
return result;
}
private static Exception Finalizer(Exception __exception, Movement __instance, float[] __state)
{
if (__state != null && (Object)(object)__instance != (Object)null)
{
__instance.speedWalking = __state[0];
__instance.speedAiming = __state[1];
__instance.speedCrouching = __state[2];
__instance.speedRunning = __state[3];
}
return __exception;
}
private static void Fly(Movement m)
{
//IL_0051: 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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: 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_0107: 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_0113: 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_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
body = m;
if ((Object)(object)m.controller != (Object)null)
{
((Collider)m.controller).enabled = false;
}
m.jumping = false;
bool isGrounded = (m.wasGrounded = true);
m.isGrounded = isGrounded;
CharacterBehaviour playerCharacter = m.playerCharacter;
Vector2 input = (((Object)(object)playerCharacter != (Object)null) ? playerCharacter.GetInputMovement() : Vector2.zero);
Camera val = (((Object)(object)playerCharacter != (Object)null) ? playerCharacter.GetCameraWorld() : null);
Transform look = (((Object)(object)val != (Object)null) ? ((Component)val).transform : ((Component)m).transform);
Keyboard current = Keyboard.current;
float num = ((current == null) ? 0f : ((((ButtonControl)current.spaceKey).isPressed ? 1f : 0f) - (current.ctrlKey.isPressed ? 1f : 0f)));
float num2 = m.speedRunning * ((current != null && current.shiftKey.isPressed) ? 3f : 1f);
Transform transform = ((Component)m).transform;
transform.position += Flight(look, input, num2, Time.deltaTime) + Vector3.up * num * num2 * Time.deltaTime;
}
internal static void LandIfFlying()
{
if ((Object)(object)body != (Object)null)
{
Land(body);
}
}
private static void Land(Movement m)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
body = null;
m.velocity = Vector3.zero;
Settle(((Component)m).transform);
if ((Object)(object)m.controller != (Object)null)
{
((Collider)m.controller).enabled = true;
}
}
}
[HarmonyPatch(typeof(Character), "OnTryJump")]
internal static class NoJump
{
private static bool Prefix()
{
return Safe(() => !FlatMove.Flying, fallback: true);
}
}
[HarmonyPatch(typeof(Movement), "Crouch")]
internal static class NoCrouch
{
private static bool Prefix()
{
return Safe(() => !FlatMove.Flying, fallback: true);
}
}
[HarmonyPatch(typeof(HVRHeadCollision), "checkHeadCollision")]
internal static class NoWallFade
{
private static readonly HashSet<IntPtr> cleared = new HashSet<IntPtr>();
private static bool Prefix(HVRHeadCollision __instance)
{
return Safe(delegate
{
if (!FlatMove.Flying && !VrTick.Flying)
{
cleared.Clear();
return true;
}
if (cleared.Add(((Il2CppObjectBase)__instance).Pointer))
{
if ((Object)(object)__instance.ScreenFade != (Object)null)
{
((MonoBehaviour)__instance.ScreenFade).StopAllCoroutines();
__instance.ScreenFade.UpdateFade(0f);
}
ANBGameLogic aNBmain = ANBStaticGameManager.ANBmain;
if ((Object)(object)aNBmain != (Object)null)
{
aNBmain.HeadInWall = false;
}
}
return false;
}, fallback: true);
}
}
[HarmonyPatch(typeof(ANBUnderMapTrigger), "OnTriggerEnter")]
internal static class UnderMap
{
private static bool Prefix(Collider activator)
{
return Safe(delegate
{
if (!CheatState.NoclipActive || (Object)(object)activator == (Object)null)
{
return true;
}
ANBGameLogic aNBmain = ANBStaticGameManager.ANBmain;
return (Object)(object)aNBmain == (Object)null || (Object)(object)aNBmain.PlayerTriggerActivator == (Object)null || ((Il2CppObjectBase)aNBmain.PlayerTriggerActivator).Pointer != ((Il2CppObjectBase)activator).Pointer;
}, fallback: true);
}
}
[HarmonyPatch(typeof(ANBFootsteps), "InflictDropPain")]
internal static class DropPain
{
private static bool Prefix()
{
return Safe(() => !CheatState.NoclipActive, fallback: true);
}
}
internal static readonly Type[] Patches = new Type[7]
{
typeof(VrTick),
typeof(FlatMove),
typeof(NoJump),
typeof(NoCrouch),
typeof(NoWallFade),
typeof(UnderMap),
typeof(DropPain)
};
private static bool failed;
private static T Safe<T>(Func<T> body, T fallback)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
if (failed)
{
return fallback;
}
try
{
return body();
}
catch (Exception ex)
{
failed = true;
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(64, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CheatsTabPlus movement cheats stopped, movement is stock again: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
logger.LogWarning(val);
}
try
{
VrTick.LandIfFlying();
}
catch (Exception)
{
}
try
{
FlatMove.LandIfFlying();
}
catch (Exception)
{
}
return fallback;
}
}
private static Vector3 Flight(Transform look, Vector2 input, float speed, float deltaTime)
{
//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_000c: 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_0017: 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_0022: 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_002e: Unknown result type (might be due to invalid IL or missing references)
return (look.forward * input.y + look.right * input.x) * speed * deltaTime;
}
private static void Settle(Transform body)
{
//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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//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_0067: Unknown result type (might be due to invalid IL or missing references)
ANBGameLogic aNBmain = ANBStaticGameManager.ANBmain;
if ((Object)(object)aNBmain != (Object)null && !Physics.Raycast(body.position + Vector3.up * 0.1f, Vector3.down, 1000f, -1, (QueryTriggerInteraction)1))
{
body.position = aNBmain.lastValidPlayerPosition;
}
foreach (ANBFootsteps item in Object.FindObjectsByType<ANBFootsteps>((FindObjectsSortMode)0))
{
if (item.isPlayer)
{
item.airborneStartY = body.position.y;
item.airborneTime = 0f;
}
}
}
}
[BepInPlugin("cheatstabplus.gunmancontracts", "CheatsTabPlus", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("GunmanContracts.exe")]
public sealed class Plugin : BasePlugin
{
internal static ManualLogSource Logger;
private const string Guid = "cheatstabplus.gunmancontracts";
public override void Load()
{
Logger = ((BasePlugin)this).Log;
Start();
}
public override bool Unload()
{
return false;
}
private static void Start()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Expected O, but got Unknown
Harmony val = new Harmony("cheatstabplus.gunmancontracts");
try
{
Type[] array;
if (IdgafManActive())
{
Logger.LogInfo((object)"CheatsTabPlus: IDGAFMan's patches are active, leaving cheat detection and Steam blocking to it.");
}
else
{
array = new Type[3]
{
typeof(CheatIntegrity.RunStart),
typeof(CheatIntegrity.RunReset),
typeof(CheatIntegrity.Check)
};
foreach (Type type in array)
{
val.PatchAll(type);
}
array = SteamBlock.Patches;
foreach (Type type2 in array)
{
val.PatchAll(type2);
}
Logger.LogInfo((object)"CheatsTabPlus: Steam leaderboard uploads blocked.");
}
val.PatchAll(typeof(CheatState.Reset));
array = WeaponCheats.Patches;
foreach (Type type3 in array)
{
val.PatchAll(type3);
}
array = MovementCheats.Patches;
foreach (Type type4 in array)
{
val.PatchAll(type4);
}
array = BigHeads.Patches;
foreach (Type type5 in array)
{
val.PatchAll(type5);
}
array = HealthCheats.Patches;
foreach (Type type6 in array)
{
val.PatchAll(type6);
}
val.PatchAll(typeof(CheatRows.Open));
val.PatchAll(typeof(CheatRows.FromSettings));
val.PatchAll(typeof(CheatRows.LockWatch));
Logger.LogInfo((object)"CheatsTabPlus enabled: No Recoil, No Spread, No Spread for Shotguns, Double Speed, Noclip, Big Heads, One Hit Enemies and OHKO added to the Cheats tab.");
}
catch (Exception ex)
{
val.UnpatchSelf();
ManualLogSource logger = Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(72, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CheatsTabPlus could not install every hook and removed the ones it had: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
logger.LogError(val2);
}
}
private static bool IdgafManActive()
{
IntPtr intPtr = IL2CPP.il2cpp_class_get_method_from_name(Il2CppClassPointerStore<ANBGameLogic>.NativeClassPtr, "CheckForCheats", 0);
if (intPtr == IntPtr.Zero)
{
return false;
}
IntPtr intPtr2 = Marshal.ReadIntPtr(intPtr);
if (intPtr2 != IntPtr.Zero && Marshal.ReadByte(intPtr2) == 49 && Marshal.ReadByte(intPtr2, 1) == 192)
{
return Marshal.ReadByte(intPtr2, 2) == 195;
}
return false;
}
}
internal static class SteamBlock
{
[HarmonyPatch(typeof(SteamLeaderboard))]
internal static class Board
{
[HarmonyPrefix]
[HarmonyPatch("SubmitScore")]
private static bool Submit()
{
return false;
}
[HarmonyPrefix]
[HarmonyPatch("ReplaceScore")]
private static bool Replace()
{
return false;
}
}
[HarmonyPatch(typeof(LeaderboardUI))]
internal static class Ui
{
[HarmonyPrefix]
[HarmonyPatch("SaveScoreViaButton")]
private static bool Button()
{
return false;
}
[HarmonyPrefix]
[HarmonyPatch("SaveScore")]
private static bool Direct()
{
return false;
}
}
internal static readonly Type[] Patches = new Type[2]
{
typeof(Board),
typeof(Ui)
};
}
internal static class WeaponCheats
{
[HarmonyPatch(typeof(HVRGunBase), "Recoil")]
internal static class GunRecoil
{
private static bool Prefix(HVRGunBase __instance)
{
return Safe(() => !IsPlayerGun(((Il2CppObjectBase)__instance).TryCast<ANBHVRGunBase>()) || !CheatState.NoRecoilOn, fallback: true);
}
}
[HarmonyPatch(typeof(RecoilMotion), "Tick")]
internal static class CameraKick
{
private static bool Prefix()
{
return Safe(() => !CheatState.NoRecoilCameraOn, fallback: true);
}
}
[HarmonyPatch(typeof(ANBHVRGunBase), "FPSshoot")]
internal static class FlatScreenShot
{
private static void Prefix(ANBHVRGunBase __instance, ref int shotsFired, out float[] __state)
{
int shots = shotsFired;
__state = Safe(delegate
{
if (!IsPlayerGun(__instance) || !CheatState.NoSpreadFor(__instance.isShotgun))
{
return (float[])null;
}
shots = 1;
return (!__instance.isShotgun) ? null : Centre(__instance);
}, null);
shotsFired = shots;
}
private static Exception Finalizer(Exception __exception, ANBHVRGunBase __instance, float[] __state)
{
Restore(__instance, __state);
return __exception;
}
}
[HarmonyPatch]
internal static class ShotgunPellets
{
private static readonly Type Coroutine = typeof(ANBHVRGunBase).GetNestedTypes(AccessTools.all).Single((Type type) => type.Name.StartsWith("_FireShotgun_d__", StringComparison.Ordinal));
private static readonly PropertyInfo This = AccessTools.Property(Coroutine, "__4__this");
private static ANBHVRGunBase Owner(object coroutine)
{
object? value = This.GetValue(coroutine);
return (ANBHVRGunBase)((value is ANBHVRGunBase) ? value : null);
}
private static MethodBase TargetMethod()
{
return AccessTools.Method(Coroutine, "MoveNext", (Type[])null, (Type[])null);
}
private static void Prefix(object __instance, out float[] __state)
{
__state = Safe(delegate
{
ANBHVRGunBase gun = Owner(__instance);
return (!IsPlayerGun(gun) || !CheatState.NoSpreadFor(shotgun: true)) ? null : Centre(gun);
}, null);
}
private static Exception Finalizer(Exception __exception, object __instance, float[] __state)
{
if (__state != null)
{
Restore(Owner(__instance), __state);
}
return __exception;
}
}
internal static readonly Type[] Patches = new Type[4]
{
typeof(GunRecoil),
typeof(CameraKick),
typeof(FlatScreenShot),
typeof(ShotgunPellets)
};
private static bool failed;
private static bool IsPlayerGun(ANBHVRGunBase gun)
{
if ((Object)(object)gun != (Object)null && !gun.EnemyGun)
{
if (!gun.gunbaseHolding)
{
return gun.FPSGun;
}
return true;
}
return false;
}
private static T Safe<T>(Func<T> body, T fallback)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
if (failed)
{
return fallback;
}
try
{
return body();
}
catch (Exception ex)
{
failed = true;
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(59, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CheatsTabPlus weapon cheats stopped, guns are stock again: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
logger.LogWarning(val);
}
return fallback;
}
}
private static float[] Centre(ANBHVRGunBase gun)
{
float[] result = new float[2] { gun.ShotRadius, gun.ShotExtraRadius };
gun.ShotRadius = 0f;
gun.ShotExtraRadius = 0f;
return result;
}
private static void Restore(ANBHVRGunBase gun, float[] saved)
{
if (!((Object)(object)gun == (Object)null) && saved != null)
{
gun.ShotRadius = saved[0];
gun.ShotExtraRadius = saved[1];
}
}
}