Decompiled source of Automatic1911 v1.2.0

Automatic1911.dll

Decompiled 4 days ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Automatic1911;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Equipping;
using Il2CppScheduleOne.PlayerScripts;
using MelonLoader;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(global::Automatic1911.Automatic1911), "Automatic1911", "1.0", "Jumble", null)]
[assembly: MelonColor]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Automatic1911")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Automatic1911")]
[assembly: AssemblyTitle("Automatic1911")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Automatic1911;

public static class BuildInfo
{
	public const string Name = "Automatic1911";

	public const string Description = "Makes the 1911 fully automatic.";

	public const string Author = "Jumble";

	public const string Company = null;

	public const string Version = "1.0";

	public const string DownloadLink = null;
}
public static class Config
{
	public static float fireRate = 0.1f;

	private static string modsFolderPath = Path.Combine(Application.dataPath, "../Mods");

	private static string automatic1911FolderPath = Path.Combine(modsFolderPath, "Automatic1911");

	private static string configPath = Path.Combine(automatic1911FolderPath, "Automatic1911Config.ini");

	public static void Load()
	{
		if (!Directory.Exists(automatic1911FolderPath))
		{
			Directory.CreateDirectory(automatic1911FolderPath);
			MelonLogger.Msg("Created 'Automatic1911' folder in Mods directory.");
		}
		if (!File.Exists(configPath))
		{
			File.WriteAllText(configPath, "fireRate = 0.1");
			MelonLogger.Msg("Automatic1911Config.ini created with default values.");
		}
		string[] array = File.ReadAllLines(configPath);
		for (int i = 0; i < array.Length; i++)
		{
			string text = array[i].Trim();
			if (text.StartsWith(";") || text.StartsWith("#") || string.IsNullOrWhiteSpace(text))
			{
				continue;
			}
			string[] array2 = text.Split('=');
			if (array2.Length == 2)
			{
				string text2 = array2[0].Trim();
				string s = array2[1].Trim();
				if (text2.ToLowerInvariant() == "firerate" && float.TryParse(s, out var result))
				{
					fireRate = result;
				}
			}
		}
		MelonLogger.Msg("Automatic1911Config.ini loaded.");
	}
}
public class Automatic1911 : MelonMod
{
	private Equippable_RangedWeapon stored1911;

	public override void OnInitializeMelon()
	{
		Config.Load();
	}

	public override void OnUpdate()
	{
		if (Input.GetKey((KeyCode)323) && Input.GetKey((KeyCode)324))
		{
			if (((Object)(object)stored1911 == (Object)null || !((Component)stored1911).gameObject.activeInHierarchy) && Object.op_Implicit((Object)(object)PlayerSingleton<PlayerInventory>.Instance.equippedSlot.Equippable) && ((Object)PlayerSingleton<PlayerInventory>.Instance.equippedSlot.Equippable).name == "M1911_Equippable(Clone)")
			{
				stored1911 = ((Il2CppObjectBase)PlayerSingleton<PlayerInventory>.Instance.equippedSlot.Equippable).Cast<Equippable_RangedWeapon>();
				stored1911.FireCooldown = Config.fireRate;
			}
			if ((Object)(object)stored1911 != (Object)null && stored1911.TimeSinceFire >= Config.fireRate)
			{
				stored1911.shotQueued = true;
			}
			if ((Object)(object)stored1911 == (Object)null)
			{
				MelonLogger.Msg("1911 not found");
			}
		}
	}
}