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 UncannyJackBlack v1.0.1
UncannyJackBlack.dll
Decompiled 2 years agousing System; using System.Collections; using System.Diagnostics; using System.IO; using System.Linq; 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 LethalLib.Modules; using UncannyJackBlack.src.main.c_sharp.net.alien.UncannyJackBlack.item; using UncannyJackBlack.src.main.c_sharp.net.alien.UncannyJackBlack.sound; using UncannyJackBlack.src.main.c_sharp.net.alien.UncannyJackBlack.util; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using uncannyJackBlack; using uncannyJackBlack.Behaviours; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("UncannyJackBlack")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("UncannyJackBlack")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("482e497d-a94a-4a11-b6e2-ee1a1d13054f")] [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 UncannyJackBlack.src.main.c_sharp.net.alien.UncannyJackBlack.util { public static class ModRegisters { public static void registerSimpleScrap(Item item, int rarity = 0, LevelTypes moons = 1) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab); Utilities.FixMixerGroups(item.spawnPrefab); Items.RegisterScrap(item, rarity, moons); } public static void registerSimpleEnemy(EnemyType enemyType, int spawnWeight, LevelTypes moons, TerminalNode terminalNode = null, TerminalKeyword terminalKeyword = null) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) NetworkPrefabs.RegisterNetworkPrefab(enemyType.enemyPrefab); Utilities.FixMixerGroups(enemyType.enemyPrefab); Enemies.RegisterEnemy(enemyType, spawnWeight, moons, terminalNode, terminalKeyword); } } } namespace UncannyJackBlack.src.main.c_sharp.net.alien.UncannyJackBlack.sound { public class ModSounds { public static AudioClip GROWL_AUDIO; public static AudioClip SCREAM_AUDIO; public static AudioClip OOF; public static void init() { GROWL_AUDIO = ModMain.BUNDLE.LoadAsset<AudioClip>("Assets/Unity/MOD_ASSETS/uncannyJackBlack/Growl.mp3"); SCREAM_AUDIO = ModMain.BUNDLE.LoadAsset<AudioClip>("Assets/Unity/MOD_ASSETS/uncannyJackBlack/Scream.mp3"); OOF = ModMain.BUNDLE.LoadAsset<AudioClip>("Assets/Unity/MOD_ASSETS/uncannyJackBlack/OOF.mp3"); ModMain.LOGGER.LogInfo((object)"Registered sounds!"); } } } namespace UncannyJackBlack.src.main.c_sharp.net.alien.UncannyJackBlack.item { public class ModEnemies { public static EnemyType JACK_BLACK_ENEMY; public static void init() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) JACK_BLACK_ENEMY = ModMain.BUNDLE.LoadAsset<EnemyType>("Assets/Unity/MOD_ASSETS/uncannyJackBlack/JackBlackEnemy.asset"); JackBlackBehaviour jackBlackBehaviour = JACK_BLACK_ENEMY.enemyPrefab.AddComponent<JackBlackBehaviour>(); ((EnemyAI)jackBlackBehaviour).enemyType = JACK_BLACK_ENEMY; ((EnemyAI)jackBlackBehaviour).eye = JACK_BLACK_ENEMY.enemyPrefab.transform.Find("Eye"); Transform obj = JACK_BLACK_ENEMY.enemyPrefab.transform.Find("Eye"); obj.position += new Vector3(0f, 1f, 0f); ((EnemyAI)jackBlackBehaviour).agent = JACK_BLACK_ENEMY.enemyPrefab.GetComponent<NavMeshAgent>(); ((Component)JACK_BLACK_ENEMY.enemyPrefab.transform.Find("Body")).GetComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)jackBlackBehaviour; JACK_BLACK_ENEMY.enemyPrefab.transform.localScale = new Vector3(2f, 2f, 2f); jackBlackBehaviour.growlAudio = ModSounds.GROWL_AUDIO; jackBlackBehaviour.screamAudio = ModSounds.SCREAM_AUDIO; ((EnemyAI)jackBlackBehaviour).creatureAnimator = JACK_BLACK_ENEMY.enemyPrefab.GetComponent<Animator>(); ((EnemyAI)jackBlackBehaviour).enemyHP = 5; jackBlackBehaviour.deathScrap = ModItems.DIAMOND_PICKAXE; ModRegisters.registerSimpleEnemy(JACK_BLACK_ENEMY, ModMain.CONFIGURATION.spawnWeight.Value, (LevelTypes)(-1)); ModMain.LOGGER.LogInfo((object)"Registered enemies!"); } } public class ModItems { public static Item DIAMOND_PICKAXE; public static void init() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) DIAMOND_PICKAXE = ModMain.BUNDLE.LoadAsset<Item>("Assets/Unity/MOD_ASSETS/uncannyJackBlack/DiamondPickaxeItem.asset"); DIAMOND_PICKAXE.spawnPrefab.transform.localScale = new Vector3(0.03f, 0.03f, 0.03f); DIAMOND_PICKAXE.syncGrabFunction = false; DIAMOND_PICKAXE.syncUseFunction = true; DIAMOND_PICKAXE.syncDiscardFunction = false; DIAMOND_PICKAXE.syncInteractLRFunction = false; ModRegisters.registerSimpleScrap(DIAMOND_PICKAXE, 0, (LevelTypes)1); ModMain.LOGGER.LogInfo((object)"Registered items!"); } } } namespace uncannyJackBlack { public class ModConfiguration { public ConfigEntry<int> spawnWeight; public ModConfiguration(ConfigFile config) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown spawnWeight = config.Bind<int>("Spawn Weight", "Jack Black Spawn Weight", 25, new ConfigDescription("The spawn-weight/rarity of Uncanny Jack Black.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); } } [BepInPlugin("Alien.UncannyJackBlack", "Uncanny Jack Jack", "1.0.1")] public class ModMain : BaseUnityPlugin { private const string modGUID = "Alien.UncannyJackBlack"; private const string modName = "Uncanny Jack Jack"; private const string modVersion = "1.0.1"; private readonly Harmony harmony = new Harmony("Alien.UncannyJackBlack"); private static ModMain instance; public static ManualLogSource LOGGER; public static AssetBundle BUNDLE; public static ModConfiguration CONFIGURATION { get; internal set; } private void Awake() { if ((Object)(object)instance == (Object)null) { instance = this; } LOGGER = Logger.CreateLogSource("Alien.UncannyJackBlack"); LOGGER.LogInfo((object)"hey buddy"); CONFIGURATION = new ModConfiguration(((BaseUnityPlugin)this).Config); string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Alien.UncannyJackBlack".Contains(".") ? (string.Join("", "Alien.UncannyJackBlack".Split(new char[1] { '.' }).Skip(1)).ToLower() + "assets") : ("Alien.UncannyJackBlack".ToLower() + "assets")); BUNDLE = AssetBundle.LoadFromFile(text); ModSounds.init(); ModItems.init(); ModEnemies.init(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Alien.UncannyJackBlack is loaded! IRTHGRTUIGHOIERGHUEHGERHU"); } } } namespace uncannyJackBlack.Behaviours { public class JackBlackBehaviour : EnemyAI { public enum behaviourStates { wanderingState, growlingState, chasingState } public AISearchRoutine searchRoutine; private const float jackBlackSearchWidth = 65f; private Vector3 lastPlayerSeenPos; private Collider[] nearPlayerColliders; private PlayerControllerB player; private bool playerFound = false; private bool lostPlayer = false; private bool isGrowling = false; private bool isScreaming = false; private Transform hair; private float sinceLastKill = 0f; private float defaultSpeed; private const float chaseSpeed = 12f; private const float growlDuration = 7f; public AudioClip growlAudio; public AudioClip screamAudio; public Item deathScrap; public AudioSource audioSource; private EnemyBehaviourState wanderingState = new EnemyBehaviourState(); private EnemyBehaviourState growlingState = new EnemyBehaviourState(); private EnemyBehaviourState chasingState = new EnemyBehaviourState(); private Random enemyRandom; public override void Start() { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Start(); enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex); nearPlayerColliders = (Collider[])(object)new Collider[4]; wanderingState.name = "WANDERING"; growlingState.name = "GROWLING"; chasingState.name = "CHASING"; base.creatureAnimator.SetTrigger("startWalk"); base.enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[3] { wanderingState, growlingState, chasingState }; base.currentBehaviourStateIndex = 0; audioSource = ((Component)this).GetComponent<AudioSource>(); ((EnemyAI)this).StartSearch(((Component)this).transform.position, searchRoutine); defaultSpeed = base.agent.speed; } public override void DoAIInterval() { ((EnemyAI)this).DoAIInterval(); checkPlayers(); behaviourHandler(); } public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { if (!base.isEnemyDead) { base.enemyHP -= force; if (base.enemyHP <= 0) { killJackBlack(); ((EnemyAI)this).KillEnemy(false); Object.Destroy((Object)(object)((Component)this).gameObject); } } } private void behaviourHandler() { //IL_011f: Unknown result type (might be due to invalid IL or missing references) switch (base.currentBehaviourStateIndex) { case 0: if (Object.op_Implicit((Object)(object)player)) { ModMain.LOGGER.LogInfo((object)"Found player; beginning to growl"); ((EnemyAI)this).SwitchToBehaviourState(1); sinceLastKill = Time.time; } else { checkPlayers(); base.agent.speed = defaultSpeed; ModMain.LOGGER.LogInfo((object)"Wandering..."); } break; case 1: if (!isGrowling) { ((MonoBehaviour)this).StartCoroutine(growl()); } break; case 2: { PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(false, false, false); ((EnemyAI)this).SetMovingTowardsTargetPlayer(closestPlayer); ModMain.LOGGER.LogInfo((object)sinceLastKill); if (Time.time - sinceLastKill >= 20f) { ModMain.LOGGER.LogInfo((object)"Switching back to wandering!"); base.creatureAnimator.SetTrigger("stopChase"); ((EnemyAI)this).SwitchToBehaviourState(0); ((EnemyAI)this).StartSearch(((Component)this).transform.position, searchRoutine); } else { audioSource.PlayOneShot(screamAudio); ((EnemyAI)this).StopSearch(searchRoutine, true); base.agent.speed = 12f; ModMain.LOGGER.LogInfo((object)"Chasing closest player"); } break; } } } private void playLoopedAudio(AudioClip audioClip) { audioSource.clip = audioClip; audioSource.loop = true; audioSource.Play(); WalkieTalkie.TransmitOneShotAudio(audioSource, audioSource.clip, 1f); } private void stopLoopedAudio() { audioSource.clip = null; audioSource.Stop(); } private void killJackBlack() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (!base.isEnemyDead) { base.isEnemyDead = true; Landmine.SpawnExplosion(((Component)this).transform.position, true, 0f, 0f, 0, 0f, (GameObject)null, false); GameObject val = Object.Instantiate<GameObject>(deathScrap.spawnPrefab, ((Component)this).transform.position, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer); val.GetComponent<NetworkObject>().Spawn(false); PhysicsProp component = val.GetComponent<PhysicsProp>(); ((GrabbableObject)component).SetScrapValue(Random.Range(350, 500)); } } private IEnumerator growl() { isGrowling = true; base.agent.speed = 0f; float shakeSpeed = 50f; float shakeAmount = 50f; float elapsedTime = 0f; base.creatureAnimator.SetTrigger("stopWalk"); Quaternion originalRotation = ((Component)this).transform.localRotation; while (elapsedTime < 7f) { ModMain.LOGGER.LogInfo((object)"You spin me right round baby"); float currentSpinSpeed = Mathf.Sin(Time.time * shakeSpeed) * shakeAmount; audioSource.PlayOneShot(growlAudio); ((Component)this).transform.Rotate(Vector3.up, currentSpinSpeed * Time.deltaTime, (Space)1); elapsedTime += Time.deltaTime; yield return null; } base.agent.speed = defaultSpeed; isGrowling = false; ((Component)this).transform.localRotation = originalRotation; stopLoopedAudio(); ((EnemyAI)this).SwitchToBehaviourState(2); base.creatureAnimator.SetTrigger("startWalk"); base.creatureAnimator.SetTrigger("startChase"); } public override void OnCollideWithPlayer(Collider other) { //IL_002e: 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_003e: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false); if ((Object)(object)val != (Object)null) { val.BreakLegsSFXServerRpc(); val.KillPlayer(new Vector3(30f, 30f, 30f), true, (CauseOfDeath)6, 7, default(Vector3)); ModMain.LOGGER.LogInfo((object)"Killed player!"); } } private void foundPlayer() { ModMain.LOGGER.LogInfo((object)"Found a player!"); } private void noPlayer() { player = null; ModMain.LOGGER.LogInfo((object)"No player found."); } private void checkPlayers() { //IL_0048: 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_007d: Unknown result type (might be due to invalid IL or missing references) player = ((EnemyAI)this).CheckLineOfSightForPlayer(65f, 45, -1); if (Object.op_Implicit((Object)(object)player)) { foundPlayer(); } else { noPlayer(); } if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position, 70f, 25, -1f)) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position); if (num < 4f) { GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.9f, true); } else if (num < 9f) { GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.4f, true); } } } } }