Decompiled source of RoR2StreamCompanion v2.3.0

StreamCompanion.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.Captain.Weapon;
using EntityStates.Toolbot;
using On.EntityStates.Captain.Weapon;
using On.EntityStates.Toolbot;
using On.RoR2;
using RoR2;
using UnityEngine;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("StreamCompanion")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+88aa30031ab1684e17f5c10ab374298b929e10a4")]
[assembly: AssemblyProduct("StreamCompanion")]
[assembly: AssemblyTitle("StreamCompanion")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace StreamCompanion;

internal static class Log
{
	private 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);
	}
}
[BepInPlugin("TaranDev.RoR2StreamCompanion", "RoR2StreamCompanion", "2.2.0")]
public class StreamCompanion : BaseUnityPlugin
{
	public const string PluginGUID = "TaranDev.RoR2StreamCompanion";

	public const string PluginAuthor = "TaranDev";

	public const string PluginName = "RoR2StreamCompanion";

	public const string PluginVersion = "2.2.0";

	public const string url = "https://ror2-sc-api.herokuapp.com/";

	public static string inventoryItemsString = "";

	public static string equipmentString = "";

	public static string skillsString = "";

	public static string bodyColourString = "";

	public static List<string> VanillaItems = new List<string>
	{
		"ITEM_BOSSDAMAGEBONUS_NAME", "ITEM_SECONDARYSKILLMAGAZINE_NAME", "ITEM_FLATHEALTH_NAME", "ITEM_FIREWORK_NAME", "ITEM_MUSHROOM_NAME", "ITEM_HEALWHILESAFE_NAME", "ITEM_CROWBAR_NAME", "ITEM_FRAGILEDAMAGEBONUS_NAME", "ITEM_SPRINTBONUS_NAME", "ITEM_NEARBYDAMAGEBONUS_NAME",
		"ITEM_IGNITEONKILL_NAME", "ITEM_SCRAPWHITE_NAME", "ITEM_CRITGLASSES_NAME", "ITEM_MEDKIT_NAME", "ITEM_ATTACKSPEEDANDMOVESPEED_NAME", "ITEM_TOOTH_NAME", "ITEM_OUTOFCOMBATARMOR_NAME", "ITEM_HOOF_NAME", "ITEM_PERSONALSHIELD_NAME", "ITEM_HEALINGPOTION_NAME",
		"ITEM_REPULSIONARMORPLATE_NAME", "ITEM_GOLDONHURT_NAME", "ITEM_TREASURECACHE_NAME", "ITEM_SYRINGE_NAME", "ITEM_STICKYBOMB_NAME", "ITEM_STUNCHANCEONHIT_NAME", "ITEM_BARRIERONKILL_NAME", "ITEM_BEAR_NAME", "ITEM_BLEEDONHIT_NAME", "ITEM_WARDONLEVEL_NAME",
		"ITEM_MISSILE_NAME", "ITEM_BANDOLIER_NAME", "ITEM_WARCRYONMULTIKILL_NAME", "ITEM_SLOWONHIT_NAME", "ITEM_DEATHMARK_NAME", "ITEM_EQUIPMENTMAGAZINE_NAME", "ITEM_BONUSGOLDPACKONKILL_NAME", "ITEM_HEALONCRIT_NAME", "ITEM_FEATHER_NAME", "ITEM_MOVESPEEDONKILL_NAME",
		"ITEM_STRENGTHENBURN_NAME", "ITEM_INFUSION_NAME", "ITEM_SCRAPGREEN_NAME", "ITEM_FIRERING_NAME", "ITEM_SEED_NAME", "ITEM_TPHEALINGNOVA_NAME", "ITEM_EXECUTELOWHEALTHELITE_NAME", "ITEM_PHASING_NAME", "ITEM_ATTACKSPEEDONCRIT_NAME", "ITEM_THORNS_NAME",
		"ITEM_SPRINTOUTOFCOMBAT_NAME", "ITEM_REGENERATINGSCRAP_NAME", "ITEM_SPRINTARMOR_NAME", "ITEM_ICERING_NAME", "ITEM_FREECHEST_NAME", "ITEM_PRIMARYSKILLSHURIKEN_NAME", "ITEM_SQUIDTURRET_NAME", "ITEM_CHAINLIGHTNING_NAME", "ITEM_ENERGIZEDONEQUIPMENTUSE_NAME", "ITEM_JUMPBOOST_NAME",
		"ITEM_EXPLODEONDEATH_NAME", "ITEM_CLOVER_NAME", "ITEM_BARRIERONOVERHEAL_NAME", "ITEM_ALIENHEAD_NAME", "ITEM_IMMUNETODEBUFF_NAME", "ITEM_RANDOMEQUIPMENTTRIGGER_NAME", "ITEM_KILLELITEFRENZY_NAME", "ITEM_BEHEMOTH_NAME", "ITEM_DAGGER_NAME", "ITEM_CAPTAINDEFENSEMATRIX_NAME",
		"ITEM_EXTRALIFE_NAME", "ITEM_ICICLE_NAME", "ITEM_FALLBOOTS_NAME", "ITEM_GHOSTONKILL_NAME", "ITEM_UTILITYSKILLMAGAZINE_NAME", "ITEM_INTERSTELLARDESKPLANT_NAME", "ITEM_SCRAPRED_NAME", "ITEM_CRITDAMAGE_NAME", "ITEM_NOVAONHEAL_NAME", "ITEM_MOREMISSILE_NAME",
		"ITEM_INCREASEHEALING_NAME", "ITEM_LASERTURBINE_NAME", "ITEM_BOUNCENEARBY_NAME", "ITEM_ARMORREDUCTIONONHIT_NAME", "ITEM_TALISMAN_NAME", "ITEM_DRONEWEAPONS_NAME", "ITEM_PERMANENTDEBUFFONHIT_NAME", "ITEM_SHOCKNEARBY_NAME", "ITEM_HEADHUNTER_NAME", "ITEM_ARTIFACTKEY_NAME",
		"ITEM_LIGHTNINGSTRIKEONHIT_NAME", "ITEM_MINORCONSTRUCTONKILL_NAME", "ITEM_ROBOBALLBUDDY_NAME", "ITEM_NOVAONLOWHEALTH_NAME", "ITEM_TITANGOLDDURINGTP_NAME", "ITEM_SHINYPEARL_NAME", "ITEM_SCRAPYELLOW_NAME", "ITEM_SPRINTWISP_NAME", "ITEM_SIPHONONLOWHEALTH_NAME", "ITEM_FIREBALLSONHIT_NAME",
		"ITEM_PEARL_NAME", "ITEM_PARENTEGG_NAME", "ITEM_BEETLEGLAND_NAME", "ITEM_BLEEDONHITANDEXPLODE_NAME", "ITEM_KNURL_NAME", "ITEM_LUNARTRINKET_NAME", "ITEM_GOLDONHIT_NAME", "ITEM_REPEATHEAL_NAME", "ITEM_MONSTERSONSHRINEUSE_NAME", "ITEM_LUNARSUN_NAME",
		"ITEM_LUNARSPECIALREPLACEMENT_NAME", "ITEM_RANDOMLYLUNAR_NAME", "ITEM_FOCUSEDCONVERGENCE_NAME", "ITEM_AUTOCASTEQUIPMENT_NAME", "ITEM_LUNARSECONDARYREPLACEMENT_NAME", "ITEM_HALFATTACKSPEEDHALFCOOLDOWNS_NAME", "ITEM_RANDOMDAMAGEZONE_NAME", "ITEM_LUNARBADLUCK_NAME", "ITEM_LUNARDAGGER_NAME", "ITEM_HALFSPEEDDOUBLEHEALTH_NAME",
		"ITEM_LUNARUTILITYREPLACEMENT_NAME", "ITEM_SHIELDONLY_NAME", "ITEM_LUNARPRIMARYREPLACEMENT_NAME", "ITEM_CLOVERVOID_NAME", "ITEM_TREASURECACHEVOID_NAME", "ITEM_CRITGLASSESVOID_NAME", "ITEM_EQUIPMENTMAGAZINEVOID_NAME", "ITEM_BLEEDONHITVOID_NAME", "ITEM_VOIDMEGACRABITEM_NAME", "ITEM_MISSILEVOID_NAME",
		"ITEM_EXTRALIFEVOID_NAME", "ITEM_CHAINLIGHTNINGVOID_NAME", "ITEM_BEARVOID_NAME", "ITEM_ELEMENTALRINGVOID_NAME", "ITEM_SLOWONHITVOID_NAME", "ITEM_EXPLODEONDEATHVOID_NAME", "ITEM_MUSHROOMVOID_NAME", "ITEM_FRAGILEDAMAGEBONUSCONSUMED_NAME", "ITEM_EXTRALIFECONSUMED_NAME", "ITEM_HEALINGPOTIONCONSUMED_NAME",
		"ITEM_EXTRALIFEVOIDCONSUMED_NAME", "ITEM_REGENERATINGSCRAPCONSUMED_NAME", "ITEM_TONICAFFLICTION_NAME"
	};

	public static List<string> CaptainBeacons = new List<string> { "CAPTAIN_SUPPLY_HEAL_NAME", "CAPTAIN_SUPPLY_DEFENSE_NAME", "CAPTAIN_SUPPLY_HACKING_NAME", "CAPTAIN_SUPPLY_EQUIPMENT_RESTOCK_NAME", "CAPTAIN_SUPPLY_SHOCKING_NAME" };

	public static List<string> MULTPrimarySkills = new List<string> { "TOOLBOT_PRIMARY_NAME", "TOOLBOT_PRIMARY_ALT1_NAME", "TOOLBOT_PRIMARY_ALT2_NAME", "TOOLBOT_PRIMARY_ALT3_NAME" };

	public static bool isWaitingForUpdate = false;

	public static ConfigEntry<string> TwitchNameConfigEntry { get; set; }

	public static ConfigEntry<string> SecretKeyConfigEntry { get; set; }

	public static ConfigEntry<double> DelayConfigEntry { get; set; }

	public void Awake()
	{
		Log.Init(((BaseUnityPlugin)this).Logger);
		TwitchNameConfigEntry = ((BaseUnityPlugin)this).Config.Bind<string>("RoR2 Stream Companion", "Twitch Name", "exampleTwitchName", "The name of your channel on Twitch");
		SecretKeyConfigEntry = ((BaseUnityPlugin)this).Config.Bind<string>("RoR2 Stream Companion", "Secret Key", "123MySecretKey", "The secret key you generated in the extension config page on Twitch");
		DelayConfigEntry = ((BaseUnityPlugin)this).Config.Bind<double>("RoR2 Stream Companion", "Delay", 2.0, "The delay of your twitch stream in seconds");
		SendItemsUpdate(inventoryItemsString, equipmentString, skillsString, bodyColourString);
	}

