Decompiled source of RadioFurniture v1.0.0

BepInEx/plugins/RadioBrowser.dll

Decompiled 11 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using RadioBrowser.Api;
using RadioBrowser.Internals;
using RadioBrowser.Internals.JsonConverters;
using RadioBrowser.Models;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("bt")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("(c) 2020 by bt, GPL v3")]
[assembly: AssemblyDescription("Radio Browser API wrapper")]
[assembly: AssemblyFileVersion("0.7.0.0")]
[assembly: AssemblyInformationalVersion("0.7.0")]
[assembly: AssemblyProduct("RadioBrowser")]
[assembly: AssemblyTitle("RadioBrowser")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://git.sr.ht/youkai/RadioBrowser.NET")]
[assembly: AssemblyVersion("0.7.0.0")]
namespace RadioBrowser
{
	public interface IRadioBrowserClient
	{
		Search Search { get; }

		Lists Lists { get; }

		Stations Stations { get; }

		RadioBrowser.Internals.HttpClient HttpClient { get; }

		Modify Modify { get; }
	}
	public class RadioBrowserClient : IRadioBrowserClient
	{
		public Search Search { get; }

		public Lists Lists { get; }

		public Stations Stations { get; }

		public RadioBrowser.Internals.HttpClient HttpClient { get; }

		public Modify Modify { get; }

		public RadioBrowserClient(string apiUrl = null, string customUserAgent = null)
		{
			Converters converters = new Converters();
			HttpClient = new RadioBrowser.Internals.HttpClient(apiUrl, customUserAgent);
			Search = new Search(HttpClient, converters);
			Lists = new Lists(HttpClient, converters);
			Stations = new Stations(HttpClient, converters);
			Modify = new Modify(HttpClient, converters);
		}
	}
}
namespace RadioBrowser.Models
{
	public class ActionResult
	{
		public bool Ok { get; set; }

		public string Message { get; set; }
	}
	public class AddStationResult : ActionResult
	{
		public Guid Uuid { get; set; }
	}
	public class AdvancedSearchOptions
	{
		public string Name { get; set; }

		public string NameExact { get; set; }

		public string Country { get; set; }

		public bool? CountryExact { get; set; }

		public string Countrycode { get; set; }

		public string State { get; set; }

		public bool? StateExact { get; set; }

		public string Language { get; set; }

		public string LanguageExact { get; set; }

		public bool? TagExact { get; set; }

		public string TagList { get; set; }

		public string Codec { get; set; }

		public uint? BitrateMin { get; set; }

		public uint? BitrateMax { get; set; }

		public string Order { get; set; }

		public bool? Reverse { get; set; }

		public uint? Offset { get; set; }

		public uint? Limit { get; set; }
	}
	public class ClickResult : ActionResult
	{
		public Guid StationUuid { get; set; }

		public string Name { get; set; }

		public Uri Url { get; set; }
	}
	public class NameAndCount
	{
		public string Name { get; set; }

		public uint Stationcount { get; set; }
	}
	public class NewStation
	{
		public string Name { get; set; }

		public Uri Url { get; set; }

		public Uri Homepage { get; set; }

		public Uri Favicon { get; set; }

		public string Country { get; set; }

		public string CountryCode { get; set; }

		public string State { get; set; }

		public string Language { get; set; }

		public string Tags { get; set; }
	}
	public class State : NameAndCount
	{
		public string Country { get; set; }
	}
	public class StationInfo
	{
		public Guid ChangeUuid { get; set; }

		public Guid StationUuid { get; set; }

		public string Name { get; set; }

		[JsonConverter(typeof(UriConverter))]
		public Uri Url { get; set; }

		[JsonProperty("url_resolved")]
		[JsonConverter(typeof(UriConverter))]
		public Uri UrlResolved { get; set; }

		[JsonConverter(typeof(UriConverter))]
		public Uri Homepage { get; set; }

		[JsonConverter(typeof(UriConverter))]
		public Uri Favicon { get; set; }

		[JsonConverter(typeof(ListConverter))]
		public List<string> Tags { get; set; }

		public string CountryCode { get; set; }

		[JsonConverter(typeof(ListConverter))]
		public List<string> Language { get; set; }

		public int Votes { get; set; }

		[JsonConverter(typeof(DateTimeConverter))]
		public DateTime LastChangeTime { get; set; }

		public string Codec { get; set; }

		public int Bitrate { get; set; }

		[JsonConverter(typeof(BoolConverter))]
		public bool Hls { get; set; }

		[JsonConverter(typeof(BoolConverter))]
		public bool LastCheckOk { get; set; }

		[JsonConverter(typeof(DateTimeConverter))]
		public DateTime LastCheckTime { get; set; }

		[JsonConverter(typeof(DateTimeConverter))]
		public DateTime LastCheckOkTime { get; set; }

		[JsonConverter(typeof(DateTimeConverter))]
		public DateTime LastLocalCheckTime { get; set; }

		[JsonConverter(typeof(DateTimeConverter))]
		public DateTime ClickTimestamp { get; set; }

		public int ClickCount { get; set; }

		public int ClickTrend { get; set; }
	}
}
namespace RadioBrowser.Internals
{
	internal class Converters
	{
		private readonly JsonSerializerSettings _jsonSerializerSettings;

		internal Converters()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0030: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			_jsonSerializerSettings = new JsonSerializerSettings
			{
				ContractResolver = (IContractResolver)new DefaultContractResolver
				{
					NamingStrategy = (NamingStrategy)new CamelCaseNamingStrategy
					{
						ProcessDictionaryKeys = true,
						OverrideSpecifiedNames = false
					}
				},
				NullValueHandling = (NullValueHandling)1
			};
		}

		internal List<StationInfo> ToStationsList(string json)
		{
			return JsonConvert.DeserializeObject<List<StationInfo>>(json, _jsonSerializerSettings);
		}

		internal List<NameAndCount> ToNameAndCountList(string json)
		{
			return JsonConvert.DeserializeObject<List<NameAndCount>>(json, _jsonSerializerSettings);
		}

		internal List<State> ToStatesList(string json)
		{
			return JsonConvert.DeserializeObject<List<State>>(json, _jsonSerializerSettings);
		}

		internal ActionResult ToActionResult(string json)
		{
			return JsonConvert.DeserializeObject<ActionResult>(json, _jsonSerializerSettings);
		}

		internal ClickResult ToClickResult(string json)
		{
			return JsonConvert.DeserializeObject<ClickResult>(json, _jsonSerializerSettings);
		}

		internal AddStationResult ToAddStationResult(string json)
		{
			return JsonConvert.DeserializeObject<AddStationResult>(json, _jsonSerializerSettings);
		}

		internal static string GetQueryString(object obj)
		{
			IEnumerable<string> source = from p in obj.GetType().GetProperties()
				where p.GetValue(obj, null) != null
				select char.ToLowerInvariant(p.Name[0]) + p.Name.Substring(1) + "=" + HttpUtility.UrlEncode(Convert.ToString(p.GetValue(obj, null)));
			return string.Join("&", source.ToArray());
		}
	}
	public class HttpClient
	{
		private readonly System.Net.Http.HttpClient _httpClient;

		public string ApiUrl { get; }

		public string UserAgent { get; }

		internal HttpClient(string apiUrl, string userAgent)
		{
			ApiUrl = apiUrl ?? GetRadioBrowserApiUrl();
			UserAgent = userAgent ?? "RadioBrowser.NET Library/0.4";
			_httpClient = new System.Net.Http.HttpClient();
			_httpClient.DefaultRequestHeaders.Add("User-Agent", UserAgent);
		}

		private static string GetRadioBrowserApiUrl()
		{
			IPAddress[] hostAddresses = Dns.GetHostAddresses("all.api.radio-browser.info");
			long num = long.MaxValue;
			string text = "de1.api.radio-browser.info";
			IPAddress[] array = hostAddresses;
			foreach (IPAddress iPAddress in array)
			{
				try
				{
					PingReply pingReply = new Ping().Send(iPAddress);
					if (pingReply != null && pingReply.RoundtripTime < num)
					{
						num = pingReply.RoundtripTime;
						text = iPAddress.ToString();
					}
				}
				catch (SocketException)
				{
				}
			}
			IPHostEntry hostEntry = Dns.GetHostEntry(text);
			if (!string.IsNullOrEmpty(hostEntry.HostName))
			{
				text = hostEntry.HostName;
			}
			return text;
		}

		internal async Task<string> GetAsync(string endpoint)
		{
			HttpResponseMessage httpResponseMessage = await _httpClient.GetAsync("https://" + ApiUrl + "/json/" + endpoint);
			return (!httpResponseMessage.IsSuccessStatusCode) ? null : (await httpResponseMessage.Content.ReadAsStringAsync());
		}
	}
}
namespace RadioBrowser.Internals.JsonConverters
{
	public class BoolConverter : JsonConverter
	{
		public override bool CanConvert(Type objectType)
		{
			return objectType == typeof(bool);
		}

