Decompiled source of SeaSight v0.2.0

plugins/SeaSight.dll

Decompiled 12 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
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.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("SeaSight")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+47374ca3c875469417f45b5334c4f571bf8481d5")]
[assembly: AssemblyProduct("SeaSight")]
[assembly: AssemblyTitle("SeaSight")]
[assembly: AssemblyVersion("0.2.0.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 SeaSight
{
	[BepInPlugin("sansara.SeaSight", "Sea Sight", "0.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "sansara.SeaSight";

		public const string Name = "Sea Sight";

		public const string Version = "0.2.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> ShipMultiplier;

		internal static ConfigEntry<float> CameraMaxDistanceOnShip;

		internal static ConfigEntry<float> CameraMaxDistanceOnFoot;

		internal const float CameraMinLimit = 6f;

		internal const float CameraMaxLimit = 30f;

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0077: 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_0084: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Server", "Enabled", true, new ConfigDescription("Шире открывать карту на корабле.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			ShipMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Server", "ShipMultiplier", 1.5f, new ConfigDescription("Во сколько раз радиус открытия карты на корабле больше обычного (в игре 100 м). 1 — как без мода.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2f), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			CameraMaxDistanceOnShip = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "MaxDistanceOnShip", 24f, new ConfigDescription("Как далеко можно отодвинуть камеру на корабле (у руля и на палубе), м. В игре 6. Настройка клиента.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 30f), Array.Empty<object>()));
			CameraMaxDistanceOnFoot = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "MaxDistanceOnFoot", 6f, new ConfigDescription("Как далеко можно отодвинуть камеру пешком, м. В игре 6. Настройка клиента.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 30f), Array.Empty<object>()));
			new Harmony("sansara.SeaSight").PatchAll();
			Log.LogInfo((object)(string.Format("{0} {1} загружен, множитель на корабле ×{2}, ", "Sea Sight", "0.2.0", ShipMultiplier.Value) + $"камера до {CameraMaxDistanceOnShip.Value} м на корабле и {CameraMaxDistanceOnFoot.Value} м пешком."));
		}

		internal static bool OnShip(Player player)
		{
			if ((Object)(object)player != (Object)null)
			{
				if (!((Object)(object)Ship.GetLocalShip() != (Object)null))
				{
					return ((Character)player).IsAttachedToShip();
				}
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Minimap), "Explore", new Type[]
	{
		typeof(Vector3),
		typeof(float)
	})]
	internal static class MinimapExplorePatch
	{
		private static void Prefix(ref float radius)
		{
			if (Plugin.Enabled.Value && Plugin.OnShip(Player.m_localPlayer))
			{
				radius *= Mathf.Clamp(Plugin.ShipMultiplier.Value, 1f, 2f);
			}
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
	internal static class GameCameraUpdatePatch
	{
		private static void Prefix(GameCamera __instance)
		{
			float num = Mathf.Clamp(Plugin.CameraMaxDistanceOnShip.Value, 6f, 30f);
			float num2 = Mathf.Clamp(Plugin.CameraMaxDistanceOnFoot.Value, 6f, 30f);
			__instance.m_maxDistanceBoat = num;
			__instance.m_maxDistance = (Plugin.OnShip(Player.m_localPlayer) ? num : num2);
		}
	}
}