using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInExPlugin;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FrankysAircraftSpawner (FrankysAircraftSpawner)")]
[assembly: AssemblyProduct("FrankysAircraftSpawner")]
[assembly: AssemblyVersion("1.0.0.0")]
public static class MissionReflection
{
private static FieldInfo GetField(string name)
{
FieldInfo field = typeof(Mission).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic);
if ((object)field == null)
{
throw new Exception("Mission has no private field called '" + name + "'");
}
return field;
}
public static T Get<T>(Mission mission, string fieldName)
{
return (T)GetField(fieldName).GetValue(mission);
}
public static void Set<T>(Mission mission, string fieldName, T value)
{
GetField(fieldName).SetValue(mission, value);
}
public static Mission CreateFLGMission(UnitType unitType, int unitCount = 1)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
Mission val = new Mission();
Set<MissionType>(val, "_missionType", (MissionType)6);
Set<MissionSequenceType>(val, "_sequenceType", (MissionSequenceType)2);
Set(val, "_isUnordered", value: true);
Set(val, "_isPriorityMission", value: false);
Set<GameTimer>(val, "_currentTimer", new GameTimer(0f, false));
Set<GameTimer>(val, "_prelaunchTimer", new GameTimer(0f, false));
Set(val, "_missionDuration", SingletonBehaviour<MissionManager>.Instance.DefaultMissionDuration);
Set(val, "_landingDuration", SingletonBehaviour<MissionManager>.Instance.DefaultLandingDuration);
Set<MissionState>(val, "_currentMissionState", (MissionState)0);
Set<UnitType>(val, "_requiredUnitType", unitType);
Set(val, "_requiredUnitCount", unitCount);
Set(val, "_assignedUnits", new List<Unit>());
Set(val, "_trackedUnits", new List<Unit>());
return val;
}
}
namespace BepInExPlugin
{
[BepInPlugin("FrankysAircraftSpawner", "FrankysAircraftSpawner", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ConfigEntry<string> InboundDesc;
public static ConfigEntry<KeyCode> HornetInboundValue;
public static ConfigEntry<KeyCode> SuperHornetInboundValue;
public static ConfigEntry<KeyCode> ProwlerInboundValue;
public static ConfigEntry<KeyCode> HawkeyeInboundValue;
public static ConfigEntry<KeyCode> OspreyInboundValue;
public static ConfigEntry<KeyCode> GreyhoundInboundValue;
public static ConfigEntry<KeyCode> SeahawkInboundValue;
public static ConfigEntry<KeyCode> ChinookInboundValue;
public static ConfigEntry<KeyCode> HarrierInboundValue;
public static ConfigEntry<KeyCode> VikingInboundValue;
public static ConfigEntry<string> OutboundDesc;
public static ConfigEntry<KeyCode> HornetOutboundValue;
public static ConfigEntry<KeyCode> SuperHornetOutboundValue;
public static ConfigEntry<KeyCode> ProwlerOutboundValue;
public static ConfigEntry<KeyCode> HawkeyeOutboundValue;
public static ConfigEntry<KeyCode> OspreyOutboundValue;
public static ConfigEntry<KeyCode> GreyhoundOutboundValue;
public static ConfigEntry<KeyCode> SeahawkOutboundValue;
public static ConfigEntry<KeyCode> ChinookOutboundValue;
public static ConfigEntry<KeyCode> HarrierOutboundValue;
public static ConfigEntry<KeyCode> VikingOutboundValue;
public static ConfigEntry<KeyCode> OutboundHotkeyValue;
public static ConfigEntry<string> CooldownDesc;
public static ConfigEntry<float> CooldownValue;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("FrankysAircraftSpawner");
val.PatchAll();
Debug.Log((object)"FrankysAircraftSpawner loaded");
InboundDesc = ((BaseUnityPlugin)this).Config.Bind<string>("Aircraft Hotkeys", "Description", "Set what hotkeys spawn which aircraft", "");
HornetInboundValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Aircraft Hotkeys", "Hornet Hotkey", (KeyCode)0, "");
SuperHornetInboundValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Aircraft Hotkeys", "Super Hornet Hotkey", (KeyCode)0, "");
ProwlerInboundValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Aircraft Hotkeys", "Prowler Hotkey", (KeyCode)0, "");
HawkeyeInboundValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Aircraft Hotkeys", "Hawkeye Hotkey", (KeyCode)0, "");
OspreyInboundValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Aircraft Hotkeys", "Osprey Hotkey", (KeyCode)0, "");
GreyhoundInboundValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Aircraft Hotkeys", "Greyhound Hotkey", (KeyCode)0, "");
SeahawkInboundValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Aircraft Hotkeys", "Seahawk Hotkey", (KeyCode)0, "");
ChinookInboundValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Aircraft Hotkeys", "Chinook Hotkey", (KeyCode)0, "");
HarrierInboundValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Aircraft Hotkeys", "Harrier Hotkey", (KeyCode)0, "");
VikingInboundValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Aircraft Hotkeys", "Viking Hotkey", (KeyCode)0, "");
OutboundDesc = ((BaseUnityPlugin)this).Config.Bind<string>("Outbound Hotkeys", "Description", "Set what hotkey starts FLG missions", "");
OutboundHotkeyValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Outbound Hotkeys", "NOTE: You will press and hold this key!", (KeyCode)0, "");
CooldownDesc = ((BaseUnityPlugin)this).Config.Bind<string>("Cooldown", "Description", "Time between call-ins", "");
CooldownValue = ((BaseUnityPlugin)this).Config.Bind<float>("Cooldown", "Cooldown", 2f, "");
}
}
internal static class PluginInfo
{
public const string PLUGIN_NAME = "FrankysAircraftSpawner";
public const string PLUGIN_ID = "FrankysAircraftSpawner";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace FrankysAircraftSpawner
{
[HarmonyPatch(typeof(MissionManager), "Update")]
public static class ReinforcementHotkeyPatch
{
private static float cooldown = Plugin.CooldownValue.Value;
private static float next = 0f;
private static MethodInfo method;
private static void Postfix(MissionManager __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
//IL_042d: Unknown result type (might be due to invalid IL or missing references)
//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
//IL_052f: Unknown result type (might be due to invalid IL or missing references)
KeyCode value = Plugin.HornetInboundValue.Value;
KeyCode value2 = Plugin.SuperHornetInboundValue.Value;
KeyCode value3 = Plugin.ProwlerInboundValue.Value;
KeyCode value4 = Plugin.HawkeyeInboundValue.Value;
KeyCode value5 = Plugin.OspreyInboundValue.Value;
KeyCode value6 = Plugin.GreyhoundInboundValue.Value;
KeyCode value7 = Plugin.SeahawkInboundValue.Value;
KeyCode value8 = Plugin.ChinookInboundValue.Value;
KeyCode value9 = Plugin.HarrierInboundValue.Value;
KeyCode value10 = Plugin.VikingInboundValue.Value;
bool key = Input.GetKey(Plugin.OutboundHotkeyValue.Value);
if ((object)method == null)
{
method = AccessTools.Method(typeof(MissionManager), "QueueUnitReinforcementMission", (Type[])null, (Type[])null);
}
if (Input.GetKeyDown(value) && !key)
{
if (Time.time < next)
{
return;
}
if ((object)method != null)
{
method.Invoke(__instance, new object[2]
{
(object)(UnitType)1,
1
});
Debug.Log((object)"Reinforcement requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value2) && !key)
{
if (Time.time < next)
{
return;
}
if ((object)method != null)
{
method.Invoke(__instance, new object[2]
{
(object)(UnitType)2,
1
});
Debug.Log((object)"Reinforcement requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value3) && !key)
{
if (Time.time < next)
{
return;
}
if ((object)method != null)
{
method.Invoke(__instance, new object[2]
{
(object)(UnitType)3,
1
});
Debug.Log((object)"Reinforcement requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value4) && !key)
{
if (Time.time < next)
{
return;
}
if ((object)method != null)
{
method.Invoke(__instance, new object[2]
{
(object)(UnitType)4,
1
});
Debug.Log((object)"Reinforcement requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value5) && !key)
{
if (Time.time < next)
{
return;
}
if ((object)method != null)
{
method.Invoke(__instance, new object[2]
{
(object)(UnitType)5,
1
});
Debug.Log((object)"Reinforcement requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value6) && !key)
{
if (Time.time < next)
{
return;
}
if ((object)method != null)
{
method.Invoke(__instance, new object[2]
{
(object)(UnitType)6,
1
});
Debug.Log((object)"Reinforcement requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value7) && !key)
{
if (Time.time < next)
{
return;
}
if ((object)method != null)
{
method.Invoke(__instance, new object[2]
{
(object)(UnitType)7,
1
});
Debug.Log((object)"Reinforcement requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value8) && !key)
{
if (Time.time < next)
{
return;
}
if ((object)method != null)
{
method.Invoke(__instance, new object[2]
{
(object)(UnitType)9,
1
});
Debug.Log((object)"Reinforcement requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value9) && !key)
{
if (Time.time < next)
{
return;
}
if ((object)method != null)
{
method.Invoke(__instance, new object[2]
{
(object)(UnitType)10,
1
});
Debug.Log((object)"Reinforcement requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value10) && !key && !(Time.time < next) && (object)method != null)
{
method.Invoke(__instance, new object[2]
{
(object)(UnitType)11,
1
});
Debug.Log((object)"Reinforcement requested.");
next = Time.time + cooldown;
}
}
}
[HarmonyPatch(typeof(MissionManager), "Update")]
public static class OutboundHotkeyPatch
{
private static float cooldown = Plugin.CooldownValue.Value;
private static float next = 0f;
private static MethodInfo method;
private static FieldInfo unitsField = AccessTools.Field(typeof(UnitManager), "_units");
private static void Postfix(MissionManager __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Invalid comparison between Unknown and I4
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Invalid comparison between Unknown and I4
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Invalid comparison between Unknown and I4
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Invalid comparison between Unknown and I4
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Invalid comparison between Unknown and I4
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Invalid comparison between Unknown and I4
//IL_0356: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Invalid comparison between Unknown and I4
//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Invalid comparison between Unknown and I4
//IL_0445: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Invalid comparison between Unknown and I4
//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Invalid comparison between Unknown and I4
//IL_0535: Unknown result type (might be due to invalid IL or missing references)
//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0627: Unknown result type (might be due to invalid IL or missing references)
KeyCode value = Plugin.HornetInboundValue.Value;
KeyCode value2 = Plugin.SuperHornetInboundValue.Value;
KeyCode value3 = Plugin.ProwlerInboundValue.Value;
KeyCode value4 = Plugin.HawkeyeInboundValue.Value;
KeyCode value5 = Plugin.OspreyInboundValue.Value;
KeyCode value6 = Plugin.GreyhoundInboundValue.Value;
KeyCode value7 = Plugin.SeahawkInboundValue.Value;
KeyCode value8 = Plugin.ChinookInboundValue.Value;
KeyCode value9 = Plugin.HarrierInboundValue.Value;
KeyCode value10 = Plugin.VikingInboundValue.Value;
bool key = Input.GetKey(Plugin.OutboundHotkeyValue.Value);
List<Unit> list = (List<Unit>)unitsField.GetValue(SingletonBehaviour<UnitManager>.Instance);
bool flag = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
bool flag5 = false;
bool flag6 = false;
bool flag7 = false;
bool flag8 = false;
bool flag9 = false;
bool flag10 = false;
foreach (Unit item in list)
{
if ((int)item.UnitType == 1)
{
flag = true;
}
if ((int)item.UnitType == 2)
{
flag2 = true;
}
if ((int)item.UnitType == 3)
{
flag3 = true;
}
if ((int)item.UnitType == 4)
{
flag4 = true;
}
if ((int)item.UnitType == 5)
{
flag5 = true;
}
if ((int)item.UnitType == 6)
{
flag6 = true;
}
if ((int)item.UnitType == 7)
{
flag7 = true;
}
if ((int)item.UnitType == 9)
{
flag8 = true;
}
if ((int)item.UnitType == 10)
{
flag9 = true;
}
if ((int)item.UnitType == 11)
{
flag10 = true;
}
}
if ((object)method == null)
{
method = AccessTools.Method(typeof(MissionManager), "QueueOutboundMission", (Type[])null, (Type[])null);
}
if (Input.GetKeyDown(value) && key && flag)
{
if (Time.time < next)
{
return;
}
Mission val = MissionReflection.CreateFLGMission((UnitType)1);
if ((object)method != null)
{
method.Invoke(__instance, new object[1] { val });
Debug.Log((object)"Outbound requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value2) && key && flag2)
{
if (Time.time < next)
{
return;
}
Mission val2 = MissionReflection.CreateFLGMission((UnitType)2);
if ((object)method != null)
{
method.Invoke(__instance, new object[1] { val2 });
Debug.Log((object)"Outbound requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value3) && key && flag3)
{
if (Time.time < next)
{
return;
}
Mission val3 = MissionReflection.CreateFLGMission((UnitType)3);
if ((object)method != null)
{
method.Invoke(__instance, new object[1] { val3 });
Debug.Log((object)"Outbound requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value4) && key && flag4)
{
if (Time.time < next)
{
return;
}
Mission val4 = MissionReflection.CreateFLGMission((UnitType)4);
if ((object)method != null)
{
method.Invoke(__instance, new object[1] { val4 });
Debug.Log((object)"Outbound requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value5) && key && flag5)
{
if (Time.time < next)
{
return;
}
Mission val5 = MissionReflection.CreateFLGMission((UnitType)5);
if ((object)method != null)
{
method.Invoke(__instance, new object[1] { val5 });
Debug.Log((object)"Outbound requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value6) && key && flag6)
{
if (Time.time < next)
{
return;
}
Mission val6 = MissionReflection.CreateFLGMission((UnitType)6);
if ((object)method != null)
{
method.Invoke(__instance, new object[1] { val6 });
Debug.Log((object)"Outbound requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value7) && key && flag7)
{
if (Time.time < next)
{
return;
}
Mission val7 = MissionReflection.CreateFLGMission((UnitType)7);
if ((object)method != null)
{
method.Invoke(__instance, new object[1] { val7 });
Debug.Log((object)"Outbound requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value8) && key && flag8)
{
if (Time.time < next)
{
return;
}
Mission val8 = MissionReflection.CreateFLGMission((UnitType)9);
if ((object)method != null)
{
method.Invoke(__instance, new object[1] { val8 });
Debug.Log((object)"Outbound requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value9) && key && flag9)
{
if (Time.time < next)
{
return;
}
Mission val9 = MissionReflection.CreateFLGMission((UnitType)10);
if ((object)method != null)
{
method.Invoke(__instance, new object[1] { val9 });
Debug.Log((object)"Outbound requested.");
next = Time.time + cooldown;
}
}
if (Input.GetKeyDown(value10) && key && flag10 && !(Time.time < next))
{
Mission val10 = MissionReflection.CreateFLGMission((UnitType)11);
if ((object)method != null)
{
method.Invoke(__instance, new object[1] { val10 });
Debug.Log((object)"Outbound requested.");
next = Time.time + cooldown;
}
}
}
}
}