Decompiled source of ShipManagement v1.0.1

ShipManagement.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using Quantum.Commands;
using UISystem;
using UnityEngine;
using WildSkies.Gameplay.ShipBuilding;
using WildSkies.Service;
using Wildskies.UI.Hud;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ShipManagement")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Nines (Natives)")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("ShipManagement")]
[assembly: AssemblyTitle("ShipManagement")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ShipManagement
{
	[BepInPlugin("ShipManagement", "ShipManagement", "1.0.1")]
	public class Plugin : BasePlugin
	{
		private class ShipSimpleChatCommands
		{
			private static readonly Action<bool, int, string, string, Guid> OnLoadCompleted = Action<bool, int, string, string, Guid>.op_Implicit((Action<bool, int, string, string, Guid>)delegate(bool success, int saveSlot, string key, string saveData, Guid requestId)
			{
				if (!(key != "ShipHull"))
				{
					IPersistenceService obj = ProjectContextInstaller.ResolveObject<IPersistenceService>();
					obj.LoadCompleted -= OnLoadCompleted;
					ShowNotification($"{(success ? "Loaded" : "Failed to load")} saved ship {saveSlot}.");
				}
			});

			public static string Save(int saveIndex)
			{
				ConstructedShipController item = ShipCommands.GetShipPlayerControlling().Item1;
				if ((Object)(object)item == (Object)null)
				{
					return "Get to a ship helm to save to a preset.";
				}
				item.NetworkShipyard.SaveShip(saveIndex);
				return $"Saved \"{item.shipName}\" to preset {saveIndex}.";
			}

			public static string Load(int saveIndex)
			{
				IPersistenceService obj = ProjectContextInstaller.ResolveObject<IPersistenceService>();
				obj.LoadCompleted += OnLoadCompleted;
				InstantiationCommands.ShipFromSave(saveIndex, true);
				return null;
			}
		}

		internal static ManualLogSource Log;

		internal static Harmony harmonyInstance;

		public override void Load()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ShipManagement");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			harmonyInstance = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
		}

		public override bool Unload()
		{
			Harmony obj = harmonyInstance;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			return true;
		}

		private static void ShowNotification(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return;
			}
			IUIService _uiService = default(IUIService);
			ServiceBaseCommands.GetService<IUIService>(ref _uiService);
			if (_uiService == null)
			{
				return;
			}
			Action<HudElement> action = delegate(HudElement hudElement)
			{
				if (!((Object)(object)hudElement == (Object)null))
				{
					_uiService.HUDManager.HudElementLoaded(hudElement, (IPayload)null, (Action)null);
					NotificationHud val = ((Il2CppObjectBase)hudElement).Cast<NotificationHud>();
					NotificationPopupObject notificationPopup = val.GetNotificationPopup();
					notificationPopup._icon.sprite = notificationPopup._fallbackIcon;
					float durationRemaining = (notificationPopup._displayDuration = val._viewModel.PopupDisplayDuration * 2f);
					notificationPopup._durationRemaining = durationRemaining;
					notificationPopup._fadeOutSpeedModifier = val._viewModel.PopupDisplayFadeSpeedMultiplier;
					notificationPopup._callback = val.OnPopupExpired;
					((Component)notificationPopup._shineAnimator).gameObject.SetActive(false);
					notificationPopup._message.text = text;
					val._currentNotification = notificationPopup;
					val._activeNotifications.Enqueue(val._currentNotification);
				}
			};
			if (_uiService.HUDManager._hudElementsInMemory.ContainsKey((UIHudType)14))
			{
				action(_uiService.HUDManager._hudElementsInMemory[(UIHudType)14]);
			}
			else
			{
				_uiService.HUDManager.LoadHudElement((UIHudType)14, Action<HudElement>.op_Implicit(action));
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ShipManagement";

		public const string PLUGIN_NAME = "ShipManagement";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}