Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of HitIt v1.1.0
BepInEx/plugins/HitIt/HitIt.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using HitIt.Components; using HitIt.Patches; 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("HitIt")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HitIt")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("f15a176f-89d1-4764-82b5-6019d31d17d9")] [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 HitIt { [BepInPlugin("JacobG5.HitIt", "HitIt", "1.1.0")] public class HitItCore : BaseUnityPlugin { private const string modGUID = "JacobG5.HitIt"; private const string modName = "HitIt"; private const string modVersion = "1.1.0"; private readonly Harmony harmony = new Harmony("JacobG5.HitIt"); public static HitItCore Instance; public int defaultTreeHP; internal ManualLogSource mls; public static ConfigEntry<int> treeHealth; public static ConfigEntry<bool> shouldShotgunDamageCruiser; public static ConfigEntry<bool> enableCruiserKnockback; public static ConfigEntry<bool> enableCruiserBulletKnockback; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } treeHealth = ((BaseUnityPlugin)this).Config.Bind<int>("Terrain", "treeHealth", 8, "How many hits with a shovel it takes to destroy a tree. Set to -1 to disable."); shouldShotgunDamageCruiser = ((BaseUnityPlugin)this).Config.Bind<bool>("Cruiser", "shouldShotgunDamageCruiser", true, "If cruisers should take damage from shotgun bullets."); enableCruiserKnockback = ((BaseUnityPlugin)this).Config.Bind<bool>("Cruiser", "enableCruiserKnockback", true, "Makes it so when cruisers take damage from weapons they get pushed back. It's a bit much but it's also funny."); enableCruiserBulletKnockback = ((BaseUnityPlugin)this).Config.Bind<bool>("Cruiser", "enableCruiserBulletKnockback", true, "If cruisers should take knockback from bullets from the shotgun."); mls = Logger.CreateLogSource("JacobG5.HitIt"); defaultTreeHP = treeHealth.Value; harmony.PatchAll(typeof(VehicleControllerPatch)); harmony.PatchAll(typeof(TerrainObstacleTriggerPatch)); harmony.PatchAll(typeof(ShotgunItemPatch)); } } } namespace HitIt.Patches { [HarmonyPatch(typeof(ShotgunItem))] internal class ShotgunItemPatch { [HarmonyPatch("ShootGun")] [HarmonyPrefix] public static void patchShootGun(Vector3 shotgunPosition, Vector3 shotgunForward, ShotgunItem __instance) { //IL_001d: 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) //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_00c4: 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_0103: 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) if (!HitItCore.shouldShotgunDamageCruiser.Value) { return; } RaycastHit[] array = (RaycastHit[])(object)new RaycastHit[10]; Ray val = default(Ray); ((Ray)(ref val))..ctor(shotgunPosition - shotgunForward * 10f, shotgunForward); int num = Physics.SphereCastNonAlloc(val, 5f, array, 15f, StartOfRound.Instance.collidersAndRoomMaskAndDefault); VehicleController val2 = default(VehicleController); RaycastHit val3 = default(RaycastHit); CruiserDamageController cruiserDamageController = default(CruiserDamageController); for (int i = 0; i < num; i++) { if ((!((Object)(object)((GrabbableObject)__instance).playerHeldBy != (Object)null) || !((Component)((RaycastHit)(ref array[i])).transform).TryGetComponent<VehicleController>(ref val2) || (!((Object)(object)val2.currentDriver == (Object)(object)((GrabbableObject)__instance).playerHeldBy) && !((Object)(object)val2.currentPassenger == (Object)(object)((GrabbableObject)__instance).playerHeldBy))) && !Physics.Linecast(shotgunPosition, ((RaycastHit)(ref array[i])).point, ref val3, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && ((Component)((RaycastHit)(ref array[i])).collider).TryGetComponent<CruiserDamageController>(ref cruiserDamageController)) { float num2 = Vector3.Distance(shotgunPosition, ((RaycastHit)(ref array[i])).point); int force = ((num2 < 3.7f) ? 5 : ((!(num2 < 6f)) ? 2 : 3)); cruiserDamageController.BulletHit(force, shotgunForward, ((GrabbableObject)__instance).playerHeldBy, playHitSFX: true); } } } } [HarmonyPatch(typeof(TerrainObstacleTrigger))] internal class TerrainObstacleTriggerPatch { [HarmonyPatch("OnTriggerEnter")] [HarmonyPrefix] public static void patchTrigger(TerrainObstacleTrigger __instance) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)__instance).transform.Find("TreeDamageController") == (Object)null) { int defaultTreeHP = HitItCore.Instance.defaultTreeHP; if (defaultTreeHP >= 0) { HitItCore.Instance.mls.LogInfo((object)"Creating Tree Damage Controller"); GameObject val = new GameObject("TreeDamageController"); val.transform.parent = ((Component)__instance).transform; val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.layer = 21; CapsuleCollider val2 = val.AddComponent<CapsuleCollider>(); val2.height = 8f; val2.direction = 1; val2.radius = 0.55f; TreeDamageController treeDamageController = val.AddComponent<TreeDamageController>(); treeDamageController.HP = defaultTreeHP; } } } } [HarmonyPatch(typeof(VehicleController))] internal class VehicleControllerPatch { [HarmonyPatch("Start")] [HarmonyPrefix] public static void patchStart(VehicleController __instance) { CruiserDamageController cruiserDamageController = ((Component)__instance).gameObject.AddComponent<CruiserDamageController>(); cruiserDamageController.connect(__instance); } [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(VehicleController), "DealPermanentDamage")] public static void DealPermanentDamage(object instance, int damageAmount, Vector3 damagePosition = default(Vector3)) { throw new NotImplementedException("It's a stub"); } } } namespace HitIt.Components { internal class TreeDamageController : MonoBehaviour, IHittable { public int HP = 8; public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { //IL_0040: 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) //IL_0064: 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) //IL_009f: Unknown result type (might be due to invalid IL or missing references) HP -= force; ManualLogSource mls = HitItCore.Instance.mls; string[] obj = new string[6] { "Hit: ", ((Object)this).name, " - pos: ", null, null, null }; Vector3 position = ((Component)this).transform.position; obj[3] = ((object)(Vector3)(ref position)).ToString(); obj[4] = " - rot: "; Quaternion rotation = ((Component)this).transform.rotation; obj[5] = ((object)(Quaternion)(ref rotation)).ToString(); mls.LogInfo((object)string.Concat(obj)); if (HP <= 0) { RoundManager.Instance.DestroyTreeOnLocalClient(((Component)this).transform.position); } return true; } private void Start() { HitItCore.Instance.mls.LogInfo((object)((Object)this).name); } } internal class CruiserDamageController : MonoBehaviour, IHittable { private VehicleController vehicle; public void connect(VehicleController cruiser) { vehicle = cruiser; } public bool BulletHit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { //IL_0003: 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_001e: 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) return DamageWithKnockback(force, hitDirection, HitItCore.enableCruiserBulletKnockback.Value, ((Component)vehicle).transform.position - hitDirection * 5f, playerWhoHit, playHitSFX, hitID); } public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { //IL_000b: 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_0010: Unknown result type (might be due to invalid IL or missing references) bool flag = (Object)(object)playerWhoHit != (Object)null; return DamageWithKnockback(force, hitDirection, flag, flag ? ((Component)playerWhoHit).transform.position : Vector3.zero, playerWhoHit, playHitSFX, hitID); } public bool DamageWithKnockback(int force, Vector3 hitDirection, bool doKnockback, Vector3 knockbackPos, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0041: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vehicle != (Object)null) { VehicleControllerPatch.DealPermanentDamage(vehicle, force); if (HitItCore.enableCruiserKnockback.Value && doKnockback) { vehicle.PushTruckServerRpc(knockbackPos, hitDirection); } return true; } return false; } } }