using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OdinOnDemand.Components;
using OdinOnDemand.Dynamic;
using OdinOnDemand.Interfaces;
using OdinOnDemand.MPlayer;
using OdinOnDemand.Utils;
using OdinOnDemand.Utils.Config;
using OdinOnDemand.Utils.Net;
using OdinOnDemand.Utils.Net.Explode;
using OdinOnDemand.Utils.UI;
using SoundCloudExplode;
using SoundCloudExplode.Tracks;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Serialization;
using UnityEngine.UI;
using UnityEngine.Video;
using YoutubeDLSharp;
using YoutubeDLSharp.Options;
using YoutubeExplode;
using YoutubeExplode.Common;
using YoutubeExplode.Playlists;
using YoutubeExplode.Videos;
using YoutubeExplode.Videos.Streams;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace OdinOnDemand
{
[BepInPlugin("com.valmedia.odinondemand", "OdinOnDemand", "1.0.9")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class OdinOnDemandPlugin : BaseUnityPlugin
{
public const string PluginGUID = "com.valmedia.odinondemand";
public const string PluginName = "OdinOnDemand";
public const string PluginVersion = "1.0.9";
private static readonly CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();
public static readonly RpcHandler RPCHandlers = new RpcHandler();
public static Material MainScreenMat;
public static Dictionary<string, Sprite> UISprites;
private AssetBundle _valMediaAssets;
private static Harmony _harmony;
private static string _pieceRecipeFile;
private static string _itemRecipeFile;
private static readonly string OdinConfigFolder = Paths.ConfigPath + "/OdinOnDemand/";
public static ConfigFile OdinConfig { get; private set; } = new ConfigFile(OdinConfigFolder + "config.cfg", true);
public StationManager StationManager { get; private set; }
private void Awake()
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Expected O, but got Unknown
AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs args)
{
string assemblyName = new AssemblyName(args.Name).Name + ".dll";
string text = Assembly.GetExecutingAssembly().GetManifestResourceNames().FirstOrDefault((string r) => r.EndsWith(assemblyName));
if (text != null)
{
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text))
{
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
return Assembly.Load(array);
}
}
return null;
};
OODConfig.Bind(OdinConfig);
_pieceRecipeFile = OdinConfigFolder + "/recipes.json";
_itemRecipeFile = OdinConfigFolder + "/recipes_item.json";
OODConfig.SyncManager();
RPCHandlers.Create();
GameObject val = new GameObject("OODStationMan");
StationManager = val.AddComponent<StationManager>();
Object.DontDestroyOnLoad((Object)(object)val);
AddLocalizations();
LoadAssets();
PrefabManager.OnVanillaPrefabsAvailable += AddCartVariant;
ConfigFile val2 = new ConfigFile(Path.Combine(OdinConfigFolder, "com.ood.valmedia.keyconfig.cfg"), true);
SynchronizationManager.Instance.RegisterCustomConfig(val2);
KeyConfig.SetupKeyConfig(val2);
_harmony = new Harmony("Harmony.ValMedia.OOD");
_harmony.PatchAll();
Logger.LogDebug((object)"** OdinOnDemand Initialized **");
}
private static void AddCartVariant()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Expected O, but got Unknown
PieceConfig val = new PieceConfig();
val.Name = "Bard's Wagon";
val.Description = "A mobile media player on wheels, controlled by a remote.";
val.PieceTable = "Hammer";
val.Category = "OOD";
val.AddRequirement(new RequirementConfig("Wood", 26, 0, true));
val.AddRequirement(new RequirementConfig("Bronze", 2, 0, true));
val.AddRequirement(new RequirementConfig("BronzeNails", 14, 0, true));
AssetBundle val2 = AssetUtils.LoadAssetBundleFromResources("videoplayers", typeof(OdinOnDemandPlugin).Assembly);
GameObject val3 = val2.LoadAsset<GameObject>("assets/cartplayer_attach.prefab");
val.Icon = val2.LoadAsset<Sprite>("assets/MOD ICONS/cartplayericon.png");
if (PieceManager.Instance.AddPiece(new CustomPiece("cartplayer", "Cart", val)))
{
GameObject prefab = PrefabManager.Instance.GetPrefab("cartplayer");
Object.Instantiate<GameObject>(val3, prefab.transform, true);
((Component)prefab.transform.Find("cartplayer_attach(Clone)")).gameObject.AddComponent<CartPlayerComponent>();
}
val2.Unload(false);
PrefabManager.OnVanillaPrefabsAvailable -= AddCartVariant;
}
private void LoadAssets()
{
_valMediaAssets = AssetUtils.LoadAssetBundleFromResources("videoplayers", typeof(OdinOnDemandPlugin).Assembly);
Logger.LogDebug((object)"Loading OdinOnDemand Assets");
AddRecipes();
MainScreenMat = _valMediaAssets.LoadAsset<Material>("assets/MOD MATS/screenmaterial.mat");
UISprites = new Dictionary<string, Sprite>();
string[] allAssetNames = _valMediaAssets.GetAllAssetNames();
foreach (string text in allAssetNames)
{
if (text.Contains("modui"))
{
Sprite val = _valMediaAssets.LoadAsset<Sprite>(text);
UISprites.Add(((Object)val).name, val);
}
}
_valMediaAssets.Unload(false);
}
private void AddRecipes()
{
if (!File.Exists(_pieceRecipeFile))
{
WriteDefaultPieceConfig("default.json");
Logger.LogDebug((object)("Did not find recipe json, loading and writing default recipes to: " + _pieceRecipeFile));
}
if (!File.Exists(_itemRecipeFile))
{
WriteDefaultItemConfig("default_items.json");
Logger.LogDebug((object)("Did not find item recipe json, loading and writing default recipes to: " + _itemRecipeFile));
}
string text = File.ReadAllText(_pieceRecipeFile);
if (!IsValidJson(text))
{
WriteDefaultPieceConfig("default.json");
Logger.LogWarning((object)"JSON in com.ood.valmedia.recipes.json is invalid. Setting to default recipes. If you wish to edit recipes please use a JSON validator or delete your recipe file and restart the game for a new default file.");
}
string text2 = File.ReadAllText(_itemRecipeFile);
if (!IsValidJson(text2))
{
WriteDefaultItemConfig("default_items.json");
Logger.LogWarning((object)"JSON in com.ood.valmedia.recipes_item.json is invalid. Setting to default recipes. If you wish to edit recipes please use a JSON validator or delete your recipe file and restart the game for a new default file.");
}
if ((!text.Contains("receiver") || !text.Contains("theater") || !text.Contains("speaker")) && OODConfig.AutoUpdateRecipes.Value)
{
Logger.LogDebug((object)"Old recipe file detected. Updating to new recipes.");
List<PieceConfig> oldRecipes = PieceConfig.ListFromJson(text);
string newRecipes = FileFromManifest("OdinOnDemand.Assets.default.json");
UpdateRecipeFile(newRecipes, oldRecipes, _pieceRecipeFile);
}
else if (!OODConfig.AutoUpdateRecipes.Value)
{
Logger.LogWarning((object)"Auto recipe update disabled. Skipping recipe update.");
}
LoadPieceConfigList(PieceConfig.ListFromJson(text));
LoadItemConfigList(ItemConfig.ListFromJson(text2));
}
private void UpdateRecipeFile(string newRecipes, List<PieceConfig> oldRecipes, string file)
{
if (newRecipes != "")
{
List<PieceConfig> recipesToMerge = PieceConfig.ListFromJson(newRecipes);
MergeRecipes(oldRecipes, recipesToMerge);
try
{
List<PieceConfigDTO> list = PieceConfigDTO.ToDTOList(oldRecipes);
string contents = JsonConvert.SerializeObject((object)list, (Formatting)1);
File.WriteAllText(file, contents);
return;
}
catch (Exception ex)
{
Logger.LogError((object)"Failed to write new recipes to file. Check log for details.");
Logger.LogWarning((object)ex);
return;
}
}
Logger.LogError((object)"FATAL Failed to load default recipes.");
}
private static void MergeRecipes(List<PieceConfig> mergeRecipe, List<PieceConfig> recipesToMerge)
{
foreach (PieceConfig newRecipe in recipesToMerge)
{
if (!mergeRecipe.Any((PieceConfig r) => r.Name == newRecipe.Name))
{
mergeRecipe.Add(newRecipe);
}
}
}
private void WriteDefaultPieceConfig(string fileName)
{
try
{
string pieceRecipeFile = _pieceRecipeFile;
string value = FileFromManifest("OdinOnDemand.Assets." + fileName);
StreamWriter streamWriter = File.CreateText(pieceRecipeFile);
streamWriter.Write(value);
streamWriter.Close();
streamWriter.Dispose();
}
catch (Exception ex)
{
Logger.LogError((object)"Exception when handling default recipe file. Check log for details.");
Logger.LogWarning((object)ex);
}
}
private void WriteDefaultItemConfig(string fileName)
{
try
{
string itemRecipeFile = _itemRecipeFile;
string value = FileFromManifest("OdinOnDemand.Assets." + fileName);
StreamWriter streamWriter = File.CreateText(itemRecipeFile);
streamWriter.Write(value);
streamWriter.Close();
streamWriter.Dispose();
}
catch (Exception ex)
{
Logger.LogError((object)"Exception when handling default recipe file. Check log for details.");
Logger.LogWarning((object)ex);
}
}
private static string FileFromManifest(string file)
{
string result = "";
using Stream stream = typeof(OdinOnDemandPlugin).Assembly.GetManifestResourceStream(file);
if (stream != null)
{
using StreamReader streamReader = new StreamReader(stream);
result = streamReader.ReadToEnd();
}
return result;
}
private void LoadPieceConfigList(List<PieceConfig> pieceConfigs)
{
pieceConfigs.ForEach(delegate(PieceConfig c)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Expected O, but got Unknown
string text = LocalizationManager.Instance.TryTranslate(c.Name).ToLower().Replace(" ", "")
.Replace("'", "");
Texture2D val = _valMediaAssets.LoadAsset<Texture2D>("assets/MOD ICONS/" + text + "icon.png");
Sprite icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
c.Icon = icon;
PieceManager.Instance.AddPiece(new CustomPiece(_valMediaAssets, text, false, c));
});
}
private void LoadItemConfigList(List<ItemConfig> itemConfigs)
{
itemConfigs.ForEach(delegate(ItemConfig c)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
string text = LocalizationManager.Instance.TryTranslate(c.Name).ToLower().Replace(" ", "")
.Replace("'", "");
((BaseUnityPlugin)this).Logger.LogDebug((object)("Adding item: " + text));
ItemManager.Instance.AddItem(new CustomItem(_valMediaAssets, text, false, c));
});
}
private void AddLocalizations()
{
CustomLocalization localization = Localization;
string text = "English";
localization.AddTranslation(ref text, new Dictionary<string, string>
{
{ "piece_flatscreen", "Flatscreen" },
{ "piece_tabletv", "Table TV" },
{ "piece_boombox", "Boombox" },
{ "piece_oldtv", "Old TV" },
{ "piece_laptop", "Laptop" },
{ "piece_monitor", "Monitor" },
{ "piece_gramophone", "Gramophone" },
{ "piece_theaterscreen", "Theater Screen" },
{ "piece_receiver", "Receiver" },
{ "piece_studiospeaker", "Studio Speaker" },
{ "piece_radio", "Radio" },
{ "piece_standingspeaker", "Standing Speaker" },
{ "item_remote", "Remote Control" },
{ "item_skaldsgirdle", "Skald's Girdle" },
{ "remote_usehint", "Use Screen" },
{ "remote_linkhint", "Link/Unlink" },
{ "skaldsgirdle_hint", "Consult Skald" },
{ "remote_changelinkmodehint", "Change Link Mode" },
{ "item_remote_description", "Allows you to use media-players from a distance." },
{ "item_skaldsgirdle_description", "Allows you to commune with Skald while traveling." }
});
}
private static bool IsValidJson(string strInput)
{
//IL_0061: Expected O, but got Unknown
if (string.IsNullOrWhiteSpace(strInput))
{
return false;
}
strInput = strInput.Trim();
if ((strInput.StartsWith("{") && strInput.EndsWith("}")) || (strInput.StartsWith("[") && strInput.EndsWith("]")))
{
try
{
JToken val = JToken.Parse(strInput);
return true;
}
catch (JsonReaderException val2)
{
JsonReaderException val3 = val2;
Logger.LogWarning((object)((Exception)(object)val3).Message);
return false;
}
catch (Exception ex)
{
Logger.LogWarning((object)ex.ToString());
return false;
}
}
return false;
}
}
}
namespace OdinOnDemand.MPlayer
{
public abstract class BasePlayer : MonoBehaviour, IPlayer
{
[CompilerGenerated]
private sealed class <AudioEndEvent>d__135 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public float time;
public Action method;
public BasePlayer <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <AudioEndEvent>d__135(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(time);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
method?.Invoke();
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <AudioWebRequest>d__142 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Uri url;
public BasePlayer <>4__this;
private DownloadHandlerAudioClip <dh>5__1;
private UnityWebRequest <wr>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <AudioWebRequest>d__142(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<dh>5__1 = null;
<wr>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Invalid comparison between Unknown and I4
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Invalid comparison between Unknown and I4
bool result;
try
{
switch (<>1__state)
{
default:
result = false;
break;
case 0:
<>1__state = -1;
<dh>5__1 = new DownloadHandlerAudioClip(url, (AudioType)13)
{
compressed = false
};
<wr>5__2 = new UnityWebRequest(url, "GET", (DownloadHandler)(object)<dh>5__1, (UploadHandler)null);
<>1__state = -3;
<>2__current = <wr>5__2.SendWebRequest();
<>1__state = 1;
result = true;
break;
case 1:
<>1__state = -3;
if ((int)<wr>5__2.result == 3 || (int)<wr>5__2.result == 2)
{
Logger.LogError((object)<wr>5__2.error);
}
else
{
<>4__this.mAudio.clip = <dh>5__1.audioClip;
<>4__this.mScreen.url = "";
<>4__this.mScreen.Stop();
<>4__this.mAudio.Play();
((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.DelayedExecution(0.5f, <>4__this.SendRequestTimeSync_RPC));
<>4__this.PlayerSettings.PlayerLinkType = PlayerSettings.LinkType.Audio;
<>4__this.PlayerSettings.IsPlaying = true;
<>4__this.PlayerSettings.IsPaused = false;
if (Object.op_Implicit((Object)(object)<>4__this.Animator))
{
<>4__this.Animator.SetBool(PlayerSettings.Playing, true);
}
if (Object.op_Implicit((Object)(object)<>4__this.WaveParticleSystem) && OODConfig.MobilePlayerVisuals.Value)
{
<>4__this.WaveParticleSystem.Play();
}
if (Object.op_Implicit((Object)(object)<>4__this.ScreenUICanvasObj))
{
<>4__this.ScreenUICanvasObj.SetActive(true);
}
<>4__this.UpdateRadioPanel();
<>4__this.UIController.ResetLoadingIndicator();
}
result = false;
<>m__Finally1();
break;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
return result;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<wr>5__2 != null)
{
((IDisposable)<wr>5__2).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <CreateThumbnailFromURL>d__143 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Uri url;
public BasePlayer <>4__this;
private DownloadHandlerTexture <dh>5__1;
private UnityWebRequest <wr>5__2;
private Texture2D <texture>5__3;
private Rect <rect>5__4;
private Vector2 <pivot>5__5;
private Sprite <sprite>5__6;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CreateThumbnailFromURL>d__143(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<dh>5__1 = null;
<wr>5__2 = null;
<texture>5__3 = null;
<sprite>5__6 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Invalid comparison between Unknown and I4
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Invalid comparison between Unknown and I4
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: 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)
bool result;
try
{
switch (<>1__state)
{
default:
result = false;
break;
case 0:
<>1__state = -1;
<dh>5__1 = new DownloadHandlerTexture(true);
<wr>5__2 = new UnityWebRequest(url, "GET", (DownloadHandler)(object)<dh>5__1, (UploadHandler)null);
<>1__state = -3;
<>2__current = <wr>5__2.SendWebRequest();
<>1__state = 1;
result = true;
break;
case 1:
<>1__state = -3;
if ((int)<wr>5__2.result == 3 || (int)<wr>5__2.result == 2)
{
Logger.LogError((object)("Error downloading image: " + <wr>5__2.error));
}
else
{
<texture>5__3 = DownloadHandlerTexture.GetContent(<wr>5__2);
<rect>5__4 = new Rect(0f, 0f, (float)((Texture)<texture>5__3).width, (float)((Texture)<texture>5__3).height);
<pivot>5__5 = new Vector2(0.5f, 0.5f);
<sprite>5__6 = Sprite.Create(<texture>5__3, <rect>5__4, <pivot>5__5);
<>4__this.PlayerSettings.Thumbnail = <sprite>5__6;
<texture>5__3 = null;
<sprite>5__6 = null;
}
result = false;
<>m__Finally1();
break;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
return result;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<wr>5__2 != null)
{
((IDisposable)<wr>5__2).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <CreateYoutubeAudioAndPlay>d__151 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public BasePlayer <>4__this;
private DownloadHandlerAudioClip <dh>5__1;
private UnityWebRequest <wr>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CreateYoutubeAudioAndPlay>d__151(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 2)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<dh>5__1 = null;
<wr>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Invalid comparison between Unknown and I4
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Invalid comparison between Unknown and I4
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
bool result;
try
{
switch (<>1__state)
{
default:
result = false;
break;
case 0:
<>1__state = -1;
if (<>4__this.YoutubeSoundDirectUri == null)
{
Logger.LogDebug((object)"sound url is null, waiting");
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
result = true;
break;
}
goto IL_007a;
case 1:
<>1__state = -1;
goto IL_007a;
case 2:
{
<>1__state = -3;
if ((int)<wr>5__2.result == 3 || (int)<wr>5__2.result == 2)
{
Logger.LogWarning((object)<wr>5__2.error);
<>4__this.UIController.LoadingIndicatorObj.SetActive(false);
}
else
{
<>4__this.mAudio.clip = <dh>5__1.audioClip;
if (<>4__this.YoutubeVideoDirectUri != null)
{
<>4__this.mScreen.url = <>4__this.YoutubeVideoDirectUri.AbsoluteUri;
<>4__this.mScreen.Prepare();
if (Object.op_Implicit((Object)(object)<>4__this.ScreenUICanvasObj) && Object.op_Implicit((Object)(object)<>4__this.LoadingCircleObj))
{
<>4__this.ScreenUICanvasObj.SetActive(true);
<>4__this.LoadingCircleObj.SetActive(true);
}
<>4__this.UIController.LoadingIndicatorObj.SetActive(false);
}
else
{
Logger.LogDebug((object)"nodejs: yt url is null. are you sure want to use nodejs?");
<>4__this.UIController.LoadingIndicatorObj.SetActive(false);
}
}
result = false;
<>m__Finally1();
break;
}
IL_007a:
if (<>4__this.YoutubeSoundDirectUri == null)
{
Logger.LogDebug((object)"sound url is null still, exiting");
result = false;
break;
}
<dh>5__1 = new DownloadHandlerAudioClip(<>4__this.YoutubeSoundDirectUri, (AudioType)0)
{
compressed = true
};
<wr>5__2 = new UnityWebRequest(<>4__this.YoutubeSoundDirectUri, "GET", (DownloadHandler)(object)<dh>5__1, (UploadHandler)null);
<>1__state = -3;
<>2__current = <wr>5__2.SendWebRequest();
<>1__state = 2;
result = true;
break;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
return result;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<wr>5__2 != null)
{
((IDisposable)<wr>5__2).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <DelayedExecution>d__160 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public float delay;
public Action action;
public BasePlayer <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DelayedExecution>d__160(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
action();
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <ResetLoadingIndicatorAfterDelay>d__149 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public BasePlayer <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ResetLoadingIndicatorAfterDelay>d__149(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1.75f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>4__this.UIController.ResetLoadingIndicator();
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <ShowCenterSphere>d__175 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public BasePlayer <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ShowCenterSphere>d__175(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if (!Object.op_Implicit((Object)(object)<>4__this.centerAudioSphere))
{
return false;
}
((Component)<>4__this.centerAudioSphere).gameObject.SetActive(true);
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
((Component)<>4__this.centerAudioSphere).gameObject.SetActive(false);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <YoutubeNodeQuery>d__150 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public bool isRPC;
public BasePlayer <>4__this;
private string <url>5__1;
private string <nodeUrl>5__2;
private string <authCode>5__3;
private UnityWebRequest <www>5__4;
private string[] <lines>5__5;
private Uri <cleanVideoUri>5__6;
private Uri <cleanSoundUri>5__7;
private int <i>5__8;
private string <cleanUrl>5__9;
private Uri <cleanVideoUri>5__10;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <YoutubeNodeQuery>d__150(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<url>5__1 = null;
<nodeUrl>5__2 = null;
<authCode>5__3 = null;
<www>5__4 = null;
<lines>5__5 = null;
<cleanVideoUri>5__6 = null;
<cleanSoundUri>5__7 = null;
<cleanUrl>5__9 = null;
<cleanVideoUri>5__10 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Invalid comparison between Unknown and I4
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Expected O, but got Unknown
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Expected O, but got Unknown
//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
//IL_03f1: Expected O, but got Unknown
//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
//IL_04dc: Expected O, but got Unknown
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if (<>4__this.YoutubeURLNode == null)
{
Logger.LogDebug((object)"nodejs: error in yt query, youtube url null. are you sure you want use nodejs?");
return false;
}
<url>5__1 = Uri.EscapeDataString(<>4__this.YoutubeURLNode);
<nodeUrl>5__2 = OODConfig.NodeUrl.Value;
<authCode>5__3 = OODConfig.YtAuthCode.Value;
<www>5__4 = UnityWebRequest.Get(<nodeUrl>5__2 + <url>5__1 + "/" + <authCode>5__3);
<www>5__4.timeout = 30;
<>4__this.UIController.SetLoadingIndicatorText("Processing");
<>4__this.UIController.LoadingIndicatorObj.SetActive(true);
<>2__current = <www>5__4.SendWebRequest();
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if ((int)<www>5__4.result != 1)
{
Debug.Log((object)<www>5__4.error);
<>4__this.UIController.LoadingIndicatorObj.GetComponent<Text>().text = <www>5__4.error;
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 2;
return true;
}
if (<www>5__4.downloadHandler.text.Contains("AUTH DENIED"))
{
<>4__this.UIController.SetLoadingIndicatorText("Invalid Auth");
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 3;
return true;
}
if (<www>5__4.downloadHandler.text.Contains("\\"))
{
<lines>5__5 = <www>5__4.downloadHandler.text.Split(new string[4] { "\r\n", "\r", "\n", "\\n" }, StringSplitOptions.None);
<i>5__8 = 0;
while (<i>5__8 < <lines>5__5.Length)
{
<lines>5__5[<i>5__8] = <lines>5__5[<i>5__8].Replace("\"", "");
<i>5__8++;
}
if (Uri.TryCreate(<lines>5__5[0], UriKind.Absolute, out <cleanVideoUri>5__6))
{
<>4__this.YoutubeVideoDirectUri = <cleanVideoUri>5__6;
goto IL_0382;
}
Logger.LogError((object)("Invalid URI: " + <lines>5__5[0]));
<>4__this.UIController.SetLoadingIndicatorText("Invalid URI");
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 4;
return true;
}
<cleanUrl>5__9 = <www>5__4.downloadHandler.text.Replace("\"", "");
if (Uri.TryCreate(<cleanUrl>5__9, UriKind.Absolute, out <cleanVideoUri>5__10))
{
<>4__this.YoutubeVideoDirectUri = <cleanVideoUri>5__10;
goto IL_0504;
}
Logger.LogError((object)("Invalid URI: " + <cleanUrl>5__9));
<>4__this.UIController.SetLoadingIndicatorText("Invalid URI");
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 6;
return true;
case 2:
<>1__state = -1;
<>4__this.UIController.LoadingIndicatorObj.SetActive(false);
break;
case 3:
<>1__state = -1;
<>4__this.UIController.LoadingIndicatorObj.SetActive(false);
break;
case 4:
<>1__state = -1;
<>4__this.UIController.LoadingIndicatorObj.SetActive(false);
goto IL_0382;
case 5:
<>1__state = -1;
<>4__this.UIController.LoadingIndicatorObj.SetActive(false);
goto IL_0419;
case 6:
{
<>1__state = -1;
<>4__this.UIController.LoadingIndicatorObj.SetActive(false);
goto IL_0504;
}
IL_0504:
<>4__this.mScreen.source = (VideoSource)1;
<>4__this.mScreen.url = <>4__this.YoutubeVideoDirectUri.AbsoluteUri;
<>4__this.mScreen.Prepare();
if (Object.op_Implicit((Object)(object)<>4__this.ScreenUICanvasObj) && Object.op_Implicit((Object)(object)<>4__this.LoadingCircleObj))
{
<>4__this.ScreenUICanvasObj.SetActive(true);
<>4__this.LoadingCircleObj.SetActive(true);
}
<>4__this.UIController.LoadingIndicatorObj.SetActive(false);
<cleanUrl>5__9 = null;
<cleanVideoUri>5__10 = null;
break;
IL_0419:
((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.CreateYoutubeAudioAndPlay());
<lines>5__5 = null;
<cleanVideoUri>5__6 = null;
<cleanSoundUri>5__7 = null;
break;
IL_0382:
if (Uri.TryCreate(<lines>5__5[1], UriKind.Absolute, out <cleanSoundUri>5__7))
{
<>4__this.YoutubeSoundDirectUri = <cleanSoundUri>5__7;
goto IL_0419;
}
Logger.LogError((object)("Invalid URI: " + <lines>5__5[1]));
<>4__this.UIController.SetLoadingIndicatorText("Invalid URI");
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 5;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
internal HashSet<SpeakerComponent> mSpeakers = new HashSet<SpeakerComponent>();
private Transform centerAudioSphere;
protected SphereCollider triggerCollider;
public VideoPlayer mScreen { get; set; }
public AudioSource mAudio { get; set; }
public Piece mPiece { get; internal set; }
public Animator Animator { get; set; }
protected GameObject ScreenPlaneObj { get; set; }
protected internal GameObject ScreenUICanvasObj { get; set; }
protected GameObject RadioPanelObj { get; set; }
protected Coroutine DynamicStationCoroutine { get; set; }
protected internal GameObject LoadingCircleObj { get; set; }
protected Material TargetTexMat { get; set; }
public string mName { get; set; }
public string MediaPlayerID { get; set; }
public string UnparsedURL { get; set; }
public Uri DownloadURL { get; set; }
public Uri YoutubeSoundDirectUri { get; set; }
public Uri YoutubeVideoDirectUri { get; set; }
public int PlaylistPosition { get; set; }
public string PlaylistString { get; set; }
public List<VideoInfo> CurrentPlaylist { get; set; }
public List<VideoInfo> PreShufflePlaylist { get; set; }
public string PlaylistURL { get; set; }
public PlayerSettings PlayerSettings { get; set; }
public UIController UIController { get; set; }
protected static AudioFader AudioFaderComp { get; set; }
protected ParticleSystem WaveParticleSystem { get; set; }
public URLGrab URLGrab { get; set; }
public DLSharp Ytdl { get; set; }
public RpcHandler RPC { get; set; }
public ZNetView ZNetView { get; set; }
private string YoutubeURLNode { get; set; }
public void Awake()
{
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Expected O, but got Unknown
ComponentLists.MediaComponentLists[((object)this).GetType()].Add(this);
UIController = new UIController(this);
PlayerSettings = new PlayerSettings();
ZNetView = ((Component)this).GetComponent<ZNetView>();
UIController.Initialize();
RPC = OdinOnDemandPlugin.RPCHandlers;
URLGrab = new URLGrab();
ZNetView = ((Component)this).gameObject.GetComponentInParent<ZNetView>();
mScreen = ((Component)this).gameObject.GetComponentInChildren<VideoPlayer>();
mScreen.prepareCompleted += new EventHandler(ScreenPrepareCompleted);
mScreen.loopPointReached += new EventHandler(EndReached);
SetupAudio();
((MonoBehaviour)this).InvokeRepeating("UpdateLoadingIndicator", 0.5f, 0.5f);
((MonoBehaviour)this).InvokeRepeating("UpdateChecks", 1f, 1f);
((MonoBehaviour)this).InvokeRepeating("SyncTime", OODConfig.SyncTime.Value + 30f, OODConfig.SyncTime.Value);
Ytdl = ((Component)this).gameObject.AddComponent<DLSharp>();
((MonoBehaviour)this).StartCoroutine(Ytdl.Setup());
ZDO zDO = ZNetView.GetZDO();
if (Object.op_Implicit((Object)(object)ZNetScene.instance) && zDO != null)
{
if (!zDO.GetString("MediaPlayerID", "").Equals(""))
{
RequestOwnership(zDO);
string text = GenerateUniqueID();
zDO.Set("MediaPlayerID", text);
SendUpdateZDO_RPC();
}
MediaPlayerID = zDO.GetString("MediaPlayerID", "");
}
if (OODConfig.AudioFadeType.Value != OODConfig.FadeType.None && (Object)(object)AudioFader.Instance == (Object)null && (Object)(object)GameObject.Find("OODAudioFader") == (Object)null)
{
GameObject val = new GameObject("OODAudioFader");
AudioFaderComp = val.AddComponent<AudioFader>();
Object.DontDestroyOnLoad((Object)(object)val);
}
}
public void OnDestroy()
{
ComponentLists.RemoveComponent(((object)this).GetType(), this);
}
private void EndReached(VideoPlayer source)
{
if (PlayerSettings.IsPlayingPlaylist)
{
if (PlaylistPosition < CurrentPlaylist.Count() - 1)
{
PlaylistPosition++;
SetURL(CurrentPlaylist.ElementAt(PlaylistPosition).Url);
}
else if (PlayerSettings.IsLooping)
{
PlaylistPosition = 0;
SetURL(CurrentPlaylist.ElementAt(PlaylistPosition).Url);
}
}
if (PlayerSettings.PlayerType == CinemaPackage.MediaPlayers.Radio && Object.op_Implicit((Object)(object)Animator) && (!mScreen.isLooping || !mAudio.loop) && !PlayerSettings.IsPlayingPlaylist)
{
Animator.SetBool(PlayerSettings.Playing, false);
}
bool isPlaying = mScreen.isPlaying;
PlayerSettings.IsPlaying = isPlaying;
}
private void ScreenPrepareCompleted(VideoPlayer source)
{
if (PlayerSettings.PlayerType == CinemaPackage.MediaPlayers.CinemaScreen && Object.op_Implicit((Object)(object)ScreenPlaneObj))
{
ScreenPlaneObj.SetActive(true);
}
if (Object.op_Implicit((Object)(object)WaveParticleSystem) && OODConfig.MobilePlayerVisuals.Value)
{
WaveParticleSystem.Play();
}
if (Object.op_Implicit((Object)(object)UIController.LoadingIndicatorObj))
{
UIController.LoadingIndicatorObj.SetActive(false);
}
if (Object.op_Implicit((Object)(object)ScreenUICanvasObj) && Object.op_Implicit((Object)(object)LoadingCircleObj))
{
ScreenUICanvasObj.SetActive(false);
LoadingCircleObj.SetActive(false);
}
float timeZDO = GetTimeZDO();
UpdatePlayerTime(timeZDO);
((MonoBehaviour)this).StartCoroutine(DelayedExecution(0.5f, SendRequestTimeSync_RPC));
if (!PlayerSettings.IsPaused)
{
if (Object.op_Implicit((Object)(object)Animator))
{
Animator.SetBool(PlayerSettings.Playing, true);
}
if (Object.op_Implicit((Object)(object)WaveParticleSystem) && OODConfig.MobilePlayerVisuals.Value)
{
WaveParticleSystem.Play();
}
PlayerSettings.IsPlaying = true;
PlayerSettings.IsPaused = false;
source.Play();
mAudio.Play();
}
else
{
PlayerSettings.IsPlaying = true;
PlayerSettings.IsPaused = true;
source.Pause();
mAudio.Pause();
}
}
private void UpdateChecks()
{
float num = default(float);
mAudio.outputAudioMixerGroup.audioMixer.GetFloat("MasterVolume", ref num);
if (PlayerSettings.PlayerType == CinemaPackage.MediaPlayers.CinemaScreen)
{
if (num != OODConfig.MasterVolumeScreen.Value)
{
mAudio.outputAudioMixerGroup.audioMixer.SetFloat("MasterVolume", OODConfig.MasterVolumeScreen.Value);
}
}
else if (PlayerSettings.PlayerType == CinemaPackage.MediaPlayers.BeltPlayer || PlayerSettings.PlayerType == CinemaPackage.MediaPlayers.CartPlayer)
{
if (num != OODConfig.MasterVolumeTransport.Value)
{
mAudio.outputAudioMixerGroup.audioMixer.SetFloat("MasterVolume", OODConfig.MasterVolumeTransport.Value);
}
}
else if (num != OODConfig.MasterVolumeMusicplayer.Value)
{
mAudio.outputAudioMixerGroup.audioMixer.SetFloat("MasterVolume", OODConfig.MasterVolumeMusicplayer.Value);
}
if (Object.op_Implicit((Object)(object)UIController.URLPanelObj))
{
if (PlayerSettings.IsPlayingPlaylist)
{
UIController.UpdatePlaylistUI();
UIController.PlaylistTrackText.text = PlaylistString;
}
else
{
UIController.UpdatePlaylistUI();
}
}
if (!mAudio.isPlaying && ((Object)(object)mAudio.clip == (Object)null || mAudio.time == 0f) && !mAudio.loop && (Object)(object)Animator != (Object)null)
{
Animator.SetBool(PlayerSettings.Playing, false);
}
if (Object.op_Implicit((Object)(object)triggerCollider) && triggerCollider.radius != mAudio.maxDistance)
{
triggerCollider.radius = mAudio.maxDistance;
}
}
public void SetURL(string url)
{
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
Encoding uTF = Encoding.UTF8;
byte[] bytes = uTF.GetBytes(url);
url = uTF.GetString(bytes);
UnparsedURL = url;
mAudio.clip = null;
if (UnparsedURL == "")
{
Stop(isRPC: true);
}
else
{
if (!Object.op_Implicit((Object)(object)((IPlayer)this).mScreen) && !Object.op_Implicit((Object)(object)mAudio))
{
return;
}
if (url.Contains("youtube.com/watch?v=") || url.Contains("youtube.com/shorts/") || url.Contains("youtu.be") || url.Contains("youtube.com/playlist"))
{
UIController.UpdatePlaylistInfo();
if (url.Contains("?list=") || url.Contains("&list="))
{
SetPlaylist(UnparsedURL);
return;
}
}
mScreen.time = 0.0;
if (Object.op_Implicit((Object)(object)mAudio.clip))
{
mAudio.time = 0f;
}
PlayerSettings.IsPaused = false;
PlayerSettings.IsPlaying = true;
RPC.SendData(0L, CinemaPackage.RPCDataType.SetVideoUrl, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, 0f, UnparsedURL, CinemaPackage.PlayerStatus.Playing);
SaveZDO();
}
}
private void SetPlaylist(string url)
{
((MonoBehaviour)this).StartCoroutine(URLGrab.GetYouTubePlaylistCoroutine(url, delegate(List<VideoInfo> videoInfos)
{
if (videoInfos != null)
{
CurrentPlaylist = videoInfos;
PlayerSettings.IsPlayingPlaylist = true;
PlaylistPosition = 0;
if (OODConfig.DebugEnabled.Value)
{
Logger.LogDebug((object)"Playlist info");
Logger.LogDebug((object)("Count: " + CurrentPlaylist.Count));
Logger.LogDebug((object)CurrentPlaylist.ToString());
Logger.LogDebug((object)("Playing first url of " + CurrentPlaylist.ElementAt(PlaylistPosition).Url));
}
PlaylistURL = url;
SetURL(CurrentPlaylist.ElementAt(PlaylistPosition).Url);
if (Object.op_Implicit((Object)(object)UIController.URLPanelObj))
{
UIController.UpdatePlaylistUI();
UIController.ToggleShuffleObj.GetComponentInChildren<Text>().text = "N";
UIController.ToggleShuffleObj.SetActive(true);
UIController.ToggleShuffleTextObj.SetActive(true);
}
}
else
{
Logger.LogError((object)"Failed to load playlist");
}
}));
}
public void Play(bool isRPC = false)
{
//IL_00af: 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)
if (PlayerSettings.CurrentMode == PlayerSettings.PlayerMode.Dynamic)
{
if (PlayerSettings.DynamicStation != null)
{
RPC.SendData(0L, CinemaPackage.RPCDataType.RequestStation, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, 0f, PlayerSettings.DynamicStation.Title);
}
return;
}
if (!isRPC)
{
RPC.SendData(0L, CinemaPackage.RPCDataType.Play, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, GetTime());
PlayerSettings.IsPlaying = true;
PlayerSettings.IsPaused = false;
SaveZDO();
return;
}
if (PlayerSettings.PlayerType == CinemaPackage.MediaPlayers.CinemaScreen)
{
ScreenPlaneObj.SetActive(true);
}
if (PlayerSettings.PlayerLinkType == PlayerSettings.LinkType.Youtube || PlayerSettings.PlayerLinkType == PlayerSettings.LinkType.RelativeVideo || PlayerSettings.PlayerLinkType == PlayerSettings.LinkType.Video)
{
mScreen.Play();
PlayerSettings.IsPlaying = mScreen.isPlaying;
PlayerSettings.IsPaused = mScreen.isPaused;
if (Object.op_Implicit((Object)(object)Animator))
{
Animator.SetBool(PlayerSettings.Playing, true);
}
if (Object.op_Implicit((Object)(object)WaveParticleSystem) && OODConfig.MobilePlayerVisuals.Value && (mScreen.isPlaying || mScreen.isPrepared || mAudio.isPlaying))
{
WaveParticleSystem.Play();
}
}
else if (PlayerSettings.PlayerLinkType == PlayerSettings.LinkType.Audio)
{
if (Object.op_Implicit((Object)(object)Animator))
{
Animator.SetBool(PlayerSettings.Playing, true);
}
if (Object.op_Implicit((Object)(object)WaveParticleSystem) && OODConfig.MobilePlayerVisuals.Value)
{
WaveParticleSystem.Play();
}
if (PlayerSettings.IsPaused && (Object)(object)mAudio.clip != (Object)null)
{
mAudio.UnPause();
}
else
{
mAudio.Play();
}
bool isPlaying = mAudio.isPlaying;
PlayerSettings.IsPaused = !isPlaying;
PlayerSettings.IsPlaying = isPlaying;
}
}
public void PlayStation(string stationName)
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
DynamicStation station = StationManager.Instance.GetStation(stationName);
PlayerSettings.DynamicStation = station;
PlayerSettings.IsPlaying = true;
PlayerSettings.IsPaused = false;
PlayerSettings.CurrentMode = PlayerSettings.PlayerMode.Dynamic;
UnparsedURL = PlayerSettings.DynamicStation.Title;
RPC.SendData(0L, CinemaPackage.RPCDataType.RequestStation, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, 0f, stationName);
SaveZDO();
}
public void RPC_PlayStation(string dataURL, string trackTitle, float time)
{
DynamicStation station = StationManager.Instance.GetStation(dataURL);
Track track = station?.Tracks.FirstOrDefault((Track x) => x.Title == trackTitle);
if (track != null)
{
station.CurrentTrackIndex = station.Tracks.IndexOf(track);
station.Tracks[station.CurrentTrackIndex].CurrentTime = time;
PlayerSettings.CurrentMode = PlayerSettings.PlayerMode.Dynamic;
PlayerSettings.DynamicStation = station;
PlayerSettings.IsPlaying = true;
PlayerSettings.IsPaused = false;
InitiateDynamicStationPlayback();
((MonoBehaviour)this).StartCoroutine(DelayedExecution(2f, SendRequestTimeSync_RPC));
}
}
private void InitiateDynamicStationPlayback()
{
PlayerSettings.PlayerLinkType = PlayerSettings.LinkType.Audio;
Track track = PlayerSettings.DynamicStation.Tracks[PlayerSettings.DynamicStation.CurrentTrackIndex];
mAudio.clip = track.AudioClip;
mAudio.time = track.CurrentTime;
foreach (KeyValuePair<Type, IList> mediaComponentList in ComponentLists.MediaComponentLists)
{
foreach (BasePlayer item in mediaComponentList.Value)
{
if (!((Object)(object)item == (Object)(object)this) && Object.op_Implicit((Object)(object)item) && item.PlayerSettings.DynamicStation != null && item.PlayerSettings.CurrentMode == PlayerSettings.PlayerMode.Dynamic && item.PlayerSettings.DynamicStation.Title == PlayerSettings.DynamicStation.Title && item.PlayerSettings.IsPlaying && !item.PlayerSettings.IsPaused)
{
item.mAudio.clip = track.AudioClip;
item.mAudio.time = track.CurrentTime;
}
}
}
mAudio.Play();
PlayerSettings.IsPlaying = true;
PlayerSettings.IsPaused = false;
PlayerSettings.IsPlayingPlaylist = false;
PlayerSettings.PlayerLinkType = PlayerSettings.LinkType.Audio;
PlayerSettings.CurrentMode = PlayerSettings.PlayerMode.Dynamic;
UnparsedURL = PlayerSettings.DynamicStation.Title;
float time = track.AudioClip.length - mAudio.time;
if (DynamicStationCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(DynamicStationCoroutine);
}
DynamicStationCoroutine = ((MonoBehaviour)this).StartCoroutine(AudioEndEvent(time, PlayNextDynamicStationTrack));
if (Object.op_Implicit((Object)(object)WaveParticleSystem))
{
WaveParticleSystem.Play();
}
if (Object.op_Implicit((Object)(object)Animator))
{
Animator.SetBool(PlayerSettings.Playing, true);
}
UpdateRadioPanel();
}
private void PlayNextDynamicStationTrack()
{
if (PlayerSettings.DynamicStation != null)
{
mAudio.Stop();
mAudio.clip = null;
mAudio.time = 0f;
((MonoBehaviour)this).StartCoroutine(DelayedExecution(0.35f, delegate
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
RPC.SendData(0L, CinemaPackage.RPCDataType.RequestStation, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, 0f, PlayerSettings.DynamicStation.Title);
((MonoBehaviour)this).StartCoroutine(DelayedExecution(2f, SendRequestTimeSync_RPC));
}));
}
}
[IteratorStateMachine(typeof(<AudioEndEvent>d__135))]
private IEnumerator AudioEndEvent(float time, Action method)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <AudioEndEvent>d__135(0)
{
<>4__this = this,
time = time,
method = method
};
}
public void UpdateRadioPanel()
{
if (Object.op_Implicit((Object)(object)RadioPanelObj) && Object.op_Implicit((Object)(object)UIController.RadioPanelThumbnail) && mAudio.isPlaying)
{
if (Object.op_Implicit((Object)(object)ScreenUICanvasObj))
{
ScreenUICanvasObj.SetActive(true);
}
if (Object.op_Implicit((Object)(object)ScreenPlaneObj))
{
ScreenPlaneObj.SetActive(true);
}
ClearRenderTexture(mScreen.targetTexture);
if (PlayerSettings.DynamicStation != null && PlayerSettings.CurrentMode == PlayerSettings.PlayerMode.Dynamic)
{
RadioPanelObj.SetActive(true);
UIController.RadioPanelThumbnail.sprite = (((Object)(object)PlayerSettings.DynamicStation.Thumbnail != (Object)null) ? PlayerSettings.DynamicStation.Thumbnail : null);
}
else if (mAudio.isPlaying && PlayerSettings.PlayerLinkType == PlayerSettings.LinkType.Audio)
{
RadioPanelObj.SetActive(true);
UIController.RadioPanelThumbnail.sprite = (((Object)(object)PlayerSettings.Thumbnail != (Object)null) ? PlayerSettings.Thumbnail : null);
}
else if (PlayerSettings.PlayerLinkType != PlayerSettings.LinkType.Audio)
{
RadioPanelObj.SetActive(false);
}
}
}
public void Pause(bool isRPC = false)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (!isRPC)
{
RPC.SendData(0L, CinemaPackage.RPCDataType.Pause, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, GetTime());
PlayerSettings.IsPaused = true;
SaveZDO();
return;
}
if (Object.op_Implicit((Object)(object)Animator))
{
Animator.SetBool(PlayerSettings.Playing, false);
}
if (Object.op_Implicit((Object)(object)WaveParticleSystem))
{
WaveParticleSystem.Stop();
}
mScreen.Pause();
mAudio.Pause();
PlayerSettings.IsPaused = true;
}
private void SetupAudio()
{
centerAudioSphere = ((Component)this).transform.Find("audio/centerSphere");
mAudio = ((Component)this).gameObject.GetComponentInChildren<AudioSource>();
mAudio.maxDistance = OODConfig.DefaultDistance.Value;
PlayerSettings.Volume = OODConfig.DefaultAudioSourceVolume.Value;
mAudio.spatialBlend = 1f;
mAudio.spatialize = true;
mAudio.spatializePostEffects = true;
mAudio.volume = PlayerSettings.Volume;
if ((Object)(object)mScreen != (Object)null)
{
mScreen.audioOutputMode = (VideoAudioOutputMode)1;
mScreen.SetTargetAudioSource((ushort)0, mAudio);
}
}
protected void SetupRadioPanel()
{
if (Object.op_Implicit((Object)(object)RadioPanelObj))
{
UIController.RadioPanelThumbnail = ((Component)RadioPanelObj.transform.Find("thumbnail")).GetComponent<Image>();
}
if (Object.op_Implicit((Object)(object)ScreenUICanvasObj))
{
Transform val = ScreenUICanvasObj.transform.Find("mainCanvas/radioPanel/waveformPanel");
if (Object.op_Implicit((Object)(object)val))
{
AudioWaveformVisualizer audioWaveformVisualizer = ((Component)val).gameObject.AddComponent<AudioWaveformVisualizer>();
audioWaveformVisualizer.Setup(mAudio);
}
}
if (Object.op_Implicit((Object)(object)UIController.RadioPanelThumbnail))
{
if (PlayerSettings.DynamicStation != null && PlayerSettings.CurrentMode == PlayerSettings.PlayerMode.Dynamic)
{
UIController.RadioPanelThumbnail.sprite = PlayerSettings.DynamicStation.Thumbnail;
}
if ((Object)(object)PlayerSettings.Thumbnail != (Object)null)
{
UIController.RadioPanelThumbnail.sprite = PlayerSettings.Thumbnail;
}
else
{
UIController.RadioPanelThumbnail.sprite = null;
}
}
}
protected void UpdateLoadingIndicator()
{
if (URLGrab.LoadingBool && !string.IsNullOrEmpty(UnparsedURL))
{
if (Object.op_Implicit((Object)(object)ScreenUICanvasObj) && Object.op_Implicit((Object)(object)LoadingCircleObj) && Object.op_Implicit((Object)(object)RadioPanelObj))
{
ScreenUICanvasObj.SetActive(true);
RadioPanelObj.SetActive(false);
LoadingCircleObj.SetActive(true);
}
UIController?.SetLoadingIndicatorActive(active: true);
int num = PlayerSettings.LoadingCount % 4;
if (UIController != null && (Object)(object)UIController.LoadingIndicatorObj != (Object)null)
{
UIController.LoadingIndicatorObj.GetComponent<Text>().text = UIController.LoadingMessages[num];
}
PlayerSettings.LoadingCount++;
}
else if (!URLGrab.LoadingBool && Object.op_Implicit((Object)(object)UIController.LoadingIndicatorObj) && UIController.LoadingIndicatorObj.activeSelf)
{
UIController.SetLoadingIndicatorActive(active: false);
}
}
public void Stop(bool isRPC = false)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (!isRPC)
{
RPC.SendData(0L, CinemaPackage.RPCDataType.Stop, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, GetTime());
return;
}
if (DynamicStationCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(DynamicStationCoroutine);
}
PlayerSettings.DynamicStation = null;
mScreen.Stop();
mAudio.Stop();
mScreen.url = "";
mAudio.clip = null;
mScreen.time = 0.0;
if (Object.op_Implicit((Object)(object)mAudio.clip))
{
mAudio.time = 0f;
}
if (PlayerSettings.PlayerType == CinemaPackage.MediaPlayers.CinemaScreen)
{
ScreenPlaneObj.SetActive(false);
if (Object.op_Implicit((Object)(object)ScreenUICanvasObj) && Object.op_Implicit((Object)(object)LoadingCircleObj))
{
ScreenUICanvasObj.SetActive(false);
LoadingCircleObj.SetActive(false);
}
}
if (Object.op_Implicit((Object)(object)Animator))
{
Animator.SetBool(PlayerSettings.Playing, false);
}
if (Object.op_Implicit((Object)(object)WaveParticleSystem))
{
WaveParticleSystem.Stop();
}
PlayerSettings.IsPlayingPlaylist = false;
PlayerSettings.IsPlaying = false;
PlayerSettings.IsPaused = false;
CurrentPlaylist = null;
URLGrab.Reset();
ClearRenderTexture(mScreen.targetTexture);
UnparsedURL = null;
DownloadURL = null;
YoutubeURLNode = null;
YoutubeSoundDirectUri = null;
YoutubeVideoDirectUri = null;
PlaylistURL = null;
PlaylistString = null;
PlaylistPosition = 0;
UIController.SetInputFieldText("");
UIController.UpdatePlaylistUI();
SaveZDO();
SendUpdateZDO_RPC();
}
[IteratorStateMachine(typeof(<AudioWebRequest>d__142))]
protected IEnumerator AudioWebRequest(Uri url)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <AudioWebRequest>d__142(0)
{
<>4__this = this,
url = url
};
}
[IteratorStateMachine(typeof(<CreateThumbnailFromURL>d__143))]
private IEnumerator CreateThumbnailFromURL(Uri url)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CreateThumbnailFromURL>d__143(0)
{
<>4__this = this,
url = url
};
}
public void PlaySoundcloud(string sentUrl, bool isRPC)
{
Uri url = URLGrab.CleanUrl(sentUrl);
UIController.SetLoadingIndicatorText("Processing");
UIController.SetLoadingIndicatorActive(active: true);
if (sentUrl != null)
{
((MonoBehaviour)this).StartCoroutine(URLGrab.GetSoundcloudExplodeCoroutine(url, delegate(Uri resultUrl, Uri artworkUri)
{
if (resultUrl != null)
{
if (artworkUri != null)
{
((MonoBehaviour)this).StartCoroutine(CreateThumbnailFromURL(artworkUri));
}
else
{
PlayerSettings.Thumbnail = null;
}
((MonoBehaviour)this).StartCoroutine(AudioWebRequest(resultUrl));
}
else
{
UIController.SetLoadingIndicatorText("Null, check logs");
Logger.LogWarning((object)"Failed to load Soundcloud");
((MonoBehaviour)this).StartCoroutine(ResetLoadingIndicatorAfterDelay());
}
}));
}
else
{
string message = "Soundcloud Null";
Logger.LogInfo((object)"Soundcloud Null, check for exceptions");
((MonoBehaviour)this).StartCoroutine(UIController.UnavailableIndicator(message));
}
}
public void PlayYoutube(string url)
{
if (URLGrab.LoadingBool)
{
return;
}
if (OODConfig.IsYtEnabled.Value)
{
if (PlayerSettings.IsLooping)
{
mScreen.isLooping = true;
mAudio.loop = true;
}
if (OODConfig.YoutubeAPI.Value == OODConfig.YouTubeAPI.YouTubeExplode)
{
StartYoutubeProcessing(url);
return;
}
YoutubeURLNode = url;
((MonoBehaviour)this).StartCoroutine(YoutubeNodeQuery());
}
else
{
((MonoBehaviour)this).StartCoroutine(UIController.UnavailableIndicator("YouTube disabled"));
}
}
public void RPC_SetURL(string url, bool isPaused = false, float time = 0f)
{
if (url == null)
{
return;
}
Encoding uTF = Encoding.UTF8;
byte[] bytes = uTF.GetBytes(url);
url = uTF.GetString(bytes);
PlayerSettings.IsPaused = isPaused;
ClearRenderTexture(mScreen.targetTexture);
if (URLGrab.IsAudioFile(url))
{
string relativeURL = URLGrab.GetRelativeURL(url);
if (relativeURL != "")
{
url = relativeURL;
PlayerSettings.PlayerLinkType = PlayerSettings.LinkType.RelativeAudio;
}
else
{
PlayerSettings.PlayerLinkType = PlayerSettings.LinkType.Audio;
}
DownloadURL = URLGrab.CleanUrl(url);
((MonoBehaviour)this).StartCoroutine(AudioWebRequest(DownloadURL));
}
else if (url.Contains("soundcloud.com/"))
{
PlayerSettings.PlayerLinkType = PlayerSettings.LinkType.Soundcloud;
PlaySoundcloud(url, isRPC: true);
}
else
{
if (!url.Contains("\\") && !url.Contains(".") && !url.Contains("/"))
{
return;
}
string relativeURL2 = URLGrab.GetRelativeURL(url);
if (relativeURL2 != "")
{
mScreen.source = (VideoSource)1;
mScreen.url = relativeURL2;
PlayerSettings.PlayerLinkType = PlayerSettings.LinkType.RelativeVideo;
if (OODConfig.DebugEnabled.Value)
{
Logger.LogDebug((object)("Playing: " + relativeURL2));
}
BeginLoadingPrepare();
}
if ((url.StartsWith("http://") || url.StartsWith("https://")) && !Path.HasExtension(url) && OODConfig.IsYtEnabled.Value)
{
if (PlayerSettings.IsLooping && (!mScreen.isLooping || !mAudio.loop))
{
mScreen.isLooping = true;
mAudio.loop = true;
}
PlayerSettings.PlayerLinkType = PlayerSettings.LinkType.Youtube;
PlayYoutube(url);
return;
}
PlayerSettings.PlayerLinkType = PlayerSettings.LinkType.Video;
mScreen.source = (VideoSource)1;
mScreen.url = url;
BeginLoadingPrepare();
if (OODConfig.DebugEnabled.Value)
{
Logger.LogDebug((object)("Playing: " + url));
}
}
}
private void BeginLoadingPrepare()
{
mScreen.Prepare();
ClearRenderTexture(mScreen.targetTexture);
if (Object.op_Implicit((Object)(object)ScreenUICanvasObj) && Object.op_Implicit((Object)(object)LoadingCircleObj))
{
ScreenUICanvasObj.SetActive(true);
LoadingCircleObj.SetActive(true);
}
}
public void StartYoutubeProcessing(string url)
{
if (Object.op_Implicit((Object)(object)UIController.LoadingIndicatorObj))
{
UIController.SetLoadingIndicatorText("Processing");
UIController.LoadingIndicatorObj.SetActive(true);
}
((MonoBehaviour)this).StartCoroutine(Ytdl.GetVideoUrlWithRetry(url, delegate(string resultUrl)
{
if (!string.IsNullOrEmpty(resultUrl))
{
Logger.LogDebug((object)("Result URL: " + resultUrl));
mScreen.source = (VideoSource)1;
mScreen.url = resultUrl;
BeginLoadingPrepare();
}
else
{
Logger.LogError((object)"Failed to get video URL");
UIController.SetLoadingIndicatorText("Failed to load video");
Logger.LogWarning((object)"Failed to load video");
((MonoBehaviour)this).StartCoroutine(ResetLoadingIndicatorAfterDelay());
}
}));
}
[IteratorStateMachine(typeof(<ResetLoadingIndicatorAfterDelay>d__149))]
private IEnumerator ResetLoadingIndicatorAfterDelay()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ResetLoadingIndicatorAfterDelay>d__149(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<YoutubeNodeQuery>d__150))]
private IEnumerator YoutubeNodeQuery(bool isRPC = false)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <YoutubeNodeQuery>d__150(0)
{
<>4__this = this,
isRPC = isRPC
};
}
[IteratorStateMachine(typeof(<CreateYoutubeAudioAndPlay>d__151))]
private IEnumerator CreateYoutubeAudioAndPlay()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CreateYoutubeAudioAndPlay>d__151(0)
{
<>4__this = this
};
}
public void UpdatePlayerTime(float time)
{
if (Math.Abs(mScreen.time - (double)time) > 0.05)
{
mScreen.time = time;
}
if ((Object)(object)mAudio.clip != (Object)null && (double)Math.Abs(mAudio.time - time) > 0.05)
{
mAudio.time = time;
}
}
public void SetLock(bool locked)
{
PlayerSettings.IsLocked = locked;
if (Object.op_Implicit((Object)(object)UIController.URLPanelObj))
{
if (PlayerSettings.IsLocked)
{
UIController.LockedIconObj.SetActive(true);
UIController.UnlockedIconObj.SetActive(false);
}
else
{
UIController.LockedIconObj.SetActive(false);
UIController.UnlockedIconObj.SetActive(true);
}
}
}
public void SetDynamicStation(DynamicStation station)
{
PlayerSettings.DynamicStation = station;
}
public virtual void SaveZDO(bool saveTime = true)
{
ZDO zDO = ZNetView.GetZDO();
if (zDO != null && !((Object)(object)mAudio == (Object)null))
{
RequestOwnership(zDO);
zDO.Set("distance", mAudio.maxDistance);
zDO.Set("adminOnly", PlayerSettings.AdminOnly);
zDO.Set("isLooping", PlayerSettings.IsLooping);
zDO.Set("isLocked", PlayerSettings.IsLocked);
zDO.Set("isPlaying", PlayerSettings.IsPlaying);
zDO.Set("isPaused", PlayerSettings.IsPaused);
zDO.Set("currentMode", (int)PlayerSettings.CurrentMode);
zDO.Set("url", UnparsedURL ?? "");
if (saveTime)
{
SaveTimeZDO();
}
zDO.Set("speakers", SpeakerHelper.CompressSpeakerList(mSpeakers));
zDO.Set("speakerCount", mSpeakers.Count);
}
}
public void SaveTimeZDO()
{
ZDO zDO = ZNetView.GetZDO();
if (zDO != null)
{
if (mScreen.isPlaying)
{
zDO.Set("time", (float)mScreen.time);
}
else if (mAudio.isPlaying && Object.op_Implicit((Object)(object)mAudio.clip))
{
zDO.Set("time", mAudio.time);
}
}
}
public virtual void LoadZDO()
{
ZDO zDO = ZNetView.GetZDO();
if (zDO == null)
{
return;
}
PlayerSettings.AdminOnly = zDO.GetBool("adminOnly", false);
float @float = zDO.GetFloat("distance", 0f);
if (@float != 0f)
{
mAudio.maxDistance = @float;
}
PlayerSettings.IsLocked = zDO.GetBool("isLocked", false);
UnparsedURL = zDO.GetString("url", "");
PlayerSettings.IsLooping = zDO.GetBool("isLooping", false);
mAudio.loop = PlayerSettings.IsLooping;
mScreen.isLooping = PlayerSettings.IsLooping;
mSpeakers = SpeakerHelper.DecompressSpeakerList(zDO.GetByteArray("speakers", (byte[])null));
UpdateSpeakerCenter();
PlayerSettings.IsPlaying = zDO.GetBool("isPlaying", false);
PlayerSettings.IsPaused = zDO.GetBool("isPaused", false);
PlayerSettings.CurrentMode = (PlayerSettings.PlayerMode)zDO.GetInt("currentMode", 0);
if (PlayerSettings.CurrentMode == PlayerSettings.PlayerMode.Dynamic)
{
PlayerSettings.DynamicStation = StationManager.Instance.GetStation(UnparsedURL);
if (PlayerSettings.DynamicStation != null)
{
((MonoBehaviour)this).StartCoroutine(DelayedExecution(1f, delegate
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
RPC.SendData(0L, CinemaPackage.RPCDataType.RequestStation, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, 0f, PlayerSettings.DynamicStation.Title);
}));
((MonoBehaviour)this).StartCoroutine(DelayedExecution(2f, SendRequestTimeSync_RPC));
}
}
else
{
((MonoBehaviour)this).StartCoroutine(DelayedExecution(3f, delegate
{
RPC_SetURL(UnparsedURL, PlayerSettings.IsPaused);
}));
}
}
public virtual void UpdateZDO()
{
ZDO zDO = ZNetView.GetZDO();
if (zDO == null)
{
return;
}
PlayerSettings.AdminOnly = zDO.GetBool("adminOnly", false);
float @float = zDO.GetFloat("distance", 0f);
if (@float != 0f)
{
mAudio.maxDistance = @float;
}
PlayerSettings.IsLocked = zDO.GetBool("isLocked", false);
PlayerSettings.IsLooping = zDO.GetBool("isLooping", false);
mAudio.loop = PlayerSettings.IsLooping;
mScreen.isLooping = PlayerSettings.IsLooping;
PlayerSettings.CurrentMode = (PlayerSettings.PlayerMode)zDO.GetInt("currentMode", 0);
if (zDO.GetString("url", "") != UnparsedURL)
{
if (string.IsNullOrEmpty(UnparsedURL))
{
if (PlayerSettings.CurrentMode == PlayerSettings.PlayerMode.Dynamic)
{
((MonoBehaviour)this).StartCoroutine(DelayedExecution(1f, delegate
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
PlayerSettings.DynamicStation = StationManager.Instance.GetStation(UnparsedURL);
if (PlayerSettings.DynamicStation?.Title != null)
{
RPC.SendData(0L, CinemaPackage.RPCDataType.RequestStation, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, 0f, PlayerSettings.DynamicStation.Title);
}
}));
((MonoBehaviour)this).StartCoroutine(DelayedExecution(2f, SendRequestTimeSync_RPC));
}
else
{
RPC_SetURL(UnparsedURL);
}
}
else
{
Stop(isRPC: true);
}
}
if (zDO.GetInt("speakerCount", 0) != mSpeakers.Count)
{
mSpeakers = SpeakerHelper.DecompressSpeakerList(zDO.GetByteArray("speakers", (byte[])null));
UpdateSpeakerCenter();
}
mSpeakers = SpeakerHelper.DecompressSpeakerList(zDO.GetByteArray("speakers", (byte[])null));
UpdateSpeakerCenter();
if (zDO.GetBool("isPaused", false) != PlayerSettings.IsPaused)
{
Pause(isRPC: true);
}
}
public async void RPC_UpdateZDO()
{
await Task.Delay(350);
UpdateZDO();
}
[IteratorStateMachine(typeof(<DelayedExecution>d__160))]
private IEnumerator DelayedExecution(float delay, Action action)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <DelayedExecution>d__160(0)
{
<>4__this = this,
delay = delay,
action = action
};
}
internal void SendUpdateZDO_RPC()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
RPC.SendData(0L, CinemaPackage.RPCDataType.UpdateZDO, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, GetTime());
}
private void SyncTime()
{
if (mScreen.isPlaying || mAudio.isPlaying)
{
BroadcastTime();
}
}
internal void SendRequestTimeSync_RPC()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
ZDO zDO = ZNetView.GetZDO();
if (zDO != null && (!zDO.IsOwner() || PlayerSettings.CurrentMode == PlayerSettings.PlayerMode.Dynamic))
{
RPC.SendData(0L, CinemaPackage.RPCDataType.RequestTime, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, 0f, UnparsedURL);
}
}
public void BroadcastTime()
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
ZDO zDO = ZNetView.GetZDO();
if (zDO != null && zDO.IsOwner())
{
SaveTimeZDO();
RPC.SendData(0L, CinemaPackage.RPCDataType.SyncTime, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position, GetTime());
}
}
private string GenerateUniqueID()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
string[] obj = new string[5]
{
Path.GetRandomFileName().Replace(".", ""),
"-",
DateTime.Now.Ticks.ToString(),
"-",
null
};
ZDOID zDOID = ((Character)Player.m_localPlayer).GetZDOID();
obj[4] = ((ZDOID)(ref zDOID)).UserID.ToString();
return string.Concat(obj);
}
public Coroutine StartPlayerCoroutine(IEnumerator routine)
{
return ((MonoBehaviour)this).StartCoroutine(routine);
}
public void StopPlayerCoroutine(Coroutine routine)
{
((MonoBehaviour)this).StopCoroutine(routine);
}
public void ClaimOwnership(ZDO zdo)
{
if (zdo != null && !zdo.IsOwner())
{
zdo.SetOwner(ZDOMan.GetSessionID());
}
}
public void SetOwnership(long peer)
{
ZDO zDO = ZNetView.GetZDO();
if (zDO != null && zDO.IsOwner())
{
BroadcastTime();
zDO.SetOwner(peer);
}
}
public void RequestOwnership(ZDO zdo)
{
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
if (zdo == null || zdo.IsOwner())
{
return;
}
Player val = ((IEnumerable<Player>)Player.s_players).FirstOrDefault((Func<Player, bool>)delegate(Player p)
{
//IL_0025: 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)
int result;
if ((Object)(object)p != (Object)null && (Object)(object)((Character)p).m_nview != (Object)null && ((Character)p).m_nview.IsValid())
{
ZDOID zDOID = ((Character)p).GetZDOID();
result = ((((ZDOID)(ref zDOID)).UserID == zdo.GetOwner()) ? 1 : 0);
}
else
{
result = 0;
}
return (byte)result != 0;
});
if ((Object)(object)val == (Object)null)
{
ClaimOwnership(zdo);
}
else
{
RPC.SendData(0L, CinemaPackage.RPCDataType.RequestOwnership, PlayerSettings.PlayerType, MediaPlayerID, ((Component)this).gameObject.transform.position);
}
}
public bool AddSpeaker(SpeakerComponent sp)
{
if (mSpeakers.Add(sp))
{
SaveZDO();
UpdateSpeakerCenter();
((MonoBehaviour)this).StartCoroutine(ShowCenterSphere());
SendUpdateZDO_RPC();
return true;
}
return false;
}
public void RemoveSpeaker(SpeakerComponent sp)
{
if (mSpeakers.Remove(sp))
{
SaveZDO();
UpdateSpeakerCenter();
((MonoBehaviour)this).StartCoroutine(ShowCenterSphere());
SendUpdateZDO_RPC();
}
}
private void UpdateSpeakerCenter()
{
//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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (mSpeakers.Count == 0)
{
((Component)mAudio).transform.position = ((Component)this).transform.position;
return;
}
Vector3 position = SpeakerHelper.CalculateAudioCenter(mSpeakers.ToList());
((Component)mAudio).transform.position = position;
}
public void UnlinkAllSpeakers()
{
mSpeakers.Clear();
UIController.UpdateSpeakerCount();
UpdateSpeakerCenter();
((MonoBehaviour)this).StartCoroutine(ShowCenterSphere());
SaveZDO();
SendUpdateZDO_RPC();
}
[IteratorStateMachine(typeof(<ShowCenterSphere>d__175))]
private IEnumerator ShowCenterSphere()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ShowCenterSphere>d__175(0)
{
<>4__this = this
};
}
private float GetTime()
{
if (PlayerSettings.PlayerLinkType == PlayerSettings.LinkType.Youtube || PlayerSettings.PlayerLinkType == PlayerSettings.LinkType.RelativeVideo || PlayerSettings.PlayerLinkType == PlayerSettings.LinkType.Video)
{
return (float)mScreen.time;
}
if (PlayerSettings.PlayerLinkType == PlayerSettings.LinkType.Audio && Object.op_Implicit((Object)(object)mAudio.clip))
{
return mAudio.time;
}
return 0f;
}
private float GetTimeZDO()
{
ZDO zDO = ZNetView.GetZDO();
if (zDO != null)
{
return zDO.GetFloat("time", 0f);
}
return 0f;
}
private void ClearRenderTexture(RenderTexture renderTexture)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(1, 1);
val.SetPixel(0, 0, Color.black);
val.Apply();
RenderTexture active = RenderTexture.active;
RenderTexture.active = renderTexture;
Graphics.Blit((Texture)(object)val, renderTexture);
RenderTexture.active = active;
Object.Destroy((Object)(object)val);
}
GameObject IPlayer.get_gameObject()
{
return ((Component)this).gameObject;
}
}
public class PlayerSettings
{
public enum LinkType
{
Youtube,
Soundcloud,
Video,
Audio,
RelativeAudio,
RelativeVideo
}
public enum PlayerMode
{
URL,
Dynamic
}
public static readonly int Playing = Animator.StringToHash("Playing");
public static readonly int MainTex = Shader.PropertyToID("_MainTex");
public static readonly int EmissiveColorMap = Shader.PropertyToID("_EmissiveColorMap");
internal LinkType PlayerLinkType;
public PlayerMode CurrentMode = PlayerMode.URL;
public List<AudioClip> CurrentDynamicList = new List<AudioClip>();
public bool IsPaused { get; set; }
public bool IsPlaying { get; set; }
public int LoadingCount { get; set; }
public bool IsGuiActive { get; set; }
public bool AdminOnly { get; set; }
public bool IsLocked { get; set; } = true;
public bool IsLooping { get; set; }
public bool IsPlayingPlaylist { get; set; }
public bool IsSettingsGuiActive { get; set; }
public bool IsShuffling { get; set; }
public float MuteVol { get; set; } = 0.5f;
public float VerticalDistanceDropoff { get; set; } = 0f;
public float DropoffPower { get; set; } = 1.5f;
public float Volume { get; set; } = 0.5f;
public bool IsLinkedToParent { get; set; } = false;
public CinemaPackage.MediaPlayers PlayerType { get; set; }
public DynamicStation DynamicStation { get; set; }
public Sprite Thumbnail { get; set; }
}
}
namespace OdinOnDemand.Patches
{
[HarmonyPatch(typeof(Trader), "GetAvailableItems")]
public class HaldorCustomPatch
{
private static void Postfix(ref List<TradeItem> __result)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
List<TradeItem> list = new List<TradeItem>();
if (OODConfig.SkaldsGirdleEnabled.Value)
{
GameObject prefab = PrefabManager.Instance.GetPrefab("skaldsgirdle");
if ((Object)(object)prefab != (Object)null)
{
list.Add(new TradeItem
{
m_prefab = prefab.GetComponent<ItemDrop>(),
m_stack = 1,
m_price = OODConfig.SkaldsGirdleCost.Value
});
}
}
__result = __result.Concat(list).ToList();
}
}
public class PlacePiecePatch
{
[HarmonyPatch(typeof(Player), "PlacePiece", new Type[]
{
typeof(Piece),
typeof(Vector3),
typeof(Quaternion),
typeof(bool)
})]
private static class PlacePiece_Patch
{
private static bool Prefix(Piece piece, Vector3 pos, Quaternion rot, bool doAttack = true)
{
if (Pieces.Contains(((Object)((Component)piece).gameObject).name) && OODConfig.VipMode.Value)
{
RankSystem.PlayerRank rank = RankSystem.GetRank();
if (rank != RankSystem.PlayerRank.Admin && rank != RankSystem.PlayerRank.Vip)
{
RankSystem.DisplayBlockMenu();
return false;
}
}
return true;
}
}
private static readonly string[] Pieces = new string[9] { "flatscreen", "theaterscreen", "tabletv", "monitor", "oldtv", "laptop", "radio", "boombox", "gramophone" };
}
[HarmonyPatch(typeof(Player), "RemovePiece")]
public class RemovePiecePatch
{
private static readonly string[] Pieces = new string[9] { "flatscreen", "theaterscreen", "tabletv", "monitor", "oldtv", "laptop", "radio", "boombox", "gramophone" };
[HarmonyPrefix]
public static bool PrefixRemovePiece(ref Player __instance)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
if (!OODConfig.VipMode.Value)
{
return true;
}
RaycastHit val = default(RaycastHit);
if (!Physics.Raycast(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, ref val, 50f, __instance.m_removeRayMask) || (double)Vector3.Distance(((RaycastHit)(ref val)).point, ((Character)__instance).m_eye.position) >= (double)__instance.m_maxPlaceDistance)
{
return false;
}
Piece componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Piece>();
if (!Object.op_Implicit((Object)(object)componentInParent) || !componentInParent.m_canBeRemoved)
{
return false;
}
if (Pieces.Contains(((Object)((Component)componentInParent).gameObject).name.Replace("(Clone)", "")) && OODConfig.VipMode.Value)
{
RankSystem.PlayerRank rank = RankSystem.GetRank();
if (rank != RankSystem.PlayerRank.Admin && rank != RankSystem.PlayerRank.Vip)
{
RankSystem.DisplayBlockMenu();
return false;
}
}
return true;
}
}
}
namespace OdinOnDemand.Utils
{
public class AudioFader : MonoBehaviour
{
private static MusicMan _musicMan;
public static AudioFader Instance { get; set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
else
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
public AudioFader()
{
_musicMan = MusicMan.m_instance;
}
public void Update()
{
if (OODConfig.AudioFadeType.Value == OODConfig.FadeType.Fade)
{
FadeGameMusic();
}
}
public void FadeGameMusic()
{
var (num, basePlayer) = GetDistanceFromMediaplayers();
if (!Object.op_Implicit((Object)(object)basePlayer))
{
_musicMan.m_musicVolume = PlayerPrefs.GetFloat("MusicVolume", 1f);
return;
}
float num2 = basePlayer.mAudio.maxDistance / 1.35f;
if (num > num2)
{
_musicMan.m_musicVolume = PlayerPrefs.GetFloat("MusicVolume", 1f);
return;
}
float num3 = Mathf.Clamp01(num / num2);
float num4 = 20f * Mathf.Log10(_musicMan.m_musicSource.volume);
float num5 = Mathf.Lerp(OODConfig.LowestVolumeDB.Value, num4, num3);
_musicMan.m_musicSource.volume = Mathf.Pow(10f, num5 / 20f);
}
private static (float, BasePlayer) GetDistanceFromMediaplayers()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: 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)
if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
{
return (float.MaxValue, null);
}
Vector3 position = ((Component)Player.m_localPlayer).transform.position;
float num = float.MaxValue;
BasePlayer item = null;
foreach (KeyValuePair<Type, IList> mediaComponentList in ComponentLists.MediaComponentLists)
{
foreach (BasePlayer item2 in mediaComponentList.Value)
{
if (Object.op_Implicit((Object)(object)item2) && (item2.mAudio.isPlaying || (Object.op_Implicit((Object)(object)item2.mAudio.clip) && item2.mAudio.time != 0f) || item2.mAudio.loop) && !item2.PlayerSettings.IsPaused && item2.PlayerSettings.IsPlaying)
{
Vector3 position2 = ((Component)item2).transform.position;
float num2 = Vector3.Distance(position, position2);
if (num2 < num)
{
num = num2;
item = item2;
}
}
}
}
return (num, item);
}
}
public class RankSystem : MonoBehaviour
{
public enum PlayerRank
{
Player,
Vip,
Admin
}
private class CoroutineManager : MonoBehaviour
{
}
[CompilerGenerated]
private sealed class <ShowBlockMenu>d__6 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ShowBlockMenu>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if (_blockedText.activeSelf)
{
_blockedText.SetActive(false);
return false;
}
_blockedText.SetActive(true);
<>2__current = (object)new WaitForSeconds(3f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
_blockedText.SetActive(false);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static GameObject _blockedText;
private static CoroutineManager _coroutineManager;
private static Coroutine _blockMenuCoroutine;
public static PlayerRank GetRank()
{
UserInfo localUser = UserInfo.GetLocalUser();
if (ZNet.instance.ListContainsId(ZNet.instance.m_adminList, localUser.UserId.m_userID))
{
return PlayerRank.Admin;
}
if (OODConfig.VipList.Value.Contains(localUser.UserId.m_userID))
{
return PlayerRank.Vip;
}
return PlayerRank.Player;
}
private static void CreateBlockMenu()
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)_blockedText))
{
if (GUIManager.Instance == null)
{
Logger.LogDebug((object)"GUIManager instance is null");
return;
}
if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront))
{
Logger.LogDebug((object)"GUIManager CustomGUI is null");
return;
}
_blockedText = GUIManager.Instance.CreateText(OODConfig.VipMessage.Value, GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -150f), GUIManager.Instance.AveriaSerifBold, 22, GUIManager.Instance.ValheimOrange, true, Color.black, 450f, 40f, false);
_blockedText.SetActive(false);
}
}
public static void DisplayBlockMenu()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
if ((Object)(object)_coroutineManager == (Object)null)
{
GameObject val = new GameObject("CoroutineManager");
_coroutineManager = val.AddComponent<CoroutineManager>();
Object.DontDestroyOnLoad((Object)(object)val);
}
if (!Object.op_Implicit((Object)(object)_blockedText))
{
CreateBlockMenu();
}
if (_blockMenuCoroutine != null)
{
((MonoBehaviour)_coroutineManager).StopCoroutine(_blockMenuCoroutine);
}
_blockMenuCoroutine = ((MonoBehaviour)_coroutineManager).StartCoroutine(ShowBlockMenu());
}
[IteratorStateMachine(typeof(<ShowBlockMenu>d__6))]
private static IEnumerator ShowBlockMenu()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ShowBlockMenu>d__6(0);
}
}
}
namespace OdinOnDemand.Utils.UI
{
public class AudioWaveformVisualizer : MonoBehaviour
{
public int barCount = 64;
public int smoothing = 8;
public RectTransform[] bars;
public AudioSource audioSource;
public Gradient colorGradient;
public float spacing = 10f;
public float minHeight = 0.001f;
public float maxHeight = 10f;
public bool enableGlowEffect = true;
public bool enableOutlineEffect = true;
private bool _initialUpdateDone = false;
[SerializeField]
private int midStartIndex = 10;
[SerializeField]
private int midEndIndex = 32;
[SerializeField]
private float midScalingFactor = OODConfig.VisualizerScaleFactorMid.Value;
[SerializeField]
private float highScalingFactor = OODConfig.VisualizerScaleFactorHigh.Value;
[SerializeField]
private float baseScalingFactor = OODConfig.VisualizerScaleFactorBase.Value;
public void Setup(AudioSource audio)
{
audioSource = audio;
CreateBars();
CreateGradient();
Update();
}
private void CreateGradient()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
colorGradient = new Gradient();
GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[3];
array[0].color = Color.green;
array[0].time = 0f;
array[1].color = Color.yellow;
array[1].time = 0.25f;
array[2].color = new Color(255f, 165f, 0f);
array[2].time = 1f;
GradientAlphaKey[] array2 = (GradientAlphaKey[])(object)new GradientAlphaKey[2];
array2[0].alpha = 1f;
array2[0].time = 0f;
array2[1].alpha = 1f;
array2[1].time = 1f;
colorGradient.SetKeys(array, array2);
}
private void CreateBars()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0087: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: 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_0189: Expected O, but got Unknown
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
bars = (RectTransform[])(object)new RectTransform[barCount];
float num = spacing * (float)(barCount - 1);
Rect rect = ((Component)this).GetComponent<RectTransform>().rect;
float num2 = (((Rect)(ref rect)).width - num) / (float)barCount;
for (int i = 0; i < barCount; i++)
{
GameObject val = new GameObject("Bar " + i);
val.transform.SetParent(((Component)this).transform, false);
RectTransform val2 = val.AddComponent<RectTransform>();
rect = ((Component)this).GetComponent<RectTransform>().rect;
val2.sizeDelta = new Vector2(num2, ((Rect)(ref rect)).height);
val2.anchorMin = new Vector2(0.5f, 0f);
val2.anchorMax = new Vector2(0.5f, 1f);
val2.pivot = new Vector2(0.5f, 0.5f);
float num3 = (num2 + spacing) * (float)i;
rect = ((Component)this).GetComponent<RectTransform>().rect;
val2.anchoredPosition = new Vector2(num3 - ((Rect)(ref rect)).width / 2f + num2 / 2f, 0f);
Image val3 = val.AddComponent<Image>();
val3.sprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f));
if (enableGlowEffect)
{
((Graphic)val3).material = new Material(Shader.Find("UI/Default"));
((Graphic)val3).material.EnableKeyword("_EMISSION");
((Graphic)val3).material.SetColor("_EmissionColor", Color.white);
}
if (enableOutlineEffect)
{
Outline val4 = val.AddComponent<Outline>();
((Shadow)val4).effectColor = Color.black;
}
bars[i] = val2;
}
}
private void Update()
{
//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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
if (_initialUpdateDone && !audioSource.isPlaying)
{
return;
}
float[] array = new float[128];
audioSource.GetSpectrumData(array, 0, (FFTWindow)0);
Transform parent = ((Component)this).transform.parent;
Rect rect = ((Component)parent).GetComponent<RectTransform>().rect;
float num = ((Rect)(ref rect)).height / parent.localScale.y;
for (int i = 0; i < bars.Length; i++)
{
float num2 = 1f;
if (i >= midStartIndex && i <= midEndIndex)
{
num2 = midScalingFactor;
}
else if (i > midEndIndex)
{
num2 = highScalingFactor;
}
if (i >= 0 && i <= 3)
{
num2 = 0.25f;
}
float num3 = array[i] * num2 * baseScalingFactor + minHeight;
num3 = Mathf.Clamp(num3, minHeight, Mathf.Min(maxHeight, num));
float num4 = Mathf.Lerp(((Transform)bars[i]).localScale.y, num3, Time.deltaTime * (float)smoothing);
((Transform)bars[i]).localScale = new Vector3(1f, num4, 1f);
((Graphic)((Component)bars[i]).GetComponent<Image>()).color = colorGradient.Evaluate(array[i] * num2 * 25f);
}
_initialUpdateDone = true;
}
}
public class LoadingCircle : MonoBehaviour
{
private RectTransform rectComponent;
private readonly float rotateSpeed = 200f;
private void Start()
{
rectComponent = ((Component)this).GetComponent<RectTransform>();
}
private void Update()
{
if (((Behaviour)this).isActiveAndEnabled)
{
((Transform)rectComponent).Rotate(0f, 0f, rotateSpeed * Time.deltaTime);
}
}
}
public class ScrollingText : MonoBehaviour
{
[CompilerGenerated]
private sealed class <ScrollText>d__6 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public ScrollingText <>4__this;
private int <direction>5__1;
private string <scrollText>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ScrollText>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<scrollText>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<direction>5__1 = 1;
break;
case 1:
<