Decompiled source of ModulationRevival v1.3.16

Plugins/Modulation.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using BepInEx;
using BepInEx.IL2CPP;
using BepInEx.Logging;
using ChainedPuzzles;
using GameData;
using HarmonyLib;
using Il2CppSystem;
using LevelGeneration;
using Localization;
using SNetwork;
using UnhollowerBaseLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Modulation")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Modulation")]
[assembly: AssemblyTitle("Modulation")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Modulation;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Modulation", "Modulation", "1.0.0")]
public class EntryPoint : BasePlugin
{
	private Harmony m_Harmony;

	public override void Load()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		m_Harmony = new Harmony("Modulation");
		m_Harmony.PatchAll();
	}
}
internal static class ModulationLogger
{
	private static readonly ManualLogSource _logger;

	static ModulationLogger()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		_logger = new ManualLogSource("Modulation");
		Logger.Sources.Add((ILogSource)(object)_logger);
	}

	private static string Format(object msg)
	{
		return msg.ToString();
	}

	public static void Info(object data)
	{
		_logger.LogMessage((object)Format(data));
	}

	public static void Verbose(object data)
	{
	}

	public static void Debug(object data)
	{
		_logger.LogDebug((object)Format(data));
	}

	public static void Error(object data)
	{
		_logger.LogError((object)Format(data));
	}
}
[HarmonyPatch(typeof(ChainedPuzzleManager), "OnAssetsLoaded")]
internal class Patch_ChainedPuzzleManager
{
	private static void Postfix(ChainedPuzzleManager __instance)
	{
		uint[] array = new uint[10] { 10u, 11u, 12u, 6u, 8u, 13u, 32u, 17u, 18u, 14u };
		foreach (uint num in array)
		{
			CP_PlayerScanner component = __instance.m_puzzleComponentPrefabs[num].GetComponent<CP_PlayerScanner>();
			float num2 = ((Il2CppArrayBase<float>)(object)component.m_scanSpeeds)[3];
			((Il2CppArrayBase<float>)(object)component.m_scanSpeeds)[0] = num2;
			((Il2CppArrayBase<float>)(object)component.m_scanSpeeds)[1] = num2;
			((Il2CppArrayBase<float>)(object)component.m_scanSpeeds)[2] = num2;
			((Il2CppArrayBase<float>)(object)component.m_scanSpeeds)[3] = num2;
		}
	}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class Patch_Dimension_LinkToLayer
{
	private static void Postfix(AIG_CourseNode __instance, ref LG_LayerType __result)
	{
		if (!__instance.m_dimension.IsMainDimension)
		{
			ProgressionPuzzleData progressionPuzzleToEnter = __instance.m_zone.m_settings.m_zoneData.ProgressionPuzzleToEnter;
			LocalizedText val = ((progressionPuzzleToEnter != null) ? progressionPuzzleToEnter.CustomText : null);
			string text = ((val != null) ? LocalizedText.op_Implicit(val) : string.Empty);
			if (text.StartsWith("LinkedToLayer:"))
			{
				int num = int.Parse(text.Remove(0, 14).Trim());
				__result = (LG_LayerType)(byte)num;
			}
		}
	}
}
[HarmonyPatch(typeof(LG_SecurityDoor), "OpenLockedSecurityDoor")]
internal class Patch_DoorUnlockBetter
{
	private static void Postfix(LG_SecurityDoor __instance)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Invalid comparison between Unknown and I4
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		eDoorStatus lastStatus = __instance.LastStatus;
		if (lastStatus - 3 <= 3 || (int)lastStatus == 15)
		{
			__instance.m_sync.AttemptDoorInteraction((eDoorInteractionType)0, 0f, 0f, default(Vector3), (SNet_Player)null);
		}
	}
}
[HarmonyPatch(typeof(LG_WardenObjective_Reactor))]
internal static class Patch_Meltdown_Reactor
{
	public const string MAINTERMINAL_NAME = "Main Terminal";