		public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0045: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			JsonToken tokenType = reader.TokenType;
			if ((int)tokenType != 7)
			{
				if ((int)tokenType == 9)
				{
					return reader.Value.ToString() == "1";
				}
				JsonToken tokenType2 = reader.TokenType;
				throw new JsonSerializationException("Unexpected token type: " + ((object)(JsonToken)(ref tokenType2)).ToString());
			}
			return Convert.ToInt32(reader.Value) == 1;
		}

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			throw new NotSupportedException();
		}
	}
	public class DateTimeConverter : JsonConverter<DateTime>
	{
		public override DateTime ReadJson(JsonReader reader, Type objectType, DateTime existingValue, bool hasExistingValue, JsonSerializer serializer)
		{
			try
			{
				return DateTime.ParseExact((string)reader.Value, "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture);
			}
			catch (FormatException)
			{
				return new DateTime(0L);
			}
		}

		public override void WriteJson(JsonWriter writer, DateTime value, JsonSerializer serializer)
		{
			throw new NotSupportedException();
		}
	}
	public class ListConverter : JsonConverter<List<string>>
	{
		public override List<string> ReadJson(JsonReader reader, Type objectType, List<string> existingValue, bool hasExistingValue, JsonSerializer serializer)
		{
			return (from s in ((string)reader.Value)?.Split(',')
				select s.Trim()).ToList();
		}

		public override void WriteJson(JsonWriter writer, List<string> value, JsonSerializer serializer)
		{
			throw new NotSupportedException();
		}
	}
	public class UriConverter : JsonConverter<Uri>
	{
		public override Uri ReadJson(JsonReader reader, Type objectType, Uri existingValue, bool hasExistingValue, JsonSerializer serializer)
		{
			try
			{
				return new Uri((string)reader.Value);
			}
			catch (UriFormatException)
			{
				return null;
			}
		}

		public override void WriteJson(JsonWriter writer, Uri value, JsonSerializer serializer)
		{
			throw new NotSupportedException();
		}
	}
}
namespace RadioBrowser.Api
{
	public class Lists
	{
		private readonly Converters _converters;

		private readonly RadioBrowser.Internals.HttpClient _httpClient;

		internal Lists(RadioBrowser.Internals.HttpClient httpClient, Converters converters)
		{
			_httpClient = httpClient;
			_converters = converters;
		}

		public async Task<List<StationInfo>> GetAllStationsAsync()
		{
			Converters converters = _converters;
			return converters.ToStationsList(await _httpClient.GetAsync("stations"));
		}

		public async Task<List<NameAndCount>> GetCountriesAsync(string filter = null)
		{
			List<NameAndCount> result;
			if (filter == null)
			{
				Converters converters = _converters;
				result = converters.ToNameAndCountList(await _httpClient.GetAsync("countries"));
			}
			else
			{
				Converters converters = _converters;
				result = converters.ToNameAndCountList(await _httpClient.GetAsync("countries/" + filter));
			}
			return result;
		}

		public async Task<List<NameAndCount>> GetCountriesCodesAsync(string filter = null)
		{
			List<NameAndCount> result;
			if (filter == null)
			{
				Converters converters = _converters;
				result = converters.ToNameAndCountList(await _httpClient.GetAsync("countrycodes"));
			}
			else
			{
				Converters converters = _converters;
				result = converters.ToNameAndCountList(await _httpClient.GetAsync("countrycodes/" + filter));
			}
			return result;
		}

