Decompiled source of PowerRelayMoon v3.1.2

RelayStationBehaviour.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using RelayStationBehaviour;
using RelayStationBehaviour.Behaviors;
using RelayStationBehaviour.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.VFX;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RelayStationBehaviour")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RelayStationBehaviour")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eb53a927-36f5-4819-88b0-c3eacfe2e93e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
public class UnstableRelay : MonoBehaviour
{
	private GameObject[] closeNodes;

	private GameObject[] farNodes;

	public GameObject pos1;

	public GameObject pos2;

	public GameObject pos3;

	public GameObject pos4;

	public VisualEffect veARC;

	public int chargeBuild = 0;

	public AudioClip[] strikeSFX;

	public AudioClip[] distantThunderSFX;

	public ParticleSystem Explosion;

	public Random rand;

	public Random serverRand;

	public bool powerIsOff;

	public AudioSource strikeSoundPos;

	public AudioClip[] Internal;

	public AudioClip PowerChanged;

	public AudioClip[] AfterPowerDownInside;

	public AudioSource InsideSource;

	public AudioSource InsideSourc2;

	private void Awake()
	{
		powerIsOff = false;
	}

	private void Start()
	{
		RelayPatcher.mls.LogInfo((object)"Relay Start triggered");
		CloseNodeIdentifier[] array = Object.FindObjectsOfType<CloseNodeIdentifier>();
		closeNodes = (GameObject[])(object)new GameObject[array.Length];
		for (int i = 0; i < array.Length; i++)
		{
			closeNodes[i] = ((Component)array[i]).gameObject;
		}
		FarNodeIdentifier[] array2 = Object.FindObjectsOfType<FarNodeIdentifier>();
		farNodes = (GameObject[])(object)new GameObject[array2.Length];
		for (int j = 0; j < array2.Length; j++)
		{
			farNodes[j] = ((Component)array2[j]).gameObject;
		}
		if (closeNodes.Length == 0)
		{
			RelayPatcher.mls.LogInfo((object)"Error no nodes found");
		}
		else
		{
			RelayPatcher.mls.LogInfo((object)("Nodes found: " + closeNodes.Length));
		}
		if ((Object)(object)veARC == (Object)null || (Object)(object)pos1 == (Object)null)
		{
			veARC = GameObject.Find("Lightning Arc").GetComponent<VisualEffect>();
			pos1 = GameObject.Find("Pos1");
			pos2 = GameObject.Find("Pos2");
			pos3 = GameObject.Find("Pos3");
			pos4 = GameObject.Find("Pos4");
		}
		if (((NetworkBehaviour)RelayNetwork.Instance).IsHost)
		{
			RelayPatcher.mls.LogInfo((object)"Is owner of Relay Network");
			int randomMapSeed = StartOfRound.Instance.randomMapSeed;
			rand = new Random(randomMapSeed);
			serverRand = new Random(randomMapSeed);
			RelayNetwork.Instance.SeedServerRpc(randomMapSeed);
			((MonoBehaviour)this).StartCoroutine(CallFunctionRepeatedly());
			((MonoBehaviour)this).StartCoroutine(InternalSounds());
			RoundManager val = Object.FindAnyObjectByType<RoundManager>();
			if ((Object)(object)val == (Object)null)
			{
				RelayPatcher.mls.LogInfo((object)"Error no round manager");
			}
			else
			{
				((UnityEvent<bool>)(object)val.onPowerSwitch).AddListener((UnityAction<bool>)powerChange);
			}
		}
	}

	private void powerChange(bool power)
	{
		RelayPatcher.mls.LogInfo((object)"Power Change");
		if (!powerIsOff)
		{
			powerIsOff = true;
			((MonoBehaviour)this).StartCoroutine(ChargeIncrease());
			RelayNetwork.Instance.PowerOffServerRpc();
		}
		else
		{
			powerIsOff = false;
			((MonoBehaviour)this).StopCoroutine(ChargeIncrease());
		}
	}

	public void PowerOff()
	{
		InsideSourc2.PlayOneShot(PowerChanged);
	}

