Decompiled source of ZetasTweaks v1.0.4

ZetasTweaks.dll

Decompiled 10 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Video;
using ZetasTweaks.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ZetasTweaks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ZetasTweaks")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("df8ce445-1c2b-4d11-8e47-707b490a33dd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ZetasTweaks
{
	public static class PluginInfo
	{
		public const string modGUID = "ZetasTweaks";

		public const string modName = "Zetas Tweaks";

		public const string modVersion = "1.0.4";
	}
	[BepInPlugin("ZetasTweaks", "Zetas Tweaks", "1.0.4")]
	public class ZetasTweaksBase : BaseUnityPlugin
	{
		public enum LifeIncrementType
		{
			Addition,
			Multiplier
		}

		private readonly Harmony harmony = new Harmony("ZetasTweaks");

		public static ZetasTweaksBase Instance;

		public static ConfigEntry<LifeIncrementType> Life_Increment_Type;

		public static ConfigEntry<bool> Respawn_Enabled;

		public static ConfigEntry<int> Respawn_Cost;

		public static ConfigEntry<bool> Respawn_Orbit_Only;

		public static ConfigEntry<int> Life_Increment_Amount;

		public static ConfigEntry<float> Life_Increment_Multiplier;

		public static string[] afterMethods;

		private ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("ZetasTweaks");
			mls.LogInfo((object)"Zetas Tweaks has awaken");
			ConfigSettings.BindConfigSettings();
			harmony.PatchAll(typeof(ZetasTweaksBase));
			harmony.PatchAll(typeof(ConfigSync));
			harmony.PatchAll(typeof(PlayerControllerB));
			harmony.PatchAll(typeof(StartOfRoundBPatch));
			harmony.PatchAll(typeof(ShopPricesBPatch));
			harmony.PatchAll(typeof(ShipTeleporterPatch));
			mls.LogInfo((object)"Zetas Tweaks loaded");
		}

		public static void Log(string message)
		{
			Instance.PassLog(message, isError: false);
		}

		public static void LogError(string message)
		{
			Instance.PassLog(message, isError: true);
		}

		private void PassLog(string message, bool isError)
		{
			if (isError)
			{
				mls.LogError((object)message);
			}
			else
			{
				mls.LogInfo((object)message);
			}
		}
	}
	[Serializable]
	public static class ConfigSettings
	{
		public static ConfigEntry<int> WalkieTalkieCost;

		public static ConfigEntry<int> FlashlightCost;

		public static ConfigEntry<int> ShovelCost;

		public static ConfigEntry<int> LockpickerCost;

		public static ConfigEntry<int> ProFlashlightCost;

		public static ConfigEntry<int> StunGrenadeCost;

		public static ConfigEntry<int> BoomboxCost;

		public static ConfigEntry<int> TZPCost;

		public static ConfigEntry<int> ZapGunCost;

		public static ConfigEntry<int> JetpackCost;

		public static ConfigEntry<int> ExtensionLadderCost;

		public static ConfigEntry<int> RadarBoosterCost;

		public static ConfigEntry<int> SprayPaintCost;

		public static ConfigEntry<int> SurvivalKitCost;

		public static ConfigEntry<int> TeleporterCost;

		public static ConfigEntry<int> InverseTeleporterCost;

		public static ConfigEntry<int> LoudHornCost;

		public static ConfigEntry<int> SignalTranslatorCost;

		public static ConfigEntry<int> CozyLightsCost;

		public static ConfigEntry<int> GreenSuitCost;

		public static ConfigEntry<int> HazardSuitCost;

		public static ConfigEntry<int> PajamaSuitCost;

		public static ConfigEntry<int> GoldfishCost;

		public static ConfigEntry<int> JackOLanternCost;

		public static ConfigEntry<int> TelevisionCost;

		public static ConfigEntry<int> RecordPlayerCost;

		public static ConfigEntry<int> RomanticTableCost;

		public static ConfigEntry<int> ShowerCost;

		public static ConfigEntry<int> TableCost;

		public static ConfigEntry<int> ToiletCost;

		public static ConfigEntry<int> WelcomeMatCost;

		public static ConfigEntry<int> PlushiePajamaManCost;

		public static ConfigEntry<bool> RespawnEnabled;

		public static ConfigEntry<bool> RespawnOrbitOnly;

		public static ConfigEntry<int> RespawnCost;

		public static ConfigEntry<bool> LifeIncrementEnabled;

		public static ConfigEntry<bool> LifeIncrementResets;

		public static ConfigEntry<ZetasTweaksBase.LifeIncrementType> LifeIncrementType;

		public static ConfigEntry<int> LifeIncrementAmount;

		public static ConfigEntry<float> LifeIncrementMultiplier;

		public static ConfigEntry<int> TPCooldown;

		public static ConfigEntry<int> ITPCooldown;

		public static void BindConfigSettings()
		{
			WalkieTalkieCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "WalkieTalkie", 12, "How much the walkie talkie should cost by default. Default value is 12.");
			FlashlightCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Flashlight", 15, "How much the Flashlight should cost by default. Default value is 15.");
			ShovelCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Shovel", 30, "How much the Shovel should cost by default. Default value is 30.");
			LockpickerCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Lockpicker", 20, "How much the Lockpicker should cost by default. Default value is 20.");
			ProFlashlightCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "ProFlashlight", 25, "How much the Pro-Flashlight should cost by default. Default value is 25.");
			StunGrenadeCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Stun granade", 40, "How much the Stun grenade should cost by default. Default value is 40.");
			BoomboxCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Boombox", 60, "How much the Boombox should cost by default. Default value is 60.");
			TZPCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "TZP", 120, "How much the TZP Inhalant should cost by default. Default value is 120.");
			ZapGunCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Zap gun", 400, "How much the Zap gun should cost by default. Default value is 400.");
			JetpackCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Jetpack", 700, "How much the Jetpack should cost by default. Default value is 700.");
			ExtensionLadderCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Extension ladder", 60, "How much the Extension Ladder should cost by default. Default value is 60.");
			RadarBoosterCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Radar booster", 50, "How much the Radar Booster should cost by default. Default value is 50.");
			SprayPaintCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Spray paint", 50, "How much the Spray paint should cost by default. Default value is 50.");
			SurvivalKitCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Survival Kit", 138, "How much the Survival Kit should cost by default. Default value is 138.");
			TeleporterCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Teleporter", 375, "How much the Teleporter should cost by default. Default value is 375.");
			InverseTeleporterCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Inverse Teleporter", 425, "How much the Inverse Teleporter should cost by default. Default value is 425.");
			LoudHornCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Loud Horn", 100, "How much the Loud Horn should cost by default. Default value is 100.");
			SignalTranslatorCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Signal Translator", 255, "How much the Signal Translator should cost by default. Default value is 255.");
			CozyLightsCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Cozy Lights", 140, "How much the Cozy Lights should cost by default. Default value is 140.");
			GreenSuitCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Green Suit", 60, "How much the Green Suit should cost by default. Default value is 60.");
			HazardSuitCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Hazard Suit", 90, "How much the Hazard Suit should cost by default. Default value is 90.");
			PajamaSuitCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Pajama Suit", 900, "How much the Pajama Suit should cost by default. Default value is 900.");
			GoldfishCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Goldfish", 50, "How much the Goldfish should cost by default. Default value is 50.");
			JackOLanternCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Jack O Lantern", 50, "How much the Jack O Lantern should cost by default. Default value is 50.");
			TelevisionCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Television", 130, "How much the Television should cost by default. Default value is 130.");
			RecordPlayerCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Record Player", 120, "How much the Record Player should cost by default. Default value is 120.");
			RomanticTableCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Romantic Table", 120, "How much the Romantic Table should cost by default. Default value is 120.");
			ShowerCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Shower", 180, "How much the Shower should cost by default. Default value is 180.");
			TableCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Table", 70, "How much the Table should cost by default. Default value is 70.");
			ToiletCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Toilet", 150, "How much the Toilet should cost by default. Default value is 150.");
			WelcomeMatCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Welcome Mat", 40, "How much the Welcome Mat should cost by default. Default value is 40.");
			PlushiePajamaManCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Shop Prices", "Plushie Pajama Man", 100, "How much the Plushie Pajama Man should cost by default. Default value is 100.");
			RespawnEnabled = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<bool>("Respawn Settings", "Respawn Enabled", true, "Whether you can pay to respawn employees. All following respawn-related settings only work with this on. Default value is True.");
			RespawnOrbitOnly = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<bool>("Respawn Settings", "Respawn Orbit Only", true, "Whether you can only respawn employees in orbit, intended for use with the Permadeath mod. If playing without the mod, false is recommended if you want to be able to respawn employees mid-mission as orbit is pointless. Default value is True.");
			RespawnCost = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Respawn Settings", "Respawn Cost", 100, "The starting amount of the respawn cost. Default is 100.");
			LifeIncrementEnabled = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<bool>("Respawn Settings", "Life Increment Enabled", true, "Whether the respawn cost of an employee increases each time. Default value is True.");
			LifeIncrementResets = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<bool>("Respawn Settings", "Life Increment Resets", true, "Whether the respawn cost an employee resets each quota. Default value is True.");
			LifeIncrementType = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<ZetasTweaksBase.LifeIncrementType>("Respawn Settings", "Life Increment Type", ZetasTweaksBase.LifeIncrementType.Addition, "How to increase the employee respawn cost. If 'Addition', it will use the 'Life Increment Amount', and ADD that amount each respawn. If 'Multiplier', it will use the 'Life Increment Multiplier', and MULTIPLY by that amount each respawn. Default value is 'Addition'.");
			LifeIncrementAmount = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Respawn Settings", "Life Increment Amount", 100, "How much to add to the respawn cost each time, if 'Life Increment Type' is set to 'Addition'. Default value is 100.");
			LifeIncrementMultiplier = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<float>("Respawn Settings", "Life Increment Multiplier", 2f, "How much to multiply the respawn cost each time, if 'Life Increment Type' is set to 'Multiply'. Default value is 2.0.");
			TPCooldown = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Misc Settings", "TPCooldown", 10, "How long the cooldown is on the teleporter, in seconds. Default value is 10.");
			ITPCooldown = ((BaseUnityPlugin)ZetasTweaksBase.Instance).Config.Bind<int>("Misc Settings", "ITPCooldown", 210, "How long the cooldown is on the inverse teleporter, in seconds. Default value is 210 (3 minutes 30 seconds)");
		}
	}
	[Serializable]
	[HarmonyPatch]
	public class ConfigSync
	{
		public static ConfigSync defaultConfig;

		public static ConfigSync instance;

		public static PlayerControllerB localPlayerController;

		public static bool isSynced;

		public int WalkieTalkieCost = 12;

		public int FlashlightCost = 15;

		public int ShovelCost = 30;

		public int LockpickerCost = 20;

		public int ProFlashlightCost = 25;

		public int StunGrenadeCost = 40;

		public int BoomboxCost = 60;

		public int TZPCost = 120;

		public int ZapGunCost = 400;

		public int JetpackCost = 700;

		public int ExtensionLadderCost = 60;

		public int RadarBoosterCost = 50;

		public int SprayPaintCost = 50;

		public int SurvivalKitCost;

		public int TeleporterCost;

		public int InverseTeleporterCost;

		public int LoudHornCost;

		public int SignalTranslatorCost;

		public int CozyLightsCost;

		public int GreenSuitCost;

		public int HazardSuitCost;

		public int PajamaSuitCost;

		public int GoldfishCost;

		public int JackOLanternCost;

		public int TelevisionCost;

		public int RecordPlayerCost;

		public int RomanticTableCost;

		public int ShowerCost;

		public int TableCost;

		public int ToiletCost;

		public int WelcomeMatCost;

		public int PlushiePajamaManCost;

		public bool RespawnEnabled = true;

		public bool RespawnOrbitOnly = true;

		public int RespawnCost = 100;

		public bool LifeIncrementEnabled = true;

		public bool LifeIncrementResets = true;

		public ZetasTweaksBase.LifeIncrementType LifeIncrementType = ZetasTweaksBase.LifeIncrementType.Addition;

		public int LifeIncremenentAmount = 100;

		public float LifeIncrementMultiplier = 2f;

		public int TPCooldown = 10;

		public int ITPCooldown = 210;

		public static void BuildServerConfigSync()
		{
			if (defaultConfig == null)
			{
				defaultConfig = new ConfigSync();
				defaultConfig.WalkieTalkieCost = Mathf.Clamp(ConfigSettings.WalkieTalkieCost.Value, 1, 9999);
				defaultConfig.FlashlightCost = Mathf.Clamp(ConfigSettings.FlashlightCost.Value, 1, 9999);
				defaultConfig.ShovelCost = Mathf.Clamp(ConfigSettings.ShovelCost.Value, 1, 9999);
				defaultConfig.LockpickerCost = Mathf.Clamp(ConfigSettings.LockpickerCost.Value, 1, 9999);
				defaultConfig.ProFlashlightCost = Mathf.Clamp(ConfigSettings.ProFlashlightCost.Value, 1, 9999);
				defaultConfig.StunGrenadeCost = Mathf.Clamp(ConfigSettings.StunGrenadeCost.Value, 1, 9999);
				defaultConfig.BoomboxCost = Mathf.Clamp(ConfigSettings.BoomboxCost.Value, 1, 9999);
				defaultConfig.TZPCost = Mathf.Clamp(ConfigSettings.TZPCost.Value, 1, 9999);
				defaultConfig.ZapGunCost = Mathf.Clamp(ConfigSettings.ZapGunCost.Value, 1, 9999);
				defaultConfig.JetpackCost = Mathf.Clamp(ConfigSettings.JetpackCost.Value, 1, 9999);
				defaultConfig.ExtensionLadderCost = Mathf.Clamp(ConfigSettings.ExtensionLadderCost.Value, 1, 9999);
				defaultConfig.RadarBoosterCost = Mathf.Clamp(ConfigSettings.RadarBoosterCost.Value, 1, 9999);
				defaultConfig.SprayPaintCost = Mathf.Clamp(ConfigSettings.SprayPaintCost.Value, 1, 9999);
				defaultConfig.SurvivalKitCost = Mathf.Clamp(ConfigSettings.SurvivalKitCost.Value, 1, 9999);
				defaultConfig.TeleporterCost = Mathf.Clamp(ConfigSettings.TeleporterCost.Value, 1, 9999);
				defaultConfig.InverseTeleporterCost = Mathf.Clamp(ConfigSettings.InverseTeleporterCost.Value, 1, 9999);
				defaultConfig.LoudHornCost = Mathf.Clamp(ConfigSettings.LoudHornCost.Value, 1, 9999);
				defaultConfig.SignalTranslatorCost = Mathf.Clamp(ConfigSettings.SignalTranslatorCost.Value, 1, 9999);
				defaultConfig.CozyLightsCost = Mathf.Clamp(ConfigSettings.CozyLightsCost.Value, 1, 9999);
				defaultConfig.GreenSuitCost = Mathf.Clamp(ConfigSettings.GreenSuitCost.Value, 1, 9999);
				defaultConfig.HazardSuitCost = Mathf.Clamp(ConfigSettings.HazardSuitCost.Value, 1, 9999);
				defaultConfig.PajamaSuitCost = Mathf.Clamp(ConfigSettings.PajamaSuitCost.Value, 1, 9999);
				defaultConfig.GoldfishCost = Mathf.Clamp(ConfigSettings.GoldfishCost.Value, 1, 9999);
				defaultConfig.JackOLanternCost = Mathf.Clamp(ConfigSettings.JackOLanternCost.Value, 1, 9999);
				defaultConfig.TelevisionCost = Mathf.Clamp(ConfigSettings.TelevisionCost.Value, 1, 9999);
				defaultConfig.RecordPlayerCost = Mathf.Clamp(ConfigSettings.RecordPlayerCost.Value, 1, 9999);
				defaultConfig.RomanticTableCost = Mathf.Clamp(ConfigSettings.RomanticTableCost.Value, 1, 9999);
				defaultConfig.ShowerCost = Mathf.Clamp(ConfigSettings.ShowerCost.Value, 1, 9999);
				defaultConfig.TableCost = Mathf.Clamp(ConfigSettings.TableCost.Value, 1, 9999);
				defaultConfig.ToiletCost = Mathf.Clamp(ConfigSettings.ToiletCost.Value, 1, 9999);
				defaultConfig.WelcomeMatCost = Mathf.Clamp(ConfigSettings.WelcomeMatCost.Value, 1, 9999);
				defaultConfig.PlushiePajamaManCost = Mathf.Clamp(ConfigSettings.PlushiePajamaManCost.Value, 1, 9999);
				defaultConfig.RespawnEnabled = ConfigSettings.RespawnEnabled.Value;
				defaultConfig.RespawnOrbitOnly = ConfigSettings.RespawnOrbitOnly.Value;
				defaultConfig.RespawnCost = Mathf.Clamp(ConfigSettings.RespawnCost.Value, 1, 9999);
				defaultConfig.LifeIncrementEnabled = ConfigSettings.LifeIncrementEnabled.Value;
				defaultConfig.LifeIncrementResets = ConfigSettings.LifeIncrementResets.Value;
				defaultConfig.LifeIncrementType = ConfigSettings.LifeIncrementType.Value;
				defaultConfig.LifeIncremenentAmount = Mathf.Clamp(ConfigSettings.LifeIncrementAmount.Value, 1, 9999);
				defaultConfig.LifeIncrementMultiplier = Mathf.Clamp(ConfigSettings.LifeIncrementMultiplier.Value, 0.1f, 9999f);
				defaultConfig.TPCooldown = Mathf.Clamp(ConfigSettings.TPCooldown.Value, 0, 9999);
				defaultConfig.ITPCooldown = Mathf.Clamp(ConfigSettings.ITPCooldown.Value, 0, 9999);
				instance = defaultConfig;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void InitializeLocalPlayer(PlayerControllerB __instance)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			localPlayerController = __instance;
			if (NetworkManager.Singleton.IsServer)
			{
				BuildServerConfigSync();
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("ZetasTweaks-OnRequestConfigSync", new HandleNamedMessageDelegate(OnReceiveConfigSyncRequest));
				OnLocalClientConfigSync();
			}
			else
			{
				isSynced = false;
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("ZetasTweaks-OnReceiveConfigSync", new HandleNamedMessageDelegate(OnReceiveConfigSync));
				RequestConfigSync();
			}
		}

		public static void RequestConfigSync()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsClient)
			{
				ZetasTweaksBase.Log("Sending config sync request to server.");
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("ZetasTweaks-OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			else
			{
				ZetasTweaksBase.LogError("Failed to send config sync request.");
			}
		}

		public static void OnReceiveConfigSyncRequest(ulong clientId, FastBufferReader reader)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer)
			{
				ZetasTweaksBase.Log("Receiving config sync request from client with id: " + clientId + ". Sending config sync to client.");
				byte[] array = SerializeConfigToByteArray(instance);
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(array.Length + 4, (Allocator)2, -1);
				int num = array.Length;
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("ZetasTweaks-OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
		}

		public static void OnReceiveConfigSync(ulong clientId, FastBufferReader reader)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (((FastBufferReader)(ref reader)).TryBeginRead(4))
			{
				int num = default(int);
				((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
				if (((FastBufferReader)(ref reader)).TryBeginRead(num))
				{
					ZetasTweaksBase.Log("Receiving config sync from server.");
					byte[] data = new byte[num];
					((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
					instance = DeserializeFromByteArray(data);
					OnLocalClientConfigSync();
				}
				else
				{
					ZetasTweaksBase.LogError("Error receiving sync from server.");
				}
			}
			else
			{
				ZetasTweaksBase.LogError("Error receiving bytes length.");
			}
		}

		public static void OnLocalClientConfigSync()
		{
			isSynced = true;
		}

		public static byte[] SerializeConfigToByteArray(ConfigSync config)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			MemoryStream memoryStream = new MemoryStream();
			binaryFormatter.Serialize(memoryStream, config);
			return memoryStream.ToArray();
		}

		public static ConfigSync DeserializeFromByteArray(byte[] data)
		{
			MemoryStream serializationStream = new MemoryStream(data);
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			return (ConfigSync)binaryFormatter.Deserialize(serializationStream);
		}
	}
}
namespace ZetasTweaks.Patches
{
	public class Item : ScriptableObject
	{
		public int itemId;

		public string itemName;

		[Space(3f)]
		public List<ItemGroup> spawnPositionTypes = new List<ItemGroup>();

		[Space(3f)]
		public bool twoHanded;

		public bool twoHandedAnimation;

		public bool canBeGrabbedBeforeGameStart;

		[Space(3f)]
		public float weight = 1f;

		public bool itemIsTrigger;

		public bool holdButtonUse;

		public bool itemSpawnsOnGround = true;

		[Space(5f)]
		public bool isConductiveMetal;

		[Header("Scrap-collection")]
		public bool isScrap;

		public int creditsWorth;

		public bool lockedInDemo;

		public int highestSalePercentage = 80;

		[Space(3f)]
		public int maxValue;

		public int minValue;

		public GameObject spawnPrefab;

		[Space(3f)]
		[Header("Battery")]
		public bool requiresBattery = true;

		public float batteryUsage = 15f;

		public bool automaticallySetUsingPower = true;

		[Space(5f)]
		public Sprite itemIcon;

		[Space(5f)]
		[Header("Player animations")]
		public string grabAnim;

		public string useAnim;

		public string pocketAnim;

		public string throwAnim;

		[Space(5f)]
		public float grabAnimationTime;

		[Header("Player SFX")]
		public AudioClip grabSFX;

		public AudioClip dropSFX;

		public AudioClip pocketSFX;

		public AudioClip throwSFX;

		[Header("Netcode")]
		public bool syncGrabFunction = true;

		public bool syncUseFunction = true;

		public bool syncDiscardFunction = true;

		public bool syncInteractLRFunction = true;

		[Header("Save data")]
		public bool saveItemVariable;

		[Header("MISC")]
		public bool isDefensiveWeapon;

		[Space(3f)]
		public string[] toolTips;

		public float verticalOffset;

		public int floorYOffset;

		public bool allowDroppingAheadOfPlayer = true;

		public Vector3 restingRotation = new Vector3(0f, 0f, 90f);

		public Vector3 rotationOffset = Vector3.zero;

		public Vector3 positionOffset = Vector3.zero;

		public bool meshOffset = true;

		public Mesh[] meshVariants;

		public Material[] materialVariants;

		public bool usableInSpecialAnimations;

		public bool canBeInspected = true;
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	internal class ShipTeleporterPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		private static void customCooldown(ref float ___cooldownAmount, ref bool ___isInverseTeleporter)
		{
			if (___isInverseTeleporter)
			{
				___cooldownAmount = ConfigSync.instance.ITPCooldown;
			}
			else
			{
				___cooldownAmount = ConfigSync.instance.TPCooldown;
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundBPatch
	{
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class ShopPricesBPatch
	{
		[HarmonyPatch("BeginUsingTerminal")]
		[HarmonyPostfix]
		private static void StorePrices(ref Item[] ___buyableItemsList, ref List<TerminalNode> ___ShipDecorSelection)
		{
			___buyableItemsList[0].creditsWorth = ConfigSync.instance.WalkieTalkieCost;
			ZetasTweaksBase.Log("Walkie shop price was overriden to: " + ___buyableItemsList[0].creditsWorth);
			___buyableItemsList[1].creditsWorth = ConfigSync.instance.FlashlightCost;
			___buyableItemsList[2].creditsWorth = ConfigSync.instance.ShovelCost;
			___buyableItemsList[3].creditsWorth = ConfigSync.instance.LockpickerCost;
			___buyableItemsList[4].creditsWorth = ConfigSync.instance.ProFlashlightCost;
			___buyableItemsList[5].creditsWorth = ConfigSync.instance.StunGrenadeCost;
			___buyableItemsList[6].creditsWorth = ConfigSync.instance.BoomboxCost;
			___buyableItemsList[7].creditsWorth = ConfigSync.instance.TZPCost;
			___buyableItemsList[8].creditsWorth = ConfigSync.instance.ZapGunCost;
			___buyableItemsList[9].creditsWorth = ConfigSync.instance.JetpackCost;
			___buyableItemsList[10].creditsWorth = ConfigSync.instance.ExtensionLadderCost;
			___buyableItemsList[11].creditsWorth = ConfigSync.instance.RadarBoosterCost;
			___buyableItemsList[12].creditsWorth = ConfigSync.instance.SprayPaintCost;
			StartOfRound.Instance.unlockablesList.unlockables[1].shopSelectionNode.itemCost = ConfigSync.instance.GreenSuitCost;
			StartOfRound.Instance.unlockablesList.unlockables[2].shopSelectionNode.itemCost = ConfigSync.instance.HazardSuitCost;
			StartOfRound.Instance.unlockablesList.unlockables[3].shopSelectionNode.itemCost = ConfigSync.instance.PajamaSuitCost;
			StartOfRound.Instance.unlockablesList.unlockables[4].shopSelectionNode.itemCost = ConfigSync.instance.CozyLightsCost;
			StartOfRound.Instance.unlockablesList.unlockables[6].shopSelectionNode.itemCost = ConfigSync.instance.TelevisionCost;
			StartOfRound.Instance.unlockablesList.unlockables[9].shopSelectionNode.itemCost = ConfigSync.instance.ToiletCost;
			StartOfRound.Instance.unlockablesList.unlockables[10].shopSelectionNode.itemCost = ConfigSync.instance.ShowerCost;
			StartOfRound.Instance.unlockablesList.unlockables[12].shopSelectionNode.itemCost = ConfigSync.instance.RecordPlayerCost;
			StartOfRound.Instance.unlockablesList.unlockables[13].shopSelectionNode.itemCost = ConfigSync.instance.TableCost;
			StartOfRound.Instance.unlockablesList.unlockables[14].shopSelectionNode.itemCost = ConfigSync.instance.RomanticTableCost;
			StartOfRound.Instance.unlockablesList.unlockables[17].shopSelectionNode.itemCost = ConfigSync.instance.SignalTranslatorCost;
			StartOfRound.Instance.unlockablesList.unlockables[20].shopSelectionNode.itemCost = ConfigSync.instance.JackOLanternCost;
			StartOfRound.Instance.unlockablesList.unlockables[21].shopSelectionNode.itemCost = ConfigSync.instance.WelcomeMatCost;
			StartOfRound.Instance.unlockablesList.unlockables[22].shopSelectionNode.itemCost = ConfigSync.instance.GoldfishCost;
			StartOfRound.Instance.unlockablesList.unlockables[23].shopSelectionNode.itemCost = ConfigSync.instance.PlushiePajamaManCost;
		}
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/TerminalNode", order = 2)]
	public class TerminalNode : ScriptableObject
	{
		[TextArea(2, 20)]
		public string displayText;

		public string terminalEvent;

		[Space(5f)]
		public bool clearPreviousText;

		public int maxCharactersToType = 25;

		[Space(5f)]
		[Header("Purchasing items")]
		public int buyItemIndex = -1;

		public bool isConfirmationNode;

		public int buyRerouteToMoon = -1;

		public int displayPlanetInfo = -1;

		public bool lockedInDemo;

		[Space(3f)]
		public int shipUnlockableID = -1;

		public bool buyUnlockable;

		public bool returnFromStorage;

		[Space(3f)]
		public int itemCost;

		[Header("Bestiary / Logs")]
		public int creatureFileID = -1;

		public string creatureName;

		public int storyLogFileID = -1;

		[Space(5f)]
		public bool overrideOptions;

		public bool acceptAnything;

		public CompatibleNoun[] terminalOptions;

		[Header("Misc")]
		public AudioClip playClip;

		public int playSyncedClip = -1;

		public Texture displayTexture;

		public VideoClip displayVideo;

		public bool loadImageSlowly;

		public bool persistentImage;
	}
	public class UnlockableItem
	{
		public string unlockableName;

		public GameObject prefabObject;

		public int unlockableType;

		[Space(5f)]
		public TerminalNode shopSelectionNode;

		public bool alwaysInStock;

		[Space(3f)]
		public bool IsPlaceable;

		[Space(3f)]
		public bool hasBeenMoved;

		public Vector3 placedPosition;

		public Vector3 placedRotation;

		[Space(3f)]
		public bool inStorage;

		public bool canBeStored = true;

		public int maxNumber = 1;

		[Space(3f)]
		public bool hasBeenUnlockedByPlayer;

		[Space(5f)]
		public Material suitMaterial;

		public bool alreadyUnlocked;

		public bool unlockedInChallengeFile;

		public bool spawnPrefab = true;
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/Unlockables", order = 2)]
	public class UnlockablesList : ScriptableObject
	{
		public List<UnlockableItem> unlockables = new List<UnlockableItem>();
	}
}