Decompiled source of NuclearCruiser v1.1.1

Tomatobird.NuclearCruiser.dll

Decompiled 2 weeks ago
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using NuclearCruiser.Network;
using NuclearCruiser.Utils;
using Tomatobird.NuclearCruiser.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tomatobird.NuclearCruiser")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+b2f2547cb3d480a416482bfc57a4fbd8191a8fae")]
[assembly: AssemblyProduct("NuclearCruiser")]
[assembly: AssemblyTitle("Tomatobird.NuclearCruiser")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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 NuclearCruiser
{
	[BepInPlugin("Tomatobird.NuclearCruiser", "NuclearCruiser", "1.1.1")]
	public class NuclearCruiser : BaseUnityPlugin
	{
		internal enum Fragility
		{
			Normal,
			Fragile,
			Extreme
		}

		internal static Texture2D? cruiserTexture;

		internal static Texture2D? destroyedCruiserTexture;

		internal static GameObject? nukeObject;

		internal static float nukeScale = 0.5f;

		internal static float nuclearCruiserChance = 1f;

		internal static bool infiniteBoosts = true;

		internal static bool nuclearCruiserWarning = true;

		internal static bool nuclearCruiserRadiationWarning = true;

		internal static Fragility cruiserFragility;

		internal static float minimumCrashVelocity = 4f;

		internal static int crashDamage = 4;

		internal static bool onlyPatchVanillaCruiser = true;

		public static NuclearCruiser Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			cruiserTexture = GetTexture(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cruiser.png"));
			destroyedCruiserTexture = GetTexture(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cruiser_blown.png"));
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cruisernuke"));
			nukeObject = val.LoadAsset<GameObject>("Assets/LethalCompany/Mods/TomatoScrap/Prefabs/Miscallaneous/NuclearBombCruiser.prefab");
			if ((Object)(object)cruiserTexture == (Object)null || (Object)(object)destroyedCruiserTexture == (Object)null || (Object)(object)nukeObject == (Object)null)
			{
				Logger.LogError((object)"Failed to load textures. Plugin loading failed.");
				return;
			}
			nuclearCruiserChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "NuclearCruiserChance", 1f, new ConfigDescription("Chance of cruiser being a Nuclear Cruiser. 1 is always, 0 is never.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())).Value;
			nukeScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "NukeScale", 0.75f, "How large should the explosion be? 0.5 can already cover most of a moon's surface.").Value;
			infiniteBoosts = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "InfiniteBoosts", true, "Should nuclear cruiser have infinite boosts?").Value;
			nuclearCruiserWarning = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "NuclearCruiserWarning", true, "Should a warning pop up when a Nuclear Cruiser is spawned?").Value;
			nuclearCruiserRadiationWarning = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "NuclearCruiserRadiationWarning", true, "Should a radiation warning pop up when a Nuclear Cruiser is spawned?").Value;
			string value = ((BaseUnityPlugin)this).Config.Bind<string>("General", "CruiserFragility", "Fragile", new ConfigDescription("Fragility of the cruiser. Fragile makes cruiser take heavy damage from smaller impacts. Extreme makes cruiser on any impact past minimum crash velocity threshold and may explode upon landing on some moons if set too low.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Normal", "Fragile", "Extreme" }), Array.Empty<object>())).Value;
			minimumCrashVelocity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinimumCrashVelocity", 4f, "Damaging impact velocity threshold. Default threshold is reached at very low speeds.").Value;
			crashDamage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "CrashDamage", 4, "Amount of damage cruiser takes on impact. Only used when CruiserFragility is set to Fragile.").Value;
			onlyPatchVanillaCruiser = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OnlyPatchVanillaCruiser", true, "Only turns the vanilla company cruiser into a nuclear cruiser. Setting this to false will also allow other vehicle types to be nuclear. Texture changes to other vehicles will not be applied.").Value;
			cruiserFragility = ((!(value == "Normal")) ? ((value == "Fragile") ? Fragility.Fragile : Fragility.Extreme) : Fragility.Normal);
			Transform transform = nukeObject.transform;
			transform.localScale *= nukeScale;
			((Object)cruiserTexture).name = "nukeCruiserTexture";
			((Object)destroyedCruiserTexture).name = "blownNukeCruiserTexture";
			Patch();
			PatchNetwork();
			Logger.LogInfo((object)"Tomatobird.NuclearCruiser v1.1.1 has loaded!");
		}

		internal static Texture2D? GetTexture(string path)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			if (File.Exists(path))
			{
				Texture2D val = new Texture2D(2, 2);
				ImageConversion.LoadImage(val, File.ReadAllBytes(path));
				return val;
			}
			return null;
		}

		internal static void PatchNetwork()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Tomatobird.NuclearCruiser");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Tomatobird.NuclearCruiser";

		public const string PLUGIN_NAME = "NuclearCruiser";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace NuclearCruiser.Utils
{
	internal class CruiserNuker : MonoBehaviour
	{
		internal void Explode()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(NuclearCruiser.nukeObject);
			if ((Object)(object)val != (Object)null)
			{
				val.transform.position = ((Component)this).gameObject.transform.position;
			}
		}

		private void Start()
		{
			if (NuclearCruiser.nuclearCruiserRadiationWarning && !StartOfRound.Instance.inShipPhase)
			{
				HUDManager.Instance.RadiationWarningHUD();
			}
			if (NuclearCruiser.nuclearCruiserWarning && !StartOfRound.Instance.inShipPhase)
			{
				if (NuclearCruiser.infiniteBoosts)
				{
					HUDManager.Instance.DisplayTip("NUCLEAR CRUISER SPAWNED", "Using nuclear power the cruiser can boost infinitely. Handle with extreme care.", true, false, "LC_Tip1");
				}
				else
				{
					HUDManager.Instance.DisplayTip("NUCLEAR CRUISER SPAWNED", "Handle with extreme care.", true, false, "LC_Tip1");
				}
			}
			VehicleController component = ((Component)this).GetComponent<VehicleController>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			if (NuclearCruiser.infiniteBoosts)
			{
				component.turboBoosts = 5;
				component.AddTurboBoost();
			}
			if (component.vehicleID != 0)
			{
				return;
			}
			MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshRenderer>();
			MeshRenderer[] array = componentsInChildren;
			foreach (MeshRenderer val in array)
			{
				if (((Object)((Component)val).transform).name.Contains("MainBody") || ((Object)((Component)val).transform).name == "CarHoodMesh" || ((Object)((Component)val).transform).name == "Door")
				{
					((Renderer)val).materials[0].mainTexture = (Texture)(object)NuclearCruiser.cruiserTexture;
				}
			}
		}
	}
}
namespace NuclearCruiser.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPostFix()
		{
			NetworkHandler.CreateAndRegisterPrefab();
		}

		[HarmonyPatch("Disconnect")]
		[HarmonyPrefix]
		private static void DisconnectPostfix()
		{
			NetworkHandler.DespawnNetworkHandler();
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		private static void AwakePrefix()
		{
			NetworkHandler.SpawnNetworkHandler();
		}
	}
	[HarmonyPatch(typeof(VehicleController))]
	internal class VehicleControllerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		internal static void StartPatch(VehicleController __instance)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if ((!NuclearCruiser.onlyPatchVanillaCruiser || __instance.vehicleID == 0) && (((NetworkBehaviour)__instance).NetworkManager.IsHost || ((NetworkBehaviour)__instance).NetworkManager.IsServer))
			{
				Random random = new Random();
				float num = (float)random.NextDouble();
				if (num < NuclearCruiser.nuclearCruiserChance)
				{
					NetworkHandler.Instance.AddCruiserNukerClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject));
				}
			}
		}

		[HarmonyPatch("UseTurboBoostLocalClient")]
		[HarmonyPostfix]
		internal static void UseTurboBoostLocalClientPatch(VehicleController __instance)
		{
			if (!((Object)(object)((Component)__instance).GetComponent<CruiserNuker>() == (Object)null) && NuclearCruiser.infiniteBoosts)
			{
				__instance.turboBoosts = 5;
			}
		}

		[HarmonyPatch("DestroyCar")]
		[HarmonyPrefix]
		internal static void DestroyCarPatch(VehicleController __instance)
		{
			if (__instance.carDestroyed)
			{
				return;
			}
			CruiserNuker component = ((Component)__instance).GetComponent<CruiserNuker>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			if (__instance.vehicleID == 0)
			{
				MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<MeshRenderer>();
				MeshRenderer[] array = componentsInChildren;
				foreach (MeshRenderer val in array)
				{
					if (((Object)((Component)val).transform).name.Contains("MainBody") || ((Object)((Component)val).transform).name == "CarHoodMesh" || ((Object)((Component)val).transform).name == "Door")
					{
						((Renderer)val).materials[0].mainTexture = (Texture)(object)NuclearCruiser.destroyedCruiserTexture;
					}
				}
				Transform obj = ((Component)__instance).transform.Find("Meshes");
				MeshRenderer val2 = ((obj != null) ? ((Component)obj.Find("MainBodyDestroyed")).GetComponent<MeshRenderer>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Renderer)val2).materials[0].mainTexture = (Texture)(object)NuclearCruiser.destroyedCruiserTexture;
				}
			}
			component.Explode();
		}

		[HarmonyPatch("OnCollisionEnter")]
		[HarmonyPostfix]
		internal static void OnCollisionEnterPatch(VehicleController __instance, ref Collision collision)
		{
			//IL_0090: 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_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_00f3: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)__instance).IsOwner || __instance.magnetedToShip || !__instance.hasBeenSpawned || ((Component)collision.collider).gameObject.layer != 8 || __instance.averageCount < 18 || NuclearCruiser.cruiserFragility == NuclearCruiser.Fragility.Normal || (Object)(object)((Component)__instance).GetComponent<CruiserNuker>() == (Object)null || ((Vector3)(ref __instance.averageVelocity)).magnitude < NuclearCruiser.minimumCrashVelocity)
			{
				return;
			}
			float num = 0f;
			int contacts = collision.GetContacts(__instance.contacts);
			Vector3 val;
			for (int i = 0; i < contacts; i++)
			{
				val = ((ContactPoint)(ref __instance.contacts[i])).impulse;
				if (((Vector3)(ref val)).magnitude > num)
				{
					val = ((ContactPoint)(ref __instance.contacts[i])).impulse;
					num = ((Vector3)(ref val)).magnitude;
				}
			}
			num /= Time.fixedDeltaTime;
			if (num > __instance.mediumBumpForce)
			{
				int crashDamage = NuclearCruiser.crashDamage;
				val = default(Vector3);
				__instance.DealPermanentDamage(crashDamage, val);
			}
			if (num > __instance.maximumBumpForce && ((Vector3)(ref __instance.averageVelocity)).magnitude > NuclearCruiser.minimumCrashVelocity * 3f)
			{
				int num2 = NuclearCruiser.crashDamage * 2;
				val = default(Vector3);
				__instance.DealPermanentDamage(num2, val);
			}
		}

		[HarmonyPatch("CarReactToObstacle")]
		[HarmonyPrefix]
		internal static bool CarReactToObstaclePatch(VehicleController __instance)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((Component)__instance).GetComponent<CruiserNuker>() == (Object)null)
			{
				return true;
			}
			if ((Object)(object)StartOfRound.Instance.testRoom == (Object)null && !StartOfRound.Instance.inShipPhase && !__instance.magnetedToShip && !__instance.carDestroyed && ((NetworkBehaviour)__instance).IsOwner && ((Vector3)(ref __instance.averageVelocity)).magnitude > NuclearCruiser.minimumCrashVelocity)
			{
				if (NuclearCruiser.cruiserFragility == NuclearCruiser.Fragility.Extreme)
				{
					__instance.DestroyCar();
					__instance.DestroyCarServerRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId);
				}
				if (NuclearCruiser.cruiserFragility == NuclearCruiser.Fragility.Fragile)
				{
					__instance.DealPermanentDamage(NuclearCruiser.crashDamage, default(Vector3));
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch("DealPermanentDamage")]
		[HarmonyPrefix]
		internal static bool DealPermanentDamagePatch(VehicleController __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<CruiserNuker>() == (Object)null)
			{
				return true;
			}
			if (NuclearCruiser.cruiserFragility == NuclearCruiser.Fragility.Extreme && (Object)(object)StartOfRound.Instance.testRoom == (Object)null && !StartOfRound.Instance.inShipPhase && !__instance.magnetedToShip && !__instance.carDestroyed && ((NetworkBehaviour)__instance).IsOwner)
			{
				__instance.DestroyCar();
				__instance.DestroyCarServerRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId);
				return false;
			}
			return true;
		}
	}
}
namespace NuclearCruiser.Network
{
	internal class NetworkHandler : NetworkBehaviour
	{
		private static GameObject? prefab;

