using System; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using JetBrains.Annotations; using LethalLib.Modules; using Microsoft.CodeAnalysis; using MissileTurret.NetcodePatcher; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MissileTurret")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MissileTurret")] [assembly: AssemblyTitle("MissileTurret")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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; } } } namespace MissileTurret { public class MissileAI : NetworkBehaviour { public Transform player; private float _speed = 0f; private float _currentLaunchTime; private readonly float launchTimeSeconds = 0.4f; private float _aliveTimeSeconds; private Rigidbody _rigidbody; public static float MaxTurnSpeed; public static float MaxSpeed; public static float Acceleration; public static float KillRange; public static float DamageRange; private float _isClientMult = 1f; private void Awake() { _rigidbody = ((Component)this).GetComponent(); _currentLaunchTime = launchTimeSeconds; } private void Update() { //IL_0083: 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_008f: 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_00a1: 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_00b2: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer) { _aliveTimeSeconds += Time.deltaTime; if (_currentLaunchTime > 0f) { _currentLaunchTime -= Time.deltaTime; _speed += Acceleration * Time.deltaTime; } _speed = Mathf.Clamp(_speed, 0f, MaxSpeed); Vector3 forward = ((Component)this).transform.forward; Vector3 val = _rigidbody.position + forward * (_speed * Time.deltaTime); _rigidbody.MovePosition(val); if ((Object)(object)player != (Object)null) { Vector3 val2 = player.position + Vector3.up / 2f - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; Quaternion val3 = Quaternion.LookRotation(normalized); Quaternion val4 = Quaternion.RotateTowards(_rigidbody.rotation, val3, MaxTurnSpeed * Time.deltaTime); _rigidbody.MoveRotation(val4); } if (_aliveTimeSeconds > 10f) { EndIt(); } } } private void OnCollisionEnter(Collision other) { EndIt(); } private void EndIt() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer) { ExplodeClientRpc(((Component)this).transform.position, KillRange, DamageRange); NetworkObject component = ((Component)this).GetComponent(); if (component != null && component.IsSpawned) { component.Despawn(true); } Object.Destroy((Object)(object)((Component)this).gameObject); } } [ClientRpc] public void ExplodeClientRpc(Vector3 position, float killRange, float damageRange) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1416639908u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref position); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref killRange, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref damageRange, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1416639908u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!((NetworkBehaviour)this).IsServer) { _isClientMult = 1.5f; } Landmine.SpawnExplosion(position, true, killRange * _isClientMult, damageRange, 50, 0f, (GameObject)null, false); } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1416639908u, new RpcReceiveHandler(__rpc_handler_1416639908), "ExplodeClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_1416639908(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_003c: 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_0057: 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_006c: 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) //IL_008e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); float killRange = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref killRange, default(ForPrimitives)); float damageRange = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref damageRange, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((MissileAI)(object)target).ExplodeClientRpc(position, killRange, damageRange); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "MissileAI"; } } public class MissileTurretAI : NetworkBehaviour { private enum MissileTurretState { SEARCHING, FIRING, CHARGING, DISABLED } public Transform rod; public Transform rail; public GameObject missile; public GameObject laser; public static float RotationRange; public static float RotationSpeed; private float _currentRotationSpeed; private MissileTurretState _state; private MissileTurretState _lastState; [CanBeNull] private PlayerControllerB _targetPlayer; private RaycastHit _lastHit; private float _currentReloadTime; public static float ReloadTimeSeconds; private float _currentChargeTime; public static float ChargeTimeSeconds; public AudioSource acquireTargetAudio; public AudioSource disableAudio; public AudioSource enableAudio; private float _currentDisableTime = 0f; public static float DisableTimeSeconds = 8f; private void Awake() { _currentReloadTime = ReloadTimeSeconds; _currentChargeTime = ChargeTimeSeconds; _currentRotationSpeed = RotationSpeed; _currentDisableTime = DisableTimeSeconds; TerminalAccessibleObject component = ((Component)this).GetComponent(); ((UnityEventBase)component.terminalCodeEvent).AddListener((object)this, typeof(MissileTurretAI).GetMethod("DisableTurret")); laser.SetActive(false); ToggleLaserClientRpc(active: false); } private void Update() { //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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0206: 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_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) MissileTurretState? missileTurretState = null; RaycastHit lastHit = default(RaycastHit); switch (_state) { case MissileTurretState.SEARCHING: if (Physics.Raycast(rod.position + rod.up, rod.up, ref lastHit, 30f, 1051400, (QueryTriggerInteraction)1) && ((Component)((RaycastHit)(ref lastHit)).transform).CompareTag("Player")) { if ((Object)(object)((RaycastHit)(ref lastHit)).collider != (Object)(object)((RaycastHit)(ref _lastHit)).collider) { _targetPlayer = null; _targetPlayer = ((Component)((RaycastHit)(ref lastHit)).transform).GetComponent(); _lastHit = lastHit; } if ((Object)(object)_targetPlayer != (Object)null) { missileTurretState = MissileTurretState.CHARGING; } } else { _targetPlayer = null; missileTurretState = MissileTurretState.SEARCHING; } if (((NetworkBehaviour)this).IsServer) { rod.Rotate(Vector3.forward, _currentRotationSpeed * Time.deltaTime); float z = rod.localEulerAngles.z; if ((z > RotationRange && z <= 180f && _currentRotationSpeed > 0f) || (z < 360f - RotationRange && z > 180f && _currentRotationSpeed < 0f)) { _currentRotationSpeed = 0f - _currentRotationSpeed; } SetYawClientRpc(z); } break; case MissileTurretState.CHARGING: if (_lastState != MissileTurretState.CHARGING) { acquireTargetAudio.Play(); if (((NetworkBehaviour)this).IsServer) { ToggleLaserClientRpc(active: true); } } if (_currentChargeTime <= 0f) { _currentChargeTime = ChargeTimeSeconds; missileTurretState = ((Physics.Raycast(rod.position + rod.up, ((Component)_targetPlayer).transform.position - rod.position, ref lastHit, 30f, 1051400, (QueryTriggerInteraction)1) && ((Component)((RaycastHit)(ref lastHit)).transform).CompareTag("Player")) ? new MissileTurretState?(MissileTurretState.FIRING) : new MissileTurretState?(MissileTurretState.SEARCHING)); if (((NetworkBehaviour)this).IsServer) { ToggleLaserClientRpc(active: false); } } else { _currentChargeTime -= Time.deltaTime; } break; case MissileTurretState.FIRING: if (_targetPlayer == null) { missileTurretState = MissileTurretState.SEARCHING; break; } if (_lastState != MissileTurretState.FIRING && ((NetworkBehaviour)this).IsServer) { MissileAI component = Object.Instantiate(Plugin.MissilePrefab, rod.position + Vector3.up, Quaternion.LookRotation(rod.up) * Quaternion.Euler(2f, 0f, 0f)).GetComponent(); component.player = ((Component)_targetPlayer).transform; ((Component)component).GetComponent().Spawn(true); ToggleMissileClientRpc(active: false); } if (_currentReloadTime <= 0f) { if (((NetworkBehaviour)this).IsServer) { ToggleMissileClientRpc(active: true); } _currentReloadTime = ReloadTimeSeconds; missileTurretState = MissileTurretState.SEARCHING; } else { _currentReloadTime -= Time.deltaTime; } break; case MissileTurretState.DISABLED: if (_lastState != MissileTurretState.DISABLED) { disableAudio.Play(); if (((NetworkBehaviour)this).IsServer) { Vector3 localEulerAngles = rail.localEulerAngles; localEulerAngles.x = -30f; rail.localEulerAngles = localEulerAngles; Vector3 localPosition = rail.localPosition; localPosition.y = -0.67f; rail.localPosition = localPosition; SetRailClientRpc(localEulerAngles, localPosition); } } if (_currentDisableTime <= 0f) { _currentDisableTime = DisableTimeSeconds; enableAudio.Play(); if (((NetworkBehaviour)this).IsServer) { Vector3 localEulerAngles2 = rail.localEulerAngles; localEulerAngles2.x = 0f; rail.localEulerAngles = localEulerAngles2; Vector3 localPosition2 = rail.localPosition; localPosition2.y = 0f; rail.localPosition = localPosition2; SetRailClientRpc(localEulerAngles2, localPosition2); } missileTurretState = MissileTurretState.SEARCHING; } else { _currentDisableTime -= Time.deltaTime; } break; } _lastState = _state; if (missileTurretState.HasValue && missileTurretState != _state && ((NetworkBehaviour)this).IsServer) { _state = missileTurretState.Value; SetStateClientRpc(_state, _lastState); } } public void DisableTurret(PlayerControllerB pc) { if (pc != null) { _lastState = _state; _state = MissileTurretState.DISABLED; SetStateClientRpc(_state, _lastState); } } [ClientRpc] private void SetStateClientRpc(MissileTurretState state, MissileTurretState lastState) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_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) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00f7: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3177718372u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref state, default(ForEnums)); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref lastState, default(ForEnums)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3177718372u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; _state = state; _lastState = lastState; } } } [ClientRpc] private void SetYawClientRpc(float yaw) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_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) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00ed: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2936333528u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref yaw, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2936333528u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Vector3 localEulerAngles = rod.localEulerAngles; localEulerAngles.z = yaw; rod.localEulerAngles = localEulerAngles; } } } [ClientRpc] private void SetRailClientRpc(Vector3 localEulers, Vector3 localPos) { //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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3970896126u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref localEulers); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref localPos); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3970896126u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; rail.localPosition = localPos; rail.localEulerAngles = localEulers; } } } [ClientRpc] private void ToggleMissileClientRpc(bool active) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_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) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1599590863u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref active, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1599590863u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; missile.SetActive(active); } } } [ClientRpc] private void ToggleLaserClientRpc(bool active) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_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) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1199733162u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref active, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1199733162u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; laser.SetActive(active); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(3177718372u, new RpcReceiveHandler(__rpc_handler_3177718372), "SetStateClientRpc"); ((NetworkBehaviour)this).__registerRpc(2936333528u, new RpcReceiveHandler(__rpc_handler_2936333528), "SetYawClientRpc"); ((NetworkBehaviour)this).__registerRpc(3970896126u, new RpcReceiveHandler(__rpc_handler_3970896126), "SetRailClientRpc"); ((NetworkBehaviour)this).__registerRpc(1599590863u, new RpcReceiveHandler(__rpc_handler_1599590863), "ToggleMissileClientRpc"); ((NetworkBehaviour)this).__registerRpc(1199733162u, new RpcReceiveHandler(__rpc_handler_1199733162), "ToggleLaserClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_3177718372(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_004a: 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_005f: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { MissileTurretState state = default(MissileTurretState); ((FastBufferReader)(ref reader)).ReadValueSafe(ref state, default(ForEnums)); MissileTurretState lastState = default(MissileTurretState); ((FastBufferReader)(ref reader)).ReadValueSafe(ref lastState, default(ForEnums)); target.__rpc_exec_stage = (__RpcExecStage)1; ((MissileTurretAI)(object)target).SetStateClientRpc(state, lastState); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2936333528(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_0044: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { float yawClientRpc = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref yawClientRpc, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((MissileTurretAI)(object)target).SetYawClientRpc(yawClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3970896126(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 localEulers = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref localEulers); Vector3 localPos = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref localPos); target.__rpc_exec_stage = (__RpcExecStage)1; ((MissileTurretAI)(object)target).SetRailClientRpc(localEulers, localPos); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1599590863(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_0044: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool active = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref active, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((MissileTurretAI)(object)target).ToggleMissileClientRpc(active); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1199733162(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_0044: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool active = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref active, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((MissileTurretAI)(object)target).ToggleLaserClientRpc(active); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "MissileTurretAI"; } } [BepInPlugin("Finnerex.MissileTurret", "MissileTurret", "1.3.9")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")] [HarmonyPriority(200)] public static class Patch_SpawnMapObjects { private static void Prefix() { RandomMapObject[] array = Object.FindObjectsOfType(); RandomMapObject[] array2 = array; foreach (RandomMapObject val in array2) { if (val.spawnablePrefabs.Any((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name.StartsWith("MissileTurret")) && !val.spawnablePrefabs.Any((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name.StartsWith("TurretContainer"))) { val.spawnablePrefabs.RemoveAll((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name.StartsWith("MissileTurret")); } } } } public static SpawnableMapObject MissileTurretMapObj; public static GameObject MissileTurretPrefab; public static GameObject MissilePrefab; public static ManualLogSource TheLogger; public int MaxTurrets; public int MinTurrets; public static AnimationCurve curve; private void Awake() { //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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_01e7: Expected O, but got Unknown //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Expected O, but got Unknown TheLogger = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Missile Turret Loading???"); Configure(); Patch(); string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "missileturretassetbundle")); if (val == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load assets"); return; } MissileTurretPrefab = val.LoadAsset("MissileTurret"); MissilePrefab = val.LoadAsset("Missile"); MissileTurretAI missileTurretAI = MissileTurretPrefab.AddComponent(); missileTurretAI.rod = MissileTurretPrefab.transform.Find("missileTurret/Mount/Rod"); missileTurretAI.rail = missileTurretAI.rod.Find("Rod.001"); missileTurretAI.missile = ((Component)missileTurretAI.rail.Find("Cylinder")).gameObject; missileTurretAI.acquireTargetAudio = ((Component)missileTurretAI.rod).GetComponent(); missileTurretAI.disableAudio = ((Component)missileTurretAI.rod.Find("DisableSound")).GetComponent(); missileTurretAI.enableAudio = ((Component)missileTurretAI.rod.Find("EnableSound")).GetComponent(); missileTurretAI.laser = ((Component)missileTurretAI.rod.Find("LaserLight")).gameObject; MissilePrefab.AddComponent(); Utilities.FixMixerGroups(MissileTurretPrefab); Utilities.FixMixerGroups(MissilePrefab); NetworkPrefabs.RegisterNetworkPrefab(MissileTurretPrefab); NetworkPrefabs.RegisterNetworkPrefab(MissilePrefab); if (MinTurrets >= MaxTurrets) { curve = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, (float)MinTurrets, 0f, 0f), new Keyframe(1f, (float)MaxTurrets, 0f, 0f) }); } else { curve = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, (float)MinTurrets, 0.267f, 0.267f, 0f, 0.246f), new Keyframe(1f, (float)MaxTurrets, 61f, 61f, 0.015f * (float)MaxTurrets, 0f) }); } MissileTurretMapObj = new SpawnableMapObject { prefabToSpawn = MissileTurretPrefab, spawnFacingAwayFromWall = true, numberToSpawn = curve }; MapObjects.RegisterMapObject(MissileTurretMapObj, (LevelTypes)(-1), (Func)((SelectableLevel _) => curve)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Missile Turret Loaded!!!"); } private void Patch() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("Finnerex.MissileTurret"); val.PatchAll(Assembly.GetExecutingAssembly()); } private void Configure() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Expected O, but got Unknown //IL_0048: 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_0063: Expected O, but got Unknown //IL_0063: Expected O, but got Unknown //IL_007d: 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_009c: Expected O, but got Unknown //IL_009c: Expected O, but got Unknown //IL_00bc: 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_00db: Expected O, but got Unknown //IL_00db: Expected O, but got Unknown //IL_00f5: 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_0114: Expected O, but got Unknown //IL_0114: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_0153: Expected O, but got Unknown //IL_016d: 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_018c: Expected O, but got Unknown //IL_018c: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_01c5: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown //IL_01fe: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Expected O, but got Unknown //IL_023d: Expected O, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Expected O, but got Unknown //IL_0276: Expected O, but got Unknown MaxTurrets = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Spawn Options", "Max Turrets"), 6, new ConfigDescription("Maximum number of turrets that can be spawned", (AcceptableValueBase)null, Array.Empty())).Value; MinTurrets = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Spawn Options", "Min Turrets"), 0, new ConfigDescription("Minimum number of turrets that can be spawned", (AcceptableValueBase)null, Array.Empty())).Value; MissileAI.MaxSpeed = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Missile Options", "Max Speed"), 0.7f, new ConfigDescription("Maximum speed of a missile", (AcceptableValueBase)null, Array.Empty())).Value * 100f; MissileAI.MaxTurnSpeed = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Missile Options", "Turn Rate"), 0.6f, new ConfigDescription("How fast the missile can turn", (AcceptableValueBase)null, Array.Empty())).Value; MissileAI.Acceleration = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Missile Options", "Acceleration"), 0.6f, new ConfigDescription("Acceleration of the missile", (AcceptableValueBase)null, Array.Empty())).Value * 100f; MissileAI.KillRange = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Missile Options", "Explosive Kill Range"), 2f, new ConfigDescription("Distance from explosion to kill", (AcceptableValueBase)null, Array.Empty())).Value; MissileAI.DamageRange = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Missile Options", "Explosive Damage Range"), 5f, new ConfigDescription("Distance from explosion to damage", (AcceptableValueBase)null, Array.Empty())).Value; MissileTurretAI.RotationRange = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Missile Turret Options", "Rotation Range"), 45f, new ConfigDescription("The angle the turret's search is restricted to in degrees left & right", (AcceptableValueBase)null, Array.Empty())).Value; MissileTurretAI.RotationSpeed = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Missile Turret Options", "Rotation Rate"), 0.25f, new ConfigDescription("The speed at which the turret rotates", (AcceptableValueBase)null, Array.Empty())).Value * 100f; MissileTurretAI.ReloadTimeSeconds = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Missile Turret Options", "Reload Time"), 6f, new ConfigDescription("The time it takes for the turret to reload in seconds", (AcceptableValueBase)null, Array.Empty())).Value; MissileTurretAI.ChargeTimeSeconds = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Missile Turret Options", "Charge Time"), 0.5f, new ConfigDescription("The time it takes for the turret to shoot at a target in seconds", (AcceptableValueBase)null, Array.Empty())).Value; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "MissileTurret"; public const string PLUGIN_NAME = "MissileTurret"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace MissileTurret.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }