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 ChainsawLegs;
public class LegsBeamIdentifier : MonoBehaviour
{
}
[BepInPlugin("plonk.chainsawlegs", "ChainsawLegs", "1.0.0")]
public class WeaponMakerScript : BaseUnityPlugin
{
[HarmonyPatch]
public class Patches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(ContinuousBeam), "Update")]
public static bool UpdatePatch(ContinuousBeam __instance)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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)
//IL_0075: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: 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_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_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_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_057d: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: 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_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Invalid comparison between Unknown and I4
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_0462: Unknown result type (might be due to invalid IL or missing references)
//IL_0469: Invalid comparison between Unknown and I4
//IL_044d: Unknown result type (might be due to invalid IL or missing references)
//IL_043f: Unknown result type (might be due to invalid IL or missing references)
//IL_0490: Unknown result type (might be due to invalid IL or missing references)
//IL_0497: Unknown result type (might be due to invalid IL or missing references)
//IL_049c: Unknown result type (might be due to invalid IL or missing references)
//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
//IL_04af: Unknown result type (might be due to invalid IL or missing references)
//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0452: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<LegsBeamIdentifier>()))
{
Vector3 zero = Vector3.zero;
RaycastHit val = default(RaycastHit);
zero = ((!Physics.Raycast(((Component)__instance).transform.position, ((Component)__instance).transform.forward, ref val, float.PositiveInfinity, LayerMask.op_Implicit(__instance.environmentMask))) ? (((Component)__instance).transform.position + ((Component)__instance).transform.forward * 999f) : ((RaycastHit)(ref val)).point);
__instance.lr.SetPosition(0, ((Component)__instance).transform.position);
__instance.lr.SetPosition(1, zero);
if (Object.op_Implicit((Object)(object)__instance.impactEffect))
{
__instance.impactEffect.transform.position = ((Component)__instance).transform.position + ((Component)__instance).transform.forward * Mathf.Clamp(Vector3.Distance(((Component)__instance).transform.position, zero), 0f, 3.18f);
}
RaycastHit[] array = Physics.SphereCastAll(((Component)__instance).transform.position + ((Component)__instance).transform.forward * __instance.beamWidth, __instance.beamWidth, ((Component)__instance).transform.forward, Mathf.Clamp(Vector3.Distance(((Component)__instance).transform.position, zero), 0f, 3.18f) - __instance.beamWidth, LayerMask.op_Implicit(__instance.hitMask));
if (array != null && array.Length != 0)
{
Bleeder val5 = default(Bleeder);
for (int i = 0; i < array.Length; i++)
{
if (__instance.canHitPlayer && __instance.playerCooldown <= 0f && ((Component)((RaycastHit)(ref array[i])).collider).gameObject.CompareTag("Player"))
{
__instance.playerCooldown = 0.1f;
if (!Physics.Raycast(((Component)__instance).transform.position, ((RaycastHit)(ref array[i])).point - ((Component)__instance).transform.position, ((RaycastHit)(ref array[i])).distance, LayerMask.op_Implicit(__instance.environmentMask)))
{
MonoSingleton<NewMovement>.Instance.GetHurt(Mathf.RoundToInt(__instance.damage), true, 1f, false, false, 1f, true);
}
}
else if ((((Component)((RaycastHit)(ref array[i])).transform).gameObject.layer == 10 || ((Component)((RaycastHit)(ref array[i])).transform).gameObject.layer == 11) && __instance.canHitEnemy)
{
EnemyIdentifierIdentifier component = ((Component)((RaycastHit)(ref array[i])).transform).GetComponent<EnemyIdentifierIdentifier>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.eid) && (!__instance.enemy || (component.eid.enemyType != __instance.safeEnemyType && ((int)component.eid.enemyType == 21 || !EnemyIdentifier.CheckHurtException(__instance.safeEnemyType, component.eid.enemyType, __instance.target)))))
{
EnemyIdentifier eid = component.eid;
bool flag = false;
if (__instance.hitEnemies.Contains(eid))
{
flag = true;
}
if (!flag || __instance.enemyCooldowns[__instance.hitEnemies.IndexOf(eid)] <= 0f)
{
if (!flag)
{
__instance.hitEnemies.Add(eid);
__instance.enemyCooldowns.Add(0.05f);
}
else
{
__instance.enemyCooldowns[__instance.hitEnemies.IndexOf(eid)] = 0.05f;
}
if (eid.health < __instance.damage / 10f && !eid.dead)
{
MonoSingleton<StyleHUD>.instance.AddPoints(25, "ultrakill.halfoff", (GameObject)null, eid, 1, "", "");
Object.Instantiate<GameObject>(WeaponMakerScript.FetchFromBundle<GameObject>("EnemyDeathParticle.prefab", autofill: true), Object.op_Implicit((Object)(object)eid.overrideCenter) ? eid.overrideCenter.position : ((Component)eid).transform.position, Quaternion.identity);
}
eid.hitter = (((int)eid.enemyType == 21) ? "punch" : "plonksaw");
GameObject gameObject = ((Component)((RaycastHit)(ref array[i])).transform).gameObject;
Vector3 val2 = zero - ((Component)__instance).transform.position;
eid.DeliverDamage(gameObject, ((Vector3)(ref val2)).normalized * 1000f, ((RaycastHit)(ref array[i])).point, __instance.damage / 10f, true, 0f, (GameObject)null, false, false);
}
}
}
Breakable val3 = null;
if (((Component)((RaycastHit)(ref array[i])).transform).TryGetComponent<Breakable>(ref val3) && Object.op_Implicit((Object)(object)val3) && val3.weak)
{
val3.Break();
}
Glass val4 = null;
if (((Component)((RaycastHit)(ref array[i])).transform).TryGetComponent<Glass>(ref val4) && Object.op_Implicit((Object)(object)val4))
{
val4.Shatter();
}
if (((Component)((RaycastHit)(ref array[i])).transform).gameObject.TryGetComponent<Bleeder>(ref val5))
{
val5.GetHit(((RaycastHit)(ref array[i])).point, (GoreType)2, false);
}
}
}
if (__instance.playerCooldown > 0f)
{
__instance.playerCooldown = Mathf.MoveTowards(__instance.playerCooldown, 0f, Time.deltaTime);
}
if (__instance.enemyCooldowns.Count > 0)
{
for (int j = 0; j < __instance.enemyCooldowns.Count; j++)
{
__instance.enemyCooldowns[j] = Mathf.MoveTowards(__instance.enemyCooldowns[j], 0f, Time.deltaTime);
}
}
return false;
}
return true;
}
}
public static GameObject legs;
public static AudioSource legsaud;
public static ContinuousBeam legshz;
public static AssetBundle tcbundle;
private static bool candoshit;
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/chainsawlegs/" + 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()
{
Log("kaboom (chainsawlegs loaded)");
if ((Object)(object)tcbundle == (Object)null)
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
tcbundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "chainsawlegs"));
Log("Got bundle " + (object)tcbundle);
for (int i = 0; i < tcbundle.GetAllAssetNames().Length; i++)
{
Log(tcbundle.GetAllAssetNames()[i].ToString());
}
}
}
public void Start()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("plonk.chainsawlegs");
val.PatchAll();
}
public void Update()
{
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
if (!candoshit && SceneHelper.CurrentScene == "Main Menu")
{
if ((Object)(object)tcbundle != (Object)null)
{
candoshit = true;
}
else
{
SendHudMessage("Chainsaw Legs mod failed to load.\r\n<color=green>The asset bundle (filename \"chainsawlegs\", 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"))
{
return;
}
NewMovement instance = MonoSingleton<NewMovement>.instance;
if ((Object)(object)legs == (Object)null)
{
legs = Object.Instantiate<GameObject>(WeaponMakerScript.FetchFromBundle<GameObject>("legs.prefab", autofill: true), ((Component)instance).transform.position, ((Component)instance).transform.rotation, ((Component)instance).transform);
legsaud = ((Component)legs.transform.Find("v1_combined")).GetComponentInChildren<AudioSource>();
legshz = legs.GetComponentInChildren<ContinuousBeam>();
((Component)legshz).gameObject.AddComponent<LegsBeamIdentifier>();
Log("Made Legs");
}
else
{
legs.SetActive(instance.sliding);
legs.transform.LookAt(legs.transform.position + new Vector3(instance.rb.velocity.x, 0f, instance.rb.velocity.z));
if (legs.activeSelf)
{
legsaud.pitch = Mathf.MoveTowards(legsaud.pitch, 1f, Time.deltaTime * ((1f + legsaud.pitch) * 1f));
}
else
{
legsaud.pitch = 0f;
}
}
}
}