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 MacronEnemy v1.2.0
BepInEx\plugins\MacronEnemy\MacronMod.dll
Decompiled a month agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using MacronMod; using MacronMod.NetcodePatcher; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Networking; using UnityEngine.SceneManagement; [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("MacronMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MacronMod")] [assembly: AssemblyTitle("MacronMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } 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 MacronAI : EnemyAI { private enum State { Wandering, Chasing, Attacking, Passive } [CompilerGenerated] private sealed class <DespawnBody>d__51 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MacronAI <>4__this; private Renderer[] <renderers>5__2; private Color[] <origColors>5__3; private float <fadeDuration>5__4; private float <elapsed>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DespawnBody>d__51(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <renderers>5__2 = null; <origColors>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; MacronAI macronAI = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; <renderers>5__2 = ((Component)macronAI).GetComponentsInChildren<Renderer>(true); <origColors>5__3 = (Color[])(object)new Color[<renderers>5__2.Length]; for (int i = 0; i < <renderers>5__2.Length; i++) { if ((Object)(object)<renderers>5__2[i].material != (Object)null) { <origColors>5__3[i] = <renderers>5__2[i].material.GetColor("_BaseColor"); } } <>2__current = (object)new WaitForSeconds(7f); <>1__state = 1; return true; } case 1: <>1__state = -1; <fadeDuration>5__4 = 3f; <elapsed>5__5 = 0f; break; case 2: <>1__state = -1; break; } if (<elapsed>5__5 < <fadeDuration>5__4) { <elapsed>5__5 += Time.deltaTime; float a = 1f - <elapsed>5__5 / <fadeDuration>5__4; for (int j = 0; j < <renderers>5__2.Length; j++) { if ((Object)(object)<renderers>5__2[j] != (Object)null && (Object)(object)<renderers>5__2[j].material != (Object)null) { Color val = <origColors>5__3[j]; val.a = a; <renderers>5__2[j].material.SetColor("_BaseColor", val); } } <>2__current = null; <>1__state = 2; return true; } ((EnemyAI)macronAI).EnableEnemyMesh(false, false); if (((NetworkBehaviour)macronAI).IsServer) { NetworkObject component = ((Component)macronAI).GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null && component.IsSpawned) { component.Despawn(true); } } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DoAttack>d__47 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MacronAI <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DoAttack>d__47(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_0087: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; MacronAI macronAI = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; macronAI._attackTimer = macronAI.attackCooldown; <>2__current = (object)new WaitForSeconds(0.6f); <>1__state = 1; return true; case 1: <>1__state = -1; if (((NetworkBehaviour)macronAI).IsOwner && (Object)(object)((EnemyAI)macronAI).targetPlayer != (Object)null && !((EnemyAI)macronAI).targetPlayer.isPlayerDead) { float num2 = Vector3.Distance(((Component)macronAI).transform.position, ((Component)((EnemyAI)macronAI).targetPlayer).transform.position); if (num2 <= macronAI.attackRange + 1.5f) { Debug.Log((object)$"[Macron] DoAttack → dégâts {macronAI.damage} sur joueur {((EnemyAI)macronAI).targetPlayer.playerClientId} dist={num2:F2}m"); ((EnemyAI)macronAI).targetPlayer.DamagePlayer((int)macronAI.damage, true, true, (CauseOfDeath)6, 0, false, ((Component)macronAI).transform.forward * 5f); } } <>2__current = (object)new WaitForSeconds(0.9f); <>1__state = 2; return true; case 2: <>1__state = -1; macronAI._isAttacking = false; if (((EnemyAI)macronAI).currentBehaviourStateIndex == 2) { ((EnemyAI)macronAI).SwitchToBehaviourState(1); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SelfActivate>d__34 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MacronAI <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SelfActivate>d__34(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown int num = <>1__state; MacronAI macronAI = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(2f); <>1__state = 1; return true; case 1: <>1__state = -1; if (!macronAI._ready) { macronAI._ready = true; if ((Object)(object)((EnemyAI)macronAI).agent != (Object)null) { ((Behaviour)((EnemyAI)macronAI).agent).enabled = true; } ((EnemyAI)macronAI).EnableEnemyMesh(true, false); } if ((Object)(object)macronAI._musicSource != (Object)null && !macronAI._musicSource.isPlaying) { macronAI.PlayMusic(macronAI.walkMusic); } if (((NetworkBehaviour)macronAI).IsOwner && !macronAI._wanderStarted) { macronAI._wanderStarted = true; ((MonoBehaviour)macronAI).StartCoroutine(macronAI.WanderCoroutine()); } Debug.Log((object)string.Format("[Macron] SelfActivate OK — walkMusic={0}, musicPlaying={1}, IsOwner={2}", ((Object)(object)macronAI.walkMusic != (Object)null) ? "OK" : "NULL", (Object)(object)macronAI._musicSource != (Object)null && macronAI._musicSource.isPlaying, ((NetworkBehaviour)macronAI).IsOwner)); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WanderCoroutine>d__46 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MacronAI <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WanderCoroutine>d__46(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_004e: 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_0060: 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_0068: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; MacronAI macronAI = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (!((EnemyAI)macronAI).isEnemyDead) { if (((EnemyAI)macronAI).currentBehaviourStateIndex == 0 && (Object)(object)((EnemyAI)macronAI).agent != (Object)null && ((EnemyAI)macronAI).agent.isOnNavMesh) { Vector3 randomNavMeshPositionInRadius = RoundManager.Instance.GetRandomNavMeshPositionInRadius(((Component)macronAI).transform.position, 15f, default(NavMeshHit)); ((EnemyAI)macronAI).SetDestinationToPosition(randomNavMeshPositionInRadius, false); } <>2__current = (object)new WaitForSeconds(5f); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [Header("Stats Macron")] public float attackRange = 2.5f; public float attackCooldown = 2f; public float detectionRange = 20f; public float damage = 25f; [Header("Audio Macron")] public AudioClip walkMusic; public AudioClip chaseMusic; public AudioClip attackSound; private AudioSource _musicSource; private bool _isAttacking; private float _attackTimer; private bool _ready; private bool _isDancing; private float _losTimer; private bool _wanderStarted; private int _prevState = -1; private float _damageTimer; private Vector3 _lastPos; private const int CLIP_WALK = 0; private const int CLIP_CHASE = 1; private const int CLIP_DANCE1 = 2; private const int CLIP_DANCE2 = 3; private const int CLIP_DANCE3 = 4; private AudioClip ClipByIndex(int i) { return (AudioClip)(i switch { 0 => walkMusic, 1 => chaseMusic, 2 => MacronPlugin.DanceMusic1, 3 => MacronPlugin.DanceMusic2, 4 => MacronPlugin.DanceMusic3, _ => null, }); } [ClientRpc] public void PlayMusicClientRpc(int clipIndex) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0089: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4170129946u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, clipIndex); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4170129946u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer) { PlayMusic(ClipByIndex(clipIndex)); } } } [ClientRpc] public void StopMusicClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1472828369u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1472828369u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer) { StopMusic(); } } } [ClientRpc] public void DamagePlayerClientRpc(int playerIndex, int dmg) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1035746970u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerIndex); BytePacker.WriteValueBitPacked(val2, dmg); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1035746970u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && !networkManager.IsClient && networkManager.IsHost) { } } } [ClientRpc] public void StartDancingClientRpc(int musicIndex) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0089: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1070986932u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, musicIndex); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1070986932u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && !networkManager.IsClient && networkManager.IsHost) { } } } [ClientRpc] public void StopDancingClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3731703532u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3731703532u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && !networkManager.IsClient && networkManager.IsHost) { } } } [ClientRpc] public void BeginAttackClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(399550442u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 399550442u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && !networkManager.IsClient && networkManager.IsHost) { } } } [ClientRpc] public void EndAttackClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3299348883u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3299348883u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && !networkManager.IsClient && networkManager.IsHost) { } } } [ClientRpc] public void PlayDeathSoundClientRpc(int soundIndex) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0089: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1981904846u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, soundIndex); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1981904846u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && !networkManager.IsClient && networkManager.IsHost) { } } } [ClientRpc] public void SyncLootValuesClientRpc(NetworkObjectReference[] items, int[] values) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_00fd: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4240053728u, val, (RpcDelivery)0); bool flag = items != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(items, default(ForNetworkSerializable)); } bool flag2 = values != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(values, default(ForPrimitives)); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4240053728u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && !networkManager.IsClient && networkManager.IsHost) { } } public override void Start() { //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.agent == (Object)null) { base.agent = ((Component)this).GetComponent<NavMeshAgent>(); } AudioSource[] components = ((Component)this).GetComponents<AudioSource>(); if ((Object)(object)base.creatureSFX == (Object)null && components.Length != 0) { base.creatureSFX = components[0]; } if ((Object)(object)base.creatureVoice == (Object)null && components.Length > 1) { base.creatureVoice = components[1]; } if ((Object)(object)base.creatureAnimator == (Object)null) { base.creatureAnimator = ((Component)this).GetComponentInChildren<Animator>(); } _musicSource = ((Component)this).gameObject.AddComponent<AudioSource>(); _musicSource.spatialBlend = 1f; _musicSource.rolloffMode = (AudioRolloffMode)1; _musicSource.maxDistance = 30f; _musicSource.loop = true; _musicSource.volume = 0.8f; try { ((EnemyAI)this).Start(); } catch (Exception ex) { Debug.LogError((object)("[Macron] base.Start() exception: " + ex.Message)); } if ((Object)(object)base.agent != (Object)null) { ((Behaviour)base.agent).enabled = false; } _lastPos = ((Component)this).transform.position; _prevState = -1; ((EnemyAI)this).SwitchToBehaviourState(0); ((MonoBehaviour)this).StartCoroutine(SelfActivate()); } [IteratorStateMachine(typeof(<SelfActivate>d__34))] private IEnumerator SelfActivate() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SelfActivate>d__34(0) { <>4__this = this }; } public override void EnableEnemyMesh(bool enable, bool overrideDoNotSet = false) { ((EnemyAI)this).EnableEnemyMesh(enable, overrideDoNotSet); if (enable && !_ready) { _ready = true; if ((Object)(object)base.agent != (Object)null) { ((Behaviour)base.agent).enabled = true; } PlayMusic(walkMusic); if (((NetworkBehaviour)this).IsOwner && !_wanderStarted) { _wanderStarted = true; ((MonoBehaviour)this).StartCoroutine(WanderCoroutine()); } } } public override void Update() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Update(); if (base.isEnemyDead) { return; } _attackTimer -= Time.deltaTime; _damageTimer -= Time.deltaTime; if (base.currentBehaviourStateIndex != _prevState) { OnStateChanged(_prevState = base.currentBehaviourStateIndex); } if (_isDancing || !((Object)(object)base.creatureAnimator != (Object)null)) { return; } Vector3 val = ((Component)this).transform.position - _lastPos; float magnitude = ((Vector3)(ref val)).magnitude; _lastPos = ((Component)this).transform.position; bool flag = magnitude > 0.001f && !_isAttacking; base.creatureAnimator.SetBool("Walk", flag); if (flag) { AnimatorStateInfo currentAnimatorStateInfo = base.creatureAnimator.GetCurrentAnimatorStateInfo(0); if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime >= 0.99f) { base.creatureAnimator.Play(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash, 0, 0f); } } } private void OnStateChanged(int newState) { //IL_0166: Unknown result type (might be due to invalid IL or missing references) switch (newState) { case 0: _isDancing = false; _isAttacking = false; if ((Object)(object)base.creatureAnimator != (Object)null) { base.creatureAnimator.SetBool("Dance", false); } if ((Object)(object)base.agent != (Object)null && base.agent.isOnNavMesh) { base.agent.isStopped = false; } PlayMusic(walkMusic); break; case 1: _isDancing = false; _isAttacking = false; if ((Object)(object)base.creatureAnimator != (Object)null) { base.creatureAnimator.SetBool("Dance", false); } if ((Object)(object)base.agent != (Object)null && base.agent.isOnNavMesh) { base.agent.isStopped = false; } PlayMusic(chaseMusic); break; case 2: _isAttacking = true; if ((Object)(object)base.creatureAnimator != (Object)null) { base.creatureAnimator.SetTrigger("Attack"); } break; case 3: _isDancing = true; if ((Object)(object)base.creatureAnimator != (Object)null) { base.creatureAnimator.SetBool("Walk", false); base.creatureAnimator.SetBool("Dance", true); } if ((Object)(object)base.agent != (Object)null && base.agent.isOnNavMesh) { base.agent.isStopped = true; base.agent.velocity = Vector3.zero; } PlayDanceMusic(); if (((NetworkBehaviour)this).IsServer) { SpawnShovel(); } break; } } private void PlayDanceMusic() { List<AudioClip> list = new List<AudioClip>(); if ((Object)(object)MacronPlugin.DanceMusic1 != (Object)null) { list.Add(MacronPlugin.DanceMusic1); } if ((Object)(object)MacronPlugin.DanceMusic2 != (Object)null) { list.Add(MacronPlugin.DanceMusic2); } if ((Object)(object)MacronPlugin.DanceMusic3 != (Object)null) { list.Add(MacronPlugin.DanceMusic3); } if (list.Count > 0) { int index = (int)(((NetworkBehaviour)this).NetworkObjectId % (uint)list.Count); PlayMusic(list[index]); } } public override void OnCollideWithPlayer(Collider other) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).OnCollideWithPlayer(other); if (!base.isEnemyDead && !(_damageTimer > 0f) && (base.currentBehaviourStateIndex == 2 || base.currentBehaviourStateIndex == 1)) { PlayerControllerB val = ((Component)other).GetComponent<PlayerControllerB>(); if ((Object)(object)val == (Object)null) { val = ((Component)other).GetComponentInParent<PlayerControllerB>(); } if (!((Object)(object)val == (Object)null) && !val.isPlayerDead && ((NetworkBehaviour)val).IsOwner) { _damageTimer = attackCooldown; val.DamagePlayer((int)damage, true, true, (CauseOfDeath)6, 0, false, default(Vector3)); Debug.Log((object)$"[Macron] Collision → degats {damage} HP sur joueur local"); } } } public override void DoAIInterval() { ((EnemyAI)this).DoAIInterval(); if (!((NetworkBehaviour)this).IsOwner || !_ready || base.isEnemyDead || StartOfRound.Instance.allPlayersDead || (Object)(object)base.agent == (Object)null || !base.agent.isOnNavMesh) { return; } if (!_isDancing && base.currentBehaviourStateIndex != 3) { PlayerControllerB dancingPlayer = GetDancingPlayer(); if ((Object)(object)dancingPlayer != (Object)null) { base.targetPlayer = dancingPlayer; ((EnemyAI)this).SwitchToBehaviourState(3); } } switch (base.currentBehaviourStateIndex) { case 0: DoWandering(); break; case 1: DoChasing(); break; case 3: DoPassive(); break; case 2: break; } } private bool HasLineOfSight(PlayerControllerB player) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_003f: 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_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) Vector3 val = ((Component)this).transform.position + Vector3.up * 1.5f; Vector3 val2 = ((Component)player).transform.position + Vector3.up * 1f - val; return !Physics.Raycast(val, ((Vector3)(ref val2)).normalized, ((Vector3)(ref val2)).magnitude, StartOfRound.Instance.collidersAndRoomMask); } private PlayerControllerB GetDancingPlayer() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!val.isPlayerDead && val.isPlayerControlled && val.performingEmote && Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) <= detectionRange) { return val; } } return null; } private void DoPassive() { if ((Object)(object)base.targetPlayer == (Object)null || base.targetPlayer.isPlayerDead || !base.targetPlayer.performingEmote) { Debug.Log((object)"[Macron] Joueur a arrete de danser, retour Wandering"); ((EnemyAI)this).SwitchToBehaviourState(0); } } private void DoWandering() { //IL_0017: 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) PlayerControllerB closestPlayer = GetClosestPlayer(); if (!((Object)(object)closestPlayer == (Object)null)) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)closestPlayer).transform.position); if (num <= detectionRange && HasLineOfSight(closestPlayer)) { base.targetPlayer = closestPlayer; ((EnemyAI)this).SwitchToBehaviourState(1); Debug.Log((object)$"[Macron] Joueur detecte a {num:F1}m → CHASING"); } } } private void DoChasing() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.targetPlayer == (Object)null || base.targetPlayer.isPlayerDead) { ((EnemyAI)this).SwitchToBehaviourState(0); return; } float num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position); if (num > attackRange && !HasLineOfSight(base.targetPlayer)) { _losTimer += base.AIIntervalTime; if (_losTimer >= 5f) { _losTimer = 0f; ((EnemyAI)this).SwitchToBehaviourState(0); return; } } else { _losTimer = 0f; } if (num > detectionRange * 2f) { _losTimer = 0f; ((EnemyAI)this).SwitchToBehaviourState(0); } else if (num <= attackRange && _attackTimer <= 0f && !_isAttacking) { Debug.Log((object)$"[Macron] ATTAQUE ! dist={num:F2}m"); ((EnemyAI)this).SwitchToBehaviourState(2); ((MonoBehaviour)this).StartCoroutine(DoAttack()); } else if ((Object)(object)base.agent != (Object)null && base.agent.isOnNavMesh) { ((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false); } } [IteratorStateMachine(typeof(<WanderCoroutine>d__46))] private IEnumerator WanderCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WanderCoroutine>d__46(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<DoAttack>d__47))] private IEnumerator DoAttack() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DoAttack>d__47(0) { <>4__this = this }; } public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { ((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID); if (!base.isEnemyDead) { base.enemyHP -= force; Debug.Log((object)$"[Macron] HitEnemy! force={force}, enemyHP restant={base.enemyHP}"); if (base.enemyHP <= 0) { ((EnemyAI)this).KillEnemyOnOwnerClient(false); } } } public override void KillEnemy(bool destroy = false) { ((EnemyAI)this).KillEnemy(destroy); StopMusic(); if ((Object)(object)base.creatureAnimator != (Object)null) { base.creatureAnimator.SetBool("Death", true); } PlayDeathSound(); if (((NetworkBehaviour)this).IsServer) { SpawnLoot(); } ((MonoBehaviour)this).StartCoroutine(DespawnBody()); } private void PlayDeathSound() { if (!((Object)(object)_musicSource == (Object)null)) { AudioClip deathSound = MacronPlugin.DeathSound; AudioClip deathSound2 = MacronPlugin.DeathSound2; AudioClip val = ((((NetworkBehaviour)this).NetworkObjectId % 2 == 0L) ? (deathSound ?? deathSound2) : (deathSound2 ?? deathSound)); if (!((Object)(object)val == (Object)null)) { _musicSource.loop = false; _musicSource.clip = val; _musicSource.Play(); } } } [IteratorStateMachine(typeof(<DespawnBody>d__51))] private IEnumerator DespawnBody() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DespawnBody>d__51(0) { <>4__this = this }; } private void SpawnShovel() { //IL_007d: 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_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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) Item val = null; foreach (Item items in StartOfRound.Instance.allItemsList.itemsList) { if (items.itemName == "Shovel" && (Object)(object)items.spawnPrefab != (Object)null) { val = items; break; } } if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)"[Macron] Prefab Shovel introuvable !"); return; } Vector3 val2 = ((Component)this).transform.position + ((Component)this).transform.forward * 1.5f + Vector3.up * 0.5f; Transform spawnedScrapContainer = RoundManager.Instance.spawnedScrapContainer; GameObject obj = Object.Instantiate<GameObject>(val.spawnPrefab, val2, Quaternion.identity, ((Object)(object)spawnedScrapContainer != (Object)null) ? spawnedScrapContainer : ((Component)this).transform.parent); GrabbableObject component = obj.GetComponent<GrabbableObject>(); if ((Object)(object)component != (Object)null) { ((Component)component).transform.rotation = Quaternion.Euler(val.restingRotation); component.fallTime = 0f; int num = Random.Range(30, 80); component.SetScrapValue(num); Debug.Log((object)$"[Macron] Pelle spawnee devant Macron ! Valeur: {num}"); } NetworkObject component2 = obj.GetComponent<NetworkObject>(); if ((Object)(object)component2 != (Object)null) { component2.Spawn(false); } } private void SpawnLoot() { //IL_0087: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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) List<SpawnableItemWithRarity> spawnableScrap = RoundManager.Instance.currentLevel.spawnableScrap; if (spawnableScrap == null || spawnableScrap.Count == 0) { Debug.Log((object)"[Macron] Aucun scrap dans le niveau pour le loot !"); return; } int num = Random.Range(6, 16); Debug.Log((object)$"[Macron] Drop de {num} items..."); Transform spawnedScrapContainer = RoundManager.Instance.spawnedScrapContainer; for (int i = 0; i < num; i++) { Item spawnableItem = spawnableScrap[Random.Range(0, spawnableScrap.Count)].spawnableItem; if ((Object)(object)spawnableItem.spawnPrefab == (Object)null) { continue; } Vector3 val = ((Component)this).transform.position + new Vector3(Random.Range(-2f, 2f), 0.5f, Random.Range(-2f, 2f)); GameObject obj = Object.Instantiate<GameObject>(spawnableItem.spawnPrefab, val, Quaternion.identity, ((Object)(object)spawnedScrapContainer != (Object)null) ? spawnedScrapContainer : ((Component)this).transform.parent); GrabbableObject component = obj.GetComponent<GrabbableObject>(); if ((Object)(object)component != (Object)null) { ((Component)component).transform.rotation = Quaternion.Euler(spawnableItem.restingRotation); component.fallTime = 0f; int num2 = (int)((float)Random.Range(spawnableItem.minValue, spawnableItem.maxValue + 1) * RoundManager.Instance.scrapValueMultiplier); if (num2 < 1) { num2 = Random.Range(15, 80); } component.SetScrapValue(num2); } NetworkObject component2 = obj.GetComponent<NetworkObject>(); if ((Object)(object)component2 != (Object)null) { component2.Spawn(false); } } } private void PlayMusic(AudioClip clip) { if (!((Object)(object)_musicSource == (Object)null) && !((Object)(object)clip == (Object)null) && (!((Object)(object)_musicSource.clip == (Object)(object)clip) || !_musicSource.isPlaying)) { _musicSource.clip = clip; _musicSource.Play(); } } private void StopMusic() { if ((Object)(object)_musicSource != (Object)null) { _musicSource.Stop(); } } private PlayerControllerB GetClosestPlayer() { //IL_0034: 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) PlayerControllerB result = null; float num = float.MaxValue; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!val.isPlayerDead && val.isPlayerControlled) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); if (num2 < num) { num = num2; result = val; } } } return result; } protected override void __initializeVariables() { ((EnemyAI)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_MacronAI() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(4170129946u, (RpcReceiveHandler)new RpcReceiveHandler(__rpc_handler_4170129946)); NetworkManager.__rpc_func_table.Add(1472828369u, (RpcReceiveHandler)new RpcReceiveHandler(__rpc_handler_1472828369)); NetworkManager.__rpc_func_table.Add(1035746970u, (RpcReceiveHandler)new RpcReceiveHandler(__rpc_handler_1035746970)); NetworkManager.__rpc_func_table.Add(1070986932u, (RpcReceiveHandler)new RpcReceiveHandler(__rpc_handler_1070986932)); NetworkManager.__rpc_func_table.Add(3731703532u, (RpcReceiveHandler)new RpcReceiveHandler(__rpc_handler_3731703532)); NetworkManager.__rpc_func_table.Add(399550442u, (RpcReceiveHandler)new RpcReceiveHandler(__rpc_handler_399550442)); NetworkManager.__rpc_func_table.Add(3299348883u, (RpcReceiveHandler)new RpcReceiveHandler(__rpc_handler_3299348883)); NetworkManager.__rpc_func_table.Add(1981904846u, (RpcReceiveHandler)new RpcReceiveHandler(__rpc_handler_1981904846)); NetworkManager.__rpc_func_table.Add(4240053728u, (RpcReceiveHandler)new RpcReceiveHandler(__rpc_handler_4240053728)); } private static void __rpc_handler_4170129946(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int clipIndex = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex); target.__rpc_exec_stage = (__RpcExecStage)2; ((MacronAI)(object)target).PlayMusicClientRpc(clipIndex); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1472828369(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((MacronAI)(object)target).StopMusicClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1035746970(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int playerIndex = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerIndex); int dmg = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref dmg); target.__rpc_exec_stage = (__RpcExecStage)2; ((MacronAI)(object)target).DamagePlayerClientRpc(playerIndex, dmg); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1070986932(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int musicIndex = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref musicIndex); target.__rpc_exec_stage = (__RpcExecStage)2; ((MacronAI)(object)target).StartDancingClientRpc(musicIndex); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3731703532(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((MacronAI)(object)target).StopDancingClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_399550442(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((MacronAI)(object)target).BeginAttackClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3299348883(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((MacronAI)(object)target).EndAttackClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1981904846(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int soundIndex = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref soundIndex); target.__rpc_exec_stage = (__RpcExecStage)2; ((MacronAI)(object)target).PlayDeathSoundClientRpc(soundIndex); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4240053728(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) //IL_00d1: 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_00a3: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); NetworkObjectReference[] items = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref items, default(ForNetworkSerializable)); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives)); int[] values = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref values, default(ForPrimitives)); } target.__rpc_exec_stage = (__RpcExecStage)2; ((MacronAI)(object)target).SyncLootValuesClientRpc(items, values); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "MacronAI"; } } namespace MacronMod { [BepInPlugin("jamesmod.macron", "Macron Enemy", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MacronPlugin : BaseUnityPlugin { public const string GUID = "jamesmod.macron"; public const string NAME = "Macron Enemy"; public const string VERSION = "1.2.0"; internal static ManualLogSource Log; internal static MacronPlugin Instance; public static EnemyType MacronEnemyType; public static AudioClip WalkingMusic; public static AudioClip ChaseMusic; public static AudioClip DeathSound; public static AudioClip DeathSound2; public static AudioClip DanceMusic1; public static AudioClip DanceMusic2; public static AudioClip DanceMusic3; private static bool _helperCreated; private void Awake() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Chargement du mod Macron..."); InitializeNetcodeRPCs(); LoadAssets(); RegisterEnemy(); new Harmony("jamesmod.macron").PatchAll(Assembly.GetExecutingAssembly()); SceneManager.sceneLoaded += OnSceneLoaded; Log.LogInfo((object)"Macron pret !"); } private static void InitializeNetcodeRPCs() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); int num = 0; Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { bool flag = methodInfo.Name.StartsWith("InitializeRPCS_"); if (!flag) { foreach (CustomAttributeData customAttribute in methodInfo.CustomAttributes) { if (customAttribute.AttributeType.Name == "RuntimeInitializeOnLoadMethodAttribute") { flag = true; break; } } } if (flag && methodInfo.IsStatic) { try { methodInfo.Invoke(null, null); num++; Log.LogInfo((object)("[Netcode] RPC init OK: " + type.Name + "." + methodInfo.Name)); } catch (Exception ex) { Log.LogError((object)("[Netcode] RPC init ECHEC: " + type.Name + "." + methodInfo.Name + " → " + (ex.InnerException?.Message ?? ex.Message))); } } } } Log.LogInfo((object)$"[Netcode] Total RPC handlers enregistres: {num}"); if (num == 0) { Log.LogWarning((object)"[Netcode] AUCUN handler RPC trouve !"); MethodInfo[] methods2 = typeof(MacronAI).GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); Log.LogWarning((object)$"[Netcode] Debug — méthodes statiques de MacronAI ({methods2.Length}):"); MethodInfo[] methods = methods2; foreach (MethodInfo methodInfo2 in methods) { Log.LogWarning((object)("[Netcode] " + methodInfo2.Name)); } } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (!_helperCreated) { _helperCreated = true; GameObject val = new GameObject("MacronSoundLoader"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<MacronSoundLoader>(); } } private void LoadAssets() { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Expected O, but got Unknown //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Expected O, but got Unknown //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Expected O, but got Unknown //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Expected O, but got Unknown AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "macronassets")); if ((Object)(object)val == (Object)null) { Log.LogError((object)"Impossible de charger macronassets !"); return; } GameObject val2 = val.LoadAsset<GameObject>("MacronEnnemy"); if ((Object)(object)val2 == (Object)null) { val2 = val.LoadAsset<GameObject>("macronennemy"); } if ((Object)(object)val2 == (Object)null) { Log.LogError((object)"Prefab non trouve !"); return; } val2.layer = 19; Shader val3 = Shader.Find("HDRP/Lit"); Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val4 in componentsInChildren) { ((Component)val4).gameObject.SetActive(true); ((Component)val4).gameObject.layer = 19; if ((Object)(object)val3 != (Object)null && (Object)(object)val4.sharedMaterial != (Object)null) { Texture mainTexture = val4.sharedMaterial.mainTexture; Color color = val4.sharedMaterial.color; Material val5 = new Material(val3); if ((Object)(object)mainTexture != (Object)null) { val5.SetTexture("_BaseColorMap", mainTexture); } val5.SetColor("_BaseColor", color); val4.sharedMaterial = val5; } SkinnedMeshRenderer val6 = (SkinnedMeshRenderer)(object)((val4 is SkinnedMeshRenderer) ? val4 : null); if (val6 != null) { val6.updateWhenOffscreen = true; } } if ((Object)(object)val3 != (Object)null) { Log.LogInfo((object)"Matériaux convertis vers HDRP/Lit"); } else { Log.LogWarning((object)"Shader HDRP/Lit introuvable au chargement — sera corrigé au runtime"); } val2.transform.localScale = Vector3.one * 1.7f; NetworkObject val7 = val2.GetComponent<NetworkObject>(); if ((Object)(object)val7 == (Object)null) { val7 = val2.AddComponent<NetworkObject>(); } uint num = 2023072077u; FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { field = typeof(NetworkObject).GetField("m_GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); } if (field != null) { field.SetValue(val7, num); Log.LogInfo((object)$"NetworkObject hash force a {num}"); } else { Log.LogWarning((object)"Impossible de forcer le hash NetworkObject — multi peut ne pas fonctionner"); } if ((Object)(object)val2.GetComponent<NavMeshAgent>() == (Object)null) { val2.AddComponent<NavMeshAgent>(); } AudioSource[] components = val2.GetComponents<AudioSource>(); AudioSource creatureSFX = ((components.Length != 0) ? components[0] : val2.AddComponent<AudioSource>()); AudioSource creatureVoice = ((components.Length > 1) ? components[1] : val2.AddComponent<AudioSource>()); MacronAI macronAI = val2.GetComponent<MacronAI>(); if ((Object)(object)macronAI == (Object)null) { macronAI = val2.AddComponent<MacronAI>(); } ((EnemyAI)macronAI).enemyHP = 3; ((EnemyAI)macronAI).creatureSFX = creatureSFX; ((EnemyAI)macronAI).creatureVoice = creatureVoice; ((EnemyAI)macronAI).creatureAnimator = val2.GetComponentInChildren<Animator>(); ((EnemyAI)macronAI).agent = val2.GetComponent<NavMeshAgent>(); ((EnemyAI)macronAI).agent.speed = 3.5f; ((EnemyAI)macronAI).agent.angularSpeed = 120f; ((EnemyAI)macronAI).agent.acceleration = 8f; BoxCollider val8 = val2.GetComponent<BoxCollider>(); if ((Object)(object)val8 == (Object)null) { val8 = val2.AddComponent<BoxCollider>(); } val8.center = new Vector3(0f, 0.9f, 0f); val8.size = new Vector3(0.6f, 1.8f, 0.6f); ((Collider)val8).isTrigger = true; EnemyAICollisionDetect val9 = val2.GetComponent<EnemyAICollisionDetect>(); if ((Object)(object)val9 == (Object)null) { val9 = val2.AddComponent<EnemyAICollisionDetect>(); } val9.mainScript = (EnemyAI)(object)macronAI; Log.LogInfo((object)"MacronAI configure avec tous les composants EnemyAI !"); MacronEnemyType = ScriptableObject.CreateInstance<EnemyType>(); MacronEnemyType.enemyName = "Macron"; MacronEnemyType.enemyPrefab = val2; MacronEnemyType.isOutsideEnemy = false; MacronEnemyType.isDaytimeEnemy = false; MacronEnemyType.probabilityCurve = AnimationCurve.Linear(0f, 1f, 1f, 1f); MacronEnemyType.PowerLevel = 2f; MacronEnemyType.MaxCount = 2; WalkingMusic = val.LoadAsset<AudioClip>("Macron walking music"); ChaseMusic = val.LoadAsset<AudioClip>("Macron Chase music"); macronAI.walkMusic = WalkingMusic; macronAI.chaseMusic = ChaseMusic; ((EnemyAI)macronAI).enemyType = MacronEnemyType; ((EnemyAI)macronAI).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[4] { new EnemyBehaviourState { name = "Wandering" }, new EnemyBehaviourState { name = "Chasing" }, new EnemyBehaviourState { name = "Attacking" }, new EnemyBehaviourState { name = "Passive" } }; Log.LogInfo((object)"Assets charges !"); } private void RegisterEnemy() { if ((Object)(object)MacronEnemyType == (Object)null) { Log.LogError((object)"EnemyType null, impossible d'enregistrer Macron !"); return; } NetworkPrefabs.RegisterNetworkPrefab(MacronEnemyType.enemyPrefab); Enemies.RegisterEnemy(MacronEnemyType, 100, (LevelTypes)(-1), (SpawnType)0, (TerminalNode)null, (TerminalKeyword)null); Log.LogInfo((object)"Macron enregistre comme ennemi interieur (rarity: 100) !"); } } internal class MacronSoundLoader : MonoBehaviour { [CompilerGenerated] private sealed class <LoadAllSounds>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MacronSoundLoader <>4__this; private string <pluginDir>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAllSounds>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <pluginDir>5__2 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; MacronSoundLoader macronSoundLoader = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <pluginDir>5__2 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); <>2__current = macronSoundLoader.LoadMp3(Path.Combine(<pluginDir>5__2, "macron_death.mp3"), delegate(AudioClip clip) { MacronPlugin.DeathSound = clip; }); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = macronSoundLoader.LoadMp3(Path.Combine(<pluginDir>5__2, "macron_death2.mp3"), delegate(AudioClip clip) { MacronPlugin.DeathSound2 = clip; }); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = macronSoundLoader.LoadMp3(Path.Combine(<pluginDir>5__2, "macron_dance1.mp3"), delegate(AudioClip clip) { MacronPlugin.DanceMusic1 = clip; }); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = macronSoundLoader.LoadMp3(Path.Combine(<pluginDir>5__2, "macron_dance2.mp3"), delegate(AudioClip clip) { MacronPlugin.DanceMusic2 = clip; }); <>1__state = 4; return true; case 4: <>1__state = -1; <>2__current = macronSoundLoader.LoadMp3(Path.Combine(<pluginDir>5__2, "macron_dance3.mp3"), delegate(AudioClip clip) { MacronPlugin.DanceMusic3 = clip; }); <>1__state = 5; return true; case 5: <>1__state = -1; MacronPlugin.Log.LogInfo((object)"Sons charges (death + dance) !"); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadMp3>d__2 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string path; public Action<AudioClip> onLoaded; private UnityWebRequest <request>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadMp3>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <request>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Invalid comparison between Unknown and I4 try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; if (!File.Exists(path)) { MacronPlugin.Log.LogWarning((object)("Fichier non trouve: " + Path.GetFileName(path))); return false; } string text = "file:///" + path.Replace("\\", "/"); <request>5__2 = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)13); <>1__state = -3; <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; return true; } case 1: <>1__state = -3; if ((int)<request>5__2.result == 1) { onLoaded(DownloadHandlerAudioClip.GetContent(<request>5__2)); } else { MacronPlugin.Log.LogError((object)("Erreur chargement: " + <request>5__2.error)); } <>m__Finally1(); <request>5__2 = null; return false; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<request>5__2 != null) { ((IDisposable)<request>5__2).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private void Start() { ((MonoBehaviour)this).StartCoroutine(LoadAllSounds()); } [IteratorStateMachine(typeof(<LoadAllSounds>d__1))] private IEnumerator LoadAllSounds() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAllSounds>d__1(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<LoadMp3>d__2))] private IEnumerator LoadMp3(string path, Action<AudioClip> onLoaded) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadMp3>d__2(0) { path = path, onLoaded = onLoaded }; } } } namespace MacronMod.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }