Decompiled source of Terminal Livestream Chat v2.0.0

plugins/TerminalLivestreamChat/TerminalLivestreamChat.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using TMPro;
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("TerminalLivestreamChat")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TerminalLivestreamChat")]
[assembly: AssemblyTitle("TerminalLivestreamChat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TerminalLivestreamChat
{
	internal class Event_Terminal447 : MonoSingleton
	{
		public int TerminalID = 447;

		public GameObject terminalmessagePrefab;

		public Transform contentTransform;

		public Transform canvastc;

		public TextMeshProUGUI curMessageText;

		public string[] joinMessages = new string[1] { "ugh" };

		public string[] randomMessages = new string[6] { "you are so bad at this game v2 plays better", "holy FUCKING SHIYT V1 YOU SUCK", "please v1 just QUIT PLAYING", "V2 PLAYS BETTER HE ONLY LOST DUE TO BAD LUCK", "V2 IS A WAY BETTER FIGHTER", "<color=red>KYS V1</color> <color=grey>(Flagged as possible harassment due to term : \"KYS\")</color>" };

		private IEnumerator Start()
		{
			AddMessageToChat(joinMessages[Random.Range(0, joinMessages.Length)]);
			while (true)
			{
				yield return (object)new WaitForSeconds(Random.Range(2f, 4f));
				AddMessageToChat(randomMessages[Random.Range(0, randomMessages.Length)]);
				if (((TMP_Text)curMessageText).text == "<color=yellow>Terminal 447</color> - <color=red>KYS V1</color> <color=grey>(Flagged as possible harassment due to term : \"KYS\")</color>")
				{
					yield return (object)new WaitForSeconds(Random.Range(0.5f, 1f));
					((TMP_Text)curMessageText).text = "<color=grey>Message removed by moderator for : Harassment</color>";
					yield return (object)new WaitForSeconds(Random.Range(3f, 1f));
					AddMessageToChat("THE MODERATORS CANT SILENCE ME V1 I WILL TALK ABOUT HOW BAD YOU ARE UNTIL I DIE");
				}
			}
		}

		private void AddMessageToChat(string msg)
		{
			Transform val = ((Component)canvastc).transform.Find("Image/Scroll View/Viewport/Content/Section Reference/Grid/StreamBegunText");
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			string text = "";
			text = $"<color=yellow>Terminal {TerminalID}</color> - {msg}";
			GameObject val2 = Object.Instantiate<GameObject>(terminalmessagePrefab, contentTransform);
			((TMP_Text)(curMessageText = val2.GetComponentInChildren<TextMeshProUGUI>())).text = text;
		}

		public void LeaveStream()
		{
			AddMessageToChat("boring stream im leaving");
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	[BepInPlugin("lazy.terminal.livestream", "Terminal Live Chat", "1.0.0.0")]
	public class PluginTerminal : BaseUnityPlugin
	{
		private static AssetBundle assetBundle;

		private static GameObject canvastc;

		private static List<TerminalWatcher> Terminals = new List<TerminalWatcher>();

		private static List<GameObject> instantiatedMessages = new List<GameObject>();

		private static GameObject terminalmessagePrefab;

		private static Transform contentTransform;

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TerminalLivestreamChat is loaded!");
			assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "terminal_livestream"));
			canvastc = assetBundle.LoadAsset<GameObject>("CanvasTERMINALCHAT");
			canvastc = Object.Instantiate<GameObject>(canvastc);
			Object.DontDestroyOnLoad((Object)(object)canvastc);
			contentTransform = canvastc.transform.Find("Image/Scroll View/Viewport/Content/Section Reference/Grid");
			terminalmessagePrefab = assetBundle.LoadAsset<GameObject>("TerminalMessage");
			((MonoBehaviour)this).StartCoroutine(createTerminalClass());
		}

		private int GetAmountOfSubscribers()
		{
			int num = 0;
			for (int i = 0; i < Terminals.Count; i++)
			{
				TerminalWatcher terminalWatcher = Terminals[i];
				if (terminalWatcher.GetIfSubbed())
				{
					num++;
				}
			}
			return num;
		}

		private void Update()
		{
			GameObject gameObject = ((Component)canvastc.transform.Find("ViewCount")).gameObject;
			TextMeshProUGUI component = gameObject.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = $"VIEW COUNT:{Terminals.Count}\n<color=green> SUB COUNT:{GetAmountOfSubscribers()}";
			if (contentTransform.childCount > 9)
			{
				GameObject gameObject2 = ((Component)contentTransform.GetChild(0)).gameObject;
				Object.Destroy((Object)(object)gameObject2);
			}
		}

		private IEnumerator createTerminalClass()
		{
			while (true)
			{
				yield return (object)new WaitForSeconds(0.1f);
				if (SceneHelper.CurrentScene != "Main Menu" && SceneHelper.CurrentScene != "Intro" && SceneHelper.CurrentScene != "Bootstrap")
				{
					StyleHUD styleHUD = MonoSingleton<StyleHUD>.Instance;
					if (styleHUD.rankIndex == 0)
					{
						yield return (object)new WaitForSeconds(8f);
					}
					else if (styleHUD.rankIndex == 1)
					{
						yield return (object)new WaitForSeconds(7f);
					}
					else if (styleHUD.rankIndex == 2)
					{
						yield return (object)new WaitForSeconds(6f);
					}
					else if (styleHUD.rankIndex == 3)
					{
						yield return (object)new WaitForSeconds(5f);
					}
					else if (styleHUD.rankIndex == 4)
					{
						yield return (object)new WaitForSeconds(4f);
					}
					else if (styleHUD.rankIndex == 5)
					{
						yield return (object)new WaitForSeconds(3f);
					}
					else if (styleHUD.rankIndex == 6)
					{
						yield return (object)new WaitForSeconds(2f);
					}
					else if (styleHUD.rankIndex == 7)
					{
						yield return (object)new WaitForSeconds(0.6f);
					}
					int terminalid;
					do
					{
						terminalid = Random.Range(1, 9999);
					}
					while (terminalid == 447);
					TerminalWatcher terminalWatcher = ((Component)contentTransform).gameObject.AddComponent<TerminalWatcher>();
					terminalWatcher.TerminalID = terminalid;
					terminalWatcher.HowMuchPeeDoDeyHav = Random.Range(400, 5000000);
					terminalWatcher.contentTransform = contentTransform;
					terminalWatcher.canvastc = canvastc.transform;
					terminalWatcher.terminalmessagePrefab = terminalmessagePrefab;
					terminalWatcher.minimum = Random.Range(2, 6);
					terminalWatcher.Subscribed = Random.Range(0, 10) == 1;
					Terminals.Add(terminalWatcher);
				}
			}
		}

		private IEnumerator specialEvents()
		{
			int specialEventsAmount = 1;
			Transform contentTransform = canvastc.transform.Find("Image/Scroll View/Viewport/Content/Section Reference/Grid");
			while (true)
			{
				yield return (object)new WaitForSeconds((float)Random.Range(100, 300));
				if (specialEventsAmount == 1)
				{
					Debug.Log((object)"terminal 447 spawned");
					Event_Terminal447 term447 = ((Component)contentTransform).gameObject.AddComponent<Event_Terminal447>();
					term447.contentTransform = contentTransform;
					term447.canvastc = canvastc.transform;
					term447.terminalmessagePrefab = terminalmessagePrefab;
					yield return (object)new WaitForSeconds((float)Random.Range(10, 50));
					term447.LeaveStream();
				}
			}
		}
	}
	internal class TerminalWatcher : MonoSingleton
	{
		public int TerminalID;

		public GameObject terminalmessagePrefab;

		public Transform contentTransform;

		public Transform canvastc;

		public TextMeshProUGUI curMessageText;

		public bool Subscribed;

		public bool Lurker;

		public bool thinkPlayerIsPlayingBad;

		public bool thinkPlayerIsPlayingBetter;

		public int minimum;

		public int HowMuchPeeDoDeyHav;

		public string[] joinMessages = new string[4] { "hello v1! just joined, what are we doing today?", "whats UP gamers", "did i miss anything important yet i just joined", "oh holy peak v1 is streaming" };

		public string[] randomMessages = new string[20]
		{
			"how is your day going V1", "ULTRAKILL", "V1 have you killed V2 yet", "Grahhhhhhhhhh", "Have Fun V1", "V1 did you know that you can punch your own bullets?", "V1 did you see what i said", "V1 did you know that you can shoot your coins at the right time to do a splitshot?", "Hello fellow chatters!", "bro",
			"Hakita", "V1 im such a big fan please", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "im bored", "Skibidi dop dop dop yes yes", "V1 you are SO cool", "V1 can you please do a chargeback i think thatll be cool", "hello v1 my grandma terminal is terminally ill and is about to die soon can you give me a shout out to make my day better", "when r u fighitnvg v3", "mmmm"
		};

		public string[] playingBadQuotes = new string[8] { "ur bad", "BORING", "be stylish IDIOT", "V1 you gotta be more stylish man", "Get! That! Style!", "be more stylish i dont care how you do it but BE MORE STYLISH", "please be stylish", "this is boring be more stylish" };

		public string[] playingGoodQuotes = new string[3] { "I rank you an ULTRAKILL outta 10!", "holy shit you are amazing at this", "v1 really be poppin off" };

		private IEnumerator Start()
		{
			if (Random.Range(0, 5) != 0)
			{
				AddMessageToChat(joinMessages[Random.Range(0, joinMessages.Length)]);
			}
			while (true)
			{
				yield return (object)new WaitForSeconds(Random.Range(10f, 30f));
				if (Random.Range(0, 50) == 1)
				{
					((MonoBehaviour)this).StartCoroutine(Subscribe());
				}
				else if (Random.Range(0, 5) >= 1)
				{
					AddMessageToChat(randomMessages[Random.Range(0, randomMessages.Length)]);
				}
				else
				{
					ReactToCurrentStyle();
				}
				if (((TMP_Text)curMessageText).text == $"<color=yellow>Terminal {TerminalID}</color> - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" || ((TMP_Text)curMessageText).text == $"<color=green>Terminal {TerminalID} (SUBSCRIBER)</color> - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
				{
					Debug.Log((object)"aaaaaa");
					yield return (object)new WaitForSeconds(Random.Range(0.5f, 1f));
					((TMP_Text)curMessageText).text = "<color=grey>Message removed by moderator for : Spam</color>";
				}
				if (((TMP_Text)curMessageText).text == $"<color=yellow>Terminal {TerminalID}</color> - Skibidi dop dop dop yes yes" || ((TMP_Text)curMessageText).text == $"<color=green>Terminal {TerminalID} (SUBSCRIBER)</color> - Skibidi dop dop dop yes yes")
				{
					Debug.Log((object)"skivbi");
					yield return (object)new WaitForSeconds(Random.Range(0.5f, 1f));
					((TMP_Text)curMessageText).text = $"<color=grey>Terminal {TerminalID} was timed out for 10 minutes by moderator for : stop</color>";
					yield return (object)new WaitForSeconds(600f);
					AddMessageToChat("WOOOHOO im UNMUTED");
				}
			}
		}

		private void AddMessageToChat(string msg)
		{
			Transform val = ((Component)canvastc).transform.Find("Image/Scroll View/Viewport/Content/Section Reference/Grid/StreamBegunText");
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			string text = "";
			text = (Subscribed ? $"<color=green>Terminal {TerminalID} (SUBSCRIBER) </color> - {msg}" : $"<color=yellow>Terminal {TerminalID}</color> - {msg}");
			GameObject val2 = Object.Instantiate<GameObject>(terminalmessagePrefab, contentTransform);
			((TMP_Text)(curMessageText = val2.GetComponentInChildren<TextMeshProUGUI>())).text = text;
		}

		private IEnumerator Subscribe()
		{
			if (HowMuchPeeDoDeyHav >= 300 && !Subscribed)
			{
				HowMuchPeeDoDeyHav -= 100;
				Transform t = ((Component)canvastc).transform.Find("Image/Scroll View/Viewport/Content/Section Reference/Grid/StreamBegunText");
				if ((Object)(object)t != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)t).gameObject);
				}
				string newMessage = $"<color=green>TERMINAL {TerminalID} JUST SUBSCRIBED TO THE CHANNEL! THANK YOU!";
				Subscribed = true;
				GameObject terminalMessageInstance = Object.Instantiate<GameObject>(terminalmessagePrefab, contentTransform);
				((TMP_Text)(curMessageText = terminalMessageInstance.GetComponentInChildren<TextMeshProUGUI>())).text = newMessage;
				yield return (object)new WaitForSeconds(2f);
				AddMessageToChat("Hey V1 I just bought a subscription!");
			}
		}

		public bool GetIfSubbed()
		{
			return Subscribed;
		}

		private void ReactToCurrentStyle()
		{
			if (SceneHelper.CurrentScene != "Main Menu" && SceneHelper.CurrentScene != "Intro")
			{
				AddMessageToChat(joinMessages[Random.Range(0, joinMessages.Length)]);
				return;
			}
			StyleHUD instance = MonoSingleton<StyleHUD>.Instance;
			thinkPlayerIsPlayingBad = instance.rankIndex <= minimum;
			if (instance.rankIndex <= 1)
			{
				AddMessageToChat(playingBadQuotes[Random.Range(0, playingBadQuotes.Length)]);
			}
			else if (thinkPlayerIsPlayingBad)
			{
				AddMessageToChat(playingBadQuotes[Random.Range(0, playingBadQuotes.Length)]);
			}
			else if (instance.rankIndex == 7)
			{
				AddMessageToChat(playingGoodQuotes[Random.Range(0, playingGoodQuotes.Length)]);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TerminalLivestreamChat";

		public const string PLUGIN_NAME = "TerminalLivestreamChat";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}