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 la grosse oreille lo v1.0.1
BigEar.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using BigEar; using GameNetcodeStuff; using LethalLib.Modules; using Unity.Netcode; 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("BigEar")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BigEar")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b7c79f20-57e6-4b7d-9fd7-e61b1d8afc51")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] public class EarBehavior : EnemyAI { public AISearchRoutine AIRoutine = new AISearchRoutine(); private EnemyAICollisionDetect AICollisionDetect = new EnemyAICollisionDetect(); private const float CHANCE_IN_PERCENT_TO_ULTRA_AGGRO = 5f; private const float MINIMUM_NOISE_LEVEL_TO_FLEE = 7f; private const float MINIMUM_NOISE_LEVEL_TO_AGGRO = 1f; private const float PLAYER_VOICE_STRENGTH_MULTIPLICATOR = 10f; private const float PLAYER_VOICE_ID = 75f; private const float CHASING_SPEED = 7f; private const float ULTRA_VENERE_CHASING_SPEED = 9f; private const float ROAMING_SPEED = 3f; private const float FLEEING_SPEED = 9f; private const float HIT_RANGE = 3f; private const int NORMAL_HIT_STRENGTH = 6; private const int VIOLENT_HIT_STRENGTH = 20; private int HIT_INTERVAL = 3; private int currentHitInterval = 0; private const float MAX_FLEEING_TIME = 3f; private float timeFleed = 0f; private const float MAX_STUN_TIME = 3f; private float timeStunned = 0f; private const float MAX_PATIENCE = 20f; private float currentPatienceLevel = 0f; private const float SOFT_FOOTSTEP_INTERVAL = 2f; private float softFootstepValue = 0f; private float currentNoiseHeard = 0f; private bool nearBoomBoxPlaying = false; private const string RUN_TRIGGER = "RunTrigger"; private const string WALK_TRIGGER = "WalkTrigger"; private const string IDLE_TRIGGER = "IdleTrigger"; private const string STUN_TRIGGER = "StunTrigger"; private const string DEATH_TRIGGER = "DeathTrigger"; private Action state; private Animator animator => ((Component)this).GetComponentInChildren<Animator>(); private CapsuleCollider collider => ((Component)this).GetComponent<CapsuleCollider>(); private AudioSource audioSource => ((Component)this).GetComponent<AudioSource>(); private List<string> triggerList => new List<string> { "RunTrigger", "IdleTrigger", "StunTrigger", "DeathTrigger", "WalkTrigger" }; public override void Start() { ((EnemyAI)this).Start(); AICollisionDetect = ((Component)((Component)this).transform.GetChild(0)).gameObject.AddComponent<EnemyAICollisionDetect>(); AICollisionDetect.mainScript = (EnemyAI)(object)this; AICollisionDetect.onlyCollideWhenGrounded = false; ((Component)((Component)this).transform.GetChild(0)).gameObject.layer = 19; SetModRoam(); ((Behaviour)base.agent).enabled = true; base.agent.acceleration = 999999f; } public override void DoAIInterval() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (!base.isEnemyDead) { if ((Object)(object)((EnemyAI)this).GetClosestPlayer(false, false, false) != (Object)null) { BigEarPlugin.mls.LogInfo((object)("ladistansse : " + Vector3.Distance(base.eye.position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position) + " " + state.Method.Name + " " + currentNoiseHeard)); } ((EnemyAI)this).DoAIInterval(); if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead) { state(); currentNoiseHeard = 0f; } } } private void SetModRoam() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) state = DoActionRoam; base.movingTowardsTargetPlayer = false; base.agent.speed = 3f; ((Collider)collider).isTrigger = true; ((EnemyAI)this).StartSearch(((Component)this).transform.position, AIRoutine); ChangeAnimationTrigger("WalkTrigger"); } private void DoActionRoam() { if (softFootstepValue >= 2f) { audioSource.PlayOneShot(BigEarPlugin.instance.assetBundle.LoadAsset<AudioClip>("Assets/Ear/SoftWalk.mp3")); softFootstepValue = 0f; } else { softFootstepValue += 1f; } PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(true, false, false); if ((Object)(object)closestPlayer != (Object)null) { SetModObserve(closestPlayer); } } private void SetModRushPlayer(PlayerControllerB playerToRush) { state = DoActionRushPlayer; ((Collider)collider).isTrigger = true; base.targetNode = ((Component)playerToRush).transform; base.targetPlayer = playerToRush; base.movingTowardsTargetPlayer = true; base.agent.speed = 7f; ChangeAnimationTrigger("RunTrigger"); } private void DoActionRushPlayer() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) audioSource.PlayOneShot(BigEarPlugin.instance.assetBundle.LoadAsset<AudioClip>("Assets/Ear/HardWalk.mp3")); PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(true, false, false); if (((Object)(object)closestPlayer == (Object)null || (Object)(object)closestPlayer != (Object)(object)base.targetPlayer) && currentPatienceLevel < 20f) { currentPatienceLevel += 1f; return; } currentPatienceLevel = 0f; if (Vector3.Distance(base.eye.position, ((Component)closestPlayer).transform.position) < 3f) { TryHit(closestPlayer); } if ((Object)(object)closestPlayer == (Object)null) { SetModRoam(); } else if ((Object)(object)closestPlayer != (Object)(object)base.targetPlayer) { SetModRushPlayer(closestPlayer); } if (currentNoiseHeard >= 7f) { SetModStunned(); } } private void SetModRushUltraVenere(PlayerControllerB playerToRush) { audioSource.PlayOneShot(BigEarPlugin.instance.assetBundle.LoadAsset<AudioClip>("Assets/Ear/RAOUUUUHH.mp3")); state = DoActionRushUltraVenere; ((Collider)collider).isTrigger = true; base.targetNode = ((Component)playerToRush).transform; base.targetPlayer = playerToRush; base.movingTowardsTargetPlayer = true; base.agent.speed = 9f; ChangeAnimationTrigger("RunTrigger"); } private void DoActionRushUltraVenere() { audioSource.PlayOneShot(BigEarPlugin.instance.assetBundle.LoadAsset<AudioClip>("Assets/Ear/HardWalk.mp3")); if (!base.targetPlayer.isInsideFactory) { SetModRoam(); } } private void SetModFlee(Transform fleeingPoint) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) state = DoActionFlee; timeFleed = 0f; ((Collider)collider).isTrigger = true; base.targetNode = fleeingPoint; ((EnemyAI)this).SetDestinationToPosition(base.targetNode.position, false); base.movingTowardsTargetPlayer = false; base.agent.speed = 9f; ChangeAnimationTrigger("RunTrigger"); } private void DoActionFlee() { audioSource.PlayOneShot(BigEarPlugin.instance.assetBundle.LoadAsset<AudioClip>("Assets/Ear/SoftWalk.mp3")); timeFleed += 0.1f; if (timeFleed > 3f) { SetModRoam(); } } private void SetModObserve(PlayerControllerB playerToObserve) { state = DoActionObserve; ((Collider)collider).isTrigger = false; ((EnemyAI)this).StopSearch(AIRoutine, true); base.targetNode = ((Component)playerToObserve).transform; base.targetPlayer = playerToObserve; base.movingTowardsTargetPlayer = true; base.agent.speed = 0f; ChangeAnimationTrigger("IdleTrigger"); } private void DoActionObserve() { PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(true, false, false); if ((Object)(object)closestPlayer == (Object)null) { SetModRoam(); } else if ((Object)(object)closestPlayer != (Object)(object)base.targetPlayer) { SetModObserve(closestPlayer); } if (currentNoiseHeard >= 7f) { SetModStunned(); } else if (currentNoiseHeard >= 1f) { SetModRushPlayer(closestPlayer); } } private void SetModStunned() { state = DoActionStunned; audioSource.PlayOneShot(BigEarPlugin.instance.assetBundle.LoadAsset<AudioClip>("Assets/Ear/Acouphene.mp3")); audioSource.PlayOneShot(BigEarPlugin.instance.assetBundle.LoadAsset<AudioClip>("Assets/Ear/Grrr.mp3")); ((Collider)collider).isTrigger = false; timeStunned = 0f; base.movingTowardsTargetPlayer = false; base.agent.speed = 0f; ChangeAnimationTrigger("StunTrigger"); } private void DoActionStunned() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(false, false, false); timeStunned += 0.1f; if (timeStunned > 3f) { SetModRoam(); } if (!(currentNoiseHeard < 7f) && !((Object)(object)closestPlayer == (Object)null)) { Transform val = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position, true, 0, false); if ((float)Random.Range(1, 101) <= 5f || (Object)(object)val == (Object)null) { SetModRushUltraVenere(closestPlayer); } else { SetModFlee(val); } } } private void SetModDanse() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) state = DoActionDanse; timeFleed = 0f; ((Collider)collider).isTrigger = false; ((EnemyAI)this).SetDestinationToPosition(base.targetNode.position, false); base.movingTowardsTargetPlayer = false; base.agent.speed = 9f; } private void DoActionDanse() { if (!nearBoomBoxPlaying) { SetModRoam(); } } private void ChangeAnimationTrigger(string triggerToActivate) { if (((NetworkBehaviour)this).IsServer) { ChangeAnimForClient(triggerToActivate); } foreach (string trigger in triggerList) { animator.SetBool(trigger, false); } animator.SetBool(triggerToActivate, true); } [ClientRpc] private void ChangeAnimForClient(string triggerToActivate) { foreach (string trigger in triggerList) { animator.SetBool(trigger, false); } animator.SetBool(triggerToActivate, true); } private void TryHit(PlayerControllerB playerToHit, bool isViolent = false) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (HIT_INTERVAL > currentHitInterval) { currentHitInterval++; return; } currentHitInterval = 0; if (isViolent) { playerToHit.DamagePlayer(20, false, true, (CauseOfDeath)8, 0, false, default(Vector3)); } else { playerToHit.DamagePlayer(6, false, true, (CauseOfDeath)8, 0, false, default(Vector3)); } } public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if ((float)noiseID == 75f) { noiseLoudness *= 10f; } BigEarPlugin.mls.LogInfo((object)("id du type qui parle : " + noiseID)); ((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID); currentNoiseHeard += noiseLoudness; } private int MultiplyByTwo(int number) { BigEarPlugin.mls.LogInfo((object)"The lying function has been called !!!!!!"); return number * 3; } } namespace BigEar; [BepInPlugin("Gouuu.BigEar", "BigEar", "1.0.0.0")] public class BigEarPlugin : BaseUnityPlugin { public static BigEarPlugin instance; private const string modGUID = "Gouuu.BigEar"; private const string modName = "BigEar"; private const string modVersion = "1.0.0.0"; public static ManualLogSource mls; public static AudioClip WalkSound; public AssetBundle assetBundle; private string assetDir => Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "epicball"); private void Awake() { if ((Object)(object)instance == (Object)null) { instance = this; } assetBundle = AssetBundle.LoadFromFile(assetDir); mls = Logger.CreateLogSource("Gouuu.BigEar"); Item val = assetBundle.LoadAsset<Item>("Assets/TestItem/EpicBall.asset"); NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); Utilities.FixMixerGroups(val.spawnPrefab); EnemyType val2 = assetBundle.LoadAsset<EnemyType>("Assets/Ear/Ear.asset"); EarBehavior earBehavior = val2.enemyPrefab.AddComponent<EarBehavior>(); ((EnemyAI)earBehavior).currentSearch = earBehavior.AIRoutine; ((EnemyAI)earBehavior).enemyType = val2; ((EnemyAI)earBehavior).eye = ((Component)earBehavior).transform; NetworkPrefabs.RegisterNetworkPrefab(val2.enemyPrefab); Utilities.FixMixerGroups(val2.enemyPrefab); TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val3).name = "Ear"; val3.clearPreviousText = true; val3.displayText = "The Listenear resembles a large, Human ear, with two legs attached to each sides of it's body. An eye replaces the hole where you'd typically find an ear-drum, if you were to decide to base it on human anatomy. Similarly to the Coil-Heads, no extensive researches have been done on this rare biological incoherence, due to it's extreme sensitivity to any kind of sounds. Its legs seems to be partially made of non-biological matter, especially their feets, which doesn't seem to be made of any skin, flesh, or other anatomical structures that would characterize any other living organisms, prompting us to think that it is, at least partially, human made. \r\nIt is believed that it makes them immune to Hydrodere, since this specie cannot have access to the biological parts of the Listenear with those.\r\n\r\nIts sensitivity to sound can be detrimental, as it seems to be quite in pain when any sound sources are too loud for its standards. It is believed that, unlike the Coil-Head's probable use for war, it could have been looking to be for a more defensive purpose. Exercising with caution is reccomended, and using sound is deemed as a risky solution."; val3.creatureFileID = 18; val3.creatureName = "Ear"; val3.maxCharactersToType = 35; Enemies.RegisterEnemy(val2, 10000, (LevelTypes)(-1), (SpawnType)0, new string[0], val3, (TerminalKeyword)null); mls.LogInfo((object)"THE EAR MOD IS WORKING !! ! ! !! ! ! !"); } }