		public async Task<List<NameAndCount>> GetCodecsAsync(string filter = null)
		{
			List<NameAndCount> result;
			if (filter == null)
			{
				Converters converters = _converters;
				result = converters.ToNameAndCountList(await _httpClient.GetAsync("codecs"));
			}
			else
			{
				Converters converters = _converters;
				result = converters.ToNameAndCountList(await _httpClient.GetAsync("codecs/" + filter));
			}
			return result;
		}

		public async Task<List<State>> GetStatesAsync(string filter = null)
		{
			List<State> result;
			if (filter == null)
			{
				Converters converters = _converters;
				result = converters.ToStatesList(await _httpClient.GetAsync("states"));
			}
			else
			{
				Converters converters = _converters;
				result = converters.ToStatesList(await _httpClient.GetAsync("states/" + filter));
			}
			return result;
		}

		public async Task<List<NameAndCount>> GetLanguagesAsync(string filter = null)
		{
			List<NameAndCount> result;
			if (filter == null)
			{
				Converters converters = _converters;
				result = converters.ToNameAndCountList(await _httpClient.GetAsync("languages"));
			}
			else
			{
				Converters converters = _converters;
				result = converters.ToNameAndCountList(await _httpClient.GetAsync("languages/" + filter));
			}
			return result;
		}

		public async Task<List<NameAndCount>> GetTagsAsync(string filter = null)
		{
			List<NameAndCount> result;
			if (filter == null)
			{
				Converters converters = _converters;
				result = converters.ToNameAndCountList(await _httpClient.GetAsync("tags"));
			}
			else
			{
				Converters converters = _converters;
				result = converters.ToNameAndCountList(await _httpClient.GetAsync("tags/" + filter));
			}
			return result;
		}
	}
	public class Modify
	{
		private readonly Converters _converters;

		private readonly RadioBrowser.Internals.HttpClient _httpClient;

		internal Modify(RadioBrowser.Internals.HttpClient httpClient, Converters converters)
		{
			_httpClient = httpClient;
			_converters = converters;
		}

		public async Task<ClickResult> ClickAsync(Guid uuid)
		{
			string json = await _httpClient.GetAsync($"/url/{uuid}");
			return _converters.ToClickResult(json);
		}

		public async Task<ActionResult> VoteAsync(Guid uuid)
		{
			string json = await _httpClient.GetAsync($"/vote/{uuid}");
			return _converters.ToActionResult(json);
		}

		public async Task<AddStationResult> AddStationAsync(NewStation newStation)
		{
			string json = await _httpClient.GetAsync("json/add/" + Converters.GetQueryString(newStation));
			return _converters.ToAddStationResult(json);
		}
	}
	public class Search
	{
		private readonly Converters _converters;

		private readonly RadioBrowser.Internals.HttpClient _httpClient;

		internal Search(RadioBrowser.Internals.HttpClient httpClient, Converters converters)
		{
			_httpClient = httpClient;
			_converters = converters;
		}

		public async Task<List<StationInfo>> AdvancedAsync(AdvancedSearchOptions searchOptions)
		{
			string json = await _httpClient.GetAsync("stations/search?" + Converters.GetQueryString(searchOptions));
			return _converters.ToStationsList(json);
		}

		public async Task<List<StationInfo>> ByNameAsync(string name)
		{
			string json = await _httpClient.GetAsync("stations/search?name=" + name);
			return _converters.ToStationsList(json);
		}

		public async Task<List<StationInfo>> ByUuidAsync(Guid uuid)
		{
			string json = await _httpClient.GetAsync("stations/byuuid?uuids=" + uuid);
			return _converters.ToStationsList(json);
		}

		public async Task<List<StationInfo>> ByUrlAsync(string url)
		{
			string json = await _httpClient.GetAsync("stations/byurl?url=" + url);
			return _converters.ToStationsList(json);
		}
	}
	public class Stations
	{
		private readonly Converters _converters;

		private readonly RadioBrowser.Internals.HttpClient _httpClient;

		internal Stations(RadioBrowser.Internals.HttpClient httpClient, Converters converters)
		{
			_httpClient = httpClient;
			_converters = converters;
		}

		public async Task<List<StationInfo>> GetByClicksAsync(uint limit = 0u)
		{
			Converters converters;
			if (limit == 0)
			{
				converters = _converters;
				return converters.ToStationsList(await _httpClient.GetAsync("stations/topclick"));
			}
			converters = _converters;
			return converters.ToStationsList(await _httpClient.GetAsync($"stations/topclick/{limit}"));
		}

		public async Task<List<StationInfo>> GetByVotesAsync(uint limit = 0u)
		{
			Converters converters;
			if (limit == 0)
			{
				converters = _converters;
				return converters.ToStationsList(await _httpClient.GetAsync("stations/topvote"));
			}
			converters = _converters;
			return converters.ToStationsList(await _httpClient.GetAsync($"stations/topvote/{limit}"));
		}

		public async Task<List<StationInfo>> GetByRecentClickAsync(uint limit = 0u)
		{
			Converters converters;
			if (limit == 0)
			{
				converters = _converters;
				return converters.ToStationsList(await _httpClient.GetAsync("stations/lastclick"));
			}
			converters = _converters;
			return converters.ToStationsList(await _httpClient.GetAsync($"stations/lastclick/{limit}"));
		}

		public async Task<List<StationInfo>> GetByLastChangesAsync(uint limit = 0u)
		{
			Converters converters;
			if (limit == 0)
			{
				converters = _converters;
				return converters.ToStationsList(await _httpClient.GetAsync("stations/lastchange"));
			}
			converters = _converters;
			return converters.ToStationsList(await _httpClient.GetAsync($"stations/lastchange/{limit}"));
		}

		public async Task<List<StationInfo>> GetByCodecAsync(string codec, uint limit = 0u)
		{
			Converters converters;
			if (limit == 0)
			{
				converters = _converters;
				return converters.ToStationsList(await _httpClient.GetAsync("stations/bycodec/" + codec));
			}
			converters = _converters;
			return converters.ToStationsList(await _httpClient.GetAsync($"stations/bycodec/{codec}/{limit}"));
		}
	}
}

