Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Lets Go Gambling SFX Mod v1.2.2
letsgogambling.dll
Decompiled 2 years agousing System; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using LetsGoGambling.Modules; using LetsGoGambling.Modules.Networking; using MonoMod.Cil; using MonoMod.RuntimeDetour; using On.RoR2; using On.RoR2.UI; using R2API; using R2API.Networking; using R2API.Networking.Interfaces; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.Audio; using RoR2.UI; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("letsgogambling")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e57e6f3c3560bd1e4b7bcd6339b485b6053ac12c")] [assembly: AssemblyProduct("letsgogambling")] [assembly: AssemblyTitle("letsgogambling")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: UnverifiableCode] namespace LetsGoGambling { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.PopcornFactory.LetsGoGambling", "LetsGoGambling", "1.2.1")] public class LetsGoGamblingPlugin : BaseUnityPlugin { public const string MODUID = "com.PopcornFactory.LetsGoGambling"; public const string MODNAME = "LetsGoGambling"; public const string MODVERSION = "1.2.1"; public const string DEVELOPER_PREFIX = "POPCORN"; public static LetsGoGamblingPlugin instance; private static Hook AddBankAfterAKSoundEngineInit; public static bool hasSucceeded; public static PluginInfo PInfo { get; private set; } private void Awake() { instance = this; PInfo = ((BaseUnityPlugin)this).Info; Log.Init(((BaseUnityPlugin)this).Logger); PluginAssets.Initialize(); Config.ReadConfig(); if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { Config.SetupRiskOfOptions(); Config.OnChangeHooks(); } Hook(); SetupNetworkMessages(); } private void Start() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown AddBankAfterAKSoundEngineInit = new Hook((MethodBase)Reflection.GetMethodCached(typeof(AkSoundEngineInitialization), "InitializeSoundEngine"), Reflection.GetMethodCached(typeof(LetsGoGamblingPlugin), "UpdateAfterInit")); } private static bool UpdateAfterInit(Func<AkSoundEngineInitialization, bool> orig, AkSoundEngineInitialization self) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) bool result = orig.Invoke(self); if (AkSoundEngine.IsInitialized()) { AkSoundEngine.SetRTPCValue("Volume_Gambling_SFX", Config.volumeSlider.Value); } return result; } private void Hook() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown ShrineChanceBehavior.AddShrineStack += new hook_AddShrineStack(ShrineChanceBehavior_AddShrineStack); PingIndicator.RebuildPing += new hook_RebuildPing(PingIndicator_RebuildPing); } private void PingIndicator_RebuildPing(orig_RebuildPing orig, PingIndicator self) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); CharacterMaster component = self.pingOwner.GetComponent<CharacterMaster>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)self.pingTarget) && component.hasEffectiveAuthority && Config.playOnPing.Value && ((Object)self.pingTarget.gameObject).name.Contains("ShrineChance")) { ShrineChanceBehavior component2 = self.pingTarget.GetComponent<ShrineChanceBehavior>(); if (Config.playEvenIfExpended.Value || component2.successfulPurchaseCount < component2.maxPurchaseCount) { NetMessageExtensions.Send((INetMessage)(object)new PlaySoundNetworkRequest(((NetworkBehaviour)component.GetBody()).netId, "gambling_letsgogambling"), (NetworkDestination)1); } } } private void ShrineChanceBehavior_AddShrineStack(orig_AddShrineStack orig, ShrineChanceBehavior self, Interactor activator) { //IL_004b: 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_0082: Unknown result type (might be due to invalid IL or missing references) int successfulPurchaseCount = self.successfulPurchaseCount; orig.Invoke(self, activator); int successfulPurchaseCount2 = self.successfulPurchaseCount; if (NetworkServer.active) { if (hasSucceeded && successfulPurchaseCount != successfulPurchaseCount2) { NetMessageExtensions.Send((INetMessage)(object)new EmitSoundAtPoint(444218535u, ((Component)self).gameObject.transform.position), (NetworkDestination)1); } else if (successfulPurchaseCount != successfulPurchaseCount2) { hasSucceeded = true; NetMessageExtensions.Send((INetMessage)(object)new EmitSoundAtPoint(853644935u, ((Component)self).gameObject.transform.position), (NetworkDestination)1); } else { hasSucceeded = false; NetMessageExtensions.Send((INetMessage)(object)new EmitSoundAtPoint(51628376u, ((Component)self).gameObject.transform.position), (NetworkDestination)1); } } } private void SetupNetworkMessages() { NetworkingAPI.RegisterMessageType<EmitSoundAtPoint>(); NetworkingAPI.RegisterMessageType<PlaySoundNetworkRequest>(); } } internal static class Log { internal static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } } namespace LetsGoGambling.Modules { public static class Config { public static ConfigEntry<bool> playOnPing; public static ConfigEntry<float> volumeSlider; public static ConfigEntry<bool> playEvenIfExpended; public static void ReadConfig() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0068: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_009c: Expected O, but got Unknown volumeSlider = ((BaseUnityPlugin)LetsGoGamblingPlugin.instance).Config.Bind<float>(new ConfigDefinition("01 - Volume", "Volume Slider"), 50f, new ConfigDescription("Changes the volume on the SFX. In-game Volume SFX affects this too!", (AcceptableValueBase)null, Array.Empty<object>())); playOnPing = ((BaseUnityPlugin)LetsGoGamblingPlugin.instance).Config.Bind<bool>(new ConfigDefinition("02 - Misc", "Play on ping"), true, new ConfigDescription("Plays the \"Let's go gambling!\" SFX on ping on a shrine.", (AcceptableValueBase)null, Array.Empty<object>())); playEvenIfExpended = ((BaseUnityPlugin)LetsGoGamblingPlugin.instance).Config.Bind<bool>(new ConfigDefinition("02 - Misc", "Play even if expended"), false, new ConfigDescription("Plays the sound even if the shrine is expended of times it can be used.", (AcceptableValueBase)null, Array.Empty<object>())); } public static void SetupRiskOfOptions() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0051: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown ModSettingsManager.SetModIcon(PluginAssets.mainAssetBundle.LoadAsset<Sprite>("rooIcon")); ModSettingsManager.SetModDescription("Plays the gamblecore SFX on Shrine of Chance attempts."); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(volumeSlider, new StepSliderConfig { min = 0f, max = 100f, increment = 1f })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(playOnPing)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(playEvenIfExpended)); } public static void OnChangeHooks() { volumeSlider.SettingChanged += VolumeSlider_SettingChanged; } private static void VolumeSlider_SettingChanged(object sender, EventArgs e) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (AkSoundEngine.IsInitialized()) { AkSoundEngine.SetRTPCValue("Volume_Gambling_SFX", volumeSlider.Value); } } } internal static class PluginAssets { private const string csProjName = "letsgogambling"; internal static AssetBundle mainAssetBundle; public static string SoundBankDirectory => Path.Combine(Path.GetDirectoryName(LetsGoGamblingPlugin.PInfo.Location), ""); internal static void Initialize() { LoadAssetBundle(); LoadSoundbank(); } internal static void LoadAssetBundle() { try { if ((Object)(object)mainAssetBundle == (Object)null) { using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("letsgogambling.letsgogamblingassets")) { mainAssetBundle = AssetBundle.LoadFromStream(stream); return; } } } catch (Exception ex) { Log.Error("Failed to load assetbundle. Make sure your assetbundle name is setup correctly\n" + ex); } } internal static void LoadSoundbank() { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("letsgogambling.letsgogamblingSoundbank.bnk"); byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); SoundBanks.Add(array); } } } namespace LetsGoGambling.Modules.Networking { internal class EmitSoundAtPoint : INetMessage, ISerializableObject { private uint soundNum; private Vector3 position; public EmitSoundAtPoint() { } public EmitSoundAtPoint(uint soundNum, Vector3 position) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) this.soundNum = soundNum; this.position = position; } public void Deserialize(NetworkReader reader) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) soundNum = reader.ReadUInt32(); position = reader.ReadVector3(); } public void Serialize(NetworkWriter writer) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) writer.Write(soundNum); writer.Write(position); } public void OnReceived() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) PointSoundManager.EmitSoundLocal(AkEventIdArg.op_Implicit(soundNum), position); } } internal class PlaySoundNetworkRequest : INetMessage, ISerializableObject { private NetworkInstanceId charnetID; private uint soundNum; private string soundStr; private GameObject bodyObj; public PlaySoundNetworkRequest() { } public PlaySoundNetworkRequest(NetworkInstanceId charnetID, uint soundNum) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) this.charnetID = charnetID; this.soundNum = soundNum; soundStr = ""; } public PlaySoundNetworkRequest(NetworkInstanceId charnetID, string soundStr) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) this.charnetID = charnetID; this.soundStr = soundStr; soundNum = 0u; } public void Deserialize(NetworkReader reader) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) charnetID = reader.ReadNetworkId(); soundNum = reader.ReadUInt32(); soundStr = reader.ReadString(); } public void Serialize(NetworkWriter writer) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) writer.Write(charnetID); writer.Write(soundNum); writer.Write(soundStr); } public void OnReceived() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) GameObject val = Util.FindNetworkObject(charnetID); if (Object.op_Implicit((Object)(object)val)) { if (soundNum != 0) { AkSoundEngine.PostEvent(soundNum, val); } if (soundStr != "") { AkSoundEngine.PostEvent(soundStr, val); } } } } }