		public static NetworkHandler Instance { get; private set; }

		public static void CreateAndRegisterPrefab()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)prefab != (Object)null))
			{
				prefab = new GameObject("Tomatobird.NuclearCruiser Prefab");
				GameObject? obj = prefab;
				((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x3D);
				NetworkObject obj2 = prefab.AddComponent<NetworkObject>();
				FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic);
				field.SetValue(obj2, GetHash("Tomatobird.NuclearCruiser Prefab"));
				prefab.AddComponent<NetworkHandler>();
				NetworkManager.Singleton.AddNetworkPrefab(prefab);
				NuclearCruiser.Logger.LogInfo((object)"Nuclear Cruiser network prefab done.");
			}
		}

		public static void SpawnNetworkHandler()
		{
			if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost)
			{
				GameObject obj = Object.Instantiate<GameObject>(prefab);
				if (obj != null)
				{
					obj.GetComponent<NetworkObject>().Spawn(false);
				}
				NuclearCruiser.Logger.LogInfo((object)"Spawned network handler.");
			}
		}

		public static void DespawnNetworkHandler()
		{
			if ((Object)(object)Instance != (Object)null && ((Component)Instance).gameObject.GetComponent<NetworkObject>().IsSpawned && (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost))
			{
				((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
				NuclearCruiser.Logger.LogInfo((object)"Despawned network handler.");
			}
		}

		protected internal static uint GetHash(string value)
		{
			return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0;
		}

		private void Awake()
		{
			Instance = this;
		}

		[ClientRpc]
		public void AddCruiserNukerClientRpc(NetworkObjectReference target)
		{
			//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)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1743576381u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref target, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1743576381u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref target)).TryGet(ref val3, (NetworkManager)null))
				{
					((Component)val3).gameObject.AddComponent<CruiserNuker>();
				}
				else
				{
					NuclearCruiser.Logger.LogError((object)"NetworkObject couldn't be found for AddCruiserNukerClientRpc");
				}
			}
		}

		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(1743576381u, new RpcReceiveHandler(__rpc_handler_1743576381), "AddCruiserNukerClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1743576381(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_004f: 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)
			{
				NetworkObjectReference target2 = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref target2, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetworkHandler)(object)target).AddCruiserNukerClientRpc(target2);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "NetworkHandler";
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace Tomatobird.NuclearCruiser.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}