BepInEx/plugins/RadioFurniture.dll

Decompiled 11 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.CompilerServices;
using HarmonyLib;
using LethalLib.Extras;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using NAudio.Wave;
using RadioBrowser;
using RadioBrowser.Models;
using RadioFurniture.Behaviour;
using RadioFurniture.ClipLoading;
using RadioFurniture.Events;
using RadioFurniture.Managers;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Networking;

[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("RadioFurniture")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RadioFurniture")]
[assembly: AssemblyTitle("RadioFurniture")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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 WebRequestAudio.ClipLoading
{
	public class DisposableAudioWebRequest : IDisposable
	{
		private DisposableAudioClip _disposableAudioClip;

		private UnityWebRequest _request;

		private bool _disposed = false;

		private string _error;

		private int _code;

		private bool _isDone = false;

		public DisposableAudioClip AudioClip => _disposableAudioClip;

		public string Error => _error;

		public int Code => _code;

		public bool IsDone => _isDone;

		public bool IsDisposed => _disposed;

		public DisposableAudioWebRequest(UnityWebRequest request)
		{
			_request = request;
		}

		public string GetReadableError()
		{
			return $"Code : {_code} {_error}";
		}

		public bool HasErrors()
		{
			return !string.IsNullOrEmpty(_error);
		}

		internal void SetDisposableClip(DisposableAudioClip clip)
		{
			_disposableAudioClip = clip;
		}

		internal void SetStatus()
		{
			_code = (int)_request.responseCode;
			_error = _request.error;
			_isDone = _request.isDone;
		}

		public void Dispose()
		{
			if (!_disposed)
			{
				_disposed = true;
				if (_request != null)
				{
					SetStatus();
					_request.Dispose();
				}
				_request = null;
			}
		}
	}
}
namespace RadioFurniture
{
	[BepInPlugin("RadioFurniture", "RadioFurniture", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance;

		private void Awake()
		{
			Instance = this;
			UnlockableItemDef val = LoadAssets();
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Failed to load radio because assetbundle does not exist. Disabling!");
				return;
			}
			RegisterRPCs();
			Unlockables.RegisterUnlockable(val.unlockable, 80, (StoreType)1);
			RadioManager.PreloadStations();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RadioFurniture is loaded!");
		}

		private void RegisterRPCs()
		{
			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);
					}
				}
			}
		}

		private UnlockableItemDef? LoadAssets()
		{
			string text = Path.Join((ReadOnlySpan<char>)Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), (ReadOnlySpan<char>)"radio");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			UnlockableItemDef val2 = val.LoadAsset<UnlockableItemDef>("assets/data/radio.asset");
			if ((Object)(object)val2?.unlockable?.prefabObject != (Object)null)
			{
				NetworkPrefabs.RegisterNetworkPrefab(val2.unlockable.prefabObject);
			}
			return val2;
		}

		public static void Log(string log)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)log);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "RadioFurniture";

		public const string PLUGIN_NAME = "RadioFurniture";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace RadioFurniture.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	public class RoundManagerPatches
	{
		[HarmonyPatch("SetToCurrentLevelWeather")]
		[HarmonyPostfix]
		private static void SetToCurrentLevelWeather(ref SelectableLevel ___currentLevel)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			if ((int)___currentLevel.currentWeather == 2)
			{
				WeatherEvents.StormStart();
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartOfRoundPatches
	{
		[HarmonyPatch("EndOfGame")]
		[HarmonyPrefix]
		private static void EndOfGame(ref SelectableLevel ___currentLevel)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			if ((int)___currentLevel.currentWeather == 2)
			{
				WeatherEvents.StormEnd();
			}
		}

		[HarmonyPatch("PowerSurgeShip")]
		[HarmonyPostfix]
		private static void PowerSurgeShip()
		{
			try
			{
				RadioBehaviour radioBehaviour = Object.FindObjectOfType<RadioBehaviour>();
				if ((Object)(object)radioBehaviour != (Object)null)
				{
					radioBehaviour.TurnOffRadioServerRpc();
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)"Something went wrong forcing radio off...");
				Debug.LogWarning((object)ex);
			}
		}

		[HarmonyPatch("SyncShipUnlockablesClientRpc")]
		[HarmonyPostfix]
		private static void SyncShipUnlockablesClientRpc()
		{
			try
			{
				RadioBehaviour radioBehaviour = Object.FindObjectOfType<RadioBehaviour>();
				if ((Object)(object)radioBehaviour != (Object)null)
				{
					radioBehaviour.SyncRadioServerRpc();
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)"Something went wrong forcing radio sync...");
				Debug.LogWarning((object)ex);
			}
		}
	}
}
namespace RadioFurniture.Managers
{
	public static class RadioManager
	{
		[CompilerGenerated]
		private sealed class <GetRadioStations>d__2 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			private RadioBrowserClient <radioBrowser>5__1;

			private List<StationInfo> <topByVotes>5__2;

			private List<StationInfo> <>s__3;

			private TaskAwaiter<List<StationInfo>> <>u__1;