	public static bool IsMeltdown = false;

	public static uint IntroTextID = 0u;

	public static uint IntenseTextID = 0u;

	public static uint VerifyTextID = 0u;

	public static uint CompleteTextID = 0u;

	public static LG_Light[] Lights = null;

	private static Color LowTemperature = ColorExt.Hex("#23E4F2") * 2.5f;

	private static Color HighTemperature = ColorExt.Hex("#F63838") * 12f;

	private static float _updateTimer = 0f;

	[HarmonyPostfix]
	[HarmonyPatch("OnBuildDone")]
	private static void Post_BuildDone(LG_WardenObjective_Reactor __instance)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		LG_WardenObjective_Reactor reactor = __instance;
		LG_ComputerTerminal reactorTerminal = __instance.m_terminal;
		WardenObjectiveDataBlock val = WardenObjectiveManager.ActiveWardenObjective(reactor.SpawnNode.LayerType);
		if (!((GameDataBlockBase<WardenObjectiveDataBlock>)(object)val).name.Contains("[MELTDOWN]", StringComparison.InvariantCultureIgnoreCase))
		{
			IsMeltdown = false;
			return;
		}
		IsMeltdown = true;
		LG_WardenObjective_Reactor obj = reactor;
		((Object)obj).name = ((Object)obj).name + "Meltdown!";
		IntroTextID = GameDataBlockBase<TextDataBlock>.GetBlockID("InGame.WardenObjective_Reactor.MeltdownIntro");
		IntenseTextID = GameDataBlockBase<TextDataBlock>.GetBlockID("InGame.WardenObjective_Reactor.MeltdownWave");
		VerifyTextID = GameDataBlockBase<TextDataBlock>.GetBlockID("InGame.WardenObjective_Reactor.MeltdownVerification");
		CompleteTextID = GameDataBlockBase<TextDataBlock>.GetBlockID("InGame.WardenObjective_Reactor.MeltdownComplete");
		Lights = (from x in Il2CppArrayBase<LG_Light>.op_Implicit((Il2CppArrayBase<LG_Light>)(object)reactor.SpawnNode.m_lightsInNode)
			where (int)x.m_category == 3
			select x).ToArray();
		__instance.m_lightCollection.RemoveLights(Il2CppReferenceArray<LG_Light>.op_Implicit(Lights));
		eDimensionIndex dimensionIndex = reactor.SpawnNode.m_dimension.DimensionIndex;
		LG_LayerType layerType = reactor.SpawnNode.LayerType;
		LG_Zone val3 = default(LG_Zone);
		for (int i = 0; i < reactor.m_waveCountMax; i++)
		{
			ReactorWaveData val2 = val.ReactorWaves[i];
			if (!val2.HasVerificationTerminal)
			{
				LG_ComputerTerminalCommandInterpreter command = reactorTerminal.m_command;
				((Il2CppArrayBase<string>)(object)reactor.m_overrideCodes)[i] = reactor.m_terminal.SyncID.ToString(CultureInfo.InvariantCulture);
				if (!command.HasRegisteredCommand((TERM_Command)39))
				{
					command.AddCommand((TERM_Command)39, "REACTOR_UNSTUCK", "Unstuck Reactor Emergency Shutdown Cooling Protocol");
				}
			}
			else
			{
				if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(dimensionIndex, layerType, val2.ZoneForVerification, ref val3))
				{
					continue;
				}
				int count = val3.TerminalsSpawnedInZone.Count;
				for (int j = 0; j < count; j++)
				{
					LG_ComputerTerminal val4 = val3.TerminalsSpawnedInZone[j];
					LG_ComputerTerminalCommandInterpreter command2 = val4.m_command;
					if (val4.ItemKey.Equals(val2.VerificationTerminalSerial))
					{
						val4.ConnectedReactor = reactor;
						val4.RemoveLocalLog(val2.VerificationTerminalFileName.ToUpperInvariant());
						((Il2CppArrayBase<string>)(object)reactor.m_overrideCodes)[i] = val4.SyncID.ToString(CultureInfo.InvariantCulture);
						if (!command2.HasRegisteredCommand((TERM_Command)39))
						{
							command2.AddCommand((TERM_Command)39, "REACTOR_UNSTUCK", "Unstuck Reactor Emergency Shutdown Cooling Protocol");
						}
						break;
					}
				}
			}
		}
		if (SNet.IsMaster)
		{
			ElevatorRide.OnElevatorHasArrived += Action.op_Implicit((Action)delegate
			{
				reactorTerminal.TrySyncSetCommandRemoved((TERM_Command)21);
				reactorTerminal.TrySyncSetCommandRemoved((TERM_Command)22);
				reactor.AttemptInteract((eReactorInteraction)0, 0f);
			});
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch("Update")]
	private static void Post_Update(LG_WardenObjective_Reactor __instance)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected I4, but got Unknown
		if (!IsMeltdown)
		{
			return;
		}
		eReactorStatus status = __instance.m_currentState.status;
		UpdateLight(status, __instance.m_currentWaveProgress);
		switch (status - 2)
		{
		case 0:
			__instance.SetGUIMessage(true, FormatText(IntroTextID, __instance.m_currentWaveCount, __instance.m_waveCountMax), (ePUIMessageStyle)3, true, "<size=125%>" + Text.Get(1102u), "</size>");
			break;
		case 1:
			__instance.SetGUIMessage(true, FormatText(IntenseTextID, __instance.m_currentWaveCount, __instance.m_waveCountMax), (ePUIMessageStyle)3, true, "<size=125%>" + Text.Get(1102u), "</size>");
			break;
		case 2:
		{
			string text = "Main Terminal";
			if (__instance.m_currentWaveData.HasVerificationTerminal)
			{
				text = __instance.m_currentWaveData.VerificationTerminalSerial;
			}
			__instance.SetGUIMessage(true, FormatText(VerifyTextID, __instance.m_currentWaveCount, __instance.m_waveCountMax, "<color=orange>" + text + "</color>"), (ePUIMessageStyle)3, true, "<size=125%>" + Text.Get(1104u), "</size>");
			break;
		}
		case 3:
			__instance.SetGUIMessage(true, Text.Get(CompleteTextID), (ePUIMessageStyle)0, false, "", "");
			break;
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch("OnTerminalStartupSequenceVerify")]
	private static void Post_Verify(LG_WardenObjective_Reactor __instance)
	{
		if (IsMeltdown)
		{
			__instance.m_sound.Post(1797090640u, true);
		}
	}

	private static void UpdateLight(eReactorStatus status, float progress)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected I4, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		if (!(_updateTimer > Clock.Time))
		{
			_updateTimer = Clock.Time + 0.15f;
			switch (status - 1)
			{
			case 4:
				SetLightColor(LowTemperature);
				break;
			case 0:
				SetLightColor(Color.black);
				break;
			case 1:
				SetLightColor(Color.Lerp(LowTemperature, HighTemperature, progress));
				break;
			case 3:
				SetLightColor(LowTemperature);
				break;
			case 2:
				SetLightColor(Color.Lerp(HighTemperature, LowTemperature, progress));
				break;
			}
		}
	}

	private static void SetLightColor(Color color)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		if (Lights != null)
		{
			for (int i = 0; i < Lights.Length; i++)
			{
				Lights[i].ChangeColor(color);
			}
		}
	}

	private static string FormatText(uint id, params object[] objs)
	{
		return string.Format(Text.Get(id), objs);
	}
}
[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "ReceiveCommand")]
internal static class Patch_Meltdown_Reactor_Terminal
{
	private static void Prefix(ref TERM_Command cmd, ref string param1, LG_ComputerTerminalCommandInterpreter __instance)
	{
		LG_WardenObjective_Reactor connectedReactor = __instance.m_terminal.ConnectedReactor;
		ModulationLogger.Info("Try Reactor Verify");
		if ((Object)(object)connectedReactor != (Object)null && (int)cmd == 39)
		{
			string text = __instance.m_terminal.SyncID.ToString(CultureInfo.InvariantCulture);
			ModulationLogger.Info("Reactor Verify: " + connectedReactor.CurrentStateOverrideCode + " " + text);
			cmd = (TERM_Command)22;
			param1 = text;
		}
	}
}