	private void OnEnable()
	{
		//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
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		Inventory.HandleInventoryChanged += new hook_HandleInventoryChanged(OnInventoryChanged);
		GameOverController.Awake += new hook_Awake(OnGameOver);
		CharacterMaster.OnBodyStart += new hook_OnBodyStart(OnBodyLoaded);
		CallSupplyDropBase.OnEnter += new hook_OnEnter(OnEnterSupplyDrop);
		ToolbotStanceSwap.OnEnter += new hook_OnEnter(OnEnterRetool);
		ToolbotDualWield.OnEnter += new hook_OnEnter(OnEnterPowerMode);
		ToolbotDualWield.OnExit += new hook_OnExit(OnExitPowerMode);
	}

	private void OnDisable()
	{
		//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
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		Inventory.HandleInventoryChanged -= new hook_HandleInventoryChanged(OnInventoryChanged);
		GameOverController.Awake -= new hook_Awake(OnGameOver);
		CharacterMaster.OnBodyStart -= new hook_OnBodyStart(OnBodyLoaded);
		CallSupplyDropBase.OnEnter -= new hook_OnEnter(OnEnterSupplyDrop);
		ToolbotStanceSwap.OnEnter -= new hook_OnEnter(OnEnterRetool);
		ToolbotDualWield.OnEnter -= new hook_OnEnter(OnEnterPowerMode);
		ToolbotDualWield.OnExit -= new hook_OnExit(OnExitPowerMode);
	}