			private void MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				int num = <>1__state;
				try
				{
					TaskAwaiter<List<StationInfo>> awaiter;
					if (num != 0)
					{
						Debug.Log((object)"Searching Radio API for stations!");
						<radioBrowser>5__1 = new RadioBrowserClient((string)null, (string)null);
						awaiter = <radioBrowser>5__1.Stations.GetByVotesAsync(10000u).GetAwaiter();
						if (!awaiter.IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							<GetRadioStations>d__2 <GetRadioStations>d__ = this;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<TaskAwaiter<List<StationInfo>>, <GetRadioStations>d__2>(ref awaiter, ref <GetRadioStations>d__);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(TaskAwaiter<List<StationInfo>>);
						num = (<>1__state = -1);
					}
					<>s__3 = awaiter.GetResult();
					<topByVotes>5__2 = <>s__3;
					<>s__3 = null;
					_stations = <topByVotes>5__2.Where((StationInfo x) => x != null && x.Codec != null && x.Codec == "MP3" && x.UrlResolved != null && x.UrlResolved.Scheme == "https").ToList();
					Debug.Log((object)"Finished searching radio API for stations.");
					Debug.Log((object)$"Found {_stations.Count}");
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					<radioBrowser>5__1 = null;
					<topByVotes>5__2 = null;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				<radioBrowser>5__1 = null;
				<topByVotes>5__2 = null;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		private static List<StationInfo> _stations = new List<StationInfo>();

		public static void PreloadStations()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			UniTaskExtensions.Forget(GetRadioStations());
		}

		[AsyncStateMachine(typeof(<GetRadioStations>d__2))]
		[DebuggerStepThrough]
		private static UniTask GetRadioStations()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			<GetRadioStations>d__2 <GetRadioStations>d__ = new <GetRadioStations>d__2();
			<GetRadioStations>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<GetRadioStations>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <GetRadioStations>d__.<>t__builder)).Start<<GetRadioStations>d__2>(ref <GetRadioStations>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <GetRadioStations>d__.<>t__builder)).Task;
		}

		public static StationInfo? GetRandomRadioStation()
		{
			if (_stations.Count == 0)
			{
				return null;
			}
			StationInfo val = _stations[Random.Range(0, _stations.Count)];
			Debug.Log((object)val.Name);
			Debug.Log((object)val.StationUuid);
			return val;
		}

		public static StationInfo? GetRadioStationByGuid(Guid guid)
		{
			return ((IEnumerable<StationInfo>)_stations).FirstOrDefault((Func<StationInfo, bool>)((StationInfo x) => x.StationUuid == guid));
		}
	}
}
namespace RadioFurniture.Events
{
	public static class WeatherEvents
	{
		public static event Action OnStormStarted;

		public static event Action OnStormEnded;

		public static void StormStart()
		{
			WeatherEvents.OnStormStarted?.Invoke();
			Debug.Log((object)"Storm started!");
		}

		public static void StormEnd()
		{
			Debug.Log((object)"Storm ended!");
			WeatherEvents.OnStormEnded?.Invoke();
		}
	}
}
namespace RadioFurniture.ClipLoading
{
	public class DisposableAudioClip : IDisposable
	{
		private AudioSource _source;

		private AudioClip _clip;

		private CancellationToken _token;

		private bool _disposed = false;

		public AudioClip AudioClip => _clip;

		public bool Disposed => _disposed;

		public DisposableAudioClip(AudioSource source, AudioClip clip)
		{
			_source = source;
			_clip = clip;
			SetToken(default(CancellationToken));
		}

		internal void SetToken(CancellationToken token)
		{
			_token = token;
			_token.Register(delegate
			{
				Dispose();
			});
		}

		public void Dispose()
		{
			_disposed = true;
			if ((Object)(object)_source != (Object)null)
			{
				StopAndCleanSource();
			}
			if ((Object)(object)_clip != (Object)null)
			{
				Object.Destroy((Object)(object)_clip);
			}
			_source = null;
			_clip = null;
		}

		private void StopAndCleanSource()
		{
			if ((Object)(object)_source.clip == (Object)(object)_clip)
			{
				_source.Stop();
				_source.clip = null;
			}
		}
	}
	public class MP3Stream
	{
		private enum StreamingPlaybackState
		{
			Stopped,
			Playing,
			Buffering,
			Paused
		}

		private delegate void ShowErrorDelegate(string message);

		public bool Distorted = false;

		public bool decomp = false;

		public string buffer_info;

		public string song_info;

		public BufferedWaveProvider bufferedWaveProvider;

		private AudioSource _audioSource;

		private volatile StreamingPlaybackState playbackState;

		private volatile bool fullyDownloaded;

		private static HttpClient httpClient;

		private HttpWebRequest webRequest;

		private bool IsBufferNearlyFull => bufferedWaveProvider != null && bufferedWaveProvider.BufferLength - bufferedWaveProvider.BufferedBytes < bufferedWaveProvider.WaveFormat.AverageBytesPerSecond / 4;

		private void ShowError(string message)
		{
			Debug.LogWarning((object)message);
		}

		public void PlayStream(string streamUrl, AudioSource audioSource)
		{
			_audioSource = audioSource;
			if (playbackState == StreamingPlaybackState.Stopped)
			{
				playbackState = StreamingPlaybackState.Buffering;
				bufferedWaveProvider = null;
				ThreadPool.QueueUserWorkItem(StreamMp3, streamUrl);
			}
			else if (playbackState == StreamingPlaybackState.Paused)
			{
				playbackState = StreamingPlaybackState.Buffering;
			}
		}

