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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using Microsoft.CodeAnalysis;
using MysteryDice;
using MysteryDice.Effects;
using MysteryDice.Patches;
using UnityEngine;
using com.github.zehsteam.TwitchChatAPI;
using com.github.zehsteam.TwitchChatAPI.Objects;
[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("DiceTwitchIntegration")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Twitch Integration for The Dice Mod")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DiceTwitchIntegration")]
[assembly: AssemblyTitle("DiceTwitchIntegration")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
static <Module>()
{
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace DiceTwitchIntegration
{
public class ConfigManager
{
public static void SetupLethalConfig()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Expected O, but got Unknown
BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(TwitchHandler.enableSubs);
IntInputFieldConfigItem val2 = new IntInputFieldConfigItem(TwitchHandler.cheerMin);
IntInputFieldConfigItem val3 = new IntInputFieldConfigItem(TwitchHandler.cheerGood);
IntInputFieldConfigItem val4 = new IntInputFieldConfigItem(TwitchHandler.cheerAwful);
IntInputFieldConfigItem val5 = new IntInputFieldConfigItem(TwitchHandler.cheerGreat);
IntInputFieldConfigItem val6 = new IntInputFieldConfigItem(TwitchHandler.cheerMixed);
IntInputFieldConfigItem val7 = new IntInputFieldConfigItem(TwitchHandler.cheerBad);
BoolCheckBoxConfigItem val8 = new BoolCheckBoxConfigItem(TwitchHandler.enableCheer);
BoolCheckBoxConfigItem val9 = new BoolCheckBoxConfigItem(TwitchHandler.enableRaid);
BoolCheckBoxConfigItem val10 = new BoolCheckBoxConfigItem(TwitchHandler.enableChatEvents);
IntInputFieldConfigItem val11 = new IntInputFieldConfigItem(TwitchHandler.chattersMin);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val5);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val7);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val8);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val9);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val10);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val11);
}
}
[BepInPlugin("Slayer6409.DiceTwitchIntegration", "Dice Twitch Integration", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "Slayer6409.DiceTwitchIntegration";
private const string modName = "Dice Twitch Integration";
private const string modVersion = "0.0.1";
public static ConfigFile BepInExConfig;
private readonly Harmony harmony = new Harmony("Slayer6409.DiceTwitchIntegration");
public static ManualLogSource CustomLogger;
public static bool LethalConfigPresent;
private void Awake()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
{
LethalConfigPresent = true;
}
BepInExConfig = new ConfigFile(Path.Combine(Paths.ConfigPath, "Emergency Dice Twitch.cfg"), true);
CustomLogger = Logger.CreateLogSource("Slayer6409.DiceTwitchIntegration");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Dice Twitch Integration has been loaded!");
TwitchHandler.doConfigStuff();
TwitchHandler.Initialize();
harmony.PatchAll();
if (LethalConfigPresent)
{
ConfigManager.SetupLethalConfig();
}
}
}
public class TwitchHandler
{
public static ConfigEntry<bool> enableSubs;
public static ConfigEntry<bool> enableCheer;
public static ConfigEntry<int> cheerMin;
public static ConfigEntry<int> cheerGood;
public static ConfigEntry<int> cheerGreat;
public static ConfigEntry<int> cheerAwful;
public static ConfigEntry<int> cheerBad;
public static ConfigEntry<int> cheerMixed;
public static ConfigEntry<bool> enableRaid;
public static ConfigEntry<bool> enableChatEvents;
public static ConfigEntry<int> chattersMin;
public static HashSet<string> evnt = new HashSet<string>();
public static bool hasRan = false;
public static void Initialize()
{
try
{
API.OnMessage += OnMessageHandler;
API.OnCheer += OnCheerHandler;
API.OnSub += OnSubHandler;
API.OnRaid += OnRaidHandler;
Application.quitting += delegate
{
API.OnMessage -= OnMessageHandler;
API.OnCheer -= OnCheerHandler;
API.OnSub -= OnSubHandler;
API.OnRaid -= OnRaidHandler;
};
}
catch (Exception arg)
{
Plugin.CustomLogger.LogError((object)$"Failed to initialize TwitchIntegrationManager. {arg}");
}
}
public static void doConfigStuff()
{
enableSubs = Plugin.BepInExConfig.Bind<bool>("Twitch", "Enable Sub", true, "If Twitch Subscription events are enabled");
enableCheer = Plugin.BepInExConfig.Bind<bool>("Twitch", "Enable Cheer", true, "If Twitch Cheer events are enabled");
enableChatEvents = Plugin.BepInExConfig.Bind<bool>("Twitch", "Enable Chat Events", true, "If Twitch Chat events are enabled ");
chattersMin = Plugin.BepInExConfig.Bind<int>("Twitch", "Chatters Min", 5, "How many Chatters are required for an event to start");
enableRaid = Plugin.BepInExConfig.Bind<bool>("Twitch", "Enable Raids", true, "If Twitch Raid events are enabled (Experimental so off by default)");
cheerMin = Plugin.BepInExConfig.Bind<int>("Twitch", "Cheer Min", 50, "How many bits required before a dice event is triggered");
cheerGreat = Plugin.BepInExConfig.Bind<int>("Twitch", "Cheer Great", 1, "The ones digit for spawning a Great Effect");
cheerGood = Plugin.BepInExConfig.Bind<int>("Twitch", "Cheer Good", 2, "The ones digit for spawning a Good Effect");
cheerMixed = Plugin.BepInExConfig.Bind<int>("Twitch", "Cheer Mixed", 3, "The ones digit for spawning a Mixed Effect");
cheerBad = Plugin.BepInExConfig.Bind<int>("Twitch", "Cheer Bad", 4, "The ones digit for spawning a Bad Effect");
cheerAwful = Plugin.BepInExConfig.Bind<int>("Twitch", "Cheer Awful", 5, "The ones digit for spawning a Awful Effect");
}
public static void OnMessageHandler(TwitchMessage message)
{
//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)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
TwitchUser user = ((TwitchMessage)(ref message)).User;
if (((TwitchUser)(ref user)).Username == "slayer6409")
{
string text = ((TwitchMessage)(ref message)).Message.ToUpper();
if (((TwitchMessage)(ref message)).Message.ToUpper().Contains("RANDOM") && ((TwitchMessage)(ref message)).Message.ToUpper().Contains("DICE"))
{
if (text.Contains("GOOD"))
{
Networker.Instance.QueueSelectTypeServerRPC((EffectType)3, "twitch");
}
else if (text.Contains("BAD"))
{
Networker.Instance.QueueSelectTypeServerRPC((EffectType)1, "twitch");
}
else if (text.Contains("AWFUL"))
{
Networker.Instance.QueueSelectTypeServerRPC((EffectType)0, "twitch");
}
else if (text.Contains("GREAT"))
{
Networker.Instance.QueueSelectTypeServerRPC((EffectType)4, "twitch");
}
else if (text.Contains("MIXED"))
{
Networker.Instance.QueueSelectTypeServerRPC((EffectType)2, "twitch");
}
else
{
Networker.Instance.QueueRandomDiceEffectServerRPC("Twitch");
}
}
else if (((TwitchMessage)(ref message)).Message.ToUpper() == "SUPERTEST")
{
Test();
}
}
if (enableChatEvents.Value && ((TwitchMessage)(ref message)).Message.ToUpper().StartsWith("!EVENT"))
{
Debug.Log((object)"test");
if (evnt.Count == 0)
{
Misc.SafeTipMessage("Dice Twitch event started", $"{chattersMin.Value - 1} more users needed to trigger an event! Do !event to join the event!");
}
HashSet<string> hashSet = evnt;
user = ((TwitchMessage)(ref message)).User;
hashSet.Add(((TwitchUser)(ref user)).Username);
if (evnt.Count >= chattersMin.Value && !hasRan)
{
((MonoBehaviour)StartOfRound.Instance).StartCoroutine(waitReset());
}
}
}
public static IEnumerator waitReset()
{
hasRan = true;
Networker.Instance.QueueRandomDiceEffectServerRPC("Twitch chatters:");
yield return (object)new WaitForSeconds(120f);
evnt = new HashSet<string>();
hasRan = false;
}
public static void Test()
{
Misc.SpawnEnemyForced(GetEnemies.Lasso, 4, true, false);
}
private static void OnSubHandler(TwitchSubEvent subEvent)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Invalid comparison between Unknown and I4
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Invalid comparison between Unknown and I4
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Invalid comparison between Unknown and I4
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Invalid comparison between Unknown and I4
if (enableSubs.Value)
{
TwitchUser user = ((TwitchEvent)subEvent).User;
string displayName = ((TwitchUser)(ref user)).DisplayName;
int num = 0;
if ((int)subEvent.Tier == 1)
{
num = 1;
}
else if ((int)subEvent.Tier == 2)
{
num = 2;
}
else if ((int)subEvent.Tier == 3)
{
num = 3;
}
if ((int)subEvent.SubType == 3)
{
num *= subEvent.GiftCount;
}
for (int i = 0; i < num; i++)
{
Networker.Instance.QueueRandomDiceEffectServerRPC("Twitch:" + displayName);
}
}
}
private static void OnCheerHandler(TwitchCheerEvent cheerEvent)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
TwitchUser user = ((TwitchEvent)cheerEvent).User;
string displayName = ((TwitchUser)(ref user)).DisplayName;
if (enableCheer.Value && cheerEvent.CheerAmount >= cheerMin.Value)
{
int num = cheerEvent.CheerAmount % 10;
if (num == cheerAwful.Value)
{
Networker.Instance.QueueSelectTypeServerRPC((EffectType)0, displayName);
}
else if (num == cheerGood.Value)
{
Networker.Instance.QueueSelectTypeServerRPC((EffectType)3, displayName);
}
else if (num == cheerGreat.Value)
{
Networker.Instance.QueueSelectTypeServerRPC((EffectType)4, displayName);
}
else if (num == cheerBad.Value)
{
Networker.Instance.QueueSelectTypeServerRPC((EffectType)1, displayName);
}
else if (num == cheerMixed.Value)
{
Networker.Instance.QueueSelectTypeServerRPC((EffectType)2, displayName);
}
else
{
Networker.Instance.QueueRandomDiceEffectServerRPC("Twitch:" + displayName);
}
}
}
private static void OnRaidHandler(TwitchRaidEvent raidEvent)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
TwitchUser user = ((TwitchEvent)raidEvent).User;
string displayName = ((TwitchUser)(ref user)).DisplayName;
if (enableRaid.Value)
{
int num = raidEvent.ViewerCount / 5;
if (num > 5)
{
num = 5;
}
for (int i = 0; i < num; i++)
{
Networker.Instance.QueueRandomDiceEffectServerRPC("Twitch:" + displayName);
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DiceTwitchIntegration";
public const string PLUGIN_NAME = "DiceTwitchIntegration";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}