using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.AddressableAssets;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ThundergunRevised")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ThundergunRevised")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5711e2a0-d5a7-4ddf-b8d4-00f355fe9397")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en-FI")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Scrapheads;
internal class BeamID : MonoBehaviour
{
}
[BepInPlugin("plonk.excavator", "Excavator", "1.0.0")]
public class MainCode : BaseUnityPlugin
{
[HarmonyPatch]
public class Patches
{
private static bool injectedEndless;
private static bool injectedSpawnmenu;
private static bool injectedTerminal;
[HarmonyPostfix]
[HarmonyPatch(typeof(EndlessGrid), "Start")]
public static void OnStart(EndlessGrid __instance)
{
PrefabDatabase prefabs = __instance.prefabs;
if (isExcavator && (Object)(object)MainCode.FetchFromBundle<EndlessEnemy>("assets/ultrakill addressables/secret/sadrobot/ExcavatorEndless.asset", autofill: false) != (Object)null)
{
bool flag = true;
EndlessEnemy[] uncommonEnemies = prefabs.uncommonEnemies;
foreach (EndlessEnemy val in uncommonEnemies)
{
if ((Object)(object)val == (Object)(object)MainCode.FetchFromBundle<EndlessEnemy>("assets/ultrakill addressables/secret/sadrobot/ExcavatorEndless.asset", autofill: false))
{
Log("Excavator already in CG!");
flag = false;
}
}
if (flag)
{
EndlessEnemy[] uncommonEnemies2 = prefabs.uncommonEnemies;
EndlessEnemy[] array = (EndlessEnemy[])(object)new EndlessEnemy[uncommonEnemies2.Length + 1];
Array.Copy(uncommonEnemies2, array, uncommonEnemies2.Length);
array[^1] = MainCode.FetchFromBundle<EndlessEnemy>("assets/ultrakill addressables/secret/sadrobot/ExcavatorEndless.asset", autofill: false);
prefabs.uncommonEnemies = array;
Log("Added Excavator to CG!");
}
}
if (!injectedEndless)
{
injectedEndless = true;
if (!isExcavator)
{
EndlessEnemy[] projectileEnemies = prefabs.projectileEnemies;
EndlessEnemy[] array2 = (EndlessEnemy[])(object)new EndlessEnemy[projectileEnemies.Length + 2];
Array.Copy(projectileEnemies, array2, projectileEnemies.Length);
array2[^2] = MainCode.FetchFromBundle<EndlessEnemy>("ArmedSentryData.asset", autofill: true);
array2[^1] = MainCode.FetchFromBundle<EndlessEnemy>("MannequinData.asset", autofill: true);
prefabs.projectileEnemies = array2;
}
Debug.Log((object)("injected scrapheads: " + ((object)MainCode.FetchFromBundle<EndlessEnemy>("ArmedSentryData.asset", autofill: true).prefab)?.ToString() + ", " + ((object)MainCode.FetchFromBundle<EndlessEnemy>("HazardData.asset", autofill: true).prefab)?.ToString() + ", " + ((object)MainCode.FetchFromBundle<EndlessEnemy>("FilthmachineData.asset", autofill: true).prefab)?.ToString() + ", " + (object)MainCode.FetchFromBundle<EndlessEnemy>("MannequinData.asset", autofill: true).prefab));
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SpawnMenu), "Awake")]
public static void InjectSpawnmenu(ref SpawnableObjectsDatabase ___objects)
{
if (!injectedSpawnmenu)
{
injectedSpawnmenu = true;
if (!isExcavator)
{
SpawnableObject[] enemies = ___objects.enemies;
SpawnableObject[] array = (SpawnableObject[])(object)new SpawnableObject[enemies.Length + 3];
Array.Copy(enemies, array, enemies.Length);
array[^3] = MainCode.FetchFromBundle<SpawnableObject>("ArmedsentrySpawnable.asset", autofill: true);
array[^1] = MainCode.FetchFromBundle<SpawnableObject>("SentryquinSpawnable.asset", autofill: true);
___objects.enemies = array;
}
}
bool flag = true;
SpawnableObject[] enemies2 = ___objects.enemies;
SpawnableObject[] array2 = enemies2;
foreach (SpawnableObject val in array2)
{
if ((Object)(object)val == (Object)(object)MainCode.FetchFromBundle<SpawnableObject>("assets/ultrakill addressables/secret/sadrobot/ExcavatorSpawnable.asset", autofill: false))
{
flag = false;
}
}
if (!(isExcavator && flag))
{
return;
}
SpawnableObject[] array3 = (SpawnableObject[])(object)new SpawnableObject[enemies2.Length + 1];
for (int j = 0; j < array3.Length; j++)
{
if (j < 16)
{
array3[j] = enemies2[j];
}
if (j == 16)
{
array3[j] = MainCode.FetchFromBundle<SpawnableObject>("assets/ultrakill addressables/secret/sadrobot/ExcavatorSpawnable.asset", autofill: false);
}
if (j > 16)
{
array3[j] = enemies2[j - 1];
}
}
___objects.enemies = array3;
Log("Injected Excavator into Spawner-arm!");
}
[HarmonyPrefix]
[HarmonyPatch(typeof(EnemyInfoPage), "Start")]
public static void UpdateInfoThingy(EnemyInfoPage __instance)
{
SpawnableObjectsDatabase objects = __instance.objects;
bool flag = true;
SpawnableObject[] enemies = objects.enemies;
foreach (SpawnableObject val in enemies)
{
if ((Object)(object)val == (Object)(object)MainCode.FetchFromBundle<SpawnableObject>("assets/ultrakill addressables/secret/sadrobot/ExcavatorSpawnable.asset", autofill: false))
{
flag = false;
}
}
if (!(isExcavator && flag))
{
return;
}
SpawnableObject[] array = (SpawnableObject[])(object)new SpawnableObject[objects.enemies.Length + 1];
for (int j = 0; j < array.Length; j++)
{
if (j < 17)
{
array[j] = objects.enemies[j];
}
if (j == 17)
{
array[j] = MainCode.FetchFromBundle<SpawnableObject>("assets/ultrakill addressables/secret/sadrobot/ExcavatorSpawnable.asset", autofill: false);
}
if (j > 17)
{
array[j] = objects.enemies[j - 1];
}
}
objects.enemies = array;
Log("Injected Excavator into Terminal!");
}
}
public static AssetBundle tcbundle;
public static GameObject beam;
public static BeamgunBeam bgbeam;
private static bool isExcavator = true;
private static bool candoshit;
public static bool ForceNoIgnore;
private static bool canswitchstate = true;
public static void SendHudMessage(string msg, int delay, bool silent)
{
MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage(msg, "", "", delay, silent);
}
public static Type Fetch<Type>(string name)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return Addressables.LoadAssetAsync<Type>((object)name).WaitForCompletion();
}
public static Type FetchFromBundle<Type>(string name, bool autofill = false) where Type : Object
{
if (!autofill)
{
return tcbundle.LoadAsset<Type>(name);
}
return tcbundle.LoadAsset<Type>("assets/formods/scrapheads/" + name);
}
public static void SetLayerRecursive(GameObject gobject, string layername)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
gobject.layer = LayerMask.NameToLayer(layername);
foreach (Transform item in gobject.transform)
{
Transform val = item;
((Component)val).gameObject.layer = LayerMask.NameToLayer(layername);
Transform componentInChildren = ((Component)val).GetComponentInChildren<Transform>();
if ((Object)(object)componentInChildren != (Object)null)
{
SetLayerRecursive(((Component)val).gameObject, layername);
}
}
}
public Vector3 Shake(Vector3 originpos, Vector3 pos, float shakeamt)
{
//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_0007: Unknown result type (might be due to invalid IL or missing references)
//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_002a: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: 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_009c: 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)
Vector3 val = Vector3.zero;
val = pos + new Vector3(Random.Range(0f - shakeamt, shakeamt), Random.Range(0f - shakeamt, shakeamt), Random.Range(0f - shakeamt, shakeamt));
((Vector3)(ref val))..ctor(Mathf.Clamp(val.x, originpos.x - 0.01f, originpos.x + 0.01f), Mathf.Clamp(val.y, originpos.y - 0.01f, originpos.y + 0.01f), Mathf.Clamp(val.z, originpos.z - 0.01f, originpos.z + 0.01f));
return val;
}
public static void Log(string log, int type = 1)
{
switch (type)
{
case 1:
Debug.Log((object)log);
break;
case 2:
Debug.LogWarning((object)log);
break;
case 3:
Debug.LogError((object)log);
break;
}
}
public void Awake()
{
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
if ((Object)(object)tcbundle == (Object)null)
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (isExcavator)
{
tcbundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "excavator"));
}
else
{
tcbundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "scrapheads"));
}
Log("Got bundle " + (object)tcbundle);
for (int i = 0; i < tcbundle.GetAllAssetNames().Length; i++)
{
Log(tcbundle.GetAllAssetNames()[i].ToString());
}
}
Log("kaboom (" + (isExcavator ? "excavator" : "scrapheads") + " loaded)");
}
public void Start()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
Harmony val = new Harmony("plonk." + (isExcavator ? "excavator" : "scrapheads"));
val.PatchAll();
}
public void Update()
{
if (!candoshit && SceneHelper.CurrentScene == "Main Menu")
{
if ((Object)(object)tcbundle != (Object)null)
{
candoshit = true;
}
else
{
SendHudMessage((isExcavator ? "Excavator" : "Scrapheads") + "mod failed to load.\r\n<color=green>The asset bundle (filename \"" + (isExcavator ? "excavator" : "scrapheads") + "\", no extensions) is missing or in the wrong place. please place it where the mod's .dll is located.</color>", 0, silent: true);
}
}
if (candoshit && !(SceneHelper.CurrentScene != "Main Menu"))
{
}
}
}