Plugins/ModulationWeapon.dll

Decompiled 10 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 Agents;
using BepInEx;
using BepInEx.IL2CPP;
using BepInEx.Logging;
using GameData;
using Gear;
using HarmonyLib;
using Player;

[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 = "")]
[assembly: AssemblyCompany("ModulationWeapon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ModulationWeapon")]
[assembly: AssemblyTitle("ModulationWeapon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ModulationWeapon;

[BepInPlugin("ModulationWeapon", "ModulationWeapon", "1.0.0")]
public class EntryPoint : BasePlugin
{
	private Harmony m_Harmony;

	public override void Load()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		m_Harmony = new Harmony("ModulationWeapon");
		m_Harmony.PatchAll();
		ModulationWeaponLogger.Verbose("Applied all patches!");
	}
}
[HarmonyPatch(typeof(BulletWeapon))]
internal static class Inject_BulletWeapon
{
	public static AutoReloadType AutoReload;

	[HarmonyPostfix]
	[HarmonyPatch("OnWield")]
	private static void Post_Wield(BulletWeapon __instance)
	{
		if (((Agent)((Item)__instance).Owner).IsLocallyOwned)
		{
			string name = ((GameDataBlockBase<ArchetypeDataBlock>)(object)((ItemEquippable)__instance).ArchetypeData).name;
			if (name.Contains("[AlwaysFullClip]", StringComparison.OrdinalIgnoreCase))
			{
				AutoReload = AutoReloadType.AlwaysFullClip;
			}
			else if (name.Contains("[AutoReload]", StringComparison.OrdinalIgnoreCase))
			{
				AutoReload = AutoReloadType.AutoReload;
			}
			else
			{
				AutoReload = AutoReloadType.None;
			}
			DoReload(__instance);
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch("UpdateAmmoStatus")]
	private static void Post_UpdateAmmoStatus(BulletWeapon __instance)
	{
		DoReload(__instance);
	}

	private static void DoReload(BulletWeapon weapon)
	{
		if (!((Agent)((Item)weapon).Owner).IsLocallyOwned)
		{
			return;
		}
		switch (AutoReload)
		{
		case AutoReloadType.AlwaysFullClip:
			((Item)weapon).Owner.Inventory.DoReload();
			break;
		case AutoReloadType.AutoReload:
			if (weapon.m_clip == 0 && ((PlayerInventoryBase)((Weapon)weapon).m_inventory).CanReloadCurrent())
			{
				((ItemEquippable)weapon).TryTriggerReloadAnimationSequence();
				if (((Item)weapon).Owner.Locomotion.IsRunning)
				{
					((Item)weapon).Owner.Locomotion.ChangeState((PLOC_State)0, false);
				}
			}
			break;
		}
	}
}
public enum AutoReloadType
{
	None,
	AlwaysFullClip,
	AutoReload
}
internal static class ModulationWeaponLogger
{
	private static readonly ManualLogSource _logger;

	static ModulationWeaponLogger()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		_logger = new ManualLogSource("ModulationWeapon");
		Logger.Sources.Add((ILogSource)(object)_logger);
	}

	private static string Format(object msg)
	{
		return msg.ToString();
	}

	public static void Info(object data)
	{
		_logger.LogMessage((object)Format(data));
	}

	public static void Verbose(object data)
	{
		_logger.LogDebug((object)Format(data));
	}

	public static void Debug(object data)
	{
		_logger.LogDebug((object)Format(data));
	}

	public static void Error(object data)
	{
		_logger.LogError((object)Format(data));
	}
}