		private void StreamMp3(object state)
		{
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			fullyDownloaded = false;
			string requestUriString = (string)state;
			webRequest = (HttpWebRequest)WebRequest.Create(requestUriString);
			int num = 0;
			webRequest.Headers.Clear();
			webRequest.Headers.Add("GET", "/ HTTP/1.0");
			webRequest.Headers.Add("Icy-MetaData", "1");
			webRequest.UserAgent = "LethalCompany/RadioFurniture/1.0.0";
			HttpWebResponse httpWebResponse;
			try
			{
				httpWebResponse = (HttpWebResponse)webRequest.GetResponse();
			}
			catch (WebException ex)
			{
				if (ex.Status != WebExceptionStatus.RequestCanceled)
				{
					Console.WriteLine(ex.Message);
				}
				return;
			}
			byte[] array = new byte[65536];
			try
			{
				num = Convert.ToInt32(httpWebResponse.GetResponseHeader("icy-metaint"));
			}
			catch
			{
			}
			IMp3FrameDecompressor val = null;
			try
			{
				using Stream sourceStream = httpWebResponse.GetResponseStream();
				ReadFullyStream readFullyStream = new ReadFullyStream(sourceStream);
				do
				{
					if (IsBufferNearlyFull)
					{
						Thread.Sleep(1000);
						continue;
					}
					Mp3Frame val2;
					try
					{
						val2 = Mp3Frame.LoadFromStream((Stream)readFullyStream);
					}
					catch (EndOfStreamException)
					{
						fullyDownloaded = true;
						break;
					}
					catch (WebException)
					{
						break;
					}
					if (val2 == null)
					{
						break;
					}
					if (val == null)
					{
						val = CreateFrameDecompressor(val2);
						bufferedWaveProvider = new BufferedWaveProvider(val.OutputFormat)
						{
							BufferDuration = TimeSpan.FromSeconds(30.0)
						};
						decomp = true;
					}
					int num2 = val.DecompressFrame(val2, array, 0);
					bufferedWaveProvider.AddSamples(array, 0, num2);
				}
				while (playbackState != 0);
				Console.WriteLine("Exiting Thread");
				((IDisposable)val).Dispose();
				readFullyStream.Close();
				readFullyStream.Dispose();
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}

		public void ReadData(float[] data)
		{
			if (bufferedWaveProvider == null)
			{
				return;
			}
			WaveExtensionMethods.ToSampleProvider((IWaveProvider)(object)bufferedWaveProvider).Read(data, 0, data.Length);
			if (Distorted)
			{
				for (int i = 0; i < data.Length; i++)
				{
					float num = Mathf.Cos(0.4f * Time.time) / 3f - 0.165f;
					data[i] = Mathf.Clamp(data[i] + num + Random.Range(-0.07f, 0.07f), 0f, 1f);
				}
			}
		}

		private static IMp3FrameDecompressor CreateFrameDecompressor(Mp3Frame frame)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			WaveFormat val = (WaveFormat)new Mp3WaveFormat(frame.SampleRate, ((int)frame.ChannelMode == 3) ? 1 : 2, frame.FrameLength, frame.BitRate);
			return (IMp3FrameDecompressor)new AcmMp3FrameDecompressor(val);
		}

		private void buttonPlay_Click(object sender, EventArgs e)
		{
		}

		public void StopPlayback()
		{
			if (playbackState != 0)
			{
				if (!fullyDownloaded)
				{
				}
				decomp = false;
				playbackState = StreamingPlaybackState.Stopped;
				if ((Object)(object)_audioSource != (Object)null)
				{
					_audioSource.Stop();
				}
				ShowBufferState(0.0, 0.0);
			}
		}

		private void ShowBufferState(double buffered, double total)
		{
			buffer_info = $"{buffered:0.0}s/{total:0.0}s";
		}

		public void UpdateLoop()
		{
			if (playbackState != 0 && bufferedWaveProvider != null)
			{
				double totalSeconds = bufferedWaveProvider.BufferedDuration.TotalSeconds;
				ShowBufferState(totalSeconds, bufferedWaveProvider.BufferDuration.TotalSeconds);
				if (totalSeconds < 0.5 && playbackState == StreamingPlaybackState.Playing && !fullyDownloaded)
				{
					Pause();
				}
				else if (totalSeconds > 3.0 && playbackState == StreamingPlaybackState.Buffering)
				{
					Play();
				}
				else if (fullyDownloaded && totalSeconds < 0.5)
				{
					Plugin.Log("Reached end of stream");
					StopPlayback();
				}
			}
		}

		public void Play()
		{
			_audioSource.Play();
			playbackState = StreamingPlaybackState.Playing;
		}

		public void Pause()
		{
			playbackState = StreamingPlaybackState.Buffering;
			_audioSource.Pause();
		}
	}
	public class ReadFullyStream : Stream
	{
		private readonly Stream sourceStream;

		private long pos;

		private readonly byte[] readAheadBuffer;

		private int readAheadLength;

		private int readAheadOffset;

		public override bool CanRead => true;

		public override bool CanSeek => false;

		public override bool CanWrite => false;

		public override long Length => pos;

		public override long Position
		{
			get
			{
				return pos;
			}
			set
			{
				throw new InvalidOperationException();
			}
		}

		public ReadFullyStream(Stream sourceStream)
		{
			this.sourceStream = sourceStream;
			readAheadBuffer = new byte[4096];
		}

		public override void Flush()
		{
			throw new InvalidOperationException();
		}

		public override int Read(byte[] buffer, int offset, int count)
		{
			int num = 0;
			while (num < count)
			{
				int num2 = readAheadLength - readAheadOffset;
				int val = count - num;
				if (num2 > 0)
				{
					int num3 = Math.Min(num2, val);
					Array.Copy(readAheadBuffer, readAheadOffset, buffer, offset + num, num3);
					num += num3;
					readAheadOffset += num3;
					continue;
				}
				readAheadOffset = 0;
				readAheadLength = sourceStream.Read(readAheadBuffer, 0, readAheadBuffer.Length);
				if (readAheadLength != 0)
				{
					continue;
				}
				break;
			}
			pos += num;
			return num;
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			throw new InvalidOperationException();
		}

		public override void SetLength(long value)
		{
			throw new InvalidOperationException();
		}

		public override void Write(byte[] buffer, int offset, int count)
		{
			throw new InvalidOperationException();
		}
	}
	public class UnityAudioStream : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <StartMP3Stream>d__4 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public string uri;

			public UnityAudioStream <>4__this;

			private Awaiter <>u__1;