	public void DischargeClose()
	{
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: 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)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: 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_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: 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)
		Debug.Log((object)"discharge client");
		if (closeNodes.Length == 0)
		{
			Debug.Log((object)"Client Not yet loaded");
			return;
		}
		List<GameObject> list = new List<GameObject>();
		list.AddRange(closeNodes);
		if (chargeBuild >= 10)
		{
			list.AddRange(farNodes);
			veARC.SetVector4("color", new Vector4(0f, 0.658f, 1f, 0f));
		}
		int index = rand.Next(0, list.Count);
		GameObject val = list[index];
		pos4.transform.position = new Vector3(val.transform.position.x, val.transform.position.y + 0.15f, val.transform.position.z);
		Vector3 val2 = pos4.transform.position - pos1.transform.position;
		Vector3 val3 = pos1.transform.position + 0.4f * val2;
		float num = Mathf.Abs(pos4.transform.position.y - pos1.transform.position.y);
		pos2.transform.position = new Vector3(val3.x, val3.y + num * 0.8f, val3.z);
		val3 = pos1.transform.position + 0.7f * val2;
		pos3.transform.position = new Vector3(val3.x, val3.y + num * 0.4f, val3.z);
		veARC.Play();
		((Component)strikeSoundPos).transform.position = val.transform.position + Vector3.up * 0.5f;
		Landmine.SpawnExplosion(val.transform.position + Vector3.up * 0.2f, false, 2.4f, 5f, 50, 0f, (GameObject)null, false);
		((Component)Explosion).transform.position = val.transform.position + Vector3.up * 0.2f;
		Explosion.Play();
		((MonoBehaviour)this).StartCoroutine(disableEffects());
		PlayThunderEffects(val.transform.position, strikeSoundPos);
	}

	private void PlayThunderEffects(Vector3 strikePosition, AudioSource audio)
	{
		//IL_003d: 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_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB val = GameNetworkManager.Instance.localPlayerController;
		if (val.isPlayerDead && (Object)(object)val.spectatedPlayerScript != (Object)null)
		{
			val = val.spectatedPlayerScript;
		}
		float num = Vector3.Distance(((Component)val.gameplayCamera).transform.position, strikePosition);
		float num2 = Vector3.Distance(((Component)val.gameplayCamera).transform.position, pos1.transform.position);
		bool flag = false;
		if (num < 30f || num2 < 30f)
		{
			HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
		}
		else if (num < 70f)
		{
			HUDManager.Instance.ShakeCamera((ScreenShakeType)2);
		}
		else
		{
			flag = true;
		}
		AudioClip[] array = strikeSFX;
		if (flag && chargeBuild >= 10)
		{
			array = distantThunderSFX;
		}
		if (array.Length != 0)
		{
			if (!val.isInsideFactory && (num < 30f || num2 < 30f || chargeBuild >= 10))
			{
				RoundManager.PlayRandomClip(audio, array, true, 1f, 0, 1000);
			}
			WalkieTalkie.TransmitOneShotAudio(audio, array[Random.Range(0, array.Length)], 1f);
			Bounds bounds = StartOfRound.Instance.shipBounds.bounds;
			if (((Bounds)(ref bounds)).Contains(strikePosition))
			{
				((Component)StartOfRound.Instance.shipAnimatorObject).GetComponent<Animator>().SetTrigger("shipShake");
				RoundManager.PlayRandomClip(StartOfRound.Instance.ship3DAudio, StartOfRound.Instance.shipCreakSFX, false, 1f, 0, 1000);
				StartOfRound.Instance.PowerSurgeShip();
			}
		}
	}

	public IEnumerator disableEffects()
	{
		yield return (object)new WaitForSeconds(0.24f);
		Explosion.Stop();
		veARC.Stop();
	}

	public IEnumerator ChargeIncrease()
	{
		while (powerIsOff)
		{
			yield return null;
			chargeBuild++;
			Debug.Log((object)("Increase charge: " + chargeBuild));
			RelayNetwork.Instance.ChargeServerRpc(chargeBuild);
			yield return (object)new WaitForSeconds(15f);
		}
	}

	public IEnumerator InternalSounds()
	{
		float time = 3f;
		while (true)
		{
			if (((NetworkBehaviour)RelayNetwork.Instance).IsHost)
			{
				if (serverRand.Next(0, 5) == 0 && Internal.Length != 0)
				{
					RelayNetwork.Instance.PlaySoundServerRpc();
				}
				if (powerIsOff)
				{
					time = 2f;
				}
				yield return (object)new WaitForSeconds(time);
			}
		}
	}

	public void PickSound()
	{
		AudioClip val = Internal[rand.Next(0, Internal.Length)];
		if (powerIsOff)
		{
			val = AfterPowerDownInside[rand.Next(0, AfterPowerDownInside.Length)];
		}
		InsideSource.PlayOneShot(val);
	}

	public IEnumerator CallFunctionRepeatedly()
	{
		yield return (object)new WaitForSeconds(0.5f);
		while (true)
		{
			if (((NetworkBehaviour)RelayNetwork.Instance).IsHost)
			{
				RelayNetwork.Instance.DischargeCloseServerRpc();
				float nextStrikeSeconds = ((10f / (float)(chargeBuild / 5 + 1) >= 0.4f) ? (5f / (float)(chargeBuild / 5 + 1)) : 0.4f);
				yield return (object)new WaitForSeconds(nextStrikeSeconds);
			}
		}
	}
}
namespace RelayStationBehaviour
{
	[BepInPlugin("InstanceWorld.RelayStation", "Relay Station Scripts", "2.0.0")]
	public class RelayPatcher : BaseUnityPlugin
	{
		private Harmony harmony = new Harmony("InstanceWorld.RelayStation");

