using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DailyQuota.NetcodePatcher;
using Friskzips.patch;
using HarmonyLib;
using LobbyCompatibility.Attributes;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: AssemblyCompany("DailyQuota")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3-alpha.0.2+8b2da66df728d4504593eb40d1802a75a0321995")]
[assembly: AssemblyProduct("DailyQuota")]
[assembly: AssemblyTitle("DailyQuota")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Friskzips
{
public static class ModInfo
{
public const string GUID = "Friskzips.DailyQuota";
public const string NAME = "DailyQuota";
public const string VERSION = "1.0.0";
}
[BepInPlugin("Friskzips.DailyQuota", "DailyQuota", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("DailyQuota");
public static Plugin Instance { get; set; }
public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;
public Plugin()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
Instance = this;
}
private void Awake()
{
Log.LogInfo((object)"Applying patches...");
ApplyPluginPatch();
Log.LogInfo((object)"Patches applied");
}
private void ApplyPluginPatch()
{
_harmony.PatchAll(typeof(Game));
_harmony.PatchAll(typeof(Monitor));
_harmony.PatchAll(typeof(ResetStuff));
_harmony.PatchAll(typeof(Penality));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "DailyQuota";
public const string PLUGIN_NAME = "DailyQuota";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace Friskzips.patch
{
[HarmonyPatch(typeof(StartOfRound))]
public static class Game
{
internal static bool challengeFile = false;
internal static int curLevel = 0;
internal static int scrapValue;
internal static int scrapQuota;
internal static int scrapInShip;
internal static bool started;
internal static float showQuotaReachedText = 3f;
internal static CanvasGroup quotaReachedCanvas;
[HarmonyPatch("openingDoorsSequence")]
[HarmonyPostfix]
private static void GetRoundScrapValue(ref StartOfRound __instance)
{
scrapValue = 0;
started = false;
curLevel = __instance.currentLevel.levelID;
GameObject[] array = Object.FindObjectsOfType<GameObject>();
GameObject[] array2 = array;
foreach (GameObject val in array2)
{
if (((Object)val).name == "ProfitQuotaMet")
{
Plugin.Log.LogDebug((object)("Found object: " + ((Object)val).name));
quotaReachedCanvas = val.GetComponent<CanvasGroup>();
}
}
if (curLevel == 3 || challengeFile)
{
return;
}
started = true;
GrabbableObject[] array3 = Object.FindObjectsOfType<GrabbableObject>();
for (int j = 0; j < array3.Length; j++)
{
if (array3[j].itemProperties.isScrap && !array3[j].isInShipRoom && !array3[j].isInElevator)
{
scrapValue += array3[j].scrapValue;
}
}
Plugin.Log.LogDebug((object)("Total scrap value: " + scrapValue));
scrapQuota = (int)((double)scrapValue * 0.2);
Plugin.Log.LogDebug((object)("Scrap value to reach: " + scrapQuota));
}
[HarmonyPatch(typeof(HUDManager))]
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void CheckForQuota(ref HUDManager __instance)
{
if (showQuotaReachedText > 0f)
{
showQuotaReachedText -= 1f * Time.deltaTime;
}
if (scrapInShip >= scrapQuota && started)
{
started = false;
__instance.reachedProfitQuotaAnimator.SetBool("display", true);
__instance.UIAudio.PlayOneShot(__instance.reachedQuotaSFX);
((TMP_Text)__instance.reachedProfitQuotaBonusText).text = "";
showQuotaReachedText = 5f;
}
else if (showQuotaReachedText < 2f && showQuotaReachedText > 1f)
{
__instance.reachedProfitQuotaAnimator.SetBool("display", false);
quotaReachedCanvas.alpha = 0f;
}
else if (showQuotaReachedText < 1f && showQuotaReachedText > 0f)
{
quotaReachedCanvas.alpha = 0.65f;
Monitor.defaultMonitor = true;
}
}
}
internal class Monitor
{
internal static int quotaText;
internal static float timer;
internal static bool defaultMonitor;
[HarmonyPatch(typeof(StartOfRound))]
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdateMonitor(ref StartOfRound __instance)
{
Game.challengeFile = __instance.isChallengeFile;
if (Game.started && !Game.challengeFile)
{
timer += 1f * Time.deltaTime;
if (timer > 5f)
{
timer = 0f;
quotaText++;
}
Game.scrapInShip = __instance.GetValueOfAllScrap(true, true);
switch (quotaText)
{
case 0:
((TMP_Text)__instance.profitQuotaMonitorText).text = "DAILY QUOTA:\n$" + Game.scrapInShip + "/$" + Game.scrapQuota;
break;
case 1:
break;
case 2:
quotaText = 0;
break;
}
}
else
{
timer = 0f;
quotaText = 0;
}
}
[HarmonyPatch(typeof(TimeOfDay))]
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void showNormalQuota(ref TimeOfDay __instance)
{
if (quotaText == 1 || defaultMonitor)
{
__instance.UpdateProfitQuotaCurrentTime();
defaultMonitor = false;
}
}
}
internal class Penality
{
internal static bool failed;
internal static bool penality;
internal static bool penalityScreen;
internal static int quota;
internal static void CheckForFailure()
{
if (Game.scrapInShip < Game.scrapQuota && !Game.challengeFile && Game.curLevel != 3)
{
failed = true;
Plugin.Log.LogDebug((object)"Daily quota failed");
}
}
[HarmonyPatch(typeof(StartOfRound))]
[HarmonyPatch("ReviveDeadPlayers")]
[HarmonyPrefix]
private static void TriggerFailure()
{
Plugin.Log.LogDebug((object)"Checking penality trigger");
if (failed)
{
Plugin.Log.LogDebug((object)"Triggering penality");
penality = true;
failed = false;
}
}
[HarmonyPatch(typeof(HUDManager))]
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void ShowPenality(ref HUDManager __instance)
{
if (penalityScreen)
{
__instance.endgameStatsAnimator.SetTrigger("displayPenalty");
((TMP_Text)__instance.statsUIElements.penaltyAddition).text = "You haven't met the daily quota";
((TMP_Text)__instance.statsUIElements.penaltyTotal).text = "Now the quota is $" + quota;
penalityScreen = false;
Plugin.Log.LogDebug((object)"Penality screen");
Delay();
}
}
[HarmonyPatch(typeof(TimeOfDay))]
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void SetQuota(ref TimeOfDay __instance)
{
if (penality)
{
quota = __instance.profitQuota;
quota += (int)((double)quota * 0.1);
penality = false;
penalityScreen = true;
__instance.profitQuota = quota;
Plugin.Log.LogDebug((object)"Changed quota");
}
}
private static IEnumerator Delay()
{
yield return (object)new WaitForSeconds(4f);
}
}
internal class ResetStuff
{
[HarmonyPatch(typeof(MenuManager))]
[HarmonyPatch("OnEnable")]
[HarmonyPostfix]
private static void MainMenu()
{
Penality.failed = false;
Penality.penality = false;
Penality.penalityScreen = false;
Reset();
}
[HarmonyPatch(typeof(StartOfRound))]
[HarmonyPatch("EndOfGame")]
[HarmonyPrefix]
private static void EndOfGame()
{
Penality.CheckForFailure();
Reset();
}
private static void Reset()
{
Game.showQuotaReachedText = 0f;
Game.scrapQuota = 0;
Game.started = false;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace DailyQuota.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}