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 Dafis Mega Monster Pack Emporium v1.0.1
BaseMonster.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; using UnityEngine.AI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BaseMonster")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Base Monster for REPO")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BaseMonster")] [assembly: AssemblyTitle("BaseMonster")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public class BaseModEnemy : MonoBehaviour { public enum State { Spawn, Idle, Roam, Investigate, PlayerNotice, Attack, Leave, Stun, Despawn } protected PhotonView photonView; public State currentState; protected bool stateImpulse; protected float stateTimer; protected Vector3 agentDestination; protected PlayerAvatar playerTarget; [Header("Required Components")] public Enemy enemy; protected NavMeshAgent navMeshAgent; protected Rigidbody enemyRigidbody; [Header("Optional Components")] public Transform centerTransform; [Header("Rotation Settings")] public SpringQuaternion rotationSpring; protected Quaternion rotationTarget; protected float grabAggroTimer; protected int attacks; protected float visionTimer; protected bool visionPrevious; protected virtual void Awake() { photonView = ((Component)this).GetComponent<PhotonView>(); if ((Object)(object)enemy == (Object)null) { enemy = ((Component)this).GetComponent<Enemy>(); } navMeshAgent = ((Component)this).GetComponent<NavMeshAgent>(); if ((Object)(object)((Component)this).GetComponent<Rigidbody>() != (Object)null) { enemyRigidbody = ((Component)this).GetComponent<Rigidbody>(); } else { enemyRigidbody = ((Component)this).GetComponentInChildren<Rigidbody>(); } if ((Object)(object)centerTransform == (Object)null) { centerTransform = ((Component)this).transform; } } protected virtual void Start() { } protected virtual void Update() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 if (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient) { ProcessTimers(); if (enemy.IsStunned()) { UpdateState(State.Stun); } else if ((int)enemy.CurrentState == 11) { UpdateState(State.Despawn); } switch (currentState) { case State.Spawn: StateSpawn(); break; case State.Idle: StateIdle(); break; case State.Roam: StateRoam(); break; case State.Investigate: StateInvestigate(); break; case State.PlayerNotice: StatePlayerNotice(); break; case State.Attack: StateAttack(); break; case State.Leave: StateLeave(); break; case State.Stun: StateStun(); break; case State.Despawn: StateDespawn(); break; } } } protected virtual void StateSpawn() { if (stateImpulse) { stateImpulse = false; stateTimer = 1f; } stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { UpdateState(State.Idle); } } protected virtual void StateIdle() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { navMeshAgent.ResetPath(); navMeshAgent.Warp(((Component)this).transform.position); stateTimer = Random.Range(2f, 6f); stateImpulse = false; } if (!SemiFunc.EnemySpawnIdlePause()) { stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { UpdateState(State.Roam); } if (SemiFunc.EnemyForceLeave(enemy)) { UpdateState(State.Leave); } } } protected virtual void StateRoam() { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { navMeshAgent.ResetPath(); navMeshAgent.Warp(((Component)this).transform.position); LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, 5f, 15f); if (!Object.op_Implicit((Object)(object)val)) { val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f); } NavMeshHit val2 = default(NavMeshHit); if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" }))) { agentDestination = ((NavMeshHit)(ref val2)).position; } stateTimer = 5f; stateImpulse = false; } navMeshAgent.SetDestination(agentDestination); if (GetNotMovingTimer() > 2f) { stateTimer -= Time.deltaTime; } if (stateTimer <= 0f || Vector3.Distance(((Component)this).transform.position, agentDestination) < 1f) { UpdateState(State.Idle); } if (SemiFunc.EnemyForceLeave(enemy)) { UpdateState(State.Leave); } } protected virtual void StateInvestigate() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { stateTimer = 5f; ResetNotMovingTimer(); stateImpulse = false; } else { navMeshAgent.SetDestination(agentDestination); EnemyCartJump(); if (GetNotMovingTimer() > 2f) { stateTimer -= Time.deltaTime; } if ((stateTimer <= 0f || Vector3.Distance(((Component)this).transform.position, agentDestination) < 2f) && !IsJumping()) { EnemyCartJumpReset(); UpdateState(State.Idle); } } if (SemiFunc.EnemyForceLeave(enemy)) { UpdateState(State.Leave); } } protected virtual void StatePlayerNotice() { if (stateImpulse) { stateTimer = 1f; stateImpulse = false; } navMeshAgent.ResetPath(); navMeshAgent.isStopped = true; stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { navMeshAgent.isStopped = false; UpdateState(State.Attack); } } protected virtual void StateAttack() { if (stateImpulse) { stateTimer = 3f; attacks++; stateImpulse = false; } stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { if (attacks >= 3 || Random.Range(0f, 1f) <= 0.3f) { attacks = 0; UpdateState(State.Leave); } else { UpdateState(State.PlayerNotice); } } } protected virtual void StateLeave() { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 30f, 60f, false); if (!Object.op_Implicit((Object)(object)val)) { val = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f); } if (Object.op_Implicit((Object)(object)val)) { agentDestination = ((Component)val).transform.position; } else if ((Object)(object)enemy != (Object)null && (Object)(object)((Component)enemy).transform.parent != (Object)null) { EnemyParent component = ((Component)((Component)enemy).transform.parent).GetComponent<EnemyParent>(); if ((Object)(object)component != (Object)null) { try { component.Despawn(); } catch (NullReferenceException) { Debug.LogWarning((object)"Failed to despawn enemy properly. Destroying manually."); Object.Destroy((Object)(object)((Component)((Component)enemy).transform.parent).gameObject); } } else { Object.Destroy((Object)(object)((Component)((Component)enemy).transform.parent).gameObject); } } stateTimer = 10f; stateImpulse = false; } else { navMeshAgent.SetDestination(agentDestination); EnemyCartJump(); if (GetNotMovingTimer() > 2f) { stateTimer -= Time.deltaTime; } if (stateTimer <= 0f || Vector3.Distance(((Component)this).transform.position, agentDestination) < 1f) { UpdateState(State.Idle); } } } protected virtual void StateStun() { if (!enemy.IsStunned()) { UpdateState(State.Idle); } } protected virtual void StateDespawn() { if (stateImpulse) { stateImpulse = false; } } public virtual void OnSpawn() { if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(enemy)) { UpdateState(State.Spawn); } } public virtual void OnHurt() { } public virtual void OnDeath() { //IL_001f: 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) GameDirector.instance.CameraShake.ShakeDistance(5f, 3f, 8f, ((Component)this).transform.position, 0.5f); GameDirector.instance.CameraImpact.ShakeDistance(5f, 3f, 8f, ((Component)this).transform.position, 0.1f); if (SemiFunc.IsMasterClientOrSingleplayer() && (Object)(object)enemy != (Object)null && (Object)(object)((Component)enemy).transform.parent != (Object)null) { EnemyParent component = ((Component)((Component)enemy).transform.parent).GetComponent<EnemyParent>(); if ((Object)(object)component != (Object)null) { component.Despawn(); } } } public virtual void OnInvestigate() { //IL_0028: 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_0078: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && (currentState == State.Idle || currentState == State.Roam || currentState == State.Investigate)) { Vector3 val = ((Component)this).transform.position; MonoBehaviour component = ((Component)enemy).GetComponent<MonoBehaviour>(); if ((Object)(object)component != (Object)null && ((object)component).GetType().GetField("onInvestigateTriggeredPosition") != null) { val = (Vector3)((object)component).GetType().GetField("onInvestigateTriggeredPosition").GetValue(component); } agentDestination = val; UpdateState(State.Investigate); } } public virtual void OnVisionTriggered() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown if (!SemiFunc.IsMasterClientOrSingleplayer() || (currentState != State.Idle && currentState != State.Roam && currentState != State.Investigate)) { return; } PlayerAvatar val = null; MonoBehaviour component = ((Component)enemy).GetComponent<MonoBehaviour>(); if ((Object)(object)component != (Object)null) { FieldInfo field = ((object)component).GetType().GetField("onVisionTriggeredPlayer"); if (field != null) { val = (PlayerAvatar)field.GetValue(component); } if ((Object)(object)val != (Object)null && (Object)(object)playerTarget != (Object)(object)val) { playerTarget = val; if (GameManager.Multiplayer()) { photonView.RPC("UpdatePlayerTargetRPC", (RpcTarget)1, new object[1] { playerTarget.photonView.ViewID }); } } if (!enemy.IsStunned()) { FieldInfo field2 = ((object)component).GetType().GetField("onVisionTriggeredID"); if (field2 != null) { int playerID = (int)field2.GetValue(component); HandleNoticeAnimation(playerID); } else if ((Object)(object)val != (Object)null && (Object)(object)val.photonView != (Object)null) { HandleNoticeAnimation(val.photonView.ViewID); } } } UpdateState(State.PlayerNotice); } public virtual void OnGrabbed() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown if (!SemiFunc.IsMasterClientOrSingleplayer() || grabAggroTimer > 0f || currentState != State.Leave) { return; } grabAggroTimer = 60f; PlayerAvatar val = null; MonoBehaviour component = ((Component)enemy).GetComponent<MonoBehaviour>(); if ((Object)(object)component != (Object)null) { FieldInfo field = ((object)component).GetType().GetField("onGrabbedPlayerAvatar"); if (field != null) { val = (PlayerAvatar)field.GetValue(component); } } if ((Object)(object)val != (Object)null && (Object)(object)playerTarget != (Object)(object)val) { playerTarget = val; if (GameManager.Multiplayer()) { photonView.RPC("UpdatePlayerTargetRPC", (RpcTarget)1, new object[1] { playerTarget.photonView.ViewID }); } } UpdateState(State.PlayerNotice); if (!enemy.IsStunned() && (Object)(object)playerTarget != (Object)null) { HandleNoticeAnimation(playerTarget.photonView.ViewID); } } protected virtual void UpdateState(State _state) { if (currentState != _state) { currentState = _state; stateImpulse = true; stateTimer = 0f; if (GameManager.Multiplayer()) { photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState }); } } } protected virtual void ProcessTimers() { if (grabAggroTimer > 0f) { grabAggroTimer -= Time.deltaTime; } if (visionTimer > 0f) { visionTimer -= Time.deltaTime; } } protected virtual void HandleNoticeAnimation(int playerID) { } protected virtual void AgentVelocityRotation() { //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_0033: 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_003b: 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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_006e: 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) if ((Object)(object)navMeshAgent != (Object)null) { Vector3 velocity = navMeshAgent.velocity; if (((Vector3)(ref velocity)).magnitude > 0.05f) { velocity = navMeshAgent.velocity; Quaternion val = Quaternion.LookRotation(((Vector3)(ref velocity)).normalized); Quaternion val2 = Quaternion.Euler(0f, ((Quaternion)(ref val)).eulerAngles.y, 0f); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, 5f * Time.deltaTime); } } } protected virtual void PlayerLookAt() { //IL_0019: 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_0040: 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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)playerTarget != (Object)null) { Vector3 val = ((Component)playerTarget).transform.position - ((Component)this).transform.position; val.y = 0f; Quaternion val2 = Quaternion.LookRotation(val); Quaternion val3 = Quaternion.Euler(0f, ((Quaternion)(ref val2)).eulerAngles.y, 0f); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val3, 50f * Time.deltaTime); } } protected virtual bool VisionBlocked() { //IL_0033: 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) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) if ((Object)(object)playerTarget == (Object)null) { return true; } if (visionTimer <= 0f) { visionTimer = 0.1f; Vector3 val = ((Component)playerTarget).transform.position - ((Component)this).transform.position; visionPrevious = Physics.Raycast(((Component)this).transform.position, val, ((Vector3)(ref val)).magnitude, LayerMask.GetMask(new string[1] { "Default" })); } return visionPrevious; } protected virtual float GetNotMovingTimer() { MonoBehaviour component = ((Component)enemy).GetComponent<MonoBehaviour>(); if ((Object)(object)component != (Object)null) { FieldInfo field = ((object)component).GetType().GetField("notMovingTimer"); if (field != null) { return (float)field.GetValue(component); } } return 0f; } protected virtual void ResetNotMovingTimer() { MonoBehaviour component = ((Component)enemy).GetComponent<MonoBehaviour>(); if ((Object)(object)component != (Object)null) { FieldInfo field = ((object)component).GetType().GetField("notMovingTimer"); if (field != null) { field.SetValue(component, 0f); } } } protected virtual bool IsJumping() { MonoBehaviour component = ((Component)enemy).GetComponent<MonoBehaviour>(); if ((Object)(object)component != (Object)null) { FieldInfo field = ((object)component).GetType().GetField("jumping"); if (field != null) { return (bool)field.GetValue(component); } } return false; } protected virtual void EnemyCartJump() { SemiFunc.EnemyCartJump(enemy); } protected virtual void EnemyCartJumpReset() { SemiFunc.EnemyCartJumpReset(enemy); } [PunRPC] protected virtual void UpdateStateRPC(State _state) { currentState = _state; } [PunRPC] protected virtual void UpdatePlayerTargetRPC(int _photonViewID) { foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (item.photonView.ViewID == _photonViewID) { playerTarget = item; break; } } } [PunRPC] protected virtual void NoticeRPC(int _playerID) { } } public class BaseModEnemyAnim : MonoBehaviour { protected Animator animator; protected PhotonView photonView; [Header("Enemy Reference")] public BaseModEnemy enemyBrain; [Header("Sound Effects")] public Sound spawnSound; public Sound hurtSound; public Sound deathSound; public Sound noticeSound; public Sound attackSound; [Header("Visual Effects")] public ParticleSystem particleImpact; public ParticleSystem particleBits; public ParticleSystem particleDirectionalBits; protected int animParamStateHash; protected int animParamSpeedHash; protected int animParamHurtHash; protected int animParamDeathHash; protected int animParamAttackHash; protected virtual void Awake() { animator = ((Component)this).GetComponent<Animator>(); photonView = ((Component)this).GetComponent<PhotonView>(); if ((Object)(object)enemyBrain == (Object)null) { enemyBrain = ((Component)this).GetComponentInParent<BaseModEnemy>(); } InitializeAnimationHashes(); } protected virtual void InitializeAnimationHashes() { animParamStateHash = Animator.StringToHash("State"); animParamSpeedHash = Animator.StringToHash("Speed"); animParamHurtHash = Animator.StringToHash("Hurt"); animParamDeathHash = Animator.StringToHash("Death"); animParamAttackHash = Animator.StringToHash("Attack"); } protected virtual void Update() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)animator != (Object)null)) { return; } animator.SetInteger(animParamStateHash, (int)enemyBrain.currentState); float num = 0f; if ((Object)(object)enemyBrain != (Object)null) { NavMeshAgent component = ((Component)enemyBrain).GetComponent<NavMeshAgent>(); if ((Object)(object)component != (Object)null) { Vector3 velocity = component.velocity; num = ((Vector3)(ref velocity)).magnitude; } } animator.SetFloat(animParamSpeedHash, num); } public virtual void OnSpawn() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (spawnSound != null) { spawnSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } if ((Object)(object)animator != (Object)null) { animator.SetTrigger("Spawn"); } } public virtual void OnHurt() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)animator != (Object)null) { animator.SetTrigger(animParamHurtHash); } if (hurtSound != null) { hurtSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } } public virtual void OnDeath() { //IL_0033: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)animator != (Object)null) { animator.SetTrigger(animParamDeathHash); } if (deathSound != null) { deathSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } if ((Object)(object)particleImpact != (Object)null) { particleImpact.Play(); } if ((Object)(object)particleBits != (Object)null) { particleBits.Play(); } if (!((Object)(object)particleDirectionalBits != (Object)null)) { return; } Vector3 val = Vector3.back; if ((Object)(object)enemyBrain != (Object)null && (Object)(object)enemyBrain.enemy != (Object)null) { MonoBehaviour component = ((Component)enemyBrain.enemy).GetComponent<MonoBehaviour>(); if ((Object)(object)component != (Object)null) { FieldInfo field = ((object)component).GetType().GetField("hurtDirection"); if (field != null) { val = (Vector3)field.GetValue(component); } } } ((Component)particleDirectionalBits).transform.rotation = Quaternion.LookRotation(-((Vector3)(ref val)).normalized); particleDirectionalBits.Play(); } public virtual void NoticeSet(int playerID) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)animator != (Object)null) { animator.SetTrigger("Notice"); } if (noticeSound != null) { noticeSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } } public virtual void Attack() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)animator != (Object)null) { animator.SetTrigger(animParamAttackHash); } if (attackSound != null) { attackSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } } public virtual void Charge() { if ((Object)(object)animator != (Object)null) { animator.SetTrigger("Charge"); } } public virtual void Retreat() { if ((Object)(object)animator != (Object)null) { animator.SetTrigger("Retreat"); } } [PunRPC] protected virtual void OnHurtRPC() { OnHurt(); } [PunRPC] protected virtual void OnDeathRPC() { OnDeath(); } [PunRPC] protected virtual void NoticeRPC(int playerID) { NoticeSet(playerID); } [PunRPC] protected virtual void AttackRPC() { Attack(); } [PunRPC] protected virtual void ChargeRPC() { Charge(); } [PunRPC] protected virtual void RetreatRPC() { Retreat(); } } public class BombEnemy : BaseModEnemy { public new enum State { Spawn, Idle, Roam, Investigate, PlayerNotice, Fused, Explode, Stun, Despawn } [Header("Bomb Settings")] [Tooltip("Time in seconds before explosion once fuse is lit")] public float fuseTime = 3f; [Tooltip("Explosion radius in meters")] public float explosionRadius = 5f; [Tooltip("Explosion force applied to affected objects")] public float explosionForce = 1000f; [Tooltip("Damage applied to players")] public float explosionDamage = 50f; [Tooltip("Upward modifier for explosion force")] public float upwardModifier = 3f; [Tooltip("Layer mask for objects affected by explosion")] public LayerMask explosionLayerMask; [Header("Effects")] [Tooltip("Sound played when fuse is lit")] public Sound fuseSound; [Tooltip("Sound played during explosion")] public Sound explosionSound; [Tooltip("Particle effect for the fuse")] public ParticleSystem fuseParticleEffect; [Tooltip("Particle effect for the explosion")] public ParticleSystem explosionParticleEffect; [Header("References")] public BombEnemyAnim bombAnim; private float fuseTimer; private bool fuseActive; private bool hasExploded; public new State currentState { get { return (State)base.currentState; } set { base.currentState = (BaseModEnemy.State)value; } } protected override void Awake() { //IL_0051: 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) base.Awake(); if ((Object)(object)bombAnim == (Object)null) { bombAnim = ((Component)this).GetComponentInChildren<BombEnemyAnim>(); } if (((LayerMask)(ref explosionLayerMask)).value == 0) { explosionLayerMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[3] { "Default", "PhysGrabObject", "Player" })); } } protected override void Update() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) { return; } ProcessTimers(); if (currentState == State.Fused) { StateFused(); return; } if (enemy.IsStunned()) { base.UpdateState(BaseModEnemy.State.Stun); } else if ((int)enemy.CurrentState == 11) { base.UpdateState(BaseModEnemy.State.Despawn); } switch (currentState) { case State.Spawn: StateSpawn(); break; case State.Idle: StateIdle(); break; case State.Roam: StateRoam(); AgentVelocityRotation(); break; case State.Investigate: StateInvestigate(); AgentVelocityRotation(); break; case State.PlayerNotice: StatePlayerNotice(); PlayerLookAt(); break; case State.Explode: StateExplode(); break; case State.Stun: StateStun(); break; case State.Despawn: StateDespawn(); break; case State.Fused: break; } } protected override void StatePlayerNotice() { if (stateImpulse) { stateTimer = 1f; stateImpulse = false; } navMeshAgent.ResetPath(); navMeshAgent.isStopped = true; stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { navMeshAgent.isStopped = false; LightFuse(); } } protected virtual void StateFused() { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { fuseTimer = fuseTime; stateImpulse = false; if ((Object)(object)fuseParticleEffect != (Object)null && !fuseParticleEffect.isPlaying) { fuseParticleEffect.Play(); } if (fuseSound != null) { if (GameManager.Multiplayer()) { photonView.RPC("PlayFuseRPC", (RpcTarget)0, Array.Empty<object>()); } else { fuseSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } } if ((Object)(object)bombAnim != (Object)null) { if (GameManager.Multiplayer()) { photonView.RPC("FuseStartRPC", (RpcTarget)0, Array.Empty<object>()); } else { bombAnim.StartFuse(); } } } if ((Object)(object)playerTarget != (Object)null && !VisionBlocked()) { navMeshAgent.speed *= 1.5f; navMeshAgent.SetDestination(((Component)playerTarget).transform.position); } fuseTimer -= Time.deltaTime; if ((Object)(object)bombAnim != (Object)null) { float progress = 1f - fuseTimer / fuseTime; bombAnim.UpdateFuseProgress(progress); } if (fuseTimer <= 0f) { base.UpdateState(BaseModEnemy.State.Leave); } } protected virtual void StateExplode() { if (stateImpulse && !hasExploded) { stateImpulse = false; hasExploded = true; if (GameManager.Multiplayer()) { photonView.RPC("ExplodeRPC", (RpcTarget)0, Array.Empty<object>()); } else { Explode(); } ((MonoBehaviour)this).StartCoroutine(DestroyAfterExplosion()); } } private IEnumerator DestroyAfterExplosion() { yield return (object)new WaitForSeconds(2f); if (!SemiFunc.IsMasterClientOrSingleplayer() || !((Object)(object)enemy != (Object)null) || !((Object)(object)((Component)enemy).transform.parent != (Object)null)) { yield break; } EnemyParent component = ((Component)((Component)enemy).transform.parent).GetComponent<EnemyParent>(); if ((Object)(object)component != (Object)null) { try { component.Despawn(); yield break; } catch (NullReferenceException) { Debug.LogWarning((object)"Failed to despawn enemy properly. Destroying manually."); Object.Destroy((Object)(object)((Component)((Component)enemy).transform.parent).gameObject); yield break; } } Object.Destroy((Object)(object)((Component)((Component)enemy).transform.parent).gameObject); } protected virtual void LightFuse() { if (!fuseActive) { fuseActive = true; base.UpdateState(BaseModEnemy.State.Attack); } } protected virtual void Explode() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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) //IL_010f: 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_01b4: Unknown result type (might be due to invalid IL or missing references) if (explosionSound != null) { explosionSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } if ((Object)(object)explosionParticleEffect != (Object)null) { ((Component)explosionParticleEffect).transform.position = ((Component)this).transform.position; explosionParticleEffect.Play(); } GameDirector.instance.CameraShake.ShakeDistance(explosionRadius, 5f, 10f, ((Component)this).transform.position, 0.5f); GameDirector.instance.CameraImpact.ShakeDistance(explosionRadius, 5f, 10f, ((Component)this).transform.position, 0.2f); Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, explosionRadius, LayerMask.op_Implicit(explosionLayerMask)); foreach (Collider val in array) { Rigidbody component = ((Component)val).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { component.AddExplosionForce(explosionForce, ((Component)this).transform.position, explosionRadius, upwardModifier); } PlayerAvatar component2 = ((Component)val).GetComponent<PlayerAvatar>(); if ((Object)(object)component2 != (Object)null) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); float num2 = 1f - num / explosionRadius; float damage = explosionDamage * num2; ApplyPlayerDamage(component2, damage); } PhysGrabObject componentInParent = ((Component)val).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.rb != (Object)null) { componentInParent.rb.AddExplosionForce(explosionForce * 1.5f, ((Component)this).transform.position, explosionRadius, upwardModifier); } } if ((Object)(object)bombAnim != (Object)null) { bombAnim.OnExplode(); } } protected virtual void ApplyPlayerDamage(PlayerAvatar player, float damage) { if ((Object)(object)player.tumble != (Object)null) { player.tumble.OverrideEnemyHurt(3f); } } public override void OnHurt() { base.OnHurt(); if (currentState != State.Fused && currentState != State.Explode) { LightFuse(); } } public override void OnDeath() { if (!hasExploded) { SetBombState(State.Explode); } } private void OnDrawGizmosSelected() { //IL_0014: 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_0048: 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) Gizmos.color = new Color(1f, 0.3f, 0.3f, 0.3f); Gizmos.DrawSphere(((Component)this).transform.position, explosionRadius); Gizmos.color = new Color(1f, 0f, 0f, 0.8f); Gizmos.DrawWireSphere(((Component)this).transform.position, explosionRadius); } protected void SetBombState(State state) { base.UpdateState((BaseModEnemy.State)state); } [PunRPC] protected void PlayFuseRPC() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (fuseSound != null) { fuseSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } } [PunRPC] protected void ExplodeRPC() { Explode(); } [PunRPC] protected void FuseStartRPC() { if ((Object)(object)bombAnim != (Object)null) { bombAnim.StartFuse(); } } } public class BombEnemyAnim : BaseModEnemyAnim { [Header("Bomb-specific References")] public BombEnemy bombBrain; [Header("Bomb Visual Components")] [Tooltip("The main body of the bomb that will be hidden after explosion")] public GameObject bombModel; [Tooltip("The fuse object that will be animated")] public Transform fuseTransform; [Tooltip("Optional emissive material to flash when fuse is active")] public Renderer bodyRenderer; [Tooltip("Material index for emissive material (if using shared materials)")] public int emissiveMaterialIndex; [Header("Fuse Animation")] [Tooltip("Minimum scale of the fuse as it burns down")] public float minFuseScale = 0.1f; [Tooltip("Maximum fuse wiggle angle")] public float fuseWiggleAngle = 15f; [Tooltip("Speed of fuse wiggle")] public float fuseWiggleSpeed = 10f; [Header("Bomb Flash Settings")] [Tooltip("Color to flash when fuse is almost out")] public Color flashColor = Color.red; [Tooltip("Normal color of the emissive part")] public Color normalColor = Color.black; [Tooltip("Flash speed when about to explode")] public float flashSpeed = 10f; private Material emissiveMaterial; private float fuseProgress; private bool isFuseActive; private float flashTimer; protected int animFuseHash; protected int animExplodeHash; protected override void Awake() { base.Awake(); if ((Object)(object)bombBrain == (Object)null) { bombBrain = ((Component)this).GetComponentInParent<BombEnemy>(); } if ((Object)(object)bodyRenderer != (Object)null && bodyRenderer.materials.Length > emissiveMaterialIndex) { emissiveMaterial = bodyRenderer.materials[emissiveMaterialIndex]; } animFuseHash = Animator.StringToHash("Fuse"); animExplodeHash = Animator.StringToHash("Explode"); } protected override void Update() { base.Update(); if (isFuseActive && (Object)(object)fuseTransform != (Object)null) { AnimateFuse(); } if (isFuseActive && fuseProgress > 0.7f && (Object)(object)emissiveMaterial != (Object)null) { FlashBomb(); } } public void StartFuse() { isFuseActive = true; fuseProgress = 0f; if ((Object)(object)animator != (Object)null) { animator.SetTrigger(animFuseHash); animator.SetBool("IsFused", true); } } public void UpdateFuseProgress(float progress) { fuseProgress = Mathf.Clamp01(progress); } public void OnExplode() { isFuseActive = false; if ((Object)(object)animator != (Object)null) { animator.SetTrigger(animExplodeHash); } if ((Object)(object)bombModel != (Object)null) { bombModel.SetActive(false); } } private void AnimateFuse() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)fuseTransform != (Object)null) { float num = Mathf.Lerp(1f, minFuseScale, fuseProgress); fuseTransform.localScale = new Vector3(num, num, num); float num2 = Mathf.Sin(Time.time * fuseWiggleSpeed) * fuseWiggleAngle; num2 *= 1f - fuseProgress * 0.5f; fuseTransform.localRotation = Quaternion.Euler(0f, 0f, num2); } } private void FlashBomb() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)emissiveMaterial != (Object)null) { float num = flashSpeed * (1f + fuseProgress * 2f); flashTimer += Time.deltaTime * num; float num2 = (Mathf.Sin(flashTimer) + 1f) * 0.5f; Color val = Color.Lerp(normalColor, flashColor, num2); emissiveMaterial.SetColor("_EmissionColor", val); } } public override void OnSpawn() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) base.OnSpawn(); isFuseActive = false; fuseProgress = 0f; if ((Object)(object)bombModel != (Object)null) { bombModel.SetActive(true); } if ((Object)(object)emissiveMaterial != (Object)null) { emissiveMaterial.SetColor("_EmissionColor", normalColor); } if ((Object)(object)fuseTransform != (Object)null) { fuseTransform.localScale = Vector3.one; fuseTransform.localRotation = Quaternion.identity; } if ((Object)(object)animator != (Object)null) { animator.SetBool("IsFused", false); } } [PunRPC] public void ExplodeAnimRPC() { OnExplode(); } [PunRPC] public void StartFuseRPC() { StartFuse(); } } public class ExplosionEffect : MonoBehaviour { public float lifetime = 2f; private void Start() { Object.Destroy((Object)(object)((Component)this).gameObject, lifetime); } } public class ScaredyEnemy : BaseModEnemy { public new enum State { Spawn, Idle, Roam, Investigate, Startled, Flee, Hide, Stun, Despawn } [Header("Scaredy Settings")] [Tooltip("Duration of the startled animation before fleeing")] public float startledDuration = 0.5f; [Tooltip("Speed multiplier when fleeing")] public float fleeSpeedMultiplier = 2.5f; [Tooltip("How far away to flee from the player (minimum)")] public float fleeDistance = 30f; [Tooltip("How far the enemy can move before warping the nav agent to match")] public float positionSyncThreshold = 2f; private Vector3 lastSyncPosition; [Header("Effects")] [Tooltip("Sound played when startled")] public Sound startledSound; [Tooltip("Particle effect when startled")] public ParticleSystem startledParticleEffect; [Header("References")] public ScaredyEnemyAnim scaredyAnim; public Transform eyeLocation; internal bool isOnScreen; private float lookAtTimer; private const float LOOK_THRESHOLD = 1f; private Vector3 fleeDestination; private float originalSpeed; private Vector3 lastPlayerPosition; [Tooltip("Duration to hide after fleeing")] public float hideDuration = 5f; public new State currentState { get { return (State)base.currentState; } set { base.currentState = (BaseModEnemy.State)value; } } protected override void Awake() { base.Awake(); if ((Object)(object)scaredyAnim == (Object)null) { scaredyAnim = ((Component)this).GetComponentInChildren<ScaredyEnemyAnim>(); } } protected virtual void LateUpdate() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)navMeshAgent != (Object)null) || !((Behaviour)navMeshAgent).enabled) { return; } Rigidbody val = null; if ((Object)(object)enemy != (Object)null) { val = ((Component)enemy).GetComponent<Rigidbody>(); if ((Object)(object)val == (Object)null) { val = ((Component)enemy).GetComponentInChildren<Rigidbody>(); } } if ((Object)(object)val != (Object)null && Vector3.Distance(((Component)this).transform.position, val.position) > positionSyncThreshold) { if (navMeshAgent.hasPath && currentState == State.Flee) { Vector3 position = ((Component)this).transform.position; position.y = val.position.y; val.position = position; val.velocity = Vector3.zero; } else { navMeshAgent.Warp(val.position); } lastSyncPosition = ((Component)this).transform.position; } } protected override void Start() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) base.Start(); if ((Object)(object)navMeshAgent != (Object)null) { originalSpeed = navMeshAgent.speed; navMeshAgent.stoppingDistance = 0.5f; navMeshAgent.radius = 0.4f; navMeshAgent.height = 1.8f; navMeshAgent.baseOffset = 0f; navMeshAgent.autoTraverseOffMeshLink = true; navMeshAgent.autoRepath = true; } lastSyncPosition = ((Component)this).transform.position; if (!((Object)(object)enemy != (Object)null)) { return; } Rigidbody val = ((Component)enemy).GetComponent<Rigidbody>(); if ((Object)(object)val == (Object)null) { val = ((Component)enemy).GetComponentInChildren<Rigidbody>(); } if ((Object)(object)val != (Object)null) { val.drag = 1f; val.angularDrag = 0.5f; val.useGravity = false; } MonoBehaviour component = ((Component)enemy).GetComponent<MonoBehaviour>(); if ((Object)(object)component != (Object)null && ((object)component).GetType().Name.Contains("Vision")) { MethodInfo method = ((object)component).GetType().GetMethod("InitializeVisionsDictionary", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { method.Invoke(component, null); } } } protected virtual void FixedUpdate() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0094: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)enemy != (Object)null)) { return; } Rigidbody val = ((Component)enemy).GetComponent<Rigidbody>(); if ((Object)(object)val == (Object)null) { val = ((Component)enemy).GetComponentInChildren<Rigidbody>(); } if ((Object)(object)val != (Object)null && currentState != State.Flee && currentState != State.Roam && (Object)(object)navMeshAgent != (Object)null && !navMeshAgent.hasPath) { Vector3 position = ((Component)val).transform.position; position.y = ((Component)this).transform.position.y; ((Component)this).transform.position = position; if (val.velocity.y < -0.5f) { Vector3 velocity = val.velocity; velocity.y = 0f; val.velocity = velocity; } } } protected override void Update() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 if (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient) { ProcessTimers(); CheckIfSeenByPlayer(); if (enemy.IsStunned()) { base.UpdateState(BaseModEnemy.State.Stun); } else if ((int)enemy.CurrentState == 11) { base.UpdateState(BaseModEnemy.State.Despawn); } switch (currentState) { case State.Spawn: StateSpawn(); break; case State.Idle: StateIdle(); break; case State.Roam: StateRoam(); AgentVelocityRotation(); break; case State.Investigate: StateInvestigate(); AgentVelocityRotation(); break; case State.Startled: StateStartled(); PlayerLookAt(); break; case State.Flee: StateFlee(); AgentVelocityRotation(); break; case State.Hide: StateHide(); break; case State.Stun: StateStun(); break; case State.Despawn: StateDespawn(); break; } } } protected override void StatePlayerNotice() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { if ((Object)(object)playerTarget != (Object)null) { lastPlayerPosition = ((Component)playerTarget).transform.position; } stateTimer = 0.2f; stateImpulse = false; } stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { SetScaredyState(State.Startled); } } protected virtual void StateStartled() { if (stateImpulse) { navMeshAgent.ResetPath(); navMeshAgent.isStopped = true; if (GameManager.Multiplayer()) { photonView.RPC("StartledRPC", (RpcTarget)0, Array.Empty<object>()); } else { PlayStartledEffects(); } stateTimer = startledDuration; stateImpulse = false; } stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { CalculateFleeDestination(); navMeshAgent.isStopped = false; SetScaredyState(State.Flee); } } protected virtual void StateFlee() { //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0237: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { if ((Object)(object)navMeshAgent != (Object)null) { navMeshAgent.speed = originalSpeed * fleeSpeedMultiplier; navMeshAgent.angularSpeed = 360f; navMeshAgent.acceleration = 12f; navMeshAgent.autoBraking = false; } navMeshAgent.SetDestination(fleeDestination); if ((Object)(object)scaredyAnim != (Object)null) { if (GameManager.Multiplayer()) { photonView.RPC("FleeRPC", (RpcTarget)0, Array.Empty<object>()); } else { scaredyAnim.Flee(); } } stateTimer = 10f; stateImpulse = false; } if ((Object)(object)enemy != (Object)null) { Rigidbody val = ((Component)enemy).GetComponent<Rigidbody>(); if ((Object)(object)val == (Object)null) { val = ((Component)enemy).GetComponentInChildren<Rigidbody>(); } if ((Object)(object)val != (Object)null && navMeshAgent.hasPath && (int)navMeshAgent.pathStatus == 0) { Vector3 position = ((Component)this).transform.position; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(position.x, ((Component)val).transform.position.y, position.z); NavMeshHit val3 = default(NavMeshHit); if (NavMesh.SamplePosition(val2, ref val3, 1f, -1) && ((NavMeshHit)(ref val3)).position.y > val2.y) { val2.y = ((NavMeshHit)(ref val3)).position.y; } ((Component)val).transform.position = val2; if (val.velocity.y < 0f) { Vector3 velocity = val.velocity; velocity.y = 0f; val.velocity = velocity; } Vector3 velocity2 = navMeshAgent.velocity; if (((Vector3)(ref velocity2)).magnitude > 0.5f) { velocity2 = navMeshAgent.velocity; Quaternion val4 = Quaternion.LookRotation(((Vector3)(ref velocity2)).normalized); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val4, Time.deltaTime * 8f); ((Component)val).transform.rotation = ((Component)this).transform.rotation; } } } if (Vector3.Distance(((Component)this).transform.position, fleeDestination) < 2f || stateTimer <= 0f) { if ((Object)(object)navMeshAgent != (Object)null) { navMeshAgent.speed = originalSpeed; navMeshAgent.angularSpeed = 120f; navMeshAgent.acceleration = 8f; navMeshAgent.autoBraking = true; } SetScaredyState(State.Hide); } else { stateTimer -= Time.deltaTime; } } protected virtual void StateHide() { if (stateImpulse) { if ((Object)(object)navMeshAgent != (Object)null) { navMeshAgent.speed = originalSpeed; } navMeshAgent.ResetPath(); if ((Object)(object)scaredyAnim != (Object)null) { if (GameManager.Multiplayer()) { photonView.RPC("HideRPC", (RpcTarget)0, Array.Empty<object>()); } else { scaredyAnim.Hide(); } } stateTimer = hideDuration; stateImpulse = false; } stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { base.UpdateState(BaseModEnemy.State.Idle); } } protected void SetScaredyState(State state) { base.UpdateState((BaseModEnemy.State)state); } protected virtual void CheckIfSeenByPlayer() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (currentState == State.Startled || currentState == State.Flee || currentState == State.Hide) { lookAtTimer = 0f; return; } List<PlayerAvatar> playerList = GameDirector.instance.PlayerList; bool flag = false; foreach (PlayerAvatar item in playerList) { if (!((Object)(object)item == (Object)null) && !((Object)(object)((Component)item).gameObject == (Object)null) && ((Component)item).gameObject.activeInHierarchy && !(Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position) > 15f) && IsVisibleToPlayer(item)) { flag = true; playerTarget = item; lastPlayerPosition = ((Component)item).transform.position; if (GameManager.Multiplayer()) { photonView.RPC("UpdatePlayerTargetRPC", (RpcTarget)1, new object[1] { playerTarget.photonView.ViewID }); } if (lookAtTimer <= 0f) { lookAtTimer = 1f; } break; } } if (flag) { lookAtTimer -= Time.deltaTime; if (lookAtTimer <= 0f) { SetScaredyState(State.Startled); } } else { lookAtTimer = 1f; } } protected virtual bool IsVisibleToPlayer(PlayerAvatar player) { //IL_000b: 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) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0022: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Vector3 position = player.PlayerVisionTarget.VisionTransform.position; Vector3 val = ((Component)this).transform.position - position; RaycastHit val2 = default(RaycastHit); if (Vector3.Dot(player.PlayerVisionTarget.VisionTransform.forward, ((Vector3)(ref val)).normalized) > 0.5f && Physics.Raycast(position, val, ref val2, 20f, LayerMask.GetMask(new string[2] { "Default", "Enemy" })) && ((Object)(object)((RaycastHit)(ref val2)).transform == (Object)(object)((Component)this).transform || ((RaycastHit)(ref val2)).transform.IsChildOf(((Component)this).transform))) { SemiFunc.DoNotLookEffect(((Component)this).gameObject, true, true, true, true, true, true); isOnScreen = true; return true; } isOnScreen = false; return false; } protected virtual void CalculateFleeDestination() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_002f: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; if ((Object)(object)playerTarget != (Object)null) { val = ((Component)this).transform.position - ((Component)playerTarget).transform.position; } else if (lastPlayerPosition != Vector3.zero) { val = ((Component)this).transform.position - lastPlayerPosition; } else { val = Random.insideUnitSphere; val.y = 0f; } ((Vector3)(ref val)).Normalize(); bool flag = false; NavMeshHit val2 = default(NavMeshHit); for (float num = fleeDistance; num >= fleeDistance * 0.5f; num -= 5f) { if (NavMesh.SamplePosition(((Component)this).transform.position + val * num, ref val2, 10f, -1)) { fleeDestination = ((NavMeshHit)(ref val2)).position; flag = true; break; } } if (!flag) { LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, fleeDistance, fleeDistance * 2f, false); if (!Object.op_Implicit((Object)(object)val3)) { val3 = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f); } if (Object.op_Implicit((Object)(object)val3)) { fleeDestination = ((Component)val3).transform.position; NavMeshHit val4 = default(NavMeshHit); if (NavMesh.SamplePosition(fleeDestination, ref val4, 10f, -1)) { fleeDestination = ((NavMeshHit)(ref val4)).position; } } else { fleeDestination = ((Component)this).transform.position + Random.insideUnitSphere * fleeDistance; fleeDestination.y = ((Component)this).transform.position.y; NavMeshHit val5 = default(NavMeshHit); if (NavMesh.SamplePosition(fleeDestination, ref val5, 10f, -1)) { fleeDestination = ((NavMeshHit)(ref val5)).position; } } } Debug.DrawLine(((Component)this).transform.position, fleeDestination, Color.yellow, 3f); } protected virtual void PlayStartledEffects() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (startledSound != null) { startledSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } if ((Object)(object)startledParticleEffect != (Object)null) { startledParticleEffect.Play(); } if ((Object)(object)scaredyAnim != (Object)null) { scaredyAnim.Startled(); } } public override void OnVisionTriggered() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0078: 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) if (!SemiFunc.IsMasterClientOrSingleplayer() || (currentState != State.Idle && currentState != State.Roam && currentState != State.Investigate)) { return; } PlayerAvatar val = null; MonoBehaviour component = ((Component)enemy).GetComponent<MonoBehaviour>(); if ((Object)(object)component != (Object)null) { FieldInfo field = ((object)component).GetType().GetField("onVisionTriggeredPlayer"); if (field != null) { val = (PlayerAvatar)field.GetValue(component); } if ((Object)(object)val != (Object)null) { playerTarget = val; lastPlayerPosition = ((Component)val).transform.position; if (GameManager.Multiplayer()) { photonView.RPC("UpdatePlayerTargetRPC", (RpcTarget)1, new object[1] { playerTarget.photonView.ViewID }); } } } base.UpdateState(BaseModEnemy.State.PlayerNotice); } [PunRPC] protected void StartledRPC() { PlayStartledEffects(); } [PunRPC] protected void HideRPC() { if ((Object)(object)scaredyAnim != (Object)null) { scaredyAnim.Hide(); } } } public class ScaredyEnemyAnim : BaseModEnemyAnim { [Header("Scaredy-specific References")] public ScaredyEnemy scaredyBrain; [Header("Visual Components")] [Tooltip("Optional - eye objects that will widen when startled")] public Transform[] eyes; [Tooltip("Scale multiplier for eyes when startled")] public float eyeScaleWhenStartled = 1.5f; [Tooltip("How quickly the eyes return to normal size")] public float eyeReturnSpeed = 1f; [Tooltip("Optional - body transform that will react to startle")] public Transform bodyTransform; [Tooltip("Optional - reference to renderer for material effects")] public Renderer bodyRenderer; [Tooltip("Optional - hiding spot object that appears when hiding")] public GameObject hidingObject; [Header("Animation Settings")] [Tooltip("How high the character jumps when startled")] public float startleJumpHeight = 0.5f; [Tooltip("Duration of startled jump")] public float startleJumpDuration = 0.3f; [Tooltip("Shake intensity when startled")] public float startleShakeIntensity = 0.2f; [Tooltip("Shake frequency when startled")] public float startleShakeFrequency = 15f; private Vector3[] originalEyeScales; private Vector3[] currentEyeScales; private bool isStartled; private bool isHiding; private float startleTimer; private Vector3 originalPosition; private Color originalEmissionColor; private Material emissionMaterial; protected int animStartledHash; protected int animFleeHash; protected int animHideHash; protected override void Awake() { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) base.Awake(); if ((Object)(object)scaredyBrain == (Object)null) { scaredyBrain = ((Component)this).GetComponentInParent<ScaredyEnemy>(); } if (eyes != null && eyes.Length != 0) { originalEyeScales = (Vector3[])(object)new Vector3[eyes.Length]; currentEyeScales = (Vector3[])(object)new Vector3[eyes.Length]; for (int i = 0; i < eyes.Length; i++) { if ((Object)(object)eyes[i] != (Object)null) { originalEyeScales[i] = eyes[i].localScale; currentEyeScales[i] = originalEyeScales[i]; } } } if ((Object)(object)bodyRenderer != (Object)null && bodyRenderer.material.HasProperty("_EmissionColor")) { emissionMaterial = bodyRenderer.material; originalEmissionColor = emissionMaterial.GetColor("_EmissionColor"); } animStartledHash = Animator.StringToHash("Startled"); animFleeHash = Animator.StringToHash("Flee"); animHideHash = Animator.StringToHash("Hide"); if ((Object)(object)hidingObject != (Object)null) { hidingObject.SetActive(false); } } protected override void Update() { //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) base.Update(); if (isStartled && eyes != null && eyes.Length != 0) { for (int i = 0; i < eyes.Length; i++) { if ((Object)(object)eyes[i] != (Object)null) { eyes[i].localScale = currentEyeScales[i]; } } } else if (!isStartled && eyes != null && eyes.Length != 0) { for (int j = 0; j < eyes.Length; j++) { if ((Object)(object)eyes[j] != (Object)null && currentEyeScales[j] != originalEyeScales[j]) { currentEyeScales[j] = Vector3.Lerp(currentEyeScales[j], originalEyeScales[j], Time.deltaTime * eyeReturnSpeed); eyes[j].localScale = currentEyeScales[j]; } } } if (startleTimer > 0f) { startleTimer -= Time.deltaTime; if ((Object)(object)bodyTransform != (Object)null) { float num = 1f - startleTimer / startleJumpDuration; float num2 = startleJumpHeight * 4f * num * (1f - num); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Sin(Time.time * startleShakeFrequency) * startleShakeIntensity, 0f, Mathf.Cos(Time.time * startleShakeFrequency * 0.9f) * startleShakeIntensity); Vector3 val2 = originalPosition; val2.y += num2; bodyTransform.localPosition = val2 + val; } if (startleTimer <= 0f && (Object)(object)bodyTransform != (Object)null) { bodyTransform.localPosition = originalPosition; } } } public void Startled() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) isStartled = true; if ((Object)(object)animator != (Object)null) { animator.SetTrigger(animStartledHash); } if (eyes != null && eyes.Length != 0) { for (int i = 0; i < eyes.Length; i++) { if ((Object)(object)eyes[i] != (Object)null) { currentEyeScales[i] = originalEyeScales[i] * eyeScaleWhenStartled; } } } if ((Object)(object)bodyTransform != (Object)null) { originalPosition = bodyTransform.localPosition; startleTimer = startleJumpDuration; } if ((Object)(object)emissionMaterial != (Object)null) { emissionMaterial.SetColor("_EmissionColor", Color.white); ((MonoBehaviour)this).StartCoroutine(ResetEmissionColor()); } ((MonoBehaviour)this).Invoke("EndStartled", 1f); } public void Flee() { if ((Object)(object)animator != (Object)null) { animator.SetTrigger(animFleeHash); animator.SetBool("IsFleeing", true); } } public void Hide() { isHiding = true; if ((Object)(object)animator != (Object)null) { animator.SetTrigger(animHideHash); animator.SetBool("IsHiding", true); } if ((Object)(object)hidingObject != (Object)null) { hidingObject.SetActive(true); } } public void EndHide() { isHiding = false; if ((Object)(object)animator != (Object)null) { animator.SetBool("IsHiding", false); } if ((Object)(object)hidingObject != (Object)null) { hidingObject.SetActive(false); } } private void EndStartled() { isStartled = false; } private IEnumerator ResetEmissionColor() { yield return (object)new WaitForSeconds(0.5f); if ((Object)(object)emissionMaterial != (Object)null) { float t = 0f; Color startColor = Color.white; while (t < 1f) { t += Time.deltaTime * 2f; emissionMaterial.SetColor("_EmissionColor", Color.Lerp(startColor, originalEmissionColor, t)); yield return null; } emissionMaterial.SetColor("_EmissionColor", originalEmissionColor); } } public override void OnSpawn() { base.OnSpawn(); isStartled = false; isHiding = false; if ((Object)(object)animator != (Object)null) { animator.SetBool("IsFleeing", false); animator.SetBool("IsHiding", false); } if ((Object)(object)hidingObject != (Object)null) { hidingObject.SetActive(false); } } [PunRPC] public void StartledRPC() { Startled(); } [PunRPC] public void FleeRPC() { Flee(); } [PunRPC] public void HideRPC() { Hide(); } [PunRPC] public void EndHideRPC() { EndHide(); } } namespace REPOMonsters { [BepInPlugin("com.username.repovacuum", "REPO Vacuum Enemy", "1.0.0")] public class VacuumPlugin : BaseUnityPlugin { private static Dictionary<EnemyBowtie, AudioSource> vacuumSounds = new Dictionary<EnemyBowtie, AudioSource>(); private static AudioClip vacuumSoundClip = null; private static bool patchesApplied = false; private void Awake() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.LogInfo((object)"Vacuum Enemy Plugin is starting!"); new Harmony("com.username.repovacuum").PatchAll(typeof(VacuumPlugin)); patchesApplied = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Vacuum Enemy patches applied successfully!"); } [HarmonyPatch(typeof(EnemyBowtieAnim), "YellStart")] [HarmonyPostfix] private static void YellStartPatch(EnemyBowtieAnim __instance) { //IL_003c: 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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0070: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) EnemyBowtie controller = __instance.controller; if ((Object)(object)controller == (Object)null) { return; } Transform val = controller.verticalRotationTransform; if ((Object)(object)val == (Object)null) { val = ((Component)controller).transform; } MinMaxCurve startSpeed; if ((Object)(object)__instance.particleYell != (Object)null) { MainModule main = __instance.particleYell.main; startSpeed = ((MainModule)(ref main)).startSpeed; ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit((0f - Mathf.Abs(((MinMaxCurve)(ref startSpeed)).constant)) * 1.5f); ShapeModule shape = __instance.particleYell.shape; if (((ShapeModule)(ref shape)).enabled) { ((ShapeModule)(ref shape)).rotation = new Vector3(180f, 0f, 0f); } } if ((Object)(object)__instance.particleYellSmall != (Object)null) { MainModule main2 = __instance.particleYellSmall.main; startSpeed = ((MainModule)(ref main2)).startSpeed; ((MainModule)(ref main2)).startSpeed = MinMaxCurve.op_Implicit((0f - Mathf.Abs(((MinMaxCurve)(ref startSpeed)).constant)) * 1.5f); ShapeModule shape2 = __instance.particleYellSmall.shape; if (((ShapeModule)(ref shape2)).enabled) { ((ShapeModule)(ref shape2)).rotation = new Vector3(180f, 0f, 0f); } } AudioSource val2 = null; if (vacuumSounds.ContainsKey(controller)) { val2 = vacuumSounds[controller]; } else { val2 = ((Component)controller).gameObject.AddComponent<AudioSource>(); val2.loop = true; val2.spatialBlend = 1f; val2.minDistance = 1f; val2.maxDistance = 20f; val2.rolloffMode = (AudioRolloffMode)1; val2.volume = 0.8f; val2.pitch = 1f; if ((Object)(object)vacuumSoundClip != (Object)null) { val2.clip = vacuumSoundClip; } else { AudioSource[] components = ((Component)controller).gameObject.GetComponents<AudioSource>(); foreach (AudioSource val3 in components) { if ((Object)(object)val3 != (Object)(object)val2 && (Object)(object)val3.clip != (Object)null) { val2.clip = val3.clip; val2.pitch = 0.6f; break; } } } vacuumSounds[controller] = val2; } if ((Object)(object)val2.clip != (Object)null) { val2.Play(); } ((MonoBehaviour)controller).StartCoroutine(VacuumCoroutine(controller, val)); } private static AudioClip AccessAudioClip(Sound sound) { try { FieldInfo field = typeof(Sound).GetField("audioClip", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object? value = field.GetValue(sound); return (AudioClip)((value is AudioClip) ? value : null); } FieldInfo field2 = typeof(Sound).GetField("audioSource", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null) { object? value2 = field2.GetValue(sound); AudioSource val = (AudioSource)((value2 is AudioSource) ? value2 : null); if ((Object)(object)val != (Object)null) { return val.clip; } } return null; } catch { return null; } } [HarmonyPatch(typeof(EnemyBowtieAnim), "YellStop")] [HarmonyPostfix] private static void YellStopPatch(EnemyBowtieAnim __instance) { EnemyBowtie controller = __instance.controller; if ((Object)(object)controller != (Object)null && vacuumSounds.ContainsKey(controller)) { AudioSource val = vacuumSounds[controller]; if ((Object)(object)val != (Object)null) { val.Stop(); } } } private static IEnumerator VacuumCoroutine(EnemyBowtie controller, Transform suctionOrigin) { float suctionRadius = 8f; float suctionForce = 25f; float duration = 4.5f; float elapsed = 0f; Rigidbody enemyRb = ((Component)controller).GetComponent<Rigidbody>(); if ((Object)(object)enemyRb == (Object)null) { enemyRb = ((Component)controller).GetComponentInChildren<Rigidbody>(); } Transform enemyTransform = ((Component)controller).transform; List<PhysGrabObject> affectedObjects = new List<PhysGrabObject>(); Vector3 position = suctionOrigin.position; Debug.Log((object)("Vacuum effect started at " + ((object)(Vector3)(ref position)).ToString())); while (elapsed < duration && (Object)(object)controller != (Object)null && (int)controller.currentState == 5) { if ((Object)(object)enemyRb != (Object)null) { enemyRb.velocity = Vector3.zero; enemyRb.angularVelocity = Vector3.zero; } Collider[] array = Physics.OverlapSphere(suctionOrigin.position, suctionRadius, LayerMask.GetMask(new string[3] { "PhysGrabObject", "Default", "Player" })); Debug.Log((object)$"Found {array.Length} objects in vacuum radius"); Collider[] array2 = array; foreach (Collider val in array2) { Rigidbody attachedRigidbody = val.attachedRigidbody; if ((Object)(object)attachedRigidbody == (Object)null || (Object)(object)attachedRigidbody == (Object)(object)enemyRb || (Object)(object)((Component)val).transform == (Object)(object)enemyTransform || ((Component)val).transform.IsChildOf(enemyTransform) || ((Object)(object)((Component)val).transform.parent != (Object)null && (Object)(object)((Component)((Component)val).transform.parent).GetComponentInParent<EnemyBowtie>() == (Object)(object)controller)) { continue; } Vector3 val2 = suctionOrigin.position - attachedRigidbody.position; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude > suctionRadius)) { ((Vector3)(ref val2)).Normalize(); float num = suctionForce * (1f - magnitude / suctionRadius); PlayerAvatar componentInParent = ((Component)val).GetComponentInParent<PlayerAvatar>(); if ((Object)(object)componentInParent != (Object)null) { num *= 1.5f; SemiFunc.PlayerEyesOverride(componentInParent, suctionOrigin.position, 0.5f, ((Component)controller).gameObject); Debug.Log((object)$"Applying pull force to player: {num} in direction {val2}"); } attachedRigidbody.AddForce(val2 * num, (ForceMode)5); PhysGrabObject component = ((Component)attachedRigidbody).GetComponent<PhysGrabObject>(); if ((Object)(object)component != (Object)null && !affectedObjects.Contains(component)) { component.OverrideZeroGravity(0.1f); component.OverrideMass(0.1f, 0.1f); affectedObjects.Add(component); } } } elapsed += Time.deltaTime; yield return (object)new WaitForFixedUpdate(); } foreach (PhysGrabObject item in affectedObjects) { if ((Object)(object)item != (Object)null) { item.ResetMass(); } } affectedObjects.Clear(); if ((Object)(object)controller != (Object)null && (Object)(object)controller.anim != (Object)null) { EnemyBowtieAnim anim = controller.anim; MinMaxCurve startSpeed; if ((Object)(object)anim.particleYell != (Object)null) { MainModule main = anim.particleYell.main; startSpeed = ((MainModule)(ref main)).startSpeed; ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(Mathf.Abs(((MinMaxCurve)(ref startSpeed)).constant)); ShapeModule shape = anim.particleYell.shape; if (((ShapeModule)(ref shape)).enabled) { ((ShapeModule)(ref shape)).rotation = new Vector3(0f, 0f, 0f); } } if ((Object)(object)anim.particleYellSmall != (Object)null) { MainModule main2 = anim.particleYellSmall.main; startSpeed = ((MainModule)(ref main2)).startSpeed; ((MainModule)(ref main2)).startSpeed = MinMaxCurve.op_Implicit(Mathf.Abs(((MinMaxCurve)(ref startSpeed)).constant)); ShapeModule shape2 = anim.particleYellSmall.shape; if (((ShapeModule)(ref shape2)).enabled) { ((ShapeModule)(ref shape2)).rotation = new Vector3(0f, 0f, 0f); } } } if ((Object)(object)controller != (Object)null && vacuumSounds.ContainsKey(controller)) { AudioSource val3 = vacuumSounds[controller]; if ((Object)(object)val3 != (Object)null && val3.isPlaying) { val3.Stop(); } } } public void LoadVacuumSoundAsset(string assetBundlePath) { try { AssetBundle val = AssetBundle.LoadFromFile(assetBundlePath); if ((Object)(object)val != (Object)null) { vacuumSoundClip = val.LoadAsset<AudioClip>("vacuum_sound"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Vacuum sound loaded successfully!"); } else { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load asset bundle: " + assetBundlePath)); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Error loading vacuum sound: " + ex.Message)); } } } }