using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalNetworkAPI;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SalmonRunQuota")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SalmonRunQuota")]
[assembly: AssemblyTitle("SalmonRunQuota")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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;
}
}
}
namespace SalmonRunQuota
{
public class CutsceneManager : MonoBehaviour
{
public static CutsceneManager Instance;
private static readonly Dictionary<int, string> emotes = new Dictionary<int, string>
{
{ 1, "Armature|YoureWelcome" },
{ 2, "Armature|RoboSteppin" },
{ 3, "Armature|ReadyStance" },
{ 4, "Armature|Stuntin" },
{ 5, "Armature|SarcasticSalute" },
{ 6, "Armature|JustPlayin" }
};
public List<int> scrapCollected = new List<int>();
public int totalScrap = 0;
private AudioSource mainTheme;
private AudioSource dialogueSound;
private Text scrap;
private Text credits;
private Transform cardHolder;
private GameObject[] cards;
private GameObject textbox;
private Transform playerCardHolder;
private GameObject[] playerCards;
private Color defaultColor;
private static readonly Dictionary<ulong, SRPlayerData> playerData = new Dictionary<ulong, SRPlayerData>();
public bool readyToPlay = false;
private readonly string[] ScrapQuotes = new string[5] { "Well done. You've reached your quota and, more importantly, increased our scrap count by {0}. We'll remember this when it's time for your performance review.", "Let's see here... You collected {0} Scrap this time. Nice - that's a good haul.", "So much scrap! The moons provide, and they must LOVE you! Remind me to put that in your next review.", "Color us impressed. You are a true Professional! I can see how much you love the job!", "Spend enough time out there, and you become one with the moon itself! If that doesn't make you Executive VP material, I don't know what does!" };
private readonly string[] EndQuotes = new string[4] { "Alright, now get back down there and collect us some more scrap. Fuel isn't free.", "That must've been terrifying... If you're going to have nightmares, policy requires that you do it off the clock.", "THAT'S what we like to see! You've got a future here, kid. This'll go in your performance eval.", "Get back out there, the collection counter is waiting. Don't let us down." };
private void Start()
{
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Instance != (Object)null)
{
Object.Destroy((Object)(object)this);
}
Instance = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
try
{
AudioSource[] components = ((Component)((Component)this).transform.GetChild(0)).gameObject.GetComponents<AudioSource>();
mainTheme = components[0];
dialogueSound = components[1];
Transform child = ((Component)this).transform.GetChild(1);
scrap = ((Component)child.GetChild(2)).gameObject.GetComponent<Text>();
credits = ((Component)child.GetChild(3)).gameObject.GetComponent<Text>();
cards = (GameObject[])(object)new GameObject[3];
cardHolder = ((Component)child).transform.GetChild(4);
for (int i = 0; i < cardHolder.childCount; i++)
{
cards[i] = ((Component)cardHolder.GetChild(i)).gameObject;
}
textbox = ((Component)((Component)child).transform.GetChild(5)).gameObject;
playerCards = (GameObject[])(object)new GameObject[8];
playerCardHolder = ((Component)child).transform.GetChild(6);
for (int j = 0; j < 8; j++)
{
playerCards[j] = ((Component)playerCardHolder.GetChild(j)).gameObject;
}
((Component)this).gameObject.SetActive(false);
readyToPlay = true;
ColorUtility.TryParseHtmlString("#820000", ref defaultColor);
Plugin.Log.LogWarning((object)("SalmonRunScreen object loaded successfully: " + ((Object)((Component)this).gameObject).name));
Plugin.Log.LogWarning((object)$"Sending emote and banner data to clients... (Emote: {Plugin.Instance.Emote} | BannerColor: {Plugin.Instance.BannerColor}");
LethalClientMessage<SRPlayerData> dataMessage = new LethalClientMessage<SRPlayerData>("salmonRunPlayerData", (Action<SRPlayerData>)null, (Action<SRPlayerData, ulong>)null);
dataMessage.SendAllClients(new SRPlayerData(Plugin.Instance.Emote, Plugin.Instance.BannerColor), false, false);
dataMessage.OnReceivedFromClient += delegate(SRPlayerData data, ulong clientId)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (!playerData.ContainsKey(clientId))
{
dataMessage.SendAllClients(new SRPlayerData(Plugin.Instance.Emote, Plugin.Instance.BannerColor), false, false);
}
playerData[clientId] = data;
Plugin.Log.LogWarning((object)$"Got player {clientId}'s data. Emote: {data.Emote} | BannerColor: {data.BannerColor}");
};
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Failed to setup SalmonRunScreen object:\n" + ex));
}
}
public void RunCutscene(bool debug = false)
{
if (readyToPlay)
{
Init();
((MonoBehaviour)this).StartCoroutine(DoCutscene(debug));
}
}
private void Init()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
HUDManager.Instance.HideHUD(true);
readyToPlay = false;
((Component)this).gameObject.SetActive(true);
scrap.text = "Scrap x0";
credits.text = "Credits x0";
cardHolder.localPosition = Vector3.zero;
GameObject[] array = cards;
foreach (GameObject val in array)
{
((Component)val.transform.GetChild(1)).gameObject.GetComponent<Text>().text = "0";
val.SetActive(false);
}
textbox.SetActive(false);
playerCardHolder.localPosition = new Vector3(1000f, 0f, 0f);
GameObject[] array2 = playerCards;
foreach (GameObject val2 in array2)
{
val2.SetActive(false);
}
}
private IEnumerator DoCutscene(bool debug)
{
GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation = true;
mainTheme.Play();
scrap.text = "Scrap x" + totalScrap;
Terminal terminal = Object.FindObjectOfType<Terminal>();
credits.text = "Credits x" + (((Object)(object)terminal == (Object)null) ? "0" : terminal.groupCredits.ToString());
yield return (object)new WaitForSecondsRealtime(1.5f);
for (int i = 0; i < cards.Length; i++)
{
cards[i].SetActive(true);
if (scrapCollected.Count <= i)
{
((Component)cards[i].transform.GetChild(1)).gameObject.GetComponent<Text>().text = "0";
}
else
{
((Component)cards[i].transform.GetChild(1)).gameObject.GetComponent<Text>().text = scrapCollected[i].ToString();
}
yield return (object)new WaitForSecondsRealtime(0.5f);
}
string text = string.Format(ScrapQuotes[Random.Range(0, ScrapQuotes.Length)], totalScrap);
((MonoBehaviour)this).StartCoroutine(WriteTextInTextbox(text));
yield return (object)new WaitForSecondsRealtime(3.5f);
for (int j = 0; j < 8; j++)
{
PlayerControllerB player = StartOfRound.Instance.allPlayerScripts.ElementAtOrDefault(j);
if (!((Object)(object)player != (Object)null) || !(player.isPlayerControlled || debug))
{
continue;
}
playerCards[j].SetActive(true);
((Component)playerCards[j].transform.GetChild(0)).gameObject.GetComponent<Text>().text = player.playerUsername;
((Component)playerCards[j].transform.GetChild(1)).gameObject.GetComponent<Text>().text = HUDManager.Instance.playerLevels[player.playerLevelNumber].levelName;
if ((Object)(object)player == (Object)(object)StartOfRound.Instance.localPlayerController)
{
if (Plugin.Instance.Emote == -1)
{
((Component)playerCards[j].transform.GetChild(2).GetChild(0)).gameObject.GetComponent<Animator>().Play(emotes[Random.Range(1, 7)]);
}
else
{
((Component)playerCards[j].transform.GetChild(2).GetChild(0)).gameObject.GetComponent<Animator>().Play(emotes[Plugin.Instance.Emote]);
}
((Graphic)playerCards[j].gameObject.GetComponent<RawImage>()).color = Plugin.Instance.BannerColor;
continue;
}
ulong playerId = LethalNetworkExtensions.GetClientId(player);
if (playerData.ContainsKey(playerId))
{
SRPlayerData data = playerData[playerId];
if (data.Emote == -1)
{
((Component)playerCards[j].transform.GetChild(2).GetChild(0)).gameObject.GetComponent<Animator>().Play(emotes[Random.Range(1, 7)]);
}
else
{
((Component)playerCards[j].transform.GetChild(2).GetChild(0)).gameObject.GetComponent<Animator>().Play(emotes[data.Emote]);
}
((Graphic)playerCards[j].gameObject.GetComponent<RawImage>()).color = data.BannerColor;
}
else if (debug)
{
((Component)playerCards[j].transform.GetChild(2).GetChild(0)).gameObject.GetComponent<Animator>().Play(emotes[j % 6]);
}
else
{
((Component)playerCards[j].transform.GetChild(2).GetChild(0)).gameObject.GetComponent<Animator>().Play(emotes[Random.Range(1, 7)]);
((Graphic)playerCards[j].gameObject.GetComponent<RawImage>()).color = defaultColor;
}
}
float time = 0.25f;
float t = 0f;
while (t <= 1f)
{
t += Time.deltaTime / time;
cardHolder.localPosition = Vector3.Lerp(Vector3.zero, new Vector3(-1000f, 0f), Mathf.SmoothStep(0f, 1f, t));
playerCardHolder.localPosition = Vector3.Lerp(new Vector3(1000f, 0f), Vector3.zero, Mathf.SmoothStep(0f, 1f, t));
yield return null;
}
yield return (object)new WaitForSecondsRealtime(3f);
string text2 = EndQuotes[Random.Range(0, EndQuotes.Length)];
yield return WriteTextInTextbox(text2, 2f);
yield return (object)new WaitForSecondsRealtime(3f);
mainTheme.Stop();
((Component)this).gameObject.SetActive(false);
GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation = false;
readyToPlay = true;
scrapCollected.Clear();
totalScrap = 0;
HUDManager.Instance.HideHUD(false);
}
private IEnumerator WriteTextInTextbox(string text, float wait = 0.5f)
{
dialogueSound.Play();
textbox.SetActive(true);
Text t = ((Component)textbox.transform.GetChild(0).GetChild(0)).gameObject.GetComponent<Text>();
t.text = "";
foreach (char c in text)
{
t.text += c;
yield return (object)new WaitForSecondsRealtime(0.025f);
}
dialogueSound.Stop();
yield return (object)new WaitForSecondsRealtime(wait);
textbox.SetActive(false);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("SalmonRunQuota", "SalmonRunQuota", "0.4.0")]
public class Plugin : BaseUnityPlugin
{
public static Plugin Instance;
internal static ManualLogSource Log;
public bool isGameObjectLoaded = false;
private Harmony harmony;
private ConfigEntry<int> emoteNumber;
public int Emote;
private ConfigEntry<string> bannerColor;
public Color BannerColor;
private void Awake()
{
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
emoteNumber = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "Emote Number", 1, "The number of the emote to use. Valid emote numbers include: 1 (You're Welcome), 2 (Robo Steppin'), 3 (Ready Stance), 4 (Stuntin'), 5 (Sarcastic Salute), 6 (Just Playin')");
if (emoteNumber.Value != -1 && (emoteNumber.Value < 1 || emoteNumber.Value > 6))
{
((BaseUnityPlugin)this).Logger.LogError((object)"Emote number must be between 1 and 6, inclusive. Emote will default to -1 (random).");
emoteNumber.Value = -1;
}
Emote = emoteNumber.Value;
bannerColor = ((BaseUnityPlugin)this).Config.Bind<string>("Config", "Banner Color", "#820000", "Sets the color of your banner.");
Color val = default(Color);
if (ColorUtility.TryParseHtmlString(bannerColor.Value, ref val))
{
BannerColor = val;
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)("Failed to parse color " + bannerColor.Value + ", defaulting to #820000 (red)"));
bannerColor.Value = "#820000";
ColorUtility.TryParseHtmlString(bannerColor.Value, ref BannerColor);
}
harmony = new Harmony("SalmonRunQuota");
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded SalmonRunQuota!");
Instance = this;
}
}
[Serializable]
public struct SRPlayerData
{
public int Emote;
public Color BannerColor;
public SRPlayerData(int emote, Color bannerColor)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
Emote = emote;
BannerColor = bannerColor;
}
}
}
namespace SalmonRunQuota.Patches
{
[HarmonyPatch(typeof(HUDManager), "DisplayNewDeadline")]
public class HUDManager_DisplayNewDeadline
{
private static void Prefix()
{
if (Plugin.Instance.isGameObjectLoaded)
{
CutsceneManager.Instance.RunCutscene();
}
}
}
[HarmonyPatch(typeof(HUDManager), "FillEndGameStats")]
public class HUDManager_FillEndGameStats
{
private static void Postfix()
{
if (Plugin.Instance.isGameObjectLoaded)
{
CutsceneManager.Instance.scrapCollected.Add(RoundManager.Instance.scrapCollectedThisRound.Count);
CutsceneManager.Instance.totalScrap += RoundManager.Instance.scrapCollectedThisRound.Count;
}
}
}
[HarmonyPatch(typeof(StartOfRound), "Start")]
public class StartOfRound_Start
{
private static void Postfix()
{
if (!Plugin.Instance.isGameObjectLoaded)
{
AssetBundle val = AssetBundle.LoadFromFile(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/salmonrun");
if ((Object)(object)val == (Object)null)
{
Plugin.Log.LogError((object)"Failed to load bundle!");
return;
}
GameObject val2 = val.LoadAsset<GameObject>("SalmonRunScreen");
GameObject val3 = Object.Instantiate<GameObject>(val2);
val3.AddComponent<CutsceneManager>();
Plugin.Instance.isGameObjectLoaded = true;
}
}
}
}