	private static void OnEnterSupplyDrop(orig_OnEnter orig, CallSupplyDropBase self)
	{
		orig.Invoke(self);
		Task.Delay(500).ContinueWith(delegate
		{
			checkSkillString();
		});
	}

	private static void OnEnterRetool(orig_OnEnter orig, ToolbotStanceSwap self)
	{
		orig.Invoke(self);
		checkSkillString();
	}

	private static void OnEnterPowerMode(orig_OnEnter orig, ToolbotDualWield self)
	{
		orig.Invoke(self);
		checkSkillString();
	}

	private static void OnExitPowerMode(orig_OnExit orig, ToolbotDualWield self)
	{
		orig.Invoke(self);
		checkSkillString();
	}

	public static void OnBodyLoaded(orig_OnBodyStart orig, CharacterMaster self, CharacterBody body)
	{
		orig.Invoke(self, body);
		Task.Delay(1500).ContinueWith(delegate
		{
			checkSkillString();
		});
	}

	private static void checkSkillString()
	{
		if (PlayerCharacterMasterController.instances.Count > 0 && Object.op_Implicit((Object)(object)PlayerCharacterMasterController.instances[0].master.GetBody()))
		{
			string skillString = GetSkillString(inventoryItemsString);
			if (!skillString.Equals(skillsString))
			{
				skillsString = skillString;
				bodyColourString = GetColourString();
				WaitThenSendItemsUpdate(inventoryItemsString, equipmentString, skillsString, bodyColourString);
			}
		}
	}

	private static void OnGameOver(orig_Awake orig, GameOverController self)
	{
		inventoryItemsString = "";
		equipmentString = "";
		skillsString = "";
		bodyColourString = "";
		WaitThenSendItemsUpdate(inventoryItemsString, equipmentString, skillsString, bodyColourString);
		orig.Invoke(self);
	}

	private static void OnInventoryChanged(orig_HandleInventoryChanged orig, Inventory self)
	{
		//IL_0064: 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_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: 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_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: 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)
		orig.Invoke(self);
		if (PlayerCharacterMasterController.instances.Count <= 0 || !((object)self).Equals((object?)PlayerCharacterMasterController.instances[0].master.inventory) || Object.op_Implicit((Object)(object)GameOverController.instance))
		{
			return;
		}
		List<ItemIndex> itemAcquisitionOrder = self.itemAcquisitionOrder;
		string text = "";
		for (int i = 0; i < itemAcquisitionOrder.Count; i++)
		{
			ItemDef itemDef = ItemCatalog.GetItemDef(itemAcquisitionOrder[i]);
			if (!itemDef.hidden)
			{
				ItemTier tier;
				if (VanillaItems.Contains(itemDef.nameToken) && Language.currentLanguage == Language.english)
				{
					string[] obj = new string[5] { text, itemDef.nameToken, "[", null, null };
					tier = itemDef.tier;
					obj[3] = ((object)(ItemTier)(ref tier)).ToString();
					obj[4] = "];";
					text = string.Concat(obj);
				}
				else
				{
					string[] obj2 = new string[7]
					{
						text,
						Language.GetString(itemDef.nameToken),
						"{",
						Language.GetString(itemDef.descriptionToken),
						"}[",
						null,
						null
					};
					tier = itemDef.tier;
					obj2[5] = ((object)(ItemTier)(ref tier)).ToString();
					obj2[6] = "];";
					text = string.Concat(obj2);
				}
			}
		}
		text = text.Replace("\n", "");
		text = text.Replace("\r", "");
		EquipmentIndex currentEquipmentIndex = self.currentEquipmentIndex;
		EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(currentEquipmentIndex);
		string text2 = "";
		if (Object.op_Implicit((Object)(object)equipmentDef))
		{
			text2 = GetEquipmentString(equipmentDef);
			EquipmentIndex alternateEquipmentIndex = self.alternateEquipmentIndex;
			EquipmentDef equipmentDef2 = EquipmentCatalog.GetEquipmentDef(alternateEquipmentIndex);
			string text3 = "";
			if (Object.op_Implicit((Object)(object)equipmentDef2))
			{
				text3 = GetEquipmentString(equipmentDef2);
			}
			text2 += text3;
		}
		text2 = text2.Replace("\n", "");
		text2 = text2.Replace("\r", "");
		string text4 = "";
		string text5 = "";
		if (Object.op_Implicit((Object)(object)PlayerCharacterMasterController.instances[0].master.GetBody()))
		{
			text4 = GetSkillString(text);
			text5 = GetColourString();
		}
		if (text.Equals(inventoryItemsString) && text2.Equals(equipmentString) && text4.Equals(skillsString))
		{
			return;
		}
		inventoryItemsString = text;
		equipmentString = text2;
		skillsString = text4;
		bodyColourString = text5;
		if (Object.op_Implicit((Object)(object)PhaseCounter.instance) && PhaseCounter.instance.phase == 4)
		{
			if (!isWaitingForUpdate)
			{
				isWaitingForUpdate = true;
				WaitThenSendItemsUpdatePhase4();
			}
		}
		else
		{
			WaitThenSendItemsUpdate(inventoryItemsString, equipmentString, skillsString, bodyColourString);
		}
	}