		private const string GUID = "InstanceWorld.RelayStation";

		private const string NAME = "Relay Station Scripts";

		private const string VERSION = "2.0.0";

		private static RelayPatcher Inst;

		public static GameObject unstableRelay;

		internal static ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Inst == (Object)null)
			{
				Inst = this;
			}
			mls = Logger.CreateLogSource("InstanceWorld.RelayStation");
			mls.LogInfo((object)"Starting RelayPatcher...");
			harmony.PatchAll(typeof(RelayPatcher));
			harmony.PatchAll(typeof(UnstableRelay));
			harmony.PatchAll(typeof(CloseNodeIdentifier));
			harmony.PatchAll(typeof(FarNodeIdentifier));
			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);
					}
				}
			}
			mls.LogInfo((object)"Loaded extra scripts");
		}
	}
}
namespace RelayStationBehaviour.Behaviors
{
	public class CloseNodeIdentifier : MonoBehaviour
	{
	}
	public class FarNodeIdentifier : MonoBehaviour
	{
	}
	public class RelayNetwork : NetworkBehaviour
	{
		public static RelayNetwork Instance;

		public UnstableRelay UnstableRef;

		private void FOR_PEOPLE_THAT_ARE_LOOKING_FOR_HOW_TO_DO_NETWORKING()
		{
			Debug.Log((object)"This process took me a bit to figure out so I want to leave a note for others");
			Debug.Log((object)"Unity does some post processing on net code that does not happen when you are doing compiling in VS");
			Debug.Log((object)"step 1: Make sure your RCP call all end with the correct rcp: ex: Seed + ServerRpc for naming");
			Debug.Log((object)"step 2: dont send anything complicated into the rcp functions or you will need to create some functions that turn it into bytes");
			Debug.Log((object)"step 3: Use evaisaDev's UnityNetcodePatcher. This is a command line plugin that does the unity post processing. It looks intimidating but takes 5 min to do. Use the managed folder as references + anything else you are using");
			Debug.Log((object)"step 4: Load the complied dll into the unity project with your level. Dont make it part of an assat pack. you can now use the classes from the dll in the level. If you do this you will not need to bind things to the networkmanager (levels are static)");
			Debug.Log((object)": https://github.com/EvaisaDev/UnityNetcodePatcher + https://lethal.wiki/dev/advanced/networking");
			Debug.Log((object)"hint 1: to change the debug symbols you, rightclick the second highest file in the VS solution explorer  and click unload. After that you can rightclick it and edit the file and look for where it says full");
			Debug.Log((object)"hint 2: From testing it seems that it is best to do a serverrcp before your client rcp, but I might be wrong");
			Debug.Log((object)"hint 3: complie in VS with debug.");
			Debug.Log((object)"hint 4: make sure that randoms are synced at the start, avoid using the synced random on just one device otherwise it will desync. If a event is meant to happen at the same time, make sure that the server starts the event and tells the clients what to triggure");
			Debug.Log((object)"hope this helps, GL --InstanceWorld");
		}

		private void Awake()
		{
			Debug.Log((object)"awake network");
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			else
			{
				Object.Destroy((Object)(object)((Component)Instance).gameObject);
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				RelayPatcher.mls.LogInfo((object)"Is server");
			}
			if (((NetworkBehaviour)this).IsClient)
			{
				RelayPatcher.mls.LogInfo((object)"Is client");
			}
			if (((NetworkBehaviour)this).NetworkManager.IsServer)
			{
				RelayPatcher.mls.LogInfo((object)"Is network server");
			}
			if (((NetworkBehaviour)this).NetworkManager.IsHost)
			{
				RelayPatcher.mls.LogInfo((object)"Is network host");
			}
			if (((NetworkBehaviour)this).NetworkManager.IsClient)
			{
				RelayPatcher.mls.LogInfo((object)"Is network client");
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				RelayPatcher.mls.LogInfo((object)"Is owner");
			}
			UnstableRef = Object.FindObjectOfType<UnstableRelay>(true);
			Debug.Log((object)("Linked to networkmanager: " + (((Object)(object)((NetworkBehaviour)this).NetworkManager != (Object)null) ? "connected" : "Not connected")));
		}

