#define DEBUG
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using AdminMode.Patches;
using BepInEx;
using BepInEx.Logging;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AdminMode")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AdminMode")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("deccf9ef-8561-4a1f-bcce-851b4506848f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AdminMode
{
[BepInPlugin("AdminMode", "Testing AdminMode", "1.0.0")]
public class AdminBase : BaseUnityPlugin
{
private const string modGUID = "AdminMode";
private const string modName = "Testing AdminMode";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("AdminMode");
private static AdminBase Instance;
internal ManualLogSource mls;
public static Texture2D mainLogo;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("AdminMode");
mls.LogInfo((object)"This mod has started");
harmony.PatchAll(typeof(AdminBase));
harmony.PatchAll(typeof(TerminalInterfacePatch));
harmony.PatchAll(typeof(PlayerControllerPatch));
harmony.PatchAll(typeof(TimeOfDayPatch));
harmony.PatchAll(typeof(KillPlayerPatch));
harmony.PatchAll(typeof(EnemyPatch));
harmony.PatchAll(typeof(HUDManagerPatch));
harmony.PatchAll(typeof(GrabbableObjectPatch));
harmony.PatchAll(typeof(DoorPatch));
mls.LogInfo((object)"Mod completed loading patches");
}
}
}
namespace AdminMode.Patches
{
[HarmonyPatch(typeof(GrabbableObject))]
internal class GrabbableObjectPatch
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void InfiniteBattery(ref Battery ___insertedBattery)
{
if (TerminalInterfacePatch.changeText)
{
___insertedBattery.charge = 1f;
}
}
}
[HarmonyPatch(typeof(DungeonGenerator))]
internal class DoorPatch
{
[HarmonyPatch("LockDoorway")]
[HarmonyPrefix]
private static bool UnlockAllDoors()
{
return false;
}
}
[HarmonyPatch(typeof(EnemyAI))]
internal class EnemyPatch
{
[HarmonyPatch("PlayerIsTargetable")]
[HarmonyPrefix]
private static bool DontTargetPlayer(ref bool __result)
{
__result = false;
return false;
}
[HarmonyPatch("HitEnemy")]
[HarmonyPostfix]
private static void InstantKill(ref int ___enemyHP)
{
Debug.WriteLine("Player killed enemy using ADMIN MODE");
___enemyHP = 0;
}
}
[HarmonyPatch(typeof(KillLocalPlayer))]
internal class KillPlayerPatch
{
[HarmonyPatch("KillPlayer")]
[HarmonyPrefix]
private static bool DontKillPlayer()
{
return false;
}
}
[HarmonyPatch(typeof(HUDManager))]
internal class HUDManagerPatch
{
[HarmonyPrefix]
[HarmonyPatch("MeetsScanNodeRequirements")]
private static bool InfiniteScan(ref bool __result)
{
__result = true;
return false;
}
}
[HarmonyPatch(typeof(TimeOfDay))]
internal class TimeOfDayPatch
{
[HarmonyPatch("SetBuyingRateForDay")]
[HarmonyPostfix]
private static void BuyingRate()
{
if (TerminalInterfacePatch.changeText)
{
StartOfRound.Instance.companyBuyingRate = 1f;
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void InfiniteUpdatePatch(ref float ___sprintMeter, ref bool ___isPlayerDead, ref float ___drunkness, ref bool ___jetpackControls, ref bool ___isSinking, ref Light ___helmetLight, ref Light[] ___allHelmetLights, ref Light ___nightVision, ref float ___insanityLevel, ref float ___sinkingValue)
{
if (TerminalInterfacePatch.changeText)
{
___sprintMeter = 1f;
___isPlayerDead = false;
___drunkness = 0f;
___isSinking = false;
((Behaviour)___allHelmetLights[0]).enabled = true;
___helmetLight = ___allHelmetLights[1];
((Behaviour)___nightVision).enabled = true;
___insanityLevel = 0f;
___sinkingValue = 0f;
}
}
[HarmonyPatch("SetHoverTipAndCurrentInteractTrigger")]
[HarmonyPrefix]
private static void HandofGodPatch(ref TextMeshProUGUI ___cursorTip, ref Camera ___gameplayCamera, ref Ray ___interactRay, ref RaycastHit ___hit, ref float ___grabDistance, ref int ___interactableObjectsMask)
{
//IL_0009: 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_001a: 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_0025: Unknown result type (might be due to invalid IL or missing references)
___interactRay = new Ray(((Component)___gameplayCamera).transform.position, ((Component)___gameplayCamera).transform.forward);
if (Physics.Raycast(___interactRay, ref ___hit, ___grabDistance, ___interactableObjectsMask) && ((Component)((RaycastHit)(ref ___hit)).collider).gameObject.layer != 8 && (((Component)((RaycastHit)(ref ___hit)).collider).gameObject.layer == 19 || ((Component)((RaycastHit)(ref ___hit)).collider).gameObject.layer == 23))
{
Debug.Log((object)((Object)((RaycastHit)(ref ___hit)).collider).name);
}
}
[HarmonyPatch("SetFaceUnderwaterFilters")]
[HarmonyPostfix]
private static void DrownPatch()
{
if (TerminalInterfacePatch.changeText)
{
StartOfRound.Instance.drowningTimer = 1f;
}
}
[HarmonyPatch("DamagePlayer")]
[HarmonyPrefix]
private static void InfiniteHealthPatch(ref int ___health, ref int damageNumber)
{
if (TerminalInterfacePatch.changeText)
{
___health = 100;
damageNumber = 0;
}
}
[HarmonyPatch("KillPlayer")]
[HarmonyPrefix]
private static bool StopDeathPatch(ref bool ___isPlayerDead)
{
if (TerminalInterfacePatch.changeText)
{
Debug.Log((object)"Killed Player?!");
___isPlayerDead = false;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Terminal))]
internal class TerminalInterfacePatch
{
public static bool changeText;
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void AddMenu(ref TextMeshProUGUI ___topRightText, ref int ___groupCredits)
{
if (changeText)
{
TextMeshProUGUI obj = ___topRightText;
((TMP_Text)obj).text = ((TMP_Text)obj).text + "ADMIN";
___groupCredits = 999;
}
else
{
TextMeshProUGUI obj2 = ___topRightText;
((TMP_Text)obj2).text = ((TMP_Text)obj2).text + "USER";
}
}
[HarmonyPatch("LoadNewNodeIfAffordable")]
[HarmonyPrefix]
private static void AlwaysPurchase(ref int ___groupCredits, ref int ___totalCostOfItems)
{
if (changeText)
{
___groupCredits = Mathf.Clamp(___groupCredits + ___totalCostOfItems, 0, 10000000);
}
}
[HarmonyPatch("ParsePlayerSentence")]
[HarmonyPrefix]
private static bool DisplayCommands(ref int ___textAdded, ref TMP_InputField ___screenText, ref TerminalNodesList ___terminalNodes, ref TerminalNode __result)
{
Console.WriteLine("-------------------------------");
TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
TerminalKeyword val2 = ScriptableObject.CreateInstance<TerminalKeyword>();
val.clearPreviousText = true;
val.displayText = "ADMIN MODE ACTIVATED:PLACEHOLDER TEXT BELOW --IGNORE\n----------\nCommands:\nQUOTA: Set your quoate amount\nSCRAP: Set the amount of scrap you have\nDeadLine:Set a new deadline\n";
val.terminalEvent = "admin";
((Object)val).name = "Admin";
val2.word = "admin";
___terminalNodes.terminalNodes.Add(val);
CollectionExtensions.AddToArray<TerminalKeyword>(___terminalNodes.allKeywords, val2);
___terminalNodes.allKeywords.Append(val2);
___terminalNodes.terminalNodes.Append(val);
___terminalNodes.specialNodes.Add(val);
TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
val3.clearPreviousText = true;
val3.displayText = "ADMIN MODE ALREADY ENABLED";
val3.terminalEvent = "admin";
for (int i = 0; i < ___terminalNodes.allKeywords.Length; i++)
{
Console.WriteLine("Keyword: " + i + " " + ___terminalNodes.allKeywords[i].word);
}
for (int j = 0; j < ___terminalNodes.specialNodes.Count; j++)
{
Console.WriteLine("Special Node:" + j + " " + ((Object)___terminalNodes.specialNodes[j]).name);
}
string text = ___screenText.text.Substring(___screenText.text.Length - ___textAdded);
if (text == "admin" && !changeText)
{
changeText = true;
Console.WriteLine("Admin mode has been activated!");
Console.WriteLine("TERMINAL EVENT:");
Console.WriteLine(___terminalNodes.specialNodes[13].terminalEvent.ToString());
Console.WriteLine("TERMINAL TEXT:");
Console.WriteLine(___terminalNodes.specialNodes[13].displayText);
Console.WriteLine("TERMINAL OPTIONS:");
Console.WriteLine(___terminalNodes.specialNodes[13].terminalOptions.ToString());
__result = ___terminalNodes.specialNodes[24];
return false;
}
if (text == "user")
{
Console.WriteLine("Admin mode has been de-activated!");
changeText = false;
}
Console.WriteLine("-------------------------------");
return true;
}
}
}