using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
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 BepInEx.Logging;
using Costura;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using TMPro;
using TwitchIntegration.Twitch;
using TwitchLib.Api;
using TwitchLib.Api.Auth;
using TwitchLib.Api.Core;
using TwitchLib.Api.Core.Enums;
using TwitchLib.Api.Core.Interfaces;
using TwitchLib.Api.Helix.Models.ChannelPoints;
using TwitchLib.Api.Helix.Models.ChannelPoints.CreateCustomReward;
using TwitchLib.Api.Helix.Models.ChannelPoints.GetCustomReward;
using TwitchLib.Api.Helix.Models.ChannelPoints.UpdateCustomReward;
using TwitchLib.Communication.Clients;
using TwitchLib.EventSub.Core.EventArgs;
using TwitchLib.EventSub.Core.EventArgs.Channel;
using TwitchLib.EventSub.Core.Models;
using TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
using TwitchLib.EventSub.Websockets;
using TwitchLib.EventSub.Websockets.Core.EventArgs;
using TwitchLib.EventSub.Websockets.Extensions;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering.Universal;
[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: AssemblyCompany("TwitchIntegration")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0")]
[assembly: AssemblyProduct("TwitchIntegration")]
[assembly: AssemblyTitle("TwitchIntegration")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
static <Module>()
{
AssemblyLoader.Attach(subscribe: true);
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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]
[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;
}
}
}
public static class Secrets
{
public static string client_id = "75gfw2e3ayd75tuuvmlm7vuuac0ug4";
public static string bot_access_token = "forlatermaybe";
public static string bot_refresh_token = "whenifigureouthowtohidethesebetter";
}
namespace TwitchIntegration
{
public class IntegrationManager
{
public class Redemption(string userName, string title)
{
public string Username = userName;
public string Title = title;
}
public static Integrations integrations = new Integrations();
public ConcurrentQueue<Redemption> RedemptionQueue = new ConcurrentQueue<Redemption>();
public static Dictionary<string, string> Redemptions;
public Dictionary<string, string> RedeemTitleIds;
public string SpawnElderTitle = "Spawn Thornback Elder";
public string StrokifyTitle = "Give Stroke";
public void CallRedeem(Redemption redemption)
{
try
{
bool flag = false;
string[] array = ((redemption.title[0] == ':') ? redemption.title.Substring(1).ToLower().Split(new char[1] { ' ' }) : Redemptions[redemption.title.ToLower()].Split(new char[1] { ' ' }));
switch (integrations.Redeems.IndexOf(array[0]))
{
case 1:
flag = integrations.BrainDamage();
break;
case 2:
if (array.Length > 1)
{
flag = integrations.Command(string.Join(" ", array.Skip(1)));
}
break;
case 3:
flag = integrations.DrainBatteries();
break;
case 4:
if (array.Length == 3)
{
flag = integrations.Feed(Convert.ToInt32(array[1]), Convert.ToInt32(array[2]));
}
break;
case 5:
if (array.Length == 2)
{
flag = ((!(array[1] == "random")) ? integrations.GiveItem(array[1]) : integrations.GiveRandomItem((array.Length < 3) ? "uwu" : array[2]));
}
break;
case 6:
flag = integrations.Light(array[1]);
break;
case 7:
if (array.Length == 4)
{
flag = integrations.Opiate(Convert.ToInt32(array[1]), Convert.ToInt32(array[2]), Convert.ToInt32(array[3]));
}
break;
case 8:
flag = ((array.Length != 1) ? integrations.PlayMusic(array[1]) : integrations.PlayMusic());
break;
case 9:
flag = integrations.RandomiseLiquids(string.Concat(array.Skip(1)));
break;
case 10:
flag = integrations.SpawnElder(array.Length >= 2);
break;
case 11:
flag = integrations.Swaphands();
break;
case 12:
flag = integrations.Teleport();
break;
case 13:
flag = integrations.Trip();
break;
case 14:
flag = integrations.Unchipped();
break;
default:
flag = integrations.CustomRedeem(array);
break;
case 0:
break;
}
if (flag)
{
Plugin.Logger.LogInfo((object)("Redeem \"" + redemption.title + "\" from " + redemption.userName + " fullfilled!"));
if (array[0] == "spawnelder" && array[1] == "fake")
{
redemption.title = SpawnElderTitle;
}
else if (array[0] == "spawnelder" && array[1] == "fake")
{
redemption.title = StrokifyTitle;
}
TILogToConsole(redemption.userName + " has redeemed " + redemption.title + "!");
}
else
{
Plugin.Logger.LogError((object)("Incorrect prompt \"" + redemption.title + "\"."));
}
}
catch (Exception ex)
{
Plugin.Logger.LogError((object)("Exception: " + ex.Message));
}
}
private void TILogToConsole(string text)
{
TimeSpan timeSpan = TimeSpan.FromSeconds(Time.realtimeSinceStartup);
ConsoleScript.instance.logs.Add("[<alpha=#55>" + timeSpan.ToString("mm\\:ss") + "<alpha=#FF>] " + text);
if (ConsoleScript.instance.logs.Count > 100)
{
ConsoleScript.instance.logs.RemoveAt(0);
}
if (ConsoleScript.instance.active)
{
((TMP_Text)ConsoleScript.instance.logText).text = string.Join("\n", ConsoleScript.instance.logs);
}
}
}
public class Integrations
{
public static Integrations integrations;
public readonly List<string> RandomItemRedeems = new List<string>(8) { "medical", "food", "water", "tool", "drug", "container", "utility", "custom" };
public static Dictionary<string, LiquidType> originalliquids = Liquids.Registry;
public List<AudioClip> clips = Resources.LoadAll<AudioClip>("Sounds/music").ToList();
public readonly List<string> lightlevels = new List<string>(3) { "none", "enough", "bright" };
public string[] GroundedEnemies = new string[3] { "guard", "grabberplant", "grabbershroom" };
public bool Stutter = false;
public static Dictionary<string, KeyCode> originalKeyBinds = new Dictionary<string, KeyCode>();
public static List<string> keyBindnames = new List<string>();
public static int primarykeycluster;
public List<string> Redeems = new List<string>(21)
{
"amputate", "braindamage", "command", "disfigure", "drainbatteries", "earthquake", "feed", "give", "heal", "light",
"opiate", "playmusic", "randomiseliquids", "spawnelder", "spawnenemy", "strokify", "swaphands", "swapKeybinds", "teleport", "trip",
"unchipped"
};
private Body Expie => PlayerCamera.main.body;
public bool GiveItem(string item)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
if (Resources.Load(item) == (Object)null)
{
Plugin.Logger.LogError((object)"Could not find item!");
return false;
}
GameObject val = Utils.Create(item, Vector2.op_Implicit(((Component)Expie).transform.position), 0f);
((MonoBehaviour)Expie).StartCoroutine(MagicLight(Vector2.op_Implicit(((Component)Expie).transform.position), Color.white, 2f));
if (val.GetComponent<Item>().Stats.wearable)
{
Expie.WearWearable(val.GetComponent<Item>());
}
else
{
for (int i = 0; i < Expie.slots.Length; i++)
{
if (Expie.slots[i].canPickUp && !Expie.HoldingItem(i) && (i != 2 || !val.GetComponent<Item>().Stats.HasTag("noautopickup")) && (!val.GetComponent<Item>().Stats.onlyHoldInHands || Expie.slots[i].isHand))
{
Expie.PickUpItem(val.GetComponent<Item>(), i, true);
break;
}
}
}
return true;
}
public bool GiveRandomItem(string category)
{
if (!RandomItemRedeems.Contains(category))
{
List<string> list = Item.GlobalItems.Keys.ToList();
return GiveItem(Utils.PickRandom<string>(list));
}
return GiveItem(Utils.PickRandom<string>(ItemLootPool.pool[category]));
}
public bool BrainDamage()
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
switch (Random.Range(0, 15))
{
case 0:
{
Expie.talker.Talk(Locale.GetCharacter("hitbycreature"), (Limb)null, false, false);
Expie.eyeScareTime = 5f;
PlayerCamera.main.threatMusicTime = 8f;
Sound.Play("spiderbite", Vector2.op_Implicit(((Component)Expie).transform.position), false, true, (Transform)null, 1f, 1f, false, false);
Body expie = Expie;
expie.venomFake += 20f;
Limb obj = Utils.PickRandom<Limb>(Expie.limbs.Where((Limb x) => !x.dismembered && !x.prostheticInfo.hasProsthetic).ToList());
obj.pain += 35f;
Body expie2 = Expie;
expie2.adrenaline += 40f;
PlayerCamera.main.SetTimeScale((SpeedType)0, false, false);
break;
}
case 1:
PlayerCamera.main.radialOpen = !PlayerCamera.main.radialOpen;
break;
case 2:
Expie.UseItemInHand();
break;
case 3:
Expie.Jump();
break;
case 4:
Expie.attackCooldown = 15f;
PlayerCamera.main.lastAttackCool = 15f;
break;
case 5:
PlayerCamera.main.ToggleWoundView(true);
break;
case 6:
PlayerCamera.main.OpenCraftScreen();
break;
case 7:
Sound.Play("sonarcharge", Vector2.op_Implicit(((Component)Expie).transform.position), true, false, (Transform)null, 1f, 1f, false, false);
PlayerCamera.main.WarnSoundCannon(Vector2.op_Implicit(((Component)Expie).transform.position) + Random.insideUnitCircle * 64f);
break;
case 8:
Sound.Play("turretsee", Vector2.op_Implicit(((Component)Expie).transform.position), true, false, (Transform)null, 1f, 1f, false, false);
Expie.talker.Talk("..!", (Limb)null, false, false);
break;
case 9:
Sound.Play("mine", Vector2.op_Implicit(((Component)Expie).transform.position), false, true, (Transform)null, 1f, 1f, false, false);
break;
case 10:
((MonoBehaviour)Expie).StartCoroutine(Expie.BrainControlReverse());
break;
case 11:
((MonoBehaviour)Expie).StartCoroutine(Expie.BrainQuake());
break;
case 12:
Expie.vomiter.Vomit();
break;
case 13:
if (Random.value < 0.75f)
{
Expie.DropItem(0);
}
if (Random.value < 0.75f)
{
Expie.DropItem(1);
}
if (Random.value < 0.75f)
{
Expie.DropItem(2);
}
Expie.talker.Talk("..?", (Limb)null, false, false);
break;
case 14:
((MonoBehaviour)Expie).StartCoroutine(BrainDamageRagdoll());
break;
case 15:
((MonoBehaviour)Expie).StartCoroutine(PlayerCamera.main.FlashBrain());
break;
}
return true;
}
private IEnumerator BrainDamageRagdoll()
{
float timer = 0f;
while (timer < 5f)
{
timer += Time.deltaTime;
Expie.brainShakeIntensity = timer * 0.05f;
yield return null;
}
Expie.brainShakeIntensity = 0f;
Expie.Ragdoll();
}
public bool CustomRedeem(string[] redeem)
{
Plugin.Logger.LogInfo((object)("Passing redeem: " + string.Join(" ", redeem[0])));
return false;
}
public bool DrainBatteries()
{
//IL_0091: 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)
foreach (Item item in Expie.GetAllItemsThorough())
{
if (Object.op_Implicit((Object)(object)item.battery))
{
item.battery.DrainCharge(0.33f);
}
if (item.Stats is BatteryInfo)
{
item.condition -= 0.33f;
}
}
Sound.Play("crystalemp", Vector2.op_Implicit(((Component)Expie).transform.position), true, false, (Transform)null, 1f, 1f, false, false);
PlayerCamera.main.shaker.Shake(200f);
return true;
}
public bool Teleport()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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_002d: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: 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_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < 1000; i++)
{
Vector2 val = Vector2.op_Implicit(((Component)Expie).transform.position) + Random.insideUnitCircle * 64f;
if (val.x < (float)(0L - (long)WorldGeneration.world.halfWidth) + 10f)
{
val.x = (float)(0L - (long)WorldGeneration.world.halfWidth) + 10f;
}
if (val.x > (float)WorldGeneration.world.halfWidth - 10f)
{
val.x = (float)WorldGeneration.world.halfWidth - 10f;
}
if (!Object.op_Implicit((Object)(object)Physics2D.OverlapPoint(val, LayerMask.GetMask(new string[1] { "Ground" }))))
{
RaycastHit2D val2 = Physics2D.Raycast(val, Vector2.down, 999f, LayerMask.GetMask(new string[1] { "Ground" }));
if (RaycastHit2D.op_Implicit(val2))
{
Sound.Play("observerlaugh", Vector2.zero, true, false, (Transform)null, 1f, 1f, true, true);
((MonoBehaviour)Expie).StartCoroutine(PlayerCamera.main.FlashBrief());
Expie.consciousness = 100f;
Expie.shock = 0f;
Expie.rb.velocity = Vector2.zero;
Expie.Stand(false);
((Component)Expie).transform.position = Vector2.op_Implicit(((RaycastHit2D)(ref val2)).point + Vector2.up * 3f);
break;
}
}
}
return true;
}
public bool Trip()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
Expie.Ragdoll();
Sound.Play("plantslip", Vector2.op_Implicit(((Component)Expie).transform.position), false, true, (Transform)null, 2f, 1f, false, false);
return true;
}
public bool SpawnElder(bool fake)
{
//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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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_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_0055: 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)
if (fake)
{
((MonoBehaviour)Expie).StartCoroutine(Rattle());
}
else
{
Object obj = Resources.Load("thornbackelder");
Vector2 val = Vector2.op_Implicit(((Component)Expie).transform.position);
Vector2 insideUnitCircle = Random.insideUnitCircle;
Object.Instantiate(obj, Vector2.op_Implicit(val + ((Vector2)(ref insideUnitCircle)).normalized * 100f), Quaternion.identity);
}
return true;
}
private IEnumerator Rattle()
{
WaitForSeconds wait = new WaitForSeconds(0.5f);
for (int i = 0; i < 20; i++)
{
Expie.adrenaline = 100f;
Expie.horrifiedLevel = 50f;
if (Expie.sleeping)
{
Expie.WakeUp();
Expie.energy = Mathf.Max(Expie.energy, 10f);
}
yield return wait;
}
}
public bool Command(string command)
{
ConsoleScript.instance.ExecuteCommand(command);
return true;
}
public bool RandomiseLiquids(string values)
{
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
Dictionary<string, LiquidType> registry = Liquids.Registry;
if (values.Contains("dangerous"))
{
foreach (string danger in Liquids.DangerList)
{
registry.Remove(danger);
}
}
LiquidType[] array = registry.Values.ToArray();
string[] array2 = registry.Keys.ToArray();
for (int num = array.Length - 1; num > 1; num--)
{
int num2 = Random.Range(0, num + 1);
LiquidType[] array3 = array;
int num3 = num2;
int num4 = num;
LiquidType val = array[num];
LiquidType val2 = array[num2];
array3[num3] = val;
array[num4] = val2;
}
bool flag = values.Contains("localename");
bool flag2 = values.Contains("color");
bool flag3 = values.Contains("valueperliter");
bool flag4 = values.Contains("ondrink");
bool flag5 = values.Contains("injectionsickness");
bool flag6 = values.Contains("qualities");
for (int i = 0; i < array.Length; i++)
{
if (flag)
{
Liquids.Registry[array2[i]].localeName = array[i].localeName;
}
if (flag2)
{
Liquids.Registry[array2[i]].color = array[i].color;
}
if (flag3)
{
Liquids.Registry[array2[i]].valuePerLiter = array[i].valuePerLiter;
}
if (flag4)
{
Liquids.Registry[array2[i]].onDrink = array[i].onDrink;
}
if (flag5)
{
Liquids.Registry[array2[i]].injectionSickness = array[i].injectionSickness;
}
if (flag6)
{
Liquids.Registry[array2[i]].qualities = array[i].qualities;
}
}
Sound.Play("sonarouchblocked", Vector2.op_Implicit(((Component)Expie).transform.position), false, true, (Transform)null, 1f, 1f, false, false);
return true;
}
public bool Swaphands()
{
Expie.handSlot = ((Expie.handSlot == 0) ? 1 : 0);
PlayerCamera.main.handSwapImage.sprite = PlayerCamera.main.handSwapSprites[Expie.handSlot];
return true;
}
public bool Opiate(int opiate, int tolerance, int antagonist)
{
Painkillers orAddComponent = ComponentHolderProtocol.GetOrAddComponent<Painkillers>((Object)(object)Expie);
orAddComponent.opiateAmount += (float)opiate;
Painkillers orAddComponent2 = ComponentHolderProtocol.GetOrAddComponent<Painkillers>((Object)(object)Expie);
orAddComponent2.opiateTolerance += (float)tolerance;
Painkillers orAddComponent3 = ComponentHolderProtocol.GetOrAddComponent<Painkillers>((Object)(object)Expie);
orAddComponent3.antagonistAmount += (float)antagonist;
return true;
}
public bool PlayMusic()
{
MusicManager.main.PlaySong(clips[Random.Range(0, clips.Count - 1)]);
return true;
}
public bool PlayMusic(string song)
{
AudioClip val = clips[0];
for (int i = 0; i < clips.Count; i++)
{
if (((Object)clips[i]).name == song)
{
val = clips[i];
}
}
MusicManager.main.PlaySong(val);
return true;
}
public bool Feed(int hunger, int thirst)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
Body expie = Expie;
expie.hunger += (float)hunger;
Body expie2 = Expie;
expie2.thirst += (float)thirst;
Sound.Play("drink", Vector2.op_Implicit(((Component)Expie).transform.position), false, true, (Transform)null, 1f, 1f, false, false);
return true;
}
public bool Light(string setting)
{
if (setting == "random")
{
WorldGeneration.runSettings["ambientlight"] = (WorldGeneration.GetRunSettingInt("ambientlight") + Random.Range(0, 2)) % 3;
}
WorldGeneration.runSettings["ambientlight"] = lightlevels.IndexOf(setting);
return true;
}
public bool Unchipped()
{
WorldGeneration.world.SetUnchipped(!WorldGeneration.unchipped);
return true;
}
public bool SpawnEnemy(string[] enemies)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
string text = enemies[Random.Range(0, enemies.Length - 1)];
if (Resources.Load(text) == (Object)null)
{
return false;
}
for (int i = 0; i < 1000; i++)
{
Vector2 val = Vector2.op_Implicit(((Component)Expie).transform.position);
Vector2 insideUnitCircle = Random.insideUnitCircle;
Vector2 val2 = val + ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(10f, 50f);
if (val2.x < (float)(0L - (long)WorldGeneration.world.halfWidth) + 10f)
{
val2.x = (float)(0L - (long)WorldGeneration.world.halfWidth) + 10f;
}
if (val2.x > (float)WorldGeneration.world.halfWidth - 10f)
{
val2.x = (float)WorldGeneration.world.halfWidth - 10f;
}
if (!Object.op_Implicit((Object)(object)Physics2D.OverlapPoint(val2, LayerMask.GetMask(new string[1] { "Ground" }))))
{
if (!GroundedEnemies.Contains(text))
{
float radius = ((text == "thornbackelder") ? 30f : 5f);
((MonoBehaviour)Expie).StartCoroutine(MagicLight(val2, Color.white, radius));
Object.Instantiate(Resources.Load(text), Vector2.op_Implicit(val2), Quaternion.identity);
break;
}
RaycastHit2D val3 = Physics2D.Raycast(val2, Vector2.down, 999f, LayerMask.GetMask(new string[1] { "Ground" }));
if (RaycastHit2D.op_Implicit(val3))
{
val2 = ((RaycastHit2D)(ref val3)).point + Vector2.up * ((text == "guard") ? 3f : 0f);
float radius2 = ((text == "guard") ? 10f : 5f);
((MonoBehaviour)Expie).StartCoroutine(MagicLight(val2, Color.white, radius2));
Object.Instantiate(Resources.Load(text), Vector2.op_Implicit(val2), Quaternion.identity);
break;
}
}
}
return true;
}
public bool Earthquake()
{
WorldGeneration.world.earthquakeDelay = 0f;
return true;
}
public bool Strokify(bool fake)
{
if (fake)
{
((MonoBehaviour)Expie).StartCoroutine(Balbutire());
}
else
{
Body expie = Expie;
expie.strokeAmount += 0.1f;
}
return true;
}
private IEnumerator Balbutire()
{
Stutter = true;
yield return (object)new WaitForSeconds(300f);
Stutter = false;
}
public bool SwapKeyBinds(bool primary)
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Expected O, but got Unknown
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: 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_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Expected O, but got Unknown
int num = Random.Range(0, keyBindnames.Count - ((!primary) ? 1 : 8));
if (primarykeycluster <= num && primary)
{
num += 7;
}
int num2 = Random.Range(0, keyBindnames.Count - (primary ? 9 : 2));
if (primarykeycluster <= num2 && primary)
{
num2 += 7;
}
if (num <= num2)
{
num2++;
}
if (originalKeyBinds.ContainsKey(keyBindnames[num]))
{
originalKeyBinds.Add(keyBindnames[num], KeyBinds.GetBind(keyBindnames[num]));
}
if (originalKeyBinds.ContainsKey(keyBindnames[num2]))
{
originalKeyBinds.Add(keyBindnames[num2], KeyBinds.GetBind(keyBindnames[num2]));
}
KeyCode bind = KeyBinds.GetBind(keyBindnames[num]);
KeyBinds.CacheBind(new SettingKeybind
{
name = keyBindnames[num],
value = KeyBinds.GetBind(keyBindnames[num2]),
apply = delegate
{
},
category = (SettingCategory)3
});
KeyBinds.CacheBind(new SettingKeybind
{
name = keyBindnames[num2],
value = bind,
apply = delegate
{
},
category = (SettingCategory)3
});
return true;
}
public bool Amputate(bool soup)
{
((MonoBehaviour)Expie).StartCoroutine(Amputatorinnator(soup));
return true;
}
public IEnumerator Amputatorinnator(bool soup)
{
List<int> targets = new List<int>();
if (Expie.limbs[5].dismembered)
{
targets.Add(5);
}
if (Expie.limbs[8].dismembered)
{
targets.Add(8);
}
if (Expie.limbs[11].dismembered)
{
targets.Add(11);
}
if (Expie.limbs[14].dismembered)
{
targets.Add(14);
}
if (targets.Count == 0)
{
targets.AddRange(new <>z__ReadOnlyArray<int>(new int[4] { 5, 8, 11, 14 }));
}
int lottery = targets[Random.Range(0, targets.Count)];
while (Expie.limbs[lottery].dismembered)
{
lottery--;
}
Expie.talker.Talk(Locale.GetCharacter("pain"), Expie.limbs[lottery], false, true);
Sound.Play("turretcount", Vector2.op_Implicit(((Component)Expie).transform.position), false, false, (Transform)null, 0.5f, 0.5f, false, true);
yield return (object)new WaitForSeconds(4f);
if (Expie.limbs[lottery].prostheticInfo.hasProsthetic)
{
((MonoBehaviour)Expie).StartCoroutine(MagicLight(Vector2.op_Implicit(((Component)Expie.limbs[lottery]).transform.position), Color.white));
}
else
{
((MonoBehaviour)Expie).StartCoroutine(MagicLight(Vector2.op_Implicit(((Component)Expie.limbs[lottery]).transform.position), Color.yellow));
if (soup)
{
Utils.Create("soup", Vector2.op_Implicit(((Component)Expie.limbs[lottery]).transform.position), 0f);
}
}
Expie.limbs[lottery].Dismember();
}
public bool Disfigure()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Sound.Play("observerlaugh", Vector2.zero, true, false, (Transform)null, 1f, 1f, true, true);
if (Expie.disfigured || (Expie.eyeGone && Random.Range(0, 2) == 0))
{
Expie.RemoveEye();
}
else if (Random.Range(0, 3) < 1)
{
Expie.RemoveEye();
}
else
{
Expie.Disfigure();
}
Expie.DoGoreSound();
return true;
}
public bool Heal()
{
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
Expie.talker.Talk(Locale.GetCharacter("magicheal"), (Limb)null, false, false);
Expie.brainHealth = Mathf.Lerp(Expie.brainHealth, 100f, 0.1f);
Limb[] limbs = Expie.limbs;
Limb[] array = limbs;
foreach (Limb val in array)
{
val.bleedAmount -= 10f;
val.muscleHealth += 25f;
val.skinHealth += 25f;
val.infectionAmount -= 40f;
val.pain = 0f;
}
Body expie = Expie;
expie.happiness += 2f;
Body expie2 = Expie;
expie2.internalBleeding *= 0.5f;
Body expie3 = Expie;
expie3.septicShock *= 0.5f;
Body expie4 = Expie;
expie4.sicknessAmount *= 0.66f;
Body expie5 = Expie;
expie5.strokeAmount *= 0.1f;
Expie.temperature = 37f;
Expie.thirst = Mathf.Lerp(Expie.thirst, 125f, 0.25f);
Expie.hunger = Mathf.Lerp(Expie.hunger, 125f, 0.25f);
Body expie6 = Expie;
expie6.radiationSickness *= 0.75f;
Expie.fibrillationProgress = 0f;
Expie.bloodVolume = Mathf.Lerp(Expie.bloodVolume, 100f, 0.1f);
Sound.Play("crystalheal", Vector2.op_Implicit(((Component)Expie).transform.position), false, true, (Transform)null, 0.5f, 1f, false, false);
return true;
}
public IEnumerator MagicLight(Vector2 pos, Color color, float radius = 5f)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
GameObject magicLight = new GameObject();
magicLight.transform.position = Vector2.op_Implicit(pos);
Light2D light = magicLight.AddComponent<Light2D>();
light.pointLightOuterRadius = radius * 0.5f;
light.pointLightOuterRadius = radius;
light.color = color;
light.intensity = 15f;
WaitForSeconds wait = new WaitForSeconds(0.05f);
while (light.intensity > 0f)
{
yield return wait;
light.intensity = light.intensity * 0.8f - 0.5f;
}
light.intensity = 0f;
Object.Destroy((Object)(object)magicLight);
}
}
[BepInPlugin("Nexivyffulf.TwitchIntegration", "TwitchIntegration", "0.3.0")]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "Nexivyffulf.TwitchIntegration";
public const string MODNAME = "TwitchIntegration";
public const string VERSION = "0.3.0";
internal static ManualLogSource Logger;
private readonly Harmony _harmony = new Harmony("Nexivyffulf.TwitchIntegration");
public static ConfigEntry<bool> AutomaticRedeemHandling;
public static ConfigEntry<bool> HideRedeemsOnQuit;
public static ConfigEntry<string> Pagepath;
public static ConfigEntry<string> Redeemspath;
public static ConfigEntry<string> OAuthToken;
private TwitchClient Client;
private OAuthLogin _login;
public static bool leftconnected;
private static bool tryingToQuit;
public static Plugin Instance { get; private set; }
public void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Integrations.integrations = new Integrations();
AutomaticRedeemHandling = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Automatically Handle Redeems:", true, "Will create and dispose of the redeems for you.");
HideRedeemsOnQuit = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Should redeems be hidden instaid of killed:", false, "Lets you keep modified reward settings, like colour, picture, max per person...");
Pagepath = ((BaseUnityPlugin)this).Config.Bind<string>("File paths", "page.html", "", "The path to page.html to not waste time looking for it.");
Redeemspath = ((BaseUnityPlugin)this).Config.Bind<string>("File paths", "redeems.txt", "", "The path to redeems.txt to not waste time looking for it.");
OAuthToken = ((BaseUnityPlugin)this).Config.Bind<string>("DO NOT SHARE THIS AT ALL!", "Generated OAuth key:", "", "This is a where a saved key would go if you pressed \"Store Login Info\" and is empty otherwise.");
if (!File.Exists(Pagepath.Value) || !File.Exists(Redeemspath.Value))
{
Logger.LogInfo((object)"Finding Companion files.");
string[] files = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, "BepInEx"), "*", SearchOption.AllDirectories);
int num = 0;
string[] array = files;
foreach (string text in array)
{
if (text.Contains("page.html"))
{
Pagepath.Value = text.Remove(0, AppContext.BaseDirectory.Length + 1);
Logger.LogInfo((object)"Found page.html!");
num++;
}
if (text.Contains("Redeems.txt"))
{
Redeemspath.Value = text.Remove(0, AppContext.BaseDirectory.Length + 1);
Logger.LogInfo((object)"Found Redeems.txt!");
num++;
}
if (num == 2)
{
break;
}
}
if (num != 2)
{
Logger.LogError((object)"Missing Companion files!");
}
}
((MonoBehaviour)this).StartCoroutine(LoadAllMusic());
Application.wantsToQuit += OnWantsToQuit;
_harmony.PatchAll();
Logger.LogInfo((object)"Plugin TwitchIntegration is loaded!");
}
private IEnumerator LoadAllMusic()
{
string[] files = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, "CasualtiesUnknown_Data", "custommusic"), "*.*");
string[] array = files;
string[] array2 = array;
foreach (string file in array2)
{
if (!file.EndsWith(".mp3") && !file.EndsWith(".wav") && !file.EndsWith(".ogg"))
{
continue;
}
string uri = "file://" + file;
UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(uri, (AudioType)0);
try
{
yield return www.SendWebRequest();
if ((int)www.result == 1)
{
AudioClip content = DownloadHandlerAudioClip.GetContent(www);
Integrations.integrations.clips.Add(content);
}
else
{
Logger.LogError((object)("Failed to load: " + file));
}
}
finally
{
((IDisposable)www)?.Dispose();
}
}
}
public void Connect()
{
if (Client != null)
{
Client?.Dispose();
Client = null;
return;
}
_login = new OAuthLogin();
_login.Success += delegate(TwitchClient client)
{
Logger.LogInfo((object)"Successfully logged into Twitch!");
Client = client;
_login = null;
Setting? obj = Settings.settings.Find((Setting s) => s.name == "stay_logged_in");
if (((SettingBool)((obj is SettingBool) ? obj : null)).value)
{
OAuthToken.Value = client.Api.Settings.AccessToken;
}
};
_login.Failure += delegate
{
Logger.LogError((object)"Failed to log into Twitch!");
Settings.settings.Find((Setting s) => s.name == "connect_to_twitch").SetValue((object)false);
SettingsMenu.instance.SelectTab(2);
_login = null;
};
}
public string TestingHook(string test)
{
if (!Client.Connected)
{
return "You must at least be connected.";
}
Client.RedemptionQueue.Enqueue(new TwitchClient.Redemption("You", ":" + test));
return "Testing Redeem: " + test;
}
public void Revert()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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_0077: Expected O, but got Unknown
Logger.LogInfo((object)"Reverting permanent redeem effects...");
foreach (KeyValuePair<string, KeyCode> originalKeyBind in Integrations.originalKeyBinds)
{
KeyBinds.CacheBind(new SettingKeybind
{
name = originalKeyBind.Key,
value = originalKeyBind.Value,
apply = delegate
{
},
category = (SettingCategory)3
});
}
Integrations.originalKeyBinds = new Dictionary<string, KeyCode>();
Integrations.integrations.Stutter = false;
Liquids.Registry = Integrations.originalliquids;
Logger.LogInfo((object)"Reverted!");
}
public async void Refresh()
{
if (!Client.Connected)
{
Logger.LogError((object)"Can't refresh redeens if not connected.");
}
await Client.KILLRedeems();
await Client.CreateRedeems();
}
private bool OnWantsToQuit()
{
Logger.LogInfo((object)"Cleaning up.");
tryingToQuit = true;
if (Client.Connected)
{
Application.wantsToQuit -= OnWantsToQuit;
return true;
}
Disconnect();
return false;
}
public async void Disconnect()
{
if (AutomaticRedeemHandling.Value && Client.Connected)
{
await Client.KILLRedeems();
}
Client = null;
if (tryingToQuit)
{
Application.Quit();
}
}
public void Update()
{
_login?.Update();
Client?.Update();
}
}
[HarmonyPatch(typeof(Settings), "DefaultSettings")]
internal class Settings_DefaultSettings_Patcher
{
private static List<Setting> Postfix(List<Setting> list)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
Plugin.Logger.LogInfo((object)"Adding Settings...");
list.Insert(0, (Setting)new SettingBool
{
name = "connect_to_twitch",
value = false,
apply = delegate
{
if (!Plugin.leftconnected)
{
Setting? obj = Settings.settings.Find((Setting s) => s.name == "connect_to_twitch");
((obj is SettingBool) ? obj : null).SetValue((object)false);
Plugin.leftconnected = true;
}
else
{
Setting? obj2 = Settings.settings.Find((Setting s) => s.name == "connect_to_twitch");
if (((SettingBool)((obj2 is SettingBool) ? obj2 : null)).value)
{
Plugin.Instance.Connect();
}
else
{
Plugin.Instance.Disconnect();
}
}
},
category = (SettingCategory)2
});
list.Insert(1, (Setting)new SettingBool
{
name = "stay_logged_in",
value = false,
apply = delegate
{
Setting? obj = Settings.settings.Find((Setting s) => s.name == "stay_logged_in");
if (!((SettingBool)((obj is SettingBool) ? obj : null)).value)
{
Plugin.OAuthToken.Value = "";
}
},
category = (SettingCategory)2
});
Plugin.Logger.LogInfo((object)"Settings Added!");
return list;
}
}
[HarmonyPatch(typeof(Settings), "LoadSettings")]
internal class Settings_LoadSettings_Patcher
{
private static void Postfix()
{
Integrations.keyBindnames = new List<string>();
foreach (Setting setting in Settings.settings)
{
if (setting is SettingKeybind)
{
Integrations.keyBindnames.Add(setting.name);
}
}
}
}
[HarmonyPatch(typeof(Locale), "LoadLanguage")]
internal class Locale_LoadLanguage_Patcher
{
[HarmonyPriority(500)]
private static void Postfix()
{
Plugin.Logger.LogInfo((object)"Adding localization...");
if (!Locale.currentLang.other.ContainsKey("gamesetconnect_to_twitch"))
{
Locale.currentLang.other.Add("gamesetconnect_to_twitch", "Connect to Twitch");
}
if (!Locale.currentLang.other.ContainsKey("gamesetconnect_to_twitchdsc"))
{
Locale.currentLang.other.Add("gamesetconnect_to_twitchdsc", "Activates the mod and will open a page to ask you do authorise \"Grey Planet Live Feed\" and/or fetch the key if you already have.");
}
if (!Locale.currentLang.other.ContainsKey("gamesetstay_logged_in"))
{
Locale.currentLang.other.Add("gamesetstay_logged_in", "Stay logged in");
}
if (!Locale.currentLang.other.ContainsKey("gamesetstay_logged_indsc"))
{
Locale.currentLang.other.Add("gamesetstay_logged_indsc", "Saves the OAuth key, so connecting to Twitch does not need to open an external page.");
}
Plugin.Logger.LogInfo((object)"Localization added!");
}
}
[HarmonyPatch(typeof(ConsoleScript), "RegisterAllCommands")]
internal class ConsoleScript_RegisterAllCommands_Patcher
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Action <>9__0_0;
public static Action <>9__0_1;
public static Action <>9__0_2;
internal void <Postfix>b__0_0(string[] args)
{
Plugin.Logger.LogInfo((object)Plugin.Instance.TestingHook(string.Join(" ", args.Skip(1))));
}
internal void <Postfix>b__0_1(string[] args)
{
Plugin.Instance.Revert();
}
internal void <Postfix>b__0_2(string[] args)
{
Plugin.Instance.Refresh();
}
}
private static void Postfix()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
Plugin.Logger.LogInfo((object)"Adding console commands.");
List<Command> commands = ConsoleScript.Commands;
object obj = <>c.<>9__0_0;
if (obj == null)
{
Action val = delegate(string[] args)
{
Plugin.Logger.LogInfo((object)Plugin.Instance.TestingHook(string.Join(" ", args.Skip(1))));
};
<>c.<>9__0_0 = val;
obj = (object)val;
}
commands.Add(new Command("TI_TestRedeem", "Test a redeem via command.", (Action)obj, (Dictionary<int, List<string>>)null, new(string, string)[1] { ("redeem", "redeem syntax") }));
List<Command> commands2 = ConsoleScript.Commands;
object obj2 = <>c.<>9__0_1;
if (obj2 == null)
{
Action val2 = delegate
{
Plugin.Instance.Revert();
};
<>c.<>9__0_1 = val2;
obj2 = (object)val2;
}
commands2.Add(new Command("TI_ResetRedeems", "Clear out permanent effects.", (Action)obj2, (Dictionary<int, List<string>>)null, Array.Empty<(string, string)>()));
List<Command> commands3 = ConsoleScript.Commands;
object obj3 = <>c.<>9__0_2;
if (obj3 == null)
{
Action val3 = delegate
{
Plugin.Instance.Refresh();
};
<>c.<>9__0_2 = val3;
obj3 = (object)val3;
}
commands3.Add(new Command("TI_RefreshRedeems", "Update the redeems on Twitch", (Action)obj3, (Dictionary<int, List<string>>)null, Array.Empty<(string, string)>()));
}
}
[HarmonyPatch(typeof(PreRunScript), "StartRun")]
[HarmonyPatch(typeof(PreRunScript), "StartTutorial")]
internal class PreRunScript_Startthing_Patcher
{
private static void Prefix()
{
Plugin.Instance.Revert();
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class Talker_brainDamaged_Patcher
{
private static void Postfix(ref bool __result)
{
__result = __result || Integrations.integrations.Stutter;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "TwitchIntegration";
public const string PLUGIN_NAME = "TwitchIntegration";
public const string PLUGIN_VERSION = "0.3.0";
}
}
namespace TwitchIntegration.Twitch
{
internal class BepInExLoggerProvider : ILoggerProvider, IDisposable
{
private class BepInExLogger : ILogger
{
private readonly ManualLogSource logSource = new ManualLogSource(categoryName);
public BepInExLogger(string categoryName)
{
}//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
public IDisposable BeginScope<TState>(TState state)
{
return null;
}
public bool IsEnabled(LogLevel logLevel)
{
return true;
}
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected I4, but got Unknown
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
if (1 == 0)
{
}
LogLevel val = (LogLevel)((int)logLevel switch
{
0 => 32,
1 => 32,
2 => 16,
3 => 4,
4 => 2,
5 => 1,
6 => 0,
_ => 0,
});
if (1 == 0)
{
}
LogLevel val2 = val;
logSource.Log(val2, (object)formatter(state, exception));
}
}
public ILogger CreateLogger(string categoryName)
{
return (ILogger)(object)new BepInExLogger(categoryName);
}
public void Dispose()
{
}
}
internal class OAuthLogin : IDisposable
{
private readonly CancellationTokenSource ctokensource;
private HttpListener server;
private Task<TwitchClient> loginTask;
private static readonly List<AuthScopes> authScopes = new List<AuthScopes>(2)
{
(AuthScopes)32,
(AuthScopes)19
};
public event Action<TwitchClient> Success;
public event Action Failure;
public OAuthLogin()
{
ctokensource = new CancellationTokenSource();
loginTask = Login(ctokensource.Token);
loginTask.ContinueWith((Func<Task<TwitchClient>, bool>)ValidateLogin);
}
public static bool ValidateLogin(Task task)
{
if (task.Exception != null)
{
foreach (Exception innerException in task.Exception.InnerExceptions)
{
Plugin.Logger.LogError((object)("Task failed!\n" + Environment.StackTrace));
Plugin.Logger.LogError((object)innerException);
}
}
return !task.IsFaulted;
}
public void Update()
{
if (loginTask != null && loginTask.IsCompleted && !loginTask.IsFaulted)
{
Close();
loginTask = null;
}
}
private void Close()
{
if (loginTask != null && loginTask.IsCompleted && !loginTask.IsFaulted && loginTask.Result != null)
{
this.Success?.Invoke(loginTask.Result);
}
else
{
this.Failure?.Invoke();
}
Dispose();
}
private IServiceCollection GetDefaultServices()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
return ServiceCollectionExtensions.AddTwitchLibEventSubWebsockets(ServiceCollectionServiceExtensions.AddSingleton<TwitchAPI>(ServiceCollectionServiceExtensions.AddSingleton<WebSocketClient>(ServiceCollectionServiceExtensions.AddSingleton<IApiSettings>(LoggingServiceCollectionExtensions.AddLogging((IServiceCollection)new ServiceCollection(), (Action<ILoggingBuilder>)delegate(ILoggingBuilder logger)
{
LoggingBuilderExtensions.AddProvider(LoggingBuilderExtensions.SetMinimumLevel(logger, (LogLevel)1), (ILoggerProvider)(object)new BepInExLoggerProvider());
}), (IApiSettings)new ApiSettings
{
Scopes = authScopes
}))));
}
private async Task<TwitchClient> Login(CancellationToken ctoken)
{
Application.runInBackground = true;
ServiceProvider services = ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(GetDefaultServices());
TwitchAPI api = ServiceProviderServiceExtensions.GetRequiredService<TwitchAPI>((IServiceProvider)services);
EventSubWebsocketClient eventSub = ServiceProviderServiceExtensions.GetRequiredService<EventSubWebsocketClient>((IServiceProvider)services);
api.Settings.ClientId = Secrets.client_id;
ValidateAccessTokenResponse validation = null;
if (Plugin.OAuthToken.Value != "")
{
api.Settings.AccessToken = Plugin.OAuthToken.Value;
Plugin.Logger.LogInfo((object)"Trying saved login info...");
validation = await api.Auth.ValidateAccessTokenAsync((string)null);
ctoken.ThrowIfCancellationRequested();
}
if (validation == null)
{
Plugin.Logger.LogInfo((object)"Opening OAuth page.");
IApiSettings settings = api.Settings;
settings.AccessToken = await GetOAuthToken(api, ctoken);
ctoken.ThrowIfCancellationRequested();
Plugin.Logger.LogInfo((object)"Validating Login info...");
validation = await api.Auth.ValidateAccessTokenAsync((string)null);
ctoken.ThrowIfCancellationRequested();
}
if (validation == null)
{
Plugin.Logger.LogInfo((object)"Failed to login.");
return null;
}
Plugin.Logger.LogInfo((object)("Logged in. UserId=" + validation.UserId + ", Login=" + validation.Login));
Plugin.Logger.LogInfo((object)"Connecting to Twitch events...");
TwitchClient client = new TwitchClient(api, eventSub, validation.UserId);
if (await client.Connect())
{
Plugin.Logger.LogInfo((object)"Connected!");
return client;
}
Plugin.Logger.LogError((object)"Failed to connect!");
return null;
}
private async Task<string> GetOAuthToken(TwitchAPI api, CancellationToken ctoken)
{
string url = api.Auth.GetAuthorizationCodeUrl("http://localhost:2296/", (IEnumerable<AuthScopes>)api.Settings.Scopes, false, (string)null, (string)null).Replace("response_type=code", "response_type=token");
HttpListener server = new HttpListener
{
Prefixes = { "http://localhost:2296/" }
};
this.server = server;
try
{
server.Start();
ctoken.ThrowIfCancellationRequested();
string accessToken = null;
Application.OpenURL(url);
byte[] response = File.ReadAllBytes(Plugin.Pagepath.Value);
while (accessToken == null)
{
ctoken.ThrowIfCancellationRequested();
int status = 400;
HttpListenerContext client = await server.GetContextAsync();
if (client.Request.HttpMethod == "POST")
{
string code = new StreamReader(client.Request.InputStream).ReadToEnd();
string[] array = code.Split(new char[1] { '&' });
string[] array2 = array;
foreach (string entry in array2)
{
string[] args = entry.Split(new char[1] { '=' });
if (args.Length == 2 && args[0] == "access_token")
{
accessToken = args[1];
break;
}
}
client.Response.ContentType = "text/plain";
string text;
if (accessToken != null)
{
ValidateAccessTokenResponse validation = await api.Auth.ValidateAccessTokenAsync(accessToken);
if (validation == null)
{
text = "Error: Couldn't validate login token!";
}
else if (string.IsNullOrEmpty((await api.Helix.Users.GetUsersAsync(new List<string>(1) { validation.UserId }, (List<string>)null, accessToken)).Users[0].BroadcasterType))
{
text = "Error: " + validation.Login + " must be a partner or affiliate to use this mod!";
}
else
{
status = 200;
text = "Success: Logged in as " + validation.Login + "!";
}
}
else
{
text = "Error: Couldn't read login token!";
}
client.Response.StatusCode = status;
client.Response.Close(Encoding.ASCII.GetBytes(text), willBlock: false);
}
else
{
string localPath = client.Request.Url.LocalPath;
if (localPath == "/" || localPath == "/code")
{
client.Response.ContentType = "text/html";
client.Response.StatusCode = 200;
client.Response.Close(response, willBlock: false);
}
else
{
client.Response.StatusCode = 404;
client.Response.Close();
}
}
}
ctoken.ThrowIfCancellationRequested();
return accessToken;
}
finally
{
server.Close();
}
}
public void Dispose()
{
server?.Close();
ctokensource.Cancel();
ctokensource.Dispose();
}
}
public class TwitchClient : IDisposable
{
public class Redemption(string userName, string title)
{
public string Username = userName;
public string Title = title;
}
public static bool RunningState = Application.runInBackground;
public bool Connected = false;
public readonly TwitchAPI Api;
private readonly string ChannelId;
private readonly EventSubWebsocketClient eventSub;
private bool disposed;
public ConcurrentQueue<Redemption> RedemptionQueue = new ConcurrentQueue<Redemption>();
private static Dictionary<string, string> Redemptions;
private Dictionary<string, string> RedeemTitleIds;
private string SpawnElderTitle = "Spawn Thornback Elder";
private string StrokifyTitle = "Give Stroke";
public TwitchClient(TwitchAPI api, EventSubWebsocketClient eventSub, string channelId)
{
Api = api;
ChannelId = channelId;
this.eventSub = eventSub;
this.eventSub.ErrorOccurred += async delegate(object? _, ErrorOccuredArgs args)
{
Plugin.Logger.LogError((object)(args.Message + "\n" + args.Exception));
};
this.eventSub.WebsocketConnected += OnConnected;
this.eventSub.WebsocketDisconnected += OnDisconnected;
this.eventSub.ChannelPointsCustomRewardRedemptionAdd += OnRedemption;
}
public Task<bool> Connect()
{
return eventSub.ConnectAsync((Uri)null);
}
private async Task OnConnected(object sender, WebsocketConnectedArgs e)
{
Connected = true;
await CreateRedeems();
await Api.Helix.EventSub.CreateEventSubSubscriptionAsync("channel.channel_points_custom_reward_redemption.add", "1", new Dictionary<string, string> { { "broadcaster_user_id", ChannelId } }, (EventSubTransportMethod)1, eventSub.SessionId, (string)null, (string)null, (string)null, (string)null, (string)null);
}
private async Task OnDisconnected(object sender, EventArgs e)
{
int delay = 1000;
while (!(await eventSub.ReconnectAsync()) && !disposed)
{
await Task.Delay(delay);
delay = Math.Min(delay * 2, 30000);
}
}
private async Task OnRedemption(object sender, ChannelPointsCustomRewardRedemptionArgs e)
{
if (Redemptions.ContainsKey(((TwitchLibEventSubEventArgs<EventSubNotificationPayload<ChannelPointsCustomRewardRedemption>>)(object)e).Payload.Event.Reward.Title.ToLower()))
{
Plugin.Logger.LogInfo((object)"NEW REDEMPION DING DING DING!!");
RedemptionQueue.Enqueue(new Redemption(((TwitchLibEventSubEventArgs<EventSubNotificationPayload<ChannelPointsCustomRewardRedemption>>)(object)e).Payload.Event.UserName, ((TwitchLibEventSubEventArgs<EventSubNotificationPayload<ChannelPointsCustomRewardRedemption>>)(object)e).Payload.Event.Reward.Title));
}
}
public void Update()
{
if (PauseHandler.paused || !RedemptionQueue.TryDequeue(out var result))
{
return;
}
Plugin.Logger.LogInfo((object)"Trying redemption...");
if (Object.op_Implicit((Object)(object)PlayerCamera.main))
{
bool flag = false;
string[] array = ((result.title[0] == ':') ? result.title.Substring(1).ToLower().Split(new char[1] { ' ' }) : Redemptions[result.title.ToLower()].Split(new char[1] { ' ' }));
switch (Integrations.integrations.Redeems.IndexOf(array[0]))
{
case 0:
flag = Integrations.integrations.Amputate(array.Length == 2);
break;
case 1:
flag = Integrations.integrations.BrainDamage();
break;
case 2:
if (array.Length > 1)
{
flag = Integrations.integrations.Command(string.Join(" ", array.Skip(1)));
}
break;
case 3:
flag = Integrations.integrations.Disfigure();
break;
case 4:
flag = Integrations.integrations.DrainBatteries();
break;
case 5:
flag = Integrations.integrations.Earthquake();
break;
case 6:
if (array.Length == 3)
{
flag = Integrations.integrations.Feed(Convert.ToInt32(array[1]), Convert.ToInt32(array[2]));
}
break;
case 7:
if (array.Length == 2)
{
flag = ((!(array[1] == "random")) ? Integrations.integrations.GiveItem(array[1]) : Integrations.integrations.GiveRandomItem((array.Length < 3) ? "uwu" : array[2]));
}
break;
case 8:
flag = Integrations.integrations.Heal();
break;
case 9:
flag = Integrations.integrations.Light(array[1]);
break;
case 10:
if (array.Length == 4)
{
flag = Integrations.integrations.Opiate(Convert.ToInt32(array[1]), Convert.ToInt32(array[2]), Convert.ToInt32(array[3]));
}
break;
case 11:
flag = ((array.Length != 1) ? Integrations.integrations.PlayMusic(array[1]) : Integrations.integrations.PlayMusic());
break;
case 12:
flag = Integrations.integrations.RandomiseLiquids(string.Concat(array.Skip(1)));
break;
case 13:
flag = Integrations.integrations.SpawnElder(array.Length == 2);
break;
case 14:
if (array.Length > 1)
{
flag = Integrations.integrations.SpawnEnemy(array.Skip(1).ToArray());
}
break;
case 15:
flag = Integrations.integrations.Strokify(array.Length == 2);
break;
case 16:
flag = Integrations.integrations.Swaphands();
break;
case 17:
flag = Integrations.integrations.SwapKeyBinds(array.Length == 2);
break;
case 18:
flag = Integrations.integrations.Teleport();
break;
case 19:
flag = Integrations.integrations.Trip();
break;
case 20:
flag = Integrations.integrations.Unchipped();
break;
default:
flag = Integrations.integrations.CustomRedeem(array);
break;
case -1:
break;
}
if (flag)
{
Plugin.Logger.LogInfo((object)("Redeem \"" + result.title + "\" from " + result.userName + " fullfilled!"));
if (array[0] == "spawnelder" && array[1] == "fake")
{
result.title = SpawnElderTitle;
}
else if (array[0] == "spawnelder" && array[1] == "fake")
{
result.title = StrokifyTitle;
}
TILogToConsole(result.userName + " has redeemed " + result.title + "!");
}
else
{
Plugin.Logger.LogError((object)("Incorrect prompt \"" + result.title + "\"."));
}
}
else
{
Plugin.Logger.LogInfo((object)"Skipping Redemption.");
}
}
public async Task CreateRedeems()
{
try
{
Plugin.Logger.LogInfo((object)"Adding Redeems to channel...");
StreamReader sr = new StreamReader(Plugin.Redeemspath.Value);
sr.ReadLine();
Redemptions = new Dictionary<string, string>();
GetCustomRewardsResponse RewardsList = await Api.Helix.ChannelPoints.GetCustomRewardAsync(ChannelId, (List<string>)null, false, (string)null);
RedeemTitleIds = new Dictionary<string, string>();
CustomReward[] data = RewardsList.Data;
foreach (CustomReward reward in data)
{
RedeemTitleIds.Add(reward.Title, reward.Id);
}
for (string line = sr.ReadLine(); line != null; line = sr.ReadLine())
{
string[] tpcdhr = line.Split(new char[1] { ':' });
if (Plugin.AutomaticRedeemHandling.Value && Connected)
{
if (tpcdhr[5] == "spawnelder")
{
SpawnElderTitle = tpcdhr[0];
}
if (tpcdhr[5] == "strokify")
{
StrokifyTitle = tpcdhr[0];
}
if (RedeemTitleIds.ContainsKey(tpcdhr[0]))
{
UpdateCustomRewardRequest requestupdate = new UpdateCustomRewardRequest
{
IsEnabled = true
};
await Api.Helix.ChannelPoints.UpdateCustomRewardAsync(ChannelId, RedeemTitleIds[tpcdhr[0]], requestupdate, (string)null);
}
else
{
CreateCustomRewardsRequest requestnew = new CreateCustomRewardsRequest
{
Title = tpcdhr[0],
Prompt = tpcdhr[1],
Cost = Convert.ToInt32(tpcdhr[2]),
IsGlobalCooldownEnabled = (Convert.ToInt32(tpcdhr[3]) > 0),
GlobalCooldownSeconds = ((Convert.ToInt32(tpcdhr[3]) > 0) ? new int?(Convert.ToInt32(tpcdhr[3])) : ((int?)null)),
BackgroundColor = tpcdhr[4],
IsEnabled = true
};
await Api.Helix.ChannelPoints.CreateCustomRewardsAsync(ChannelId, requestnew, (string)null);
}
}
Redemptions.Add(tpcdhr[0].ToLower(), tpcdhr[5]);
}
sr.Close();
Plugin.Logger.LogInfo((object)"Redeems added!");
}
catch (Exception ex)
{
Exception e = ex;
Plugin.Logger.LogError((object)("Exception: " + e.Message));
}
}
public async Task KILLRedeems()
{
if (!Connected || !Plugin.AutomaticRedeemHandling.Value)
{
return;
}
Plugin.Logger.LogInfo((object)"Murdering redeems...");
if (Plugin.HideRedeemsOnQuit.Value)
{
foreach (KeyValuePair<string, string> redeem in RedeemTitleIds)
{
if (Redemptions.ContainsKey(redeem.Key))
{
await Api.Helix.ChannelPoints.UpdateCustomRewardAsync(ChannelId, redeem.Value, new UpdateCustomRewardRequest
{
IsEnabled = false
}, (string)null);
}
}
}
else
{
foreach (KeyValuePair<string, string> redeem2 in RedeemTitleIds)
{
if (Redemptions.ContainsKey(redeem2.Key))
{
await Api.Helix.ChannelPoints.DeleteCustomRewardAsync(ChannelId, redeem2.Value, (string)null);
}
}
}
Plugin.Logger.LogInfo((object)"Redeems murdered!!");
}
private void TILogToConsole(string text)
{
TimeSpan timeSpan = TimeSpan.FromSeconds(Time.realtimeSinceStartup);
ConsoleScript.instance.logs.Add("[<alpha=#55>" + timeSpan.ToString("mm\\:ss") + "<alpha=#FF>] " + text);
if (ConsoleScript.instance.logs.Count > 100)
{
ConsoleScript.instance.logs.RemoveAt(0);
}
if (ConsoleScript.instance.active)
{
((TMP_Text)ConsoleScript.instance.logText).text = string.Join("\n", ConsoleScript.instance.logs);
}
}
public void Dispose()
{
if (disposed)
{
return;
}
disposed = true;
Application.runInBackground = RunningState;
EventSubWebsocketClient obj = eventSub;
if (obj == null)
{
return;
}
obj.DisconnectAsync().ContinueWith(delegate(Task<bool> task)
{
if (!task.Result)
{
Plugin.Logger.LogError((object)"Failed to disconnect from EventSub.");
}
});
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
int ICollection.Count => _items.Length;
bool ICollection.IsSynchronized => false;
object ICollection.SyncRoot => this;
object IList.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
bool IList.IsFixedSize => true;
bool IList.IsReadOnly => true;
int IReadOnlyCollection<T>.Count => _items.Length;
T IReadOnlyList<T>.this[int index] => _items[index];
int ICollection<T>.Count => _items.Length;
bool ICollection<T>.IsReadOnly => true;
T IList<T>.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
public <>z__ReadOnlyArray(T[] items)
{
_items = items;
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_items).GetEnumerator();
}
void ICollection.CopyTo(Array array, int index)
{
((ICollection)_items).CopyTo(array, index);
}
int IList.Add(object value)
{
throw new NotSupportedException();
}
void IList.Clear()
{
throw new NotSupportedException();
}
bool IList.Contains(object value)
{
return ((IList)_items).Contains(value);
}
int IList.IndexOf(object value)
{
return ((IList)_items).IndexOf(value);
}
void IList.Insert(int index, object value)
{
throw new NotSupportedException();
}
void IList.Remove(object value)
{
throw new NotSupportedException();
}
void IList.RemoveAt(int index)
{
throw new NotSupportedException();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return ((IEnumerable<T>)_items).GetEnumerator();
}
void ICollection<T>.Add(T item)
{
throw new NotSupportedException();
}
void ICollection<T>.Clear()
{
throw new NotSupportedException();
}
bool ICollection<T>.Contains(T item)
{
return ((ICollection<T>)_items).Contains(item);
}
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
((ICollection<T>)_items).CopyTo(array, arrayIndex);
}
bool ICollection<T>.Remove(T item)
{
throw new NotSupportedException();
}
int IList<T>.IndexOf(T item)
{
return ((IList<T>)_items).IndexOf(item);
}
void IList<T>.Insert(int index, T item)
{
throw new NotSupportedException();
}
void IList<T>.RemoveAt(int index)
{
throw new NotSupportedException();
}
}
namespace Costura
{
[CompilerGenerated]
internal static class AssemblyLoader
{
private static object nullCacheLock = new object();
private static Dictionary<string, bool> nullCache = new Dictionary<string, bool>();
private static Dictionary<string, string> assemblyNames = new Dictionary<string, string>();
private static Dictionary<string, string> symbolNames = new Dictionary<string, string>();
private static int isAttached;
private static string CultureToString(CultureInfo culture)
{
if (culture == null)
{
return string.Empty;
}
return culture.Name;
}
private static Assembly ReadExistingAssembly(AssemblyName name)
{
AppDomain currentDomain = AppDomain.CurrentDomain;
Assembly[] assemblies = currentDomain.GetAssemblies();
Assembly[] array = assemblies;
foreach (Assembly assembly in array)
{
AssemblyName name2 = assembly.GetName();
if (string.Equals(name2.Name, name.Name, StringComparison.InvariantCultureIgnoreCase) && string.Equals(CultureToString(name2.CultureInfo), CultureToString(name.CultureInfo), StringComparison.InvariantCultureIgnoreCase))
{
return assembly;
}
}
return null;
}
private static string GetAssemblyResourceName(AssemblyName requestedAssemblyName)
{
string text = requestedAssemblyName.Name.ToLowerInvariant();
if (requestedAssemblyName.CultureInfo != null && !string.IsNullOrEmpty(requestedAssemblyName.CultureInfo.Name))
{
text = (CultureToString(requestedAssemblyName.CultureInfo) + "." + text).ToLowerInvariant();
}
return text;
}
private static void CopyTo(Stream source, Stream destination)
{
byte[] array = new byte[81920];
int count;
while ((count = source.Read(array, 0, array.Length)) != 0)
{
destination.Write(array, 0, count);
}
}
private static Stream LoadStream(string fullName)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
if (fullName.EndsWith(".compressed"))
{
using (Stream stream = executingAssembly.GetManifestResourceStream(fullName))
{
using DeflateStream source = new DeflateStream(stream, CompressionMode.Decompress);
MemoryStream memoryStream = new MemoryStream();
CopyTo(source, memoryStream);
memoryStream.Position = 0L;
return memoryStream;
}
}
return executingAssembly.GetManifestResourceStream(fullName);
}
private static Stream LoadStream(Dictionary<string, string> resourceNames, string name)
{
if (resourceNames.TryGetValue(name, out var value))
{
return LoadStream(value);
}
return null;
}
private static byte[] ReadStream(Stream stream)
{
using MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
private static Assembly ReadFromEmbeddedResources(Dictionary<string, string> assemblyNames, Dictionary<string, string> symbolNames, AssemblyName requestedAssemblyName)
{
string assemblyResourceName = GetAssemblyResourceName(requestedAssemblyName);
byte[] rawAssembly;
using (Stream stream = LoadStream(assemblyNames, assemblyResourceName))
{
if (stream == null)
{
return null;
}
rawAssembly = ReadStream(stream);
}
using (Stream stream2 = LoadStream(symbolNames, assemblyResourceName))
{
if (stream2 != null)
{
byte[] rawSymbolStore = ReadStream(stream2);
return Assembly.Load(rawAssembly, rawSymbolStore);
}
}
return Assembly.Load(rawAssembly);
}
public static Assembly ResolveAssembly(object sender, ResolveEventArgs e)
{
string name = e.Name;
AssemblyName assemblyName = new AssemblyName(name);
lock (nullCacheLock)
{
if (nullCache.ContainsKey(name))
{
return null;
}
}
Assembly assembly = ReadExistingAssembly(assemblyName);
if ((object)assembly != null)
{
return assembly;
}
assembly = ReadFromEmbeddedResources(assemblyNames, symbolNames, assemblyName);
if ((object)assembly == null)
{
lock (nullCacheLock)
{
nullCache[name] = true;
}
if ((assemblyName.Flags & AssemblyNameFlags.Retargetable) != AssemblyNameFlags.None)
{
assembly = Assembly.Load(assemblyName);
}
}
return assembly;
}
static AssemblyLoader()
{
assemblyNames.Add("asmresolver", "costura.asmresolver.dll.compressed");
assemblyNames.Add("asmresolver.dotnet", "costura.asmresolver.dotnet.dll.compressed");
assemblyNames.Add("asmresolver.pe", "costura.asmresolver.pe.dll.compressed");
assemblyNames.Add("asmresolver.pe.file", "costura.asmresolver.pe.file.dll.compressed");
assemblyNames.Add("bepinex.assemblypublicizer", "costura.bepinex.assemblypublicizer.dll.compressed");
assemblyNames.Add("bepinex.assemblypublicizer.msbuild", "costura.bepinex.assemblypublicizer.msbuild.dll.compressed");
assemblyNames.Add("microsoft.bcl.asyncinterfaces", "costura.microsoft.bcl.asyncinterfaces.dll.compressed");
assemblyNames.Add("microsoft.extensions.dependencyinjection.abstractions", "costura.microsoft.extensions.dependencyinjection.abstractions.dll.compressed");
assemblyNames.Add("microsoft.extensions.dependencyinjection", "costura.microsoft.extensions.dependencyinjection.dll.compressed");
assemblyNames.Add("microsoft.extensions.logging.abstractions", "costura.microsoft.extensions.logging.abstractions.dll.compressed");
assemblyNames.Add("microsoft.extensions.logging", "costura.microsoft.extensions.logging.dll.compressed");
assemblyNames.Add("microsoft.extensions.options", "costura.microsoft.extensions.options.dll.compressed");
assemblyNames.Add("microsoft.extensions.primitives", "costura.microsoft.extensions.primitives.dll.compressed");
assemblyNames.Add("system.buffers", "costura.system.buffers.dll.compressed");
assemblyNames.Add("system.diagnostics.diagnosticsource", "costura.system.diagnostics.diagnosticsource.dll.compressed");
assemblyNames.Add("system.io.pipelines", "costura.system.io.pipelines.dll.compressed");
assemblyNames.Add("system.memory", "costura.system.memory.dll.compressed");
assemblyNames.Add("system.numerics.vectors", "costura.system.numerics.vectors.dll.compressed");
assemblyNames.Add("system.runtime.compilerservices.unsafe", "costura.system.runtime.compilerservices.unsafe.dll.compressed");
assemblyNames.Add("system.text.encodings.web", "costura.system.text.encodings.web.dll.compressed");
assemblyNames.Add("system.text.json", "costura.system.text.json.dll.compressed");
assemblyNames.Add("system.threading.tasks.extensions", "costura.system.threading.tasks.extensions.dll.compressed");
assemblyNames.Add("system.valuetuple", "costura.system.valuetuple.dll.compressed");
assemblyNames.Add("twitchlib.api.core", "costura.twitchlib.api.core.dll.compressed");
assemblyNames.Add("twitchlib.api.core.enums", "costura.twitchlib.api.core.enums.dll.compressed");
assemblyNames.Add("twitchlib.api.core.interfaces", "costura.twitchlib.api.core.interfaces.dll.compressed");
assemblyNames.Add("twitchlib.api.core.models", "costura.twitchlib.api.core.models.dll.compressed");
assemblyNames.Add("twitchlib.api", "costura.twitchlib.api.dll.compressed");
assemblyNames.Add("twitchlib.api.helix", "costura.twitchlib.api.helix.dll.compressed");
assemblyNames.Add("twitchlib.api.helix.models", "costura.twitchlib.api.helix.models.dll.compressed");
assemblyNames.Add("twitchlib.client", "costura.twitchlib.client.dll.compressed");
assemblyNames.Add("twitchlib.client.enums", "costura.twitchlib.client.enums.dll.compressed");
assemblyNames.Add("twitchlib.client.models", "costura.twitchlib.client.models.dll.compressed");
assemblyNames.Add("twitchlib.communication", "costura.twitchlib.communication.dll.compressed");
assemblyNames.Add("twitchlib.eventsub.core", "costura.twitchlib.eventsub.core.dll.compressed");
assemblyNames.Add("twitchlib.eventsub.websockets", "costura.twitchlib.eventsub.websockets.dll.compressed");
}
public static void Attach(bool subscribe)
{
if (Interlocked.Exchange(ref isAttached, 1) == 1 || !subscribe)
{
return;
}
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs e)
{
string name = e.Name;
AssemblyName assemblyName = new AssemblyName(name);
lock (nullCacheLock)
{
if (nullCache.ContainsKey(name))
{
return (Assembly)null;
}
}
Assembly assembly = ReadExistingAssembly(assemblyName);
if ((object)assembly != null)
{
return assembly;
}
assembly = ReadFromEmbeddedResources(assemblyNames, symbolNames, assemblyName);
if ((object)assembly == null)
{
lock (nullCacheLock)
{
nullCache[name] = true;
}
if ((assemblyName.Flags & AssemblyNameFlags.Retargetable) != AssemblyNameFlags.None)
{
assembly = Assembly.Load(assemblyName);
}
}
return assembly;
};
}
}
}
internal class TwitchIntegration_ProcessedByFody
{
internal const string FodyVersion = "6.9.3.0";
internal const string Costura = "6.2.0";
}