	private static string GetEquipmentString(EquipmentDef equipmentInfo)
	{
		string @string = Language.GetString(equipmentInfo.descriptionToken);
		if (@string == "")
		{
			@string = Language.GetString(equipmentInfo.pickupToken);
		}
		return Language.GetString(equipmentInfo.nameToken) + "{" + @string + "}[" + equipmentInfo.isLunar + "];";
	}

	private static string GetSkillString(string InventoryItemsString)
	{
		GenericSkill primary = PlayerCharacterMasterController.instances[0].master.GetBody().skillLocator.primary;
		GenericSkill secondary = PlayerCharacterMasterController.instances[0].master.GetBody().skillLocator.secondary;
		GenericSkill utility = PlayerCharacterMasterController.instances[0].master.GetBody().skillLocator.utility;
		GenericSkill special = PlayerCharacterMasterController.instances[0].master.GetBody().skillLocator.special;
		if (!Object.op_Implicit((Object)(object)primary) || !Object.op_Implicit((Object)(object)secondary) || !Object.op_Implicit((Object)(object)utility) || !Object.op_Implicit((Object)(object)special))
		{
			return skillsString;
		}
		string text = "";
		string text2 = (InventoryItemsString.Contains("ITEM_LUNARPRIMARYREPLACEMENT_NAME") ? (Language.GetString("SKILL_LUNAR_PRIMARY_REPLACEMENT_NAME") + "{" + Language.GetString("SKILL_LUNAR_PRIMARY_REPLACEMENT_DESCRIPTION") + "};") : ((!CaptainBeacons.Contains(primary.baseSkill.GetCurrentNameToken(primary))) ? (Language.GetString(primary.baseSkill.GetCurrentNameToken(primary)) + "{" + Language.GetString(primary.baseSkill.GetCurrentDescriptionToken(primary)) + "};") : (Language.GetString("CAPTAIN_PRIMARY_NAME") + "{" + Language.GetString("CAPTAIN_PRIMARY_DESCRIPTION") + "};")));
		text += text2;
		string text3 = (MULTPrimarySkills.Contains(secondary.skillDef.GetCurrentNameToken(secondary)) ? (Language.GetString(secondary.skillDef.GetCurrentNameToken(secondary)) + "{" + Language.GetString(secondary.skillDef.GetCurrentDescriptionToken(secondary)) + "};") : (InventoryItemsString.Contains("ITEM_LUNARSECONDARYREPLACEMENT_NAME") ? (Language.GetString("SKILL_LUNAR_SECONDARY_REPLACEMENT_NAME") + "{" + Language.GetString("SKILL_LUNAR_SECONDARY_REPLACEMENT_DESCRIPTION") + "};") : ((!CaptainBeacons.Contains(secondary.baseSkill.GetCurrentNameToken(secondary))) ? (Language.GetString(secondary.baseSkill.GetCurrentNameToken(secondary)) + "{" + Language.GetString(secondary.baseSkill.GetCurrentDescriptionToken(secondary)) + "};") : (Language.GetString("CAPTAIN_SECONDARY_NAME") + "{" + Language.GetString("CAPTAIN_SECONDARY_DESCRIPTION") + "};"))));
		text += text3;
		string text4 = ((!InventoryItemsString.Contains("ITEM_LUNARUTILITYREPLACEMENT_NAME")) ? (Language.GetString(utility.baseSkill.GetCurrentNameToken(utility)) + "{" + Language.GetString(utility.baseSkill.GetCurrentDescriptionToken(utility)) + "};") : (Language.GetString("SKILL_LUNAR_UTILITY_REPLACEMENT_NAME") + "{" + Language.GetString("SKILL_LUNAR_UTILITY_REPLACEMENT_DESCRIPTION") + "};"));
		text += text4;
		string text5 = ((!InventoryItemsString.Contains("ITEM_LUNARSPECIALREPLACEMENT_NAME")) ? (Language.GetString(special.baseSkill.GetCurrentNameToken(special)) + "{" + Language.GetString(special.baseSkill.GetCurrentDescriptionToken(special)) + "};") : (Language.GetString("SKILL_LUNAR_SPECIAL_REPLACEMENT_NAME") + "{" + Language.GetString("SKILL_LUNAR_SPECIAL_REPLACEMENT_DESCRIPTION") + "};"));
		return text + text5;
	}

