using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using ShopUtils;
using ShopUtils.Language;
using ShopUtils.Network;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Networking;
using Zorro.Core.Serizalization;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WorkezyLabs.BoomboxUpgrade")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("BoomboxUpgrade")]
[assembly: AssemblyTitle("WorkezyLabs.BoomboxUpgrade")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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.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 BoomboxUpgrade
{
[ContentWarningPlugin("WorkezyLabs.BoomboxUpgrade", "1.0.1", true)]
[BepInPlugin("WorkezyLabs.BoomboxUpgrade", "BoomboxUpgrade", "1.0.1")]
public class Boombox : BaseUnityPlugin
{
public static ManualLogSource log;
public static AssetBundle asset;
public static bool InfiniteBattery = false;
public static float BatteryCapacity = 250f;
public static bool UseMouseWheel = true;
public static bool UseSounds = true;
public static ConfigEntry<KeyCode> VolumeUpKey;
public static ConfigEntry<KeyCode> VolumeDownKey;
public static ConfigEntry<KeyCode> MusicUpKey;
public static ConfigEntry<KeyCode> MusicDownKey;
private void Awake()
{
LoadConfig();
LoadBoombox();
LoadLangauge();
}
private void Start()
{
MusicLoadManager.StartLoadMusic();
}
private void LoadConfig()
{
VolumeUpKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Config", "VolumeUp", (KeyCode)61, (ConfigDescription)null);
VolumeDownKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Config", "VolumeDown", (KeyCode)45, (ConfigDescription)null);
MusicUpKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Config", "MusicUp", (KeyCode)327, (ConfigDescription)null);
MusicDownKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Config", "MusicDown", (KeyCode)326, (ConfigDescription)null);
log = ((BaseUnityPlugin)this).Logger;
Networks.SetNetworkSync(new Dictionary<string, object>
{
{
"BoomboxInfiniteBattery",
((BaseUnityPlugin)this).Config.Bind<bool>("Config", "InfiniteBattery", false, (ConfigDescription)null).Value
},
{
"BoomboxBattery",
((BaseUnityPlugin)this).Config.Bind<float>("Config", "BatteryCapacity", 250f, (ConfigDescription)null).Value
},
{
"UseMouseWheel",
((BaseUnityPlugin)this).Config.Bind<bool>("Config", "UseMouseWheel", true, (ConfigDescription)null).Value
},
{
"UseSounds",
((BaseUnityPlugin)this).Config.Bind<bool>("Config", "UseSounds", true, (ConfigDescription)null).Value
}
}, (Action<Dictionary<string, string>>)delegate(Dictionary<string, string> dic)
{
InfiniteBattery = bool.Parse(dic["BoomboxInfiniteBattery"]);
BatteryCapacity = float.Parse(dic["BoomboxBattery"]);
UseMouseWheel = bool.Parse(dic["UseMouseWheel"]);
UseSounds = bool.Parse(dic["UseSounds"]);
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Boombox Load [InfiniteBattery: {InfiniteBattery}, BatteryCapacity: {BatteryCapacity}], UseMouseWheel: {UseMouseWheel}, UseSounds: {UseSounds}");
});
}
private void LoadBoombox()
{
asset = QuickLoadAssetBundle("boombox");
Item val = asset.LoadAsset<Item>("Boombox");
val.itemObject.AddComponent<BoomboxBehaviour>();
Entries.RegisterAll();
Items.RegisterShopItem(val, (ShopItemCategory)7, ((BaseUnityPlugin)this).Config.Bind<int>("Config", "BoomboxPrice", 100, (ConfigDescription)null).Value);
Networks.RegisterItemPrice(val);
}
private void LoadLangauge()
{
Locale language = Languages.GetLanguage((LanguageEnum)0);
Languages.AddLanguage(language, "Boombox_ToolTips", "[LMB] 播放;[RMB] 切换音乐");
Languages.AddLanguage(language, "Boombox", "音响");
Languages.AddLanguage(language, "BoomboxVolume", "{0}% 音量");
Locale language2 = Languages.GetLanguage((LanguageEnum)1);
Languages.AddLanguage(language2, "Boombox_ToolTips", "[LMB] 播放;[RMB] 切換音樂");
Languages.AddLanguage(language2, "Boombox", "音響");
Languages.AddLanguage(language2, "BoomboxVolume", "{0}% 音量");
Locale language3 = Languages.GetLanguage((LanguageEnum)2);
Languages.AddLanguage(language3, "Boombox_ToolTips", "[LMB] Player;[RMB] Switch Music");
Languages.AddLanguage(language3, "Boombox", "Boombox");
Languages.AddLanguage(language3, "BoomboxVolume", "{0}% Volume");
Locale language4 = Languages.GetLanguage((LanguageEnum)3);
Languages.AddLanguage(language4, "Boombox_ToolTips", "[LMB] Jouer de la musique;[RMB] Changer de musique");
Languages.AddLanguage(language4, "Boombox", "Audio portable");
Languages.AddLanguage(language4, "BoomboxVolume", "{0}% Volume");
Locale language5 = Languages.GetLanguage((LanguageEnum)4);
Languages.AddLanguage(language5, "Boombox_ToolTips", "[LMB] Musik abspielen;[RMB] Musik wechseln");
Languages.AddLanguage(language5, "Boombox", "Boom Box");
Languages.AddLanguage(language5, "BoomboxVolume", "{0}% Volume");
Locale language6 = Languages.GetLanguage((LanguageEnum)5);
Languages.AddLanguage(language6, "Boombox_ToolTips", "[LMB] Riproduci musica;[RMB] Cambia musica");
Languages.AddLanguage(language6, "Boombox", "boom box");
Languages.AddLanguage(language6, "BoomboxVolume", "{0}% volume");
Locale language7 = Languages.GetLanguage((LanguageEnum)6);
Languages.AddLanguage(language7, "Boombox_ToolTips", "[LMB] 音楽を流す;[RMB] 音楽を切り替える");
Languages.AddLanguage(language7, "Boombox", "ポータブルオーディオ");
Languages.AddLanguage(language7, "BoomboxVolume", "{0}% 音量");
Locale language8 = Languages.GetLanguage((LanguageEnum)7);
Languages.AddLanguage(language8, "Boombox_ToolTips", "[LMB] Tocar música;[RMB] Mudar a Música");
Languages.AddLanguage(language8, "Boombox", "Sistema de áudio portátil");
Languages.AddLanguage(language8, "BoomboxVolume", "{0}% volume");
Locale language9 = Languages.GetLanguage((LanguageEnum)8);
Languages.AddLanguage(language9, "Boombox_ToolTips", "[LMB] Музыка");
Languages.AddLanguage(language9, "MusicUpKey", "[{}] Переключить музыку вперед");
Languages.AddLanguage(language9, "MusicDownKey", "[{}] Переключить музыку назад");
Languages.AddLanguage(language9, "Boombox", "Портативный звук");
Languages.AddLanguage(language9, "BoomboxVolume", "{0}% Громкость");
Locale language10 = Languages.GetLanguage((LanguageEnum)9);
Languages.AddLanguage(language10, "Boombox_ToolTips", "[LMB] Reproducir música;[RMB] Cambiar música");
Languages.AddLanguage(language10, "Boombox", "Traductor portátil");
Languages.AddLanguage(language10, "BoomboxVolume", "{0}% Volumen");
Locale language11 = Languages.GetLanguage((LanguageEnum)10);
Languages.AddLanguage(language11, "Boombox_ToolTips", "[LMB] Грати музику;[RMB] Перемкнути музику");
Languages.AddLanguage(language11, "Boombox", "Портувана аудіосистема");
Languages.AddLanguage(language11, "BoomboxVolume", "{0}% гучність");
Locale language12 = Languages.GetLanguage((LanguageEnum)11);
Languages.AddLanguage(language12, "Boombox_ToolTips", "[LMB] 음악 재생;[RMB] 음악 전환");
Languages.AddLanguage(language12, "Boombox", "휴대용 오디오");
Languages.AddLanguage(language12, "BoomboxVolume", "{0}% 볼륨");
Locale language13 = Languages.GetLanguage((LanguageEnum)12);
Languages.AddLanguage(language13, "Boombox_ToolTips", "[LMB] Spela musik;[RMB] Byt musik");
Languages.AddLanguage(language13, "Boombox", "Bärbart ljudsystem");
Languages.AddLanguage(language13, "BoomboxVolume", "{0}% volym");
}
public static AssetBundle QuickLoadAssetBundle(string name)
{
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name);
return AssetBundle.LoadFromFile(text);
}
}
public class BoomboxBehaviour : ItemInstanceBehaviour
{
public static List<AudioClip> clips = new List<AudioClip>();
private BatteryEntry batteryEntry;
private OnOffEntry onOffEntry;
private TimeEntry timeEntry;
private VolumeEntry volumeEntry;
private MusicEntry musicEntry;
private SFX_PlayOneShot Click;
private AudioSource Music;
private int currentIndex = 0;
private void Awake()
{
Click = ((Component)((Component)this).transform.Find("SFX/Click")).GetComponent<SFX_PlayOneShot>();
Music = ((Component)this).GetComponent<AudioSource>();
GameHandler instance = GameHandler.Instance;
if ((Object)(object)instance != (Object)null)
{
SFXVolumeSetting setting = instance.SettingsHandler.GetSetting<SFXVolumeSetting>();
if (setting != null)
{
Music.outputAudioMixerGroup = setting.mixerGroup;
}
}
}
public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: 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_0043: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
if (!Boombox.InfiniteBattery && !data.TryGetEntry<BatteryEntry>(ref batteryEntry))
{
batteryEntry = new BatteryEntry
{
m_charge = Boombox.BatteryCapacity,
m_maxCharge = Boombox.BatteryCapacity
};
data.AddDataEntry((ItemDataEntry)(object)batteryEntry);
}
if (!data.TryGetEntry<OnOffEntry>(ref onOffEntry))
{
onOffEntry = new OnOffEntry
{
on = false
};
data.AddDataEntry((ItemDataEntry)(object)onOffEntry);
}
if (!data.TryGetEntry<TimeEntry>(ref timeEntry))
{
timeEntry = new TimeEntry
{
currentTime = 0f
};
data.AddDataEntry((ItemDataEntry)(object)timeEntry);
}
if (!data.TryGetEntry<MusicEntry>(ref musicEntry))
{
musicEntry = new MusicEntry
{
selectMusicIndex = 0
};
data.AddDataEntry((ItemDataEntry)(object)musicEntry);
}
if (!data.TryGetEntry<VolumeEntry>(ref volumeEntry))
{
volumeEntry = new VolumeEntry
{
volume = 5
};
data.AddDataEntry((ItemDataEntry)(object)volumeEntry);
}
musicEntry.UpdateMusicName();
}
private void Update()
{
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
if (base.isHeldByMe && !Player.localPlayer.HasLockedInput())
{
if (Player.localPlayer.input.clickWasPressed)
{
if (clips.Count == 0)
{
HelmetText.Instance.SetHelmetText("No Music", 2f);
}
else
{
onOffEntry.on = !onOffEntry.on;
((ItemDataEntry)onOffEntry).SetDirty();
}
Click.Play();
}
if (Boombox.UseMouseWheel)
{
if ((double)Input.GetAxis("Mouse ScrollWheel") > 0.1)
{
MusicUp();
}
if ((double)Input.GetAxis("Mouse ScrollWheel") < -0.1)
{
MusicDown();
}
}
else
{
if (GlobalInputHandler.GetKeyUp(Boombox.MusicUpKey.Value))
{
MusicUp();
}
if (GlobalInputHandler.GetKeyUp(Boombox.MusicDownKey.Value))
{
MusicDown();
}
}
if (GlobalInputHandler.GetKeyUp(Boombox.VolumeUpKey.Value))
{
if (volumeEntry.volume <= 9)
{
volumeEntry.volume++;
((ItemDataEntry)volumeEntry).SetDirty();
}
Click.Play();
}
if (GlobalInputHandler.GetKeyUp(Boombox.VolumeDownKey.Value))
{
if (volumeEntry.volume >= 1)
{
volumeEntry.volume--;
((ItemDataEntry)volumeEntry).SetDirty();
}
Click.Play();
}
}
if (!Boombox.InfiniteBattery && batteryEntry.m_charge < 0f)
{
onOffEntry.on = false;
}
if (volumeEntry.GetVolume() != Music.volume)
{
Music.volume = volumeEntry.GetVolume();
}
bool on = onOffEntry.on;
if (on != Music.isPlaying || currentIndex != musicEntry.selectMusicIndex)
{
currentIndex = musicEntry.selectMusicIndex;
if (on)
{
if (checkMusic(musicEntry.selectMusicIndex))
{
Music.clip = clips[musicEntry.selectMusicIndex];
Music.time = timeEntry.currentTime;
Music.Play();
}
}
else
{
Music.Stop();
}
}
if (on)
{
if (!Boombox.InfiniteBattery)
{
BatteryEntry obj = batteryEntry;
obj.m_charge -= Time.deltaTime;
}
timeEntry.currentTime = Music.time;
}
}
public static bool checkMusic(int index)
{
return index <= clips.Count - 1;
}
public void MusicUp()
{
if (clips.Count > 0)
{
musicEntry.selectMusicIndex++;
musicEntry.selectMusicIndex %= clips.Count;
musicEntry.UpdateMusicName();
((ItemDataEntry)musicEntry).SetDirty();
timeEntry.currentTime = 0f;
((ItemDataEntry)timeEntry).SetDirty();
}
if (Boombox.UseSounds)
{
Click.Play();
}
}
public void MusicDown()
{
if (clips.Count > 0 && musicEntry.selectMusicIndex > 0)
{
musicEntry.selectMusicIndex--;
musicEntry.selectMusicIndex %= clips.Count;
musicEntry.UpdateMusicName();
((ItemDataEntry)musicEntry).SetDirty();
timeEntry.currentTime = 0f;
((ItemDataEntry)timeEntry).SetDirty();
}
if (Boombox.UseSounds)
{
Click.Play();
}
}
}
public class VolumeEntry : ItemDataEntry, IHaveUIData
{
public int volume;
public int max_volume = 10;
private string VolumeLanguage = "{0}% Volume";
public VolumeEntry()
{
Languages.TryGetLanguage("BoomboxVolume", ref VolumeLanguage);
}
public override void Deserialize(BinaryDeserializer binaryDeserializer)
{
volume = binaryDeserializer.ReadInt();
}
public override void Serialize(BinarySerializer binarySerializer)
{
binarySerializer.WriteInt(volume);
}
public float GetVolume()
{
return (float)volume / 10f;
}
public string GetString()
{
return string.Format(VolumeLanguage, volume * 10);
}
}
public class MusicEntry : ItemDataEntry, IHaveUIData
{
private string MusicName;
public int selectMusicIndex;
public override void Deserialize(BinaryDeserializer binaryDeserializer)
{
selectMusicIndex = binaryDeserializer.ReadInt();
}
public override void Serialize(BinarySerializer binarySerializer)
{
binarySerializer.WriteInt(selectMusicIndex);
}
public void UpdateMusicName()
{
MusicName = string.Empty;
if (BoomboxBehaviour.clips.Count > 0 && BoomboxBehaviour.checkMusic(selectMusicIndex))
{
MusicName = getMusicName(((Object)BoomboxBehaviour.clips[selectMusicIndex]).name);
}
}
public string GetString()
{
return MusicName;
}
private string getMusicName(string name)
{
int length;
if ((length = name.LastIndexOf('.')) != -1)
{
name = name.Substring(0, length);
}
if (name.Length > 15)
{
name = name.Substring(0, 15);
name += "...";
}
return name;
}
}
public class MusicLoadManager : MonoBehaviour
{
private static MusicLoadManager instance;
public static Coroutine StartCoroutine(IEnumerator enumerator)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)instance == (Object)null)
{
instance = new GameObject("MusicLoader").AddComponent<MusicLoadManager>();
Object.DontDestroyOnLoad((Object)(object)instance);
}
return ((MonoBehaviour)instance).StartCoroutine(enumerator);
}
public static void StartLoadMusic()
{
StartCoroutine(LoadMusic());
}
private static IEnumerator LoadMusic()
{
string path = Path.Combine(Paths.PluginPath, "Custom Songs");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string[] files = Directory.GetFiles(path);
foreach (string file in files)
{
AudioType type = GetAudioType(file);
if ((int)type <= 0)
{
continue;
}
UnityWebRequest loader = UnityWebRequestMultimedia.GetAudioClip(file, type);
DownloadHandlerAudioClip handler = (DownloadHandlerAudioClip)loader.downloadHandler;
handler.streamAudio = false;
loader.SendWebRequest();
yield return (object)new WaitUntil((Func<bool>)(() => loader.isDone));
if (loader.error == null)
{
AudioClip clip = DownloadHandlerAudioClip.GetContent(loader);
if (Object.op_Implicit((Object)(object)clip) && (int)clip.loadState == 2)
{
((Object)clip).name = Path.GetFileName(file);
BoomboxBehaviour.clips.Add(clip);
Boombox.log.LogInfo((object)("Music Loaded: " + ((Object)clip).name));
}
}
}
}
private static AudioType GetAudioType(string path)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
return (AudioType)(Path.GetExtension(path).ToLower() switch
{
".wav" => 20,
".ogg" => 14,
".mp3" => 13,
_ => 0,
});
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "WorkezyLabs.BoomboxUpgrade";
public const string PLUGIN_NAME = "BoomboxUpgrade";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}