Decompiled source of DiscoveryFeed v1.2.2

plugins/DiscoveryFeed/DiscoveryFeed.dll

Decompiled 9 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("DiscoveryFeed")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2")]
[assembly: AssemblyProduct("DiscoveryFeed")]
[assembly: AssemblyTitle("DiscoveryFeed")]
[assembly: AssemblyVersion("1.2.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 DiscoveryFeed
{
	internal static class CraftFeed
	{
		internal struct Key
		{
			internal string Kind;

			internal string Item;

			internal int Quality;

			internal string Station;

			internal int StationLevel;
		}

		internal const string Rpc = "DiscoveryFeed_Crafted";

		private const float FlushDelay = 4f;

		private static readonly Dictionary<Key, int> Pending = new Dictionary<Key, int>();

		private static float _flushAt;

		internal static void Add(Key k, int amount)
		{
			Pending.TryGetValue(k, out var value);
			Pending[k] = value + amount;
			_flushAt = Time.unscaledTime + 4f;
		}

		internal static void Tick()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			if (Pending.Count == 0 || Time.unscaledTime < _flushAt)
			{
				return;
			}
			if (ZRoutedRpc.instance == null || (Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer())
			{
				Pending.Clear();
				return;
			}
			ZPackage val = new ZPackage();
			val.Write(1);
			val.Write(Pending.Count);
			foreach (KeyValuePair<Key, int> item in Pending)
			{
				val.Write(item.Key.Kind);
				val.Write(item.Key.Item);
				val.Write(item.Key.Quality);
				val.Write(item.Key.Station ?? "");
				val.Write(item.Key.StationLevel);
				val.Write(item.Value);
			}
			ZRoutedRpc.instance.InvokeRoutedRPC("DiscoveryFeed_Crafted", new object[1] { val });
			Plugin.Log.LogInfo((object)$"Sent {Pending.Count} crafting entries to server");
			Pending.Clear();
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
	internal static class DoCraftingPatch
	{
		internal static bool Active;

		internal static string ItemPrefab;

		internal static string ItemName;

		internal static string Station;

		internal static int TargetQuality;

		internal static int StationLevel;

		internal static bool Upgrade;

		internal static bool Added;

		private static void Prefix(InventoryGui __instance, Player player)
		{
			Active = false;
			try
			{
				Recipe value = Traverse.Create((object)__instance).Field("m_craftRecipe").GetValue<Recipe>();
				ItemData value2 = Traverse.Create((object)__instance).Field("m_craftUpgradeItem").GetValue<ItemData>();
				if (!((Object)(object)value == (Object)null) && !((Object)(object)value.m_item == (Object)null) && !((Object)(object)player != (Object)(object)Player.m_localPlayer))
				{
					ItemPrefab = ((Object)((Component)value.m_item).gameObject).name;
					ItemName = value.m_item.m_itemData.m_shared.m_name;
					Upgrade = value2 != null;
					TargetQuality = ((!Upgrade) ? 1 : (value2.m_quality + 1));
					CraftingStation currentCraftingStation = player.GetCurrentCraftingStation();
					Station = (((Object)(object)currentCraftingStation != (Object)null) ? currentCraftingStation.m_name : "");
					StationLevel = (((Object)(object)currentCraftingStation != (Object)null) ? currentCraftingStation.GetLevel(true) : 0);
					Added = false;
					Active = true;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("craft prefix: " + ex.Message));
			}
		}

		private static void Postfix(InventoryGui __instance)
		{
			if (!Active)
			{
				return;
			}
			Active = false;
			try
			{
				ItemData value = Traverse.Create((object)__instance).Field("m_craftUpgradeItem").GetValue<ItemData>();
				if (Upgrade && !Added && value != null && !((Humanoid)Player.m_localPlayer).GetInventory().ContainsItem(value))
				{
					CraftFeed.Add(new CraftFeed.Key
					{
						Kind = "upgrade_broke",
						Item = ItemName,
						Quality = TargetQuality - 1,
						Station = Station,
						StationLevel = StationLevel
					}, 1);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("craft postfix: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
	{
		typeof(string),
		typeof(int),
		typeof(int),
		typeof(int),
		typeof(long),
		typeof(string),
		typeof(Vector2i),
		typeof(bool),
		typeof(bool),
		typeof(bool)
	})]
	internal static class AddItemPatch
	{
		private static void Postfix(string name, int stack, int quality, ItemData __result)
		{
			if (DoCraftingPatch.Active && __result != null && !(name != DoCraftingPatch.ItemPrefab))
			{
				DoCraftingPatch.Added = true;
				string kind = ((!DoCraftingPatch.Upgrade) ? "craft" : ((quality >= DoCraftingPatch.TargetQuality) ? "upgrade" : "upgrade_failed"));
				CraftFeed.Add(new CraftFeed.Key
				{
					Kind = kind,
					Item = DoCraftingPatch.ItemName,
					Quality = quality,
					Station = DoCraftingPatch.Station,
					StationLevel = DoCraftingPatch.StationLevel
				}, DoCraftingPatch.Upgrade ? 1 : stack);
			}
		}
	}
	[HarmonyPatch(typeof(Fermenter), "Interact")]
	internal static class FermenterTapPatch
	{
		private static void Prefix(Fermenter __instance, Humanoid user, bool hold)
		{
			try
			{
				if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer)
				{
					return;
				}
				Traverse val = Traverse.Create((object)__instance);
				if (!(val.Method("GetStatus", Array.Empty<object>()).GetValue()?.ToString() != "Ready"))
				{
					int value = val.Method("GetContent", Array.Empty<object>()).GetValue<int>();
					ItemConversion value2 = val.Method("GetItemConversion", new object[1] { value }).GetValue<ItemConversion>();
					if (!((Object)(object)value2?.m_to == (Object)null))
					{
						CraftFeed.Add(new CraftFeed.Key
						{
							Kind = "tap",
							Item = value2.m_to.m_itemData.m_shared.m_name,
							Quality = 1,
							Station = (((Component)__instance).GetComponent<Piece>()?.m_name ?? __instance.m_name),
							StationLevel = 0
						}, value2.m_producedItems);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("fermenter: " + ex.Message));
			}
		}
	}
	internal static class Komutlar
	{
		internal const string AdminRpc = "HuginRelay_Admin";

		internal const string ReplyRpc = "HuginRelay_AdminReply";

		private static ZRoutedRpc _kayitli;

		internal static readonly int Katilar = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" });

		internal static void Ekle()
		{
			CommandManager instance = CommandManager.Instance;
			instance.AddConsoleCommand((ConsoleCommand)(object)new SunucuKomutu("duyuru", "duyuru <mesaj> - mesajı oyundaki herkesin ekranında gösterir (yönetici)", argGerekli: true));
			instance.AddConsoleCommand((ConsoleCommand)(object)new SunucuKomutu("restart", "restart <dakika> | restart iptal - sunucuyu geri sayımla güvenle yeniden başlatır (yönetici)", argGerekli: true));
			instance.AddConsoleCommand((ConsoleCommand)(object)new SunucuKomutu("kaydet", "kaydet - dünyayı ve herkesin karakterini şimdi kaydeder, anlık yedek alınır (yönetici)", argGerekli: false));
			instance.AddConsoleCommand((ConsoleCommand)(object)new SunucuKomutu("yedekler", "yedekler - son anlık yedekleri listeler (yönetici)", argGerekli: false));
			instance.AddConsoleCommand((ConsoleCommand)(object)new SunucuKomutu("durum", "durum - oyundakiler, açık kalma süresi, son kayıt ve yedek (yönetici)", argGerekli: false));
			instance.AddConsoleCommand((ConsoleCommand)(object)new KurtarKomutu());
			instance.AddConsoleCommand((ConsoleCommand)(object)new EsyaKurtarKomutu());
			instance.AddConsoleCommand((ConsoleCommand)(object)new KarakterKaydetKomutu());
		}

		internal static bool Gonder(string komut, string arg)
		{
			ZRoutedRpc instance = ZRoutedRpc.instance;
			if (instance == null || (Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer())
			{
				return false;
			}
			if (_kayitli != instance)
			{
				instance.Register<string>("HuginRelay_AdminReply", (Action<long, string>)Cevap);
				_kayitli = instance;
			}
			instance.InvokeRoutedRPC("HuginRelay_Admin", new object[2]
			{
				komut,
				arg ?? ""
			});
			return true;
		}

		private static void Cevap(long sender, string metin)
		{
			string[] array = (metin ?? "").Split(new char[1] { '\n' });
			foreach (string text in array)
			{
				if ((Object)(object)Console.instance != (Object)null)
				{
					((Terminal)Console.instance).AddString("<color=#9fd3ff>[sunucu]</color> " + text);
				}
			}
			string text2 = (metin ?? "").Split(new char[1] { '\n' })[0];
			if ((Object)(object)MessageHud.instance != (Object)null && text2.Length > 0)
			{
				MessageHud.instance.ShowMessage((MessageType)1, text2, 0, (Sprite)null, false, true);
			}
		}
	}
	internal class SunucuKomutu : ConsoleCommand
	{
		private readonly string _ad;

		private readonly string _yardim;

		private readonly bool _argGerekli;

		public override string Name => _ad;

		public override string Help => _yardim;

		public SunucuKomutu(string ad, string yardim, bool argGerekli)
		{
			_ad = ad;
			_yardim = yardim;
			_argGerekli = argGerekli;
		}

		public override void Run(string[] args, Terminal context)
		{
			string text = string.Join(" ", args ?? new string[0]).Trim();
			if (_argGerekli && text.Length == 0)
			{
				if (context != null)
				{
					context.AddString("Kullanım: " + _yardim);
				}
			}
			else if (!Komutlar.Gonder(_ad, text))
			{
				if (context != null)
				{
					context.AddString("Bu komut yalnız bir sunucuya bağlıyken çalışır.");
				}
			}
			else if (context != null)
			{
				context.AddString("Sunucuya gönderildi, cevap bekleniyor...");
			}
		}
	}
	internal class KurtarKomutu : ConsoleCommand
	{
		private static float _son = -100f;

		public override string Name => "kurtar";

		public override string Help => "kurtar - kaya, yapı ya da toprak içinde sıkıştıysan seni hemen üstündeki ilk boş yüzeye çıkarır (en fazla 50 m)";

		public override void Run(string[] args, Terminal context)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || ((Character)localPlayer).IsTeleporting())
			{
				if (context != null)
				{
					context.AddString("Şu an kullanılamaz.");
				}
				return;
			}
			if (Time.time - _son < 10f)
			{
				if (context != null)
				{
					context.AddString("Biraz bekle (10 saniyede bir kullanılabilir).");
				}
				return;
			}
			Vector3 pos = ((Component)localPlayer).transform.position;
			List<RaycastHit> list = (from h in Physics.RaycastAll(pos + Vector3.up * 50f, Vector3.down, 52f, Komutlar.Katilar, (QueryTriggerInteraction)1)
				where ((RaycastHit)(ref h)).normal.y > 0.4f && ((RaycastHit)(ref h)).point.y > pos.y - 1f
				orderby ((RaycastHit)(ref h)).point.y
				select h).ToList();
			Vector3? val = null;
			foreach (RaycastHit item in list)
			{
				RaycastHit current = item;
				Vector3 val2 = ((RaycastHit)(ref current)).point + Vector3.up * 0.05f;
				if (!Physics.CheckCapsule(val2 + Vector3.up * 0.5f, val2 + Vector3.up * 1.5f, 0.35f, Komutlar.Katilar, (QueryTriggerInteraction)1))
				{
					val = val2;
					break;
				}
			}
			if (!val.HasValue)
			{
				if (context != null)
				{
					context.AddString("Üstünde 50 m içinde boş bir yüzey bulunamadı.");
				}
				return;
			}
			_son = Time.time;
			Vector3 val3 = val.Value + Vector3.up * 0.1f;
			((Component)localPlayer).transform.position = val3;
			Rigidbody component = ((Component)localPlayer).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.position = val3;
				component.linearVelocity = Vector3.zero;
			}
			Plugin.Log.LogInfo((object)$"kurtar: {pos:F1} -> {val3:F1}");
			if (context != null)
			{
				context.AddString($"{val3.y - pos.y:0.0} m yukarı çıkarıldın.");
			}
		}
	}
	internal class EsyaKurtarKomutu : ConsoleCommand
	{
		public override string Name => "esyakurtar";

		public override string Help => "esyakurtar - 30 m içinde yerin altına düşmüş eşyaları ayağının dibine getirir";

		public override void Run(string[] args, Terminal context)
		{
			//IL_0031: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null)
			{
				if (context != null)
				{
					context.AddString("Şu an kullanılamaz.");
				}
				return;
			}
			Vector3 position = ((Component)localPlayer).transform.position;
			int num = 0;
			ItemDrop[] array = Object.FindObjectsByType<ItemDrop>((FindObjectsSortMode)0);
			foreach (ItemDrop val in array)
			{
				if ((Object)(object)val == (Object)null || val.IsPiece())
				{
					continue;
				}
				Vector3 position2 = ((Component)val).transform.position;
				Vector2 val2 = new Vector2(position2.x - position.x, position2.z - position.z);
				if (((Vector2)(ref val2)).magnitude > 30f || position2.y >= ZoneSystem.instance.GetGroundHeight(position2) - 0.5f)
				{
					continue;
				}
				ZNetView component = ((Component)val).GetComponent<ZNetView>();
				if (!((Object)(object)component == (Object)null) && component.IsValid())
				{
					component.ClaimOwnership();
					Vector3 val3 = position + ((Component)localPlayer).transform.forward * 1.2f + Vector3.up * 0.8f + new Vector3((float)(num % 3 - 1) * 0.4f, (float)(num / 3) * 0.3f, 0f);
					((Component)val).transform.position = val3;
					Rigidbody component2 = ((Component)val).GetComponent<Rigidbody>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.position = val3;
						component2.linearVelocity = Vector3.zero;
					}
					Plugin.Log.LogInfo((object)$"esyakurtar: {val.m_itemData?.m_shared?.m_name} {position2:F1} -> {val3:F1}");
					num++;
				}
			}
			if (context != null)
			{
				context.AddString((num == 0) ? "Yakında yerin altına düşmüş eşya yok." : $"{num} eşya ayağının dibine getirildi.");
			}
		}
	}
	internal class KarakterKaydetKomutu : ConsoleCommand
	{
		private static float _son = -100f;

		public override string Name => "karakterkaydet";

		public override string Help => "karakterkaydet - karakterini şimdi sunucudaki kasaya kaydeder (dünya kaydı tetiklenmez); sunucu ayrıca bir yedeğini saklar";

		public override void Run(string[] args, Terminal context)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || ((Character)localPlayer).IsTeleporting() || (Object)(object)Game.instance == (Object)null || (Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer())
			{
				if (context != null)
				{
					context.AddString("Şu an kullanılamaz (oyunda, bir sunucuya bağlı ve hayatta olmalısın).");
				}
				return;
			}
			if (Time.time - _son < 30f)
			{
				if (context != null)
				{
					context.AddString("Biraz bekle (30 saniyede bir kullanılabilir).");
				}
				return;
			}
			_son = Time.time;
			Game.instance.SavePlayerProfile(true, false);
			Plugin.Log.LogInfo((object)"karakterkaydet: yerel kayit tetiklendi");
			if (context != null)
			{
				context.AddString("Karakterin kaydedildi ve sunucudaki kasaya gönderildi.");
			}
		}
	}
	[BepInPlugin("nuckflare.discoveryfeed", "DiscoveryFeed", "1.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "nuckflare.discoveryfeed";

		internal const string Rpc = "DiscoveryFeed_Learned";

		internal static ManualLogSource Log;

		private static readonly FieldRef<Player, HashSet<string>> Recipes = AccessTools.FieldRefAccess<Player, HashSet<string>>("m_knownRecipes");

		private static readonly FieldRef<Player, Dictionary<string, int>> Stations = AccessTools.FieldRefAccess<Player, Dictionary<string, int>>("m_knownStations");

		private static readonly FieldRef<Player, HashSet<string>> Materials = AccessTools.FieldRefAccess<Player, HashSet<string>>("m_knownMaterial");

		private static readonly FieldRef<Player, HashSet<string>> Trophies = AccessTools.FieldRefAccess<Player, HashSet<string>>("m_trophies");

		private static readonly FieldRef<Player, HashSet<string>> Biomes = AccessTools.FieldRefAccess<Player, HashSet<string>>("m_knownBiome");

		private Player _player;

		private HashSet<string> _recipes;

		private HashSet<string> _materials;

		private HashSet<string> _trophies;

		private HashSet<string> _biomes;

		private Dictionary<string, int> _stations;

		private float _next;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("nuckflare.discoveryfeed").PatchAll(typeof(Plugin).Assembly);
			Komutlar.Ekle();
		}

		private void Update()
		{
			CraftFeed.Tick();
			if (Time.unscaledTime < _next)
			{
				return;
			}
			_next = Time.unscaledTime + 1f;
			try
			{
				Check();
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Check failed: " + ex.Message));
			}
		}

		private void Check()
		{
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Expected O, but got Unknown
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer() || ZRoutedRpc.instance == null)
			{
				_player = null;
				return;
			}
			if ((Object)(object)localPlayer != (Object)(object)_player)
			{
				_player = localPlayer;
				_recipes = new HashSet<string>(Recipes.Invoke(localPlayer));
				_stations = new Dictionary<string, int>(Stations.Invoke(localPlayer));
				_materials = new HashSet<string>(Materials.Invoke(localPlayer));
				_trophies = new HashSet<string>(Trophies.Invoke(localPlayer));
				_biomes = new HashSet<string>(Biomes.Invoke(localPlayer));
				return;
			}
			HashSet<string> hashSet = Recipes.Invoke(localPlayer);
			Dictionary<string, int> dictionary = Stations.Invoke(localPlayer);
			HashSet<string> hashSet2 = Materials.Invoke(localPlayer);
			HashSet<string> hashSet3 = Trophies.Invoke(localPlayer);
			HashSet<string> hashSet4 = Biomes.Invoke(localPlayer);
			if (hashSet.Count == _recipes.Count && dictionary.Count == _stations.Count && hashSet2.Count == _materials.Count && hashSet3.Count == _trophies.Count && hashSet4.Count == _biomes.Count && dictionary.All((KeyValuePair<string, int> kv) => _stations.TryGetValue(kv.Key, out var value) && value >= kv.Value))
			{
				return;
			}
			List<string> list = hashSet.Where((string x) => !_recipes.Contains(x)).ToList();
			List<KeyValuePair<string, int>> list2 = dictionary.Where((KeyValuePair<string, int> kv) => !_stations.TryGetValue(kv.Key, out value) || value < kv.Value).ToList();
			List<string> list3 = hashSet2.Where((string x) => !_materials.Contains(x)).ToList();
			List<string> list4 = hashSet3.Where((string x) => !_trophies.Contains(x)).ToList();
			List<string> list5 = hashSet4.Where((string x) => !_biomes.Contains(x)).ToList();
			_recipes = new HashSet<string>(hashSet);
			_stations = new Dictionary<string, int>(dictionary);
			_materials = new HashSet<string>(hashSet2);
			_trophies = new HashSet<string>(hashSet3);
			_biomes = new HashSet<string>(hashSet4);
			if (list.Count + list2.Count + list3.Count + list4.Count + list5.Count == 0)
			{
				return;
			}
			ZPackage val = new ZPackage();
			val.Write(1);
			Write(val, list);
			val.Write(list2.Count);
			foreach (KeyValuePair<string, int> item in list2)
			{
				val.Write(item.Key);
				val.Write(item.Value);
			}
			Write(val, list3);
			Write(val, list4);
			Write(val, list5);
			ZRoutedRpc.instance.InvokeRoutedRPC("DiscoveryFeed_Learned", new object[1] { val });
			Log.LogInfo((object)($"Sent to server: {list.Count} recipes, {list2.Count} stations, {list3.Count} materials, " + $"{list4.Count} trophies, {list5.Count} biomes"));
		}

		private static void Write(ZPackage pkg, List<string> list)
		{
			pkg.Write(list.Count);
			foreach (string item in list)
			{
				pkg.Write(item);
			}
		}
	}
}