	private static string GetColourString()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		Color bodyColor = PlayerCharacterMasterController.instances[0].master.GetBody().bodyColor;
		return "rgb(" + Math.Round(bodyColor.r * 200f) + "," + Math.Round(bodyColor.g * 200f) + "," + Math.Round(bodyColor.b * 200f) + ")";
	}

	private static async void WaitThenSendItemsUpdate(string items, string equipment, string skills, string bodycolour)
	{
		await Task.Delay((int)(DelayConfigEntry.Value * 1000.0)).ContinueWith(delegate
		{
			SendItemsUpdate(items, equipment, skills, bodycolour);
		});
	}

	private static void WaitThenSendItemsUpdatePhase4()
	{
		Task.Delay((int)(DelayConfigEntry.Value * 1000.0) + 3000).ContinueWith(delegate
		{
			isWaitingForUpdate = false;
			SendItemsUpdate(inventoryItemsString, equipmentString, skillsString, bodyColourString);
		});
	}

	private static async void SendItemsUpdate(string items, string equipment, string skills, string bodycolour)
	{
		string hudstatus = "";
		await Task.Run(delegate
		{
			HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("https://ror2-sc-api.herokuapp.com/");
			httpWebRequest.ContentType = "application/json";
			httpWebRequest.Method = "POST";
			using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
			{
				string value = "{\"twitchName\":\"" + TwitchNameConfigEntry.Value + "\",\"secretKey\":\"" + SecretKeyConfigEntry.Value + "\",\"items\":\"" + items + "\",\"equipment\":\"" + equipment + "\",\"skills\":\"" + skills + "\",\"survivor\":\"" + bodycolour + "\",\"hudstatus\":\"" + hudstatus + "\"}";
				streamWriter.Write(value);
			}
			HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
			httpWebResponse.Close();
		});
	}

	private void Update()
	{
		if ((!Object.op_Implicit((Object)(object)PhaseCounter.instance) || PhaseCounter.instance.phase != 4) && isWaitingForUpdate)
		{
			isWaitingForUpdate = false;
		}
		if ((Object)(object)Run.instance == (Object)null && (inventoryItemsString.Length > 0 || equipmentString.Length > 0 || skillsString.Length > 0 || bodyColourString.Length > 0))
		{
			inventoryItemsString = "";
			equipmentString = "";
			skillsString = "";
			bodyColourString = "";
			SendItemsUpdate(inventoryItemsString, equipmentString, skillsString, bodyColourString);
		}
	}
}