			private void MoveNext()
			{
				//IL_004b: 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_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: 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)
				int num = <>1__state;
				try
				{
					Awaiter awaiter;
					if (num != 0)
					{
						SwitchToThreadPoolAwaitable val = UniTask.SwitchToThreadPool();
						awaiter = ((SwitchToThreadPoolAwaitable)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							<StartMP3Stream>d__4 <StartMP3Stream>d__ = this;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <StartMP3Stream>d__4>(ref awaiter, ref <StartMP3Stream>d__);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
					}
					((Awaiter)(ref awaiter)).GetResult();
					<>4__this._stream.PlayStream(uri, <>4__this._audioSource);
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		private AudioSource _audioSource;

		private MP3Stream? _stream;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			GameObject val = new GameObject("AudioSource");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			_audioSource = val.AddComponent<AudioSource>();
		}

		public void PlayAudioFromStream(string uri)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (_stream == null)
			{
				_stream = new MP3Stream();
			}
			UniTaskExtensions.Forget(StartMP3Stream(uri));
		}

		[AsyncStateMachine(typeof(<StartMP3Stream>d__4))]
		[DebuggerStepThrough]
		private UniTask StartMP3Stream(string uri)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			<StartMP3Stream>d__4 <StartMP3Stream>d__ = new <StartMP3Stream>d__4();
			<StartMP3Stream>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<StartMP3Stream>d__.<>4__this = this;
			<StartMP3Stream>d__.uri = uri;
			<StartMP3Stream>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <StartMP3Stream>d__.<>t__builder)).Start<<StartMP3Stream>d__4>(ref <StartMP3Stream>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <StartMP3Stream>d__.<>t__builder)).Task;
		}

		private void FixedUpdate()
		{
			_stream?.UpdateLoop();
		}

		private void Update()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			if (_stream != null && _stream.decomp)
			{
				_audioSource.clip = AudioClip.Create("mp3_Stream", int.MaxValue, _stream.bufferedWaveProvider.WaveFormat.Channels, _stream.bufferedWaveProvider.WaveFormat.SampleRate, true, new PCMReaderCallback(_stream.ReadData));
				_stream.decomp = false;
			}
		}

		public void Stop()
		{
			_stream?.StopPlayback();
			_stream = null;
			if ((Object)(object)_audioSource != (Object)null)
			{
				_audioSource.Stop();
				_audioSource.time = 0f;
				_audioSource.clip = null;
			}
		}
	}
}
namespace RadioFurniture.Behaviour
{
	public class RadioBehaviour : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <StartMP3Stream>d__33 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public string uri;

			public RadioBehaviour <>4__this;

			private Awaiter <>u__1;

			private void MoveNext()
			{
				//IL_004b: 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_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: 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)
				int num = <>1__state;
				try
				{
					Awaiter awaiter;
					if (num != 0)
					{
						SwitchToThreadPoolAwaitable val = UniTask.SwitchToThreadPool();
						awaiter = ((SwitchToThreadPoolAwaitable)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							<StartMP3Stream>d__33 <StartMP3Stream>d__ = this;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <StartMP3Stream>d__33>(ref awaiter, ref <StartMP3Stream>d__);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
					}
					((Awaiter)(ref awaiter)).GetResult();
					<>4__this._stream.PlayStream(uri, <>4__this._audioSource);
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		private bool _radioOn = false;

		[SerializeField]
		private AudioSource _audioSource = null;

		[SerializeField]
		private AudioSource _staticAudioSource = null;

		[SerializeField]
		private List<AudioClip> _channelSeekClips = new List<AudioClip>();

		[SerializeField]
		private AudioClip _static;

		[SerializeField]
		private Transform _volumeKnob;

		private MP3Stream? _stream;

		private Guid? _lastStationId;

		private bool _playingStatic = false;

		private bool _currentlyStorming = false;

		private float _volume = 0.4f;

		private void Awake()
		{
			SetVolume(0.4f);
			_staticAudioSource.clip = _static;
			WeatherEvents.OnStormStarted += OnStormStarted;
			WeatherEvents.OnStormEnded += OnStormEnded;
		}

		private void OnDestroy()
		{
			WeatherEvents.OnStormStarted -= OnStormStarted;
			WeatherEvents.OnStormEnded -= OnStormEnded;
		}

		private void OnStormStarted()
		{
			_currentlyStorming = true;
			if (_stream != null)
			{
				_stream.Distorted = true;
			}
		}

		private void OnStormEnded()
		{
			_currentlyStorming = false;
			if (_stream != null)
			{
				_stream.Distorted = false;
			}
		}

		public void TogglePowerLocalClient()
		{
			if (_radioOn)
			{
				TurnOffRadioServerRpc();
			}
			else
			{
				TurnOnRadioServerRpc();
			}
		}

		public void RaiseVolume()
		{
			SetVolume(_volume + 0.1f);
		}

		public void LowerVolume()
		{
			SetVolume(_volume - 0.1f);
		}

		private void SetVolume(float volume)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			volume = Mathf.Clamp01(volume);
			((Component)_volumeKnob).transform.localPosition = new Vector3(_volumeKnob.localPosition.x, _volumeKnob.localPosition.y, 0.15f + volume * 0.39f);
			_volume = volume;
			_audioSource.volume = volume;
			_staticAudioSource.volume = ((volume != 0f) ? Mathf.Clamp01(volume + 0.15f) : 0f);
		}

		private Guid GetRandomRadioGuid()
		{
			StationInfo randomRadioStation = RadioManager.GetRandomRadioStation();
			if (randomRadioStation == null)
			{
				return Guid.Empty;
			}
			return randomRadioStation.StationUuid;
		}

		public void ToggleStationLocalClient()
		{
			if (_radioOn)
			{
				ChangeStationServerRpc();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void TurnOnRadioServerRpc()
		{
			//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)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4251617049u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4251617049u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				if (!_lastStationId.HasValue)
				{
					_lastStationId = GetRandomRadioGuid();
					TurnOnAndSyncRadioClientRpc(_lastStationId.Value.ToString());
				}
				TurnOnRadioClientRpc();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void TurnOffRadioServerRpc()
		{
			//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 != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2197223129u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2197223129u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					TurnOffRadioClientRpc();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ChangeStationServerRpc()
		{
			//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 != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1241113757u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1241113757u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && _radioOn)
				{
					_lastStationId = GetRandomRadioGuid();
					TurnOnAndSyncRadioClientRpc(_lastStationId.Value.ToString());
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SyncRadioServerRpc()
		{
			//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 != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2540586508u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2540586508u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SyncRadioClientRpc(_lastStationId.ToString(), _radioOn, _currentlyStorming);
				}
			}
		}

		[ClientRpc]
		public void SyncRadioClientRpc(string guidString, bool radioOn, bool currentlyStorming)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_00f0: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3171456570u, val, (RpcDelivery)0);
				bool flag = guidString != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(guidString, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref radioOn, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref currentlyStorming, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3171456570u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			if (Guid.TryParse(guidString, out var result))
			{
				Guid guid = result;
				Guid? lastStationId = _lastStationId;
				if (lastStationId.HasValue && guid == lastStationId.GetValueOrDefault() && radioOn == _radioOn && currentlyStorming == _currentlyStorming)
				{
					return;
				}
			}
			_currentlyStorming = currentlyStorming;
			_lastStationId = result;
			TurnRadioOnOff(radioOn);
		}

		[ClientRpc]
		public void TurnOnRadioClientRpc()
		{
			//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(2356470384u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2356470384u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					TurnRadioOnOff(state: true);
				}
			}
		}

		[ClientRpc]
		public void TurnOnAndSyncRadioClientRpc(string guidString)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(355872266u, val, (RpcDelivery)0);
				bool flag = guidString != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(guidString, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 355872266u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (Guid.TryParse(guidString, out var result))
				{
					_lastStationId = result;
				}
				TurnRadioOnOff(state: true);
			}
		}

		[ClientRpc]
		public void TurnOffRadioClientRpc()
		{
			//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(1111496099u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1111496099u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					TurnRadioOnOff(state: false);
				}
			}
		}

