Decompiled source of VoidCrew DismantleAllStations v1.0.1

BepInEx/plugins/DismantleAllStationsPlugin.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using CG.Ship.Modules;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DismantleAllStationsPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DismantleAllStationsPlugin")]
[assembly: AssemblyTitle("DismantleAllStationsPlugin")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
[HarmonyPatch(typeof(CellModule), "OnPhotonInstantiate")]
public class CellModulePatch
{
	private static ManualLogSource logger;

	public static void InitializeLogger(ManualLogSource logSource)
	{
		logger = logSource;
	}

	private static void Prefix(CellModule __instance, ref PhotonMessageInfo info)
	{
		ManualLogSource obj = logger;
		if (obj != null)
		{
			obj.LogInfo((object)"OnPhotonInstantiate Prefix called");
		}
		Dictionary<int, object> dictionary = InstantiationDataParser.ParseInstantiationData(info.photonView.InstantiationData);
		ManualLogSource obj2 = logger;
		if (obj2 != null)
		{
			obj2.LogInfo((object)"Fetched DictionaryData.");
		}
		if (dictionary.ContainsKey(9))
		{
			ManualLogSource obj3 = logger;
			if (obj3 != null)
			{
				obj3.LogInfo((object)"Found DeconstructionKey");
			}
			dictionary.Remove(9);
			object[] value = ConvertDictionaryToArray(dictionary);
			Traverse.Create((object)info.photonView).Field("instantiationDataField").SetValue((object)value);
			ManualLogSource obj4 = logger;
			if (obj4 != null)
			{
				obj4.LogInfo((object)"Applied Deconstruction to Station.");
			}
		}
	}

	private static object[] ConvertDictionaryToArray(Dictionary<int, object> dictionary)
	{
		object[] array = new object[dictionary.Count * 2];
		int num = 0;
		foreach (KeyValuePair<int, object> item in dictionary)
		{
			array[num++] = item.Key;
			array[num++] = item.Value;
		}
		return array;
	}
}
namespace DismantleAllStationsMod
{
	[BepInPlugin("com.Vengeanze.VoidCrewCoreMods", "DismantleAllStationsMod", "1.0.1")]
	public class DismantleAllStationsPlugin : BaseUnityPlugin
	{
		private Harmony harmony;

		private static ManualLogSource modLogger;

		private void Awake()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			modLogger = ((BaseUnityPlugin)this).Logger;
			CellModulePatch.InitializeLogger(modLogger);
			modLogger.LogInfo((object)"Initializing MyModPlugin");
			harmony = new Harmony("com.Vengeanze.VoidCrewCoreMods");
			harmony.PatchAll();
			modLogger.LogInfo((object)"Harmony patches applied");
		}
	}
}