		[ServerRpc]
		public void SeedServerRpc(int seed)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1123113372u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, seed);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1123113372u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SyncRandomSeedClientRpc(seed);
			}
		}

		[ClientRpc]
		public void SyncRandomSeedClientRpc(int seed)
		{
			//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1604988898u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, seed);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1604988898u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					RelayPatcher.mls.LogInfo((object)("Client: seed given: " + seed));
					UnstableRef.rand = new Random(seed);
				}
			}
		}

		[ServerRpc]
		public void PowerOffServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2415708047u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2415708047u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				PowerOffClientRpc();
			}
		}

		[ClientRpc]
		private void PowerOffClientRpc()
		{
			//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3709787942u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3709787942u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					UnstableRef.PowerOff();
				}
			}
		}

		[ServerRpc]
		public void ChargeServerRpc(int newcharge)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3354784151u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, newcharge);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3354784151u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ChargeClientRpc(newcharge);
			}
		}

		[ClientRpc]
		private void ChargeClientRpc(int newcharge)
		{
			//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(510741142u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, newcharge);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 510741142u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					UnstableRef.chargeBuild = newcharge;
				}
			}
		}

		[ServerRpc]
		public void PlaySoundServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(136197912u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 136197912u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				PlaySoundClientRpc();
			}
		}

		[ClientRpc]
		private void PlaySoundClientRpc()
		{
			//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1341534218u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1341534218u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					UnstableRef.PickSound();
				}
			}
		}

		[ServerRpc]
		public void DischargeCloseServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2107098541u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2107098541u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				DischargeCloseClientRpc();
			}
		}

		[ClientRpc]
		private void DischargeCloseClientRpc()
		{
			//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1771303250u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1771303250u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					UnstableRef.DischargeClose();
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_RelayNetwork()
		{
			//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
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1123113372u, new RpcReceiveHandler(__rpc_handler_1123113372));
			NetworkManager.__rpc_func_table.Add(1604988898u, new RpcReceiveHandler(__rpc_handler_1604988898));
			NetworkManager.__rpc_func_table.Add(2415708047u, new RpcReceiveHandler(__rpc_handler_2415708047));
			NetworkManager.__rpc_func_table.Add(3709787942u, new RpcReceiveHandler(__rpc_handler_3709787942));
			NetworkManager.__rpc_func_table.Add(3354784151u, new RpcReceiveHandler(__rpc_handler_3354784151));
			NetworkManager.__rpc_func_table.Add(510741142u, new RpcReceiveHandler(__rpc_handler_510741142));
			NetworkManager.__rpc_func_table.Add(136197912u, new RpcReceiveHandler(__rpc_handler_136197912));
			NetworkManager.__rpc_func_table.Add(1341534218u, new RpcReceiveHandler(__rpc_handler_1341534218));
			NetworkManager.__rpc_func_table.Add(2107098541u, new RpcReceiveHandler(__rpc_handler_2107098541));
			NetworkManager.__rpc_func_table.Add(1771303250u, new RpcReceiveHandler(__rpc_handler_1771303250));
		}

		private static void __rpc_handler_1123113372(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				int seed = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref seed);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RelayNetwork)(object)target).SeedServerRpc(seed);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1604988898(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 seed = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref seed);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((RelayNetwork)(object)target).SyncRandomSeedClientRpc(seed);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2415708047(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RelayNetwork)(object)target).PowerOffServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3709787942(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;
				((RelayNetwork)(object)target).PowerOffClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3354784151(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				int newcharge = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref newcharge);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RelayNetwork)(object)target).ChargeServerRpc(newcharge);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_510741142(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 newcharge = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref newcharge);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((RelayNetwork)(object)target).ChargeClientRpc(newcharge);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_136197912(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RelayNetwork)(object)target).PlaySoundServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1341534218(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;
				((RelayNetwork)(object)target).PlaySoundClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2107098541(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RelayNetwork)(object)target).DischargeCloseServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1771303250(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;
				((RelayNetwork)(object)target).DischargeCloseClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "RelayNetwork";
		}
	}
}
namespace RelayStationBehaviour.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}