		private void TurnRadioOnOff(bool state)
		{
			Debug.Log((object)"Changing radio state!");
			Debug.Log((object)state);
			StopStaticIfPlaying();
			if (state && _lastStationId.HasValue)
			{
				Debug.Log((object)"Changing radio station...");
				if (_stream != null)
				{
					Stop();
				}
				PlayTransitionSound();
				PlayStatic();
				StationInfo radioStationByGuid = RadioManager.GetRadioStationByGuid(_lastStationId.Value);
				if (radioStationByGuid != null)
				{
					PlayAudioFromStream(radioStationByGuid.UrlResolved.ToString());
				}
			}
			else if (!state && _stream != null)
			{
				Stop();
				PlayTransitionSound();
			}
			_radioOn = state;
		}

		private void PlayTransitionSound()
		{
			AudioClip val = _channelSeekClips[Random.Range(0, _channelSeekClips.Count)];
			_staticAudioSource.PlayOneShot(val);
		}

		private void PlayStatic()
		{
			_playingStatic = true;
			_staticAudioSource.Play();
		}

		public void PlayAudioFromStream(string uri)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (_stream == null)
			{
				_stream = new MP3Stream();
			}
			if (_currentlyStorming)
			{
				_stream.Distorted = true;
			}
			UniTaskExtensions.Forget(StartMP3Stream(uri));
		}

		[AsyncStateMachine(typeof(<StartMP3Stream>d__33))]
		[DebuggerStepThrough]
		private UniTask StartMP3Stream(string uri)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			<StartMP3Stream>d__33 <StartMP3Stream>d__ = new <StartMP3Stream>d__33();
			<StartMP3Stream>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<StartMP3Stream>d__.<>4__this = this;
			<StartMP3Stream>d__.uri = uri;
			<StartMP3Stream>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <StartMP3Stream>d__.<>t__builder)).Start<<StartMP3Stream>d__33>(ref <StartMP3Stream>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <StartMP3Stream>d__.<>t__builder)).Task;
		}

		private void FixedUpdate()
		{
			_stream?.UpdateLoop();
		}

		private void Update()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			if (_stream != null && _stream.decomp)
			{
				if (!_currentlyStorming)
				{
					StopStaticIfPlaying();
				}
				else if (_currentlyStorming && !_playingStatic)
				{
					PlayStatic();
				}
				_audioSource.clip = AudioClip.Create("mp3_Stream", int.MaxValue, _stream.bufferedWaveProvider.WaveFormat.Channels, _stream.bufferedWaveProvider.WaveFormat.SampleRate, true, new PCMReaderCallback(_stream.ReadData));
				_stream.decomp = false;
			}
		}

		private void StopStaticIfPlaying()
		{
			if (_playingStatic)
			{
				_staticAudioSource.Stop();
				_playingStatic = false;
			}
		}

		public void Stop()
		{
			_stream?.StopPlayback();
			_stream = null;
			if ((Object)(object)_audioSource != (Object)null)
			{
				_audioSource.Stop();
				_audioSource.time = 0f;
				_audioSource.clip = null;
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_RadioBehaviour()
		{
			//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
			NetworkManager.__rpc_func_table.Add(4251617049u, new RpcReceiveHandler(__rpc_handler_4251617049));
			NetworkManager.__rpc_func_table.Add(2197223129u, new RpcReceiveHandler(__rpc_handler_2197223129));
			NetworkManager.__rpc_func_table.Add(1241113757u, new RpcReceiveHandler(__rpc_handler_1241113757));
			NetworkManager.__rpc_func_table.Add(2540586508u, new RpcReceiveHandler(__rpc_handler_2540586508));
			NetworkManager.__rpc_func_table.Add(3171456570u, new RpcReceiveHandler(__rpc_handler_3171456570));
			NetworkManager.__rpc_func_table.Add(2356470384u, new RpcReceiveHandler(__rpc_handler_2356470384));
			NetworkManager.__rpc_func_table.Add(355872266u, new RpcReceiveHandler(__rpc_handler_355872266));
			NetworkManager.__rpc_func_table.Add(1111496099u, new RpcReceiveHandler(__rpc_handler_1111496099));
		}

		private static void __rpc_handler_4251617049(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)1;
				((RadioBehaviour)(object)target).TurnOnRadioServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2197223129(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)1;
				((RadioBehaviour)(object)target).TurnOffRadioServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1241113757(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)1;
				((RadioBehaviour)(object)target).ChangeStationServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2540586508(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)1;
				((RadioBehaviour)(object)target).SyncRadioServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3171456570(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_0067: 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_0082: 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_0097: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string guidString = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref guidString, false);
				}
				bool radioOn = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref radioOn, default(ForPrimitives));
				bool currentlyStorming = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref currentlyStorming, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((RadioBehaviour)(object)target).SyncRadioClientRpc(guidString, radioOn, currentlyStorming);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2356470384(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;
				((RadioBehaviour)(object)target).TurnOnRadioClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_355872266(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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string guidString = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref guidString, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((RadioBehaviour)(object)target).TurnOnAndSyncRadioClientRpc(guidString);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1111496099(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;
				((RadioBehaviour)(object)target).TurnOffRadioClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "RadioBehaviour";
		}
	}
}