using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using SideQuests.Managers;
using SideQuests.NetcodePatcher;
using TMPro;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SideQuests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("KallenXCC")]
[assembly: AssemblyProduct("SideQuests")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f590bdf5-2171-4ef1-bc12-88aea9cdf528")]
[assembly: AssemblyFileVersion("0.4.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.4.2.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace SideQuests
{
[BepInPlugin("KallenXCC.SideQuests", "SideQuests", "0.4.2")]
public class SideQuestsBase : BaseUnityPlugin
{
private const string modGUID = "KallenXCC.SideQuests";
private const string modName = "SideQuests";
private const string modVersion = "0.4.2";
private readonly Harmony harmony = new Harmony("KallenXCC.SideQuests");
public static SideQuestsBase Instance;
public GameObject netManagerPrefab;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("KallenXCC.SideQuests");
mls.LogInfo((object)"SideQuests loading build version 0.4.2");
mls.LogInfo((object)"initializing patched NetworkBehaviours...");
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
mls.LogInfo((object)"loading network asset bundle...");
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "netcodemod");
AssetBundle val = AssetBundle.LoadFromFile(text);
netManagerPrefab = val.LoadAsset<GameObject>("Assets/Netcode/SQNetworkManager.prefab");
netManagerPrefab.AddComponent<SQNetworkManager>();
mls.LogInfo((object)"harmony patching base...");
harmony.PatchAll();
mls.LogInfo((object)"patching finished");
}
}
}
namespace SideQuests.Managers
{
public class SQNetworkManager : NetworkBehaviour
{
public static SQNetworkManager Instance;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
}
[ServerRpc(RequireOwnership = false)]
public void SyncQuotaFulfilledServerRpc(int quotaFulfilled)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(433937656u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, quotaFulfilled);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 433937656u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
SyncQuotaFulfilledClientRpc(quotaFulfilled);
}
}
}
[ClientRpc]
public void SyncQuotaFulfilledClientRpc(int quotaFulfilled)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(460492183u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, quotaFulfilled);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 460492183u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
TimeOfDay.Instance.quotaFulfilled = quotaFulfilled;
TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
}
}
}
[ServerRpc(RequireOwnership = false)]
public void SyncGroupCreditsServerRpc(int newGroupCredits)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(338059159u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, newGroupCredits);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 338059159u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
SyncGroupCreditsClientRpc(newGroupCredits);
}
}
}
[ClientRpc]
public void SyncGroupCreditsClientRpc(int newGroupCredits)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(756276352u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, newGroupCredits);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 756276352u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
Object.FindObjectOfType<Terminal>().groupCredits = newGroupCredits;
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_SQNetworkManager()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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
NetworkManager.__rpc_func_table.Add(433937656u, new RpcReceiveHandler(__rpc_handler_433937656));
NetworkManager.__rpc_func_table.Add(460492183u, new RpcReceiveHandler(__rpc_handler_460492183));
NetworkManager.__rpc_func_table.Add(338059159u, new RpcReceiveHandler(__rpc_handler_338059159));
NetworkManager.__rpc_func_table.Add(756276352u, new RpcReceiveHandler(__rpc_handler_756276352));
}
private static void __rpc_handler_433937656(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int quotaFulfilled = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref quotaFulfilled);
target.__rpc_exec_stage = (__RpcExecStage)1;
((SQNetworkManager)(object)target).SyncQuotaFulfilledServerRpc(quotaFulfilled);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_460492183(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int quotaFulfilled = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref quotaFulfilled);
target.__rpc_exec_stage = (__RpcExecStage)2;
((SQNetworkManager)(object)target).SyncQuotaFulfilledClientRpc(quotaFulfilled);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_338059159(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int newGroupCredits = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref newGroupCredits);
target.__rpc_exec_stage = (__RpcExecStage)1;
((SQNetworkManager)(object)target).SyncGroupCreditsServerRpc(newGroupCredits);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_756276352(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int newGroupCredits = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref newGroupCredits);
target.__rpc_exec_stage = (__RpcExecStage)2;
((SQNetworkManager)(object)target).SyncGroupCreditsClientRpc(newGroupCredits);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "SQNetworkManager";
}
}
}
namespace SideQuests.Patches
{
[HarmonyPatch(typeof(GameNetworkManager))]
internal class GameNetworkManagerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void AddToPrefabs(ref GameNetworkManager __instance)
{
((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(SideQuestsBase.Instance.netManagerPrefab);
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void SpawnSQNetworkManager(StartOfRound __instance)
{
if (((NetworkBehaviour)__instance).IsHost)
{
GameObject val = Object.Instantiate<GameObject>(SideQuestsBase.Instance.netManagerPrefab);
val.GetComponent<NetworkObject>().Spawn(false);
}
}
}
[HarmonyPatch(typeof(HUDManager))]
internal class HUDManagerPatch
{
[HarmonyPatch("ClearControlTips")]
[HarmonyPostfix]
private static void ClearControlTipsPatch(ref TextMeshProUGUI[] ___controlTipLines)
{
if (SQCustomStates.taskCompleted)
{
((TMP_Text)___controlTipLines[0]).text = "Task Completed!\nUse Terminal to submit";
}
else
{
((TMP_Text)___controlTipLines[0]).text = SQCustomStates.questDesc[SQCustomStates.questID];
}
}
}
[HarmonyPatch(typeof(Terminal))]
internal class TerminalPatch
{
private static IEnumerator ChangeControlTipMultipleDelayed(string[] allLines)
{
yield return (object)new WaitForSeconds(0.1f);
HUDManager.Instance.ChangeControlTipMultiple(allLines, false, (Item)null);
}
[HarmonyPatch("BeginUsingTerminal")]
[HarmonyPostfix]
private static void BeginUsingTerminalPatch()
{
string[] array = new string[3];
if (StartOfRound.Instance.localPlayerUsingController)
{
array[0] = "Quit Terminal : [Start]";
}
else
{
array[0] = "Quit Terminal : [TAB]";
}
if (SQCustomStates.taskCompleted)
{
array[1] = "Task Completed!";
array[2] = "\nEnter 'submit' in terminal\nto complete quest";
}
else
{
array[1] = SQCustomStates.questDesc[SQCustomStates.questID];
array[2] = "\nEnter 'abandon' in terminal\nto abandon quest";
}
((MonoBehaviour)HUDManager.Instance).StartCoroutine(ChangeControlTipMultipleDelayed(array));
}
[HarmonyPatch("OnSubmit")]
[HarmonyPrefix]
private static void OnSubmitPatch(ref TMP_InputField ___screenText, Terminal __instance)
{
if (___screenText.text.Length < 7)
{
return;
}
if (___screenText.text.Contains("abandon"))
{
SQCustomStates.AbandonQuest();
}
if (___screenText.text.Contains("submit") && SQCustomStates.taskCompleted)
{
HUDManager.Instance.DisplayTip("Quest Complete!", SQCustomStates.questDesc[SQCustomStates.questID], false, false, "LC_Tip1");
int reward = SQCustomStates.GetReward();
int num = __instance.groupCredits + reward;
GrabbableObject[] array = (GrabbableObject[])(object)new GrabbableObject[0];
int quotaFulfilled = TimeOfDay.Instance.quotaFulfilled + reward;
__instance.groupCredits = num;
HUDManager.Instance.DisplayCreditsEarning(reward, array, num);
if (((NetworkBehaviour)__instance).IsHost || ((NetworkBehaviour)__instance).IsServer)
{
SQNetworkManager.Instance.SyncQuotaFulfilledClientRpc(quotaFulfilled);
SQNetworkManager.Instance.SyncGroupCreditsClientRpc(num);
}
else
{
SQNetworkManager.Instance.SyncQuotaFulfilledServerRpc(quotaFulfilled);
SQNetworkManager.Instance.SyncGroupCreditsServerRpc(num);
}
SQCustomStates.RandomizeQuest();
}
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerPatch
{
[HarmonyPatch("CollectNewScrapForThisRound")]
[HarmonyPostfix]
private static void CollectNewScrapForThisRoundPatch(ref GrabbableObject scrapObject)
{
if (SQCustomStates.questID == 0)
{
string strA = scrapObject.itemProperties.itemName.Substring(0, 3);
string strB = SQCustomStates.GetItemName().Substring(0, 3);
if (string.Compare(strA, strB, StringComparison.OrdinalIgnoreCase) == 0)
{
SQCustomStates.CompleteTask();
}
}
}
}
[HarmonyPatch(typeof(DoublewingAI))]
internal class DoublewingAIPatch
{
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch()
{
if (SQCustomStates.questID == 1 && SQCustomStates.enemyID == 0)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(HoarderBugAI))]
internal class HoarderBugAIPatch
{
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch()
{
if (SQCustomStates.questID == 1 && SQCustomStates.enemyID == 1)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(CentipedeAI))]
internal class CentipedeAIPatch
{
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch()
{
if (SQCustomStates.questID == 1 && SQCustomStates.enemyID == 2)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(CrawlerAI))]
internal class CrawlerAIPatch
{
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch()
{
if (SQCustomStates.questID == 1 && SQCustomStates.enemyID == 3)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(SandSpiderAI))]
internal class SandSpiderAIPatch
{
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch()
{
if (SQCustomStates.questID == 1 && SQCustomStates.enemyID == 5)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(MaskedPlayerEnemy))]
internal class MaskedPlayerEnemyPatch
{
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch()
{
if (SQCustomStates.questID == 1 && SQCustomStates.enemyID == 4)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(BaboonBirdAI))]
internal class BaboonBirdAIPatch
{
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch()
{
if (SQCustomStates.questID == 1 && SQCustomStates.enemyID == 6)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(NutcrackerEnemyAI))]
internal class NutcrackerEnemyAIPatch
{
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch()
{
if (SQCustomStates.questID == 1 && SQCustomStates.enemyID == 7)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(FlowermanAI))]
internal class FlowermanAIPatch
{
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch()
{
if (SQCustomStates.questID == 1 && SQCustomStates.enemyID == 8)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(MouthDogAI))]
internal class MouthDogAIPatch
{
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch()
{
if (SQCustomStates.questID == 1 && SQCustomStates.enemyID == 9)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(ForestGiantAI))]
internal class ForestGiantAIPatch
{
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void KillEnemyPatch()
{
if (SQCustomStates.questID == 1 && SQCustomStates.enemyID == 10)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(BlobAI))]
internal class BlobAIPatch
{
[HarmonyPatch("DetectNoise")]
[HarmonyPostfix]
private static void DetectNoisePatch(ref float ___tamedTimer)
{
if (SQCustomStates.questID == 2 && SQCustomStates.secretID == 0 && ___tamedTimer > 0f && !SQCustomStates.taskCompleted)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(PufferAI))]
internal class PufferAIPatch
{
[HarmonyPatch("ShakeTailServerRpc")]
[HarmonyPostfix]
private static void ShakeTailServerRpcPatch()
{
if (SQCustomStates.questID == 2 && SQCustomStates.secretID == 1)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(DressGirlAI))]
internal class DressGirlAIPatch
{
[HarmonyPatch("BeginChasing")]
[HarmonyPostfix]
private static void BeginChasingPatch()
{
if (SQCustomStates.questID == 2 && SQCustomStates.secretID == 2)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(HauntedMaskItem))]
internal class HauntedMaskItemPatch
{
[HarmonyPatch("FinishAttaching")]
[HarmonyPostfix]
private static void FinishAttachingPatch()
{
if (SQCustomStates.questID == 2 && SQCustomStates.secretID == 3)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(Turret))]
internal class TurretPatch
{
[HarmonyPatch("EnterBerserkModeServerRpc")]
[HarmonyPostfix]
private static void EnterBerserkModeServerRpcPatch()
{
if (SQCustomStates.questID == 2 && SQCustomStates.secretID == 4)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(Landmine))]
internal class LandminePatch
{
[HarmonyPatch("Detonate")]
[HarmonyPostfix]
private static void DetonatePatch()
{
if (SQCustomStates.questID == 2 && SQCustomStates.secretID == 5)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(GiftBoxItem))]
internal class GiftBoxItemPatch
{
[HarmonyPatch("OpenGiftBoxServerRpc")]
[HarmonyPostfix]
private static void OpenGiftBoxServerRpcPatch()
{
if (SQCustomStates.questID == 2 && SQCustomStates.secretID == 6)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(WhoopieCushionItem))]
internal class WhoopieCushionItemPatch
{
[HarmonyPatch("Fart")]
[HarmonyPostfix]
private static void FartPatch()
{
if (SQCustomStates.questID == 2 && SQCustomStates.secretID == 7)
{
SQCustomStates.CompleteTask();
}
}
}
[HarmonyPatch(typeof(StormyWeather))]
internal class StormyWeatherPatch
{
private static bool aliveBeforeLightning;
private static bool holdingAKey;
[HarmonyPatch("LightningStrike")]
[HarmonyPrefix]
private static void LightningStrikePatchPre()
{
if (SQCustomStates.questID != 2 || SQCustomStates.secretID != 8)
{
return;
}
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
if (!localPlayerController.isPlayerDead)
{
aliveBeforeLightning = true;
}
else
{
aliveBeforeLightning = false;
}
holdingAKey = false;
for (int i = 0; i < localPlayerController.ItemSlots.Length; i++)
{
if ((Object)(object)localPlayerController.ItemSlots[i] != (Object)null)
{
string itemName = localPlayerController.ItemSlots[i].itemProperties.itemName;
if (itemName.Contains("Key"))
{
holdingAKey = true;
}
}
}
}
[HarmonyPatch("LightningStrike")]
[HarmonyPostfix]
private static void LightningStrikePatchPost()
{
if (SQCustomStates.questID == 2 && SQCustomStates.secretID == 8 && aliveBeforeLightning && holdingAKey)
{
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
if (localPlayerController.isPlayerDead)
{
SQCustomStates.CompleteTask();
}
}
}
}
public static class SQCustomStates
{
public static string[] questDesc;
public static int questID;
public static int itemID;
public static int enemyID;
public static int secretID;
public static bool taskCompleted;
private static readonly string[] itemList;
private static readonly string[] enemyList;
public const int MANTICOIL_ID = 0;
public const int LOOTBUG_ID = 1;
public const int FLEA_ID = 2;
public const int THUMPER_ID = 3;
public const int MASKED_ID = 4;
public const int SPIDER_ID = 5;
public const int BABOON_ID = 6;
public const int NUTCRACKER_ID = 7;
public const int BRACKEN_ID = 8;
public const int DOG_ID = 9;
public const int GIANT_ID = 10;
private static readonly string[] secretList;
public const int SLIME_SID = 0;
public const int SPORE_SID = 1;
public const int GHOST_SID = 2;
public const int MASK_SID = 3;
public const int TURRET_SID = 4;
public const int LANDMINE_SID = 5;
public const int GIFT_SID = 6;
public const int FART_SID = 7;
public const int ELECTRICITY_SID = 8;
private static Random random;
static SQCustomStates()
{
questDesc = new string[3];
questID = 0;
itemID = 0;
enemyID = 0;
secretID = 0;
taskCompleted = false;
itemList = new string[45];
enemyList = new string[11];
secretList = new string[9];
random = new Random();
itemList[0] = "Gift Box";
itemList[1] = "Big bolt";
itemList[2] = "V-type engine";
itemList[3] = "Large axle";
itemList[4] = "Metal sheet";
itemList[5] = "Bottles";
itemList[6] = "Tea kettle";
itemList[7] = "Bell";
itemList[8] = "Plastic fish";
itemList[9] = "Flask";
itemList[10] = "Toy cube";
itemList[11] = "Magnifying glass";
itemList[12] = "Hair brush";
itemList[13] = "Stop sign";
itemList[14] = "Cookie mold pan";
itemList[15] = "Dust pan";
itemList[16] = "Clown horn";
itemList[17] = "Coffee mug";
itemList[18] = "Tragedy";
itemList[19] = "Airhorn";
itemList[20] = "Comedy";
itemList[21] = "Fancy lamp";
itemList[22] = "Red soda";
itemList[23] = "Egg beater";
itemList[24] = "Whoopie-Cushion";
itemList[25] = "DIY-Flashbang";
itemList[26] = "Teeth";
itemList[27] = "Toothpaste";
itemList[28] = "Old phone";
itemList[29] = "Jar of pickles";
itemList[30] = "Rubber Ducky";
itemList[31] = "Remote";
itemList[32] = "Steering wheel";
itemList[33] = "Golden cup";
itemList[34] = "Yield sign";
itemList[35] = "Perfume bottle";
itemList[36] = "Ring";
itemList[37] = "Laser pointer";
itemList[38] = "Chemical jug";
itemList[39] = "Painting";
itemList[40] = "Cash register";
itemList[41] = "Candy";
itemList[42] = "Pill bottle";
itemList[43] = "Apparatus";
itemList[44] = "Hive";
enemyList[0] = "Manticoil";
enemyList[1] = "Loot Bug";
enemyList[2] = "Snare Flea";
enemyList[3] = "Thumper";
enemyList[5] = "Spider";
enemyList[4] = "Masked";
enemyList[6] = "Baboon Hawk";
enemyList[7] = "Nutcracker";
enemyList[8] = "Bracken";
enemyList[9] = "Eyeless Dog";
enemyList[10] = "Forest Giant";
secretList[0] = "Slime Buddy";
secretList[1] = "Pink Fumes";
secretList[2] = "Haunted Chase";
secretList[3] = "Drama";
secretList[4] = "Angry Turret";
secretList[5] = "BOOM";
secretList[6] = "Happy Birthday!";
secretList[7] = "Toot";
secretList[8] = "Ben Franklin";
RandomizeQuest();
HUDManager.Instance.DisplayTip("New Quest", questDesc[questID], false, false, "LC_Tip1");
}
public static void RandomizeQuest()
{
taskCompleted = false;
int num = random.Next(0, 10);
if (num < 7)
{
questID = 0;
num = random.Next(0, 10);
num = ((num < 6) ? random.Next(0, 10) : ((num >= 9) ? random.Next(26, itemList.Length) : random.Next(10, 26)));
itemID = num;
questDesc[0] = "Collect Quest:\n" + itemList[itemID];
}
else if (num < 9)
{
questID = 1;
num = random.Next(0, 10);
num = ((num < 5) ? random.Next(0, 3) : ((num >= 9) ? random.Next(8, enemyList.Length) : random.Next(3, 8)));
enemyID = num;
questDesc[1] = "Kill Quest:\n" + enemyList[enemyID];
}
else
{
questID = 2;
num = random.Next(0, secretList.Length);
secretID = num;
questDesc[2] = "Secret Quest:\n" + secretList[secretID];
}
}
public static void CompleteTask()
{
taskCompleted = true;
HUDManager.Instance.ClearControlTips();
HUDManager.Instance.DisplayTip("Task Completed", questDesc[questID], false, false, "LC_Tip1");
}
public static string GetItemName()
{
return itemList[itemID];
}
public static int GetReward()
{
int num = 50 + questID * 50;
if (questID == 0)
{
num += itemID * 3;
}
else if (questID == 1)
{
num += enemyID * 25;
}
return num;
}
public static void AbandonQuest()
{
RandomizeQuest();
HUDManager.Instance.ClearControlTips();
}
}
}
namespace SideQuests.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}