using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Text.Json.Serialization;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using EWC.Dependencies;
using ExtraObjectiveSetup.Expedition;
using GTFO.API.JSON.Converters;
using GTFO.API.Utilities;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LocalProgression;
using LocalProgression.Data;
using MTFO.API;
using Microsoft.CodeAnalysis;
using Player;
using ProgressionGear.Dependencies;
using ProgressionGear.JSON;
using ProgressionGear.Patches;
using ProgressionGear.ProgressionLock;
using ProgressionGear.Utils;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ProgressionGear")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+87a98a7e610c0197ed7807556e8e1fefc107ad4b")]
[assembly: AssemblyProduct("ProgressionGear")]
[assembly: AssemblyTitle("ProgressionGear")]
[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;
}
}
}
namespace EWC.Dependencies
{
internal static class MTFOWrapper
{
public const string PLUGIN_GUID = "com.dak.MTFO";
public static string GameDataPath => MTFOPathAPI.RundownPath;
public static string CustomPath => MTFOPathAPI.CustomPath;
public static bool HasCustomContent => MTFOPathAPI.HasRundownPath;
}
}
namespace ProgressionGear
{
internal static class Configuration
{
private static readonly ConfigFile _configFile;
public static bool DisableProgression { get; set; }
static Configuration()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
_configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "ProgressionGear.cfg"), true);
BindAll(_configFile);
}
public static void Init()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
LiveEdit.CreateListener(Paths.ConfigPath, "ProgressionGear.cfg", false).FileChanged += new LiveEditEventHandler(OnFileChanged);
}
private static void OnFileChanged(LiveEditEventArgs _)
{
_configFile.Reload();
DisableProgression = (bool)_configFile["Override", "Disable Progression Locks"].BoxedValue;
}
private static void BindAll(ConfigFile config)
{
DisableProgression = config.Bind<bool>("Override", "Disable Progression Locks", DisableProgression, "Disables progression-locking for weapons.").Value;
}
}
[BepInPlugin("Dinorush.ProgressionGear", "ProgressionGear", "1.3.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal sealed class EntryPoint : BasePlugin
{
public const string GUID = "Dinorush.ProgressionGear";
public const string MODNAME = "ProgressionGear";
public override void Load()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
PWLogger.Log("Loading ProgressionGear");
if (!MTFOWrapper.HasCustomContent)
{
PWLogger.Error("No MTFO datablocks detected. Not loading ProgressionGear...");
return;
}
MTFOHotReloadAPI.OnHotReload += FixGearInstanceDict;
Harmony val = new Harmony("ProgressionGear");
val.PatchAll();
if (!LocalProgressionWrapper.HasLocalProgression)
{
val.PatchAll(typeof(PageRundownPatches_NoLP));
}
Configuration.Init();
GearLockManager.Current.Init();
GearToggleManager.Current.Init();
ProgressionLockManager.Current.Init();
PWLogger.Log("Loaded ProgressionGear");
}
private static void FixGearInstanceDict()
{
GearManager.Current.m_allGearPerInstanceKey.Clear();
GearManager.Current.OnGearLoadingDone();
}
}
}
namespace ProgressionGear.Utils
{
internal class DictListEnumerator<T> : IEnumerator<T>, IDisposable, IEnumerator
{
private readonly IEnumerator<List<T>> _valueEnumerator;
private List<T>? _curList;
private int _index;
private T? _current;
public T Current => _current;
object IEnumerator.Current => Current;
internal DictListEnumerator(Dictionary<string, List<T>> data)
{
_valueEnumerator = data.Values.GetEnumerator();
if (_valueEnumerator.MoveNext())
{
_curList = _valueEnumerator.Current;
}
_index = -1;
}
public void Dispose()
{
}
public bool MoveNext()
{
if (_curList == null || ++_index >= _curList.Count)
{
if (!_valueEnumerator.MoveNext())
{
return false;
}
_curList = _valueEnumerator.Current;
_index = 0;
}
_current = _curList[_index];
return true;
}
public void Reset()
{
_valueEnumerator.Reset();
if (_valueEnumerator.MoveNext())
{
_curList = _valueEnumerator.Current;
}
_index = -1;
}
}
internal static class GearIDRangeExtensions
{
public static uint GetOfflineID(this GearIDRange gearIDRange)
{
string playfabItemInstanceId = gearIDRange.PlayfabItemInstanceId;
if (!playfabItemInstanceId.Contains("OfflineGear_ID_"))
{
PWLogger.Error("Find PlayfabItemInstanceId without substring 'OfflineGear_ID_'! " + playfabItemInstanceId);
return 0u;
}
try
{
return uint.Parse(playfabItemInstanceId.Substring("OfflineGear_ID_".Length));
}
catch
{
PWLogger.Error("Caught exception while trying to parse persistentID of PlayerOfflineGearDB from GearIDRange, which means itemInstanceId could be ill-formated");
return 0u;
}
}
}
internal static class PWLogger
{
private static ManualLogSource logger = Logger.CreateLogSource("ProgressionGear");
public static void Log(string format, params object[] args)
{
Log(string.Format(format, args));
}
public static void Log(string str)
{
if (logger != null)
{
logger.Log((LogLevel)8, (object)str);
}
}
public static void Warning(string format, params object[] args)
{
Warning(string.Format(format, args));
}
public static void Warning(string str)
{
if (logger != null)
{
logger.Log((LogLevel)4, (object)str);
}
}
public static void Error(string format, params object[] args)
{
Error(string.Format(format, args));
}
public static void Error(string str)
{
if (logger != null)
{
logger.Log((LogLevel)2, (object)str);
}
}
public static void Debug(string format, params object[] args)
{
Debug(string.Format(format, args));
}
public static void Debug(string str)
{
if (logger != null)
{
logger.Log((LogLevel)32, (object)str);
}
}
}
internal static class StringExtensions
{
public static T ToEnum<T>(this string? value, T defaultValue) where T : struct
{
if (string.IsNullOrEmpty(value))
{
return defaultValue;
}
if (!Enum.TryParse<T>(value.Replace(" ", null), ignoreCase: true, out var result))
{
return defaultValue;
}
return result;
}
}
}
namespace ProgressionGear.Patches
{
[HarmonyPatch]
internal static class GearManagerPatches
{
[HarmonyPatch(typeof(GearManager), "SetupGearInOfflineMode")]
[HarmonyWrapSafe]
[HarmonyPostfix]
private static void Post_SetupGearInOfflineMode()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected I4, but got Unknown
GearLockManager.Current.VanillaGearManager = GearManager.Current;
foreach (var gearSlot in GearLockManager.Current.GearSlots)
{
InventorySlot item = gearSlot.inventorySlot;
Dictionary<uint, GearIDRange> item2 = gearSlot.loadedGears;
Enumerator<GearIDRange> enumerator2 = ((Il2CppArrayBase<List<GearIDRange>>)(object)GearManager.Current.m_gearPerSlot)[(int)item].GetEnumerator();
while (enumerator2.MoveNext())
{
GearIDRange current2 = enumerator2.Current;
uint offlineID = current2.GetOfflineID();
item2.TryAdd(offlineID, current2);
}
}
GearToggleManager.Current.ResetRelatedIDs();
}
}
internal static class PageRundownPatches_NoLP
{
[HarmonyPatch(typeof(CM_PageRundown_New), "SetIconStatus")]
[HarmonyWrapSafe]
[HarmonyPostfix]
private static void Post_IconUpdate(CM_ExpeditionIcon_New icon, string mainFinishCount, string secondFinishCount, string thirdFinishCount, string allFinishedCount)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
ProgressionData progressionData = new ProgressionData();
if (mainFinishCount != "-")
{
progressionData.MainCompletionCount = int.Parse(mainFinishCount);
}
if (secondFinishCount != "-")
{
progressionData.SecondaryCompletionCount = int.Parse(secondFinishCount);
}
if (thirdFinishCount != "-")
{
progressionData.ThirdCompletionCount = int.Parse(thirdFinishCount);
}
if (allFinishedCount != "-")
{
progressionData.AllCompletionCount = int.Parse(allFinishedCount);
}
ProgressionWrapper.UpdateNativeProgression(icon.Tier, icon.ExpIndex, progressionData);
}
}
[HarmonyPatch]
internal static class PlayerLobbyBarPatches
{
public static GameObject? SwapButton;
private static CM_InventorySlotItem? _cachedItem;
[HarmonyPatch(typeof(CM_PlayerLobbyBar), "UpdateWeaponWindowInfo")]
[HarmonyPrefix]
private static void Pre_LoadoutHeaderSelected(CM_PlayerLobbyBar __instance)
{
_cachedItem = __instance.selectedWeaponSlotItem;
}
[HarmonyPatch(typeof(CM_PlayerLobbyBar), "UpdateWeaponWindowInfo")]
[HarmonyWrapSafe]
[HarmonyPostfix]
private static void Post_LoadoutHeaderSelected(CM_PlayerLobbyBar __instance, InventorySlot slot)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
BackpackItem val = default(BackpackItem);
if ((Object)(object)_cachedItem != (Object)(object)__instance.selectedWeaponSlotItem || !PlayerBackpackManager.TryGetItem(__instance.m_player, slot, ref val) || val.GearIDRange == null)
{
return;
}
uint offlineID = val.GearIDRange.GetOfflineID();
if (!GearToggleManager.Current.TryGetRelatedIDs(offlineID, out List<uint> relatedIDs))
{
return;
}
foreach (iScrollWindowContent item in (Il2CppArrayBase<iScrollWindowContent>)(object)__instance.m_popupScrollWindow.ContentItems)
{
CM_InventorySlotItem val2 = ((Il2CppObjectBase)item).TryCast<CM_InventorySlotItem>();
if (relatedIDs.Contains(val2.m_gearID.GetOfflineID()))
{
val2.IsPicked = true;
val2.LoadData(val.GearIDRange, true, true);
__instance.OnWeaponSlotItemSelected(val2);
_cachedItem = __instance.selectedWeaponSlotItem;
break;
}
}
}
[HarmonyPatch(typeof(CM_PlayerLobbyBar), "ShowWeaponSelectionPopup")]
[HarmonyWrapSafe]
[HarmonyPostfix]
private static void Post_LoadoutMenuOpened(CM_PlayerLobbyBar __instance)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
CM_PlayerLobbyBar __instance2 = __instance;
CM_ScrollWindowInfoBox infoBox = __instance2.m_popupScrollWindow.InfoBox;
SwapButton = Object.Instantiate<GameObject>(((Component)CM_PageLoadout.Current.m_copyLobbyIdButton).gameObject, ((Component)infoBox).transform);
CM_Item component = SwapButton.GetComponent<CM_Item>();
((TMP_Text)((Il2CppArrayBase<TextMeshPro>)(object)component.m_texts)[0]).SetText("Switch Gear", true);
((Component)component).transform.localPosition = new Vector3(-300f, -320f, -1f);
component.OnBtnPressCallback = null;
component.OnBtnPressCallback += Action<int>.op_Implicit((Action<int>)delegate
{
CM_InventorySlotItem val = __instance2.selectedWeaponSlotItem ?? _cachedItem;
if (!((Object)(object)val == (Object)null))
{
uint offlineID = val.m_gearID.GetOfflineID();
List<uint> relatedIDs = GearToggleManager.Current.GetRelatedIDs(offlineID);
uint value = relatedIDs[(relatedIDs.IndexOf(offlineID) + 1) % relatedIDs.Count];
GearIDRange val2 = default(GearIDRange);
if (GearManager.TryGetGear("OfflineGear_ID_" + value, ref val2))
{
val.LoadData(val2, true, true);
__instance2.OnWeaponSlotItemSelected(val);
}
else
{
PWLogger.Error($"Couldn't swap to next weapon ({value}) in toggle list!");
}
}
});
if ((Object)(object)__instance2.selectedWeaponSlotItem != (Object)null)
{
Post_LoadoutItemSelected(__instance2.selectedWeaponSlotItem);
}
}
[HarmonyPatch(typeof(CM_PlayerLobbyBar), "OnWeaponSlotItemSelected")]
[HarmonyWrapSafe]
[HarmonyPostfix]
private static void Post_LoadoutItemSelected(CM_InventorySlotItem slotItem)
{
if (!((Object)(object)SwapButton == (Object)null))
{
uint offlineID = slotItem.m_gearID.GetOfflineID();
SwapButton.SetActive(GearToggleManager.Current.HasRelatedIDs(offlineID));
}
}
}
[HarmonyPatch]
internal static class RundownManagerPatches
{
[HarmonyPatch(typeof(RundownManager), "SetActiveExpedition")]
[HarmonyAfter(new string[] { "Inas.ExtraObjectiveSetup" })]
[HarmonyPostfix]
private static void Post_RundownManager_SetActiveExpedition(pActiveExpedition expPackage)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
if ((int)expPackage.tier != 99)
{
GearLockManager.Current.SetupAllowedGearsForActiveRundown();
}
}
}
}
namespace ProgressionGear.JSON
{
public sealed class ProgressionLockDataConverter : JsonConverter<ProgressionLockData>
{
public override ProgressionLockData? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new JsonException("ProgressionLockData doesn't have a custom read!");
}
public override void Write(Utf8JsonWriter writer, ProgressionLockData? value, JsonSerializerOptions options)
{
if (value != null)
{
writer.WriteStartObject();
writer.WritePropertyName("Unlock");
JsonSerializer.Serialize(writer, value.Unlock, options);
writer.WritePropertyName("Lock");
JsonSerializer.Serialize(writer, value.Lock, options);
writer.WritePropertyName("OfflineIDs");
JsonSerializer.Serialize(writer, value.OfflineIDs, options);
writer.WriteNumber("Priority", value.Priority);
writer.WriteString("Name", value.Name);
writer.WriteEndObject();
}
}
}
public sealed class ProgressionRequirementConverter : JsonConverter<ProgressionRequirement>
{
public override ProgressionRequirement? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
ProgressionRequirement progressionRequirement = new ProgressionRequirement();
if (ParseRequirement(ref reader, progressionRequirement, options))
{
return progressionRequirement;
}
if (reader.TokenType != JsonTokenType.StartObject)
{
throw new JsonException("Expected progression requirement to be a tier, level layout ID, or object");
}
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndObject)
{
return progressionRequirement;
}
if (reader.TokenType != JsonTokenType.PropertyName)
{
throw new JsonException("Expected PropertyName token");
}
string? @string = reader.GetString();
reader.Read();
switch (@string.ToLowerInvariant().Replace(" ", ""))
{
case "levellayout":
case "requirement":
case "levelid":
case "tier":
case "level":
case "levellayoutid":
ParseRequirement(ref reader, progressionRequirement, options);
break;
case "high":
case "main":
progressionRequirement.Main = reader.GetBoolean();
break;
case "extreme":
case "secondary":
progressionRequirement.Secondary = reader.GetBoolean();
break;
case "overload":
progressionRequirement.Overload = reader.GetBoolean();
break;
case "all":
case "pe":
case "prisonerefficiency":
progressionRequirement.All = reader.GetBoolean();
break;
case "penobooster":
case "allnobooster":
case "prisonerefficiencynobooster":
progressionRequirement.AllNoBooster = reader.GetBoolean();
break;
}
}
throw new JsonException("Expected EndObject token");
}
private static bool ParseRequirement(ref Utf8JsonReader reader, ProgressionRequirement req, JsonSerializerOptions options)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Invalid comparison between Unknown and I4
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Invalid comparison between Unknown and I4
if (reader.TokenType == JsonTokenType.Null)
{
return true;
}
if (reader.TokenType == JsonTokenType.String)
{
string @string = reader.GetString();
if (@string.Length >= 5)
{
req.Tier = @string.Substring(0, 5).ToEnum<eRundownTier>((eRundownTier)99);
}
else
{
req.Tier = ("Tier" + @string[0]).ToEnum<eRundownTier>((eRundownTier)99);
}
int num = ((@string.Length < 5) ? 1 : 5);
if ((int)req.Tier != 99 && @string.Length > num)
{
string text = @string;
int num2 = num;
if (int.TryParse(text.Substring(num2, text.Length - num2), out var result))
{
req.TierIndex = result - 1;
}
else
{
req.Tier = (eRundownTier)99;
}
}
if ((int)req.Tier == 99)
{
req.LevelLayoutID = JsonSerializer.Deserialize<uint>(ref reader, options);
}
return true;
}
if (reader.TokenType == JsonTokenType.Number)
{
req.LevelLayoutID = reader.GetUInt32();
return true;
}
return false;
}
public override void Write(Utf8JsonWriter writer, ProgressionRequirement? value, JsonSerializerOptions options)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Invalid comparison between Unknown and I4
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
if (value == null)
{
return;
}
if (value.LevelLayoutID == 0 && (int)value.Tier == 99)
{
writer.WriteNullValue();
return;
}
eRundownTier tier;
if (value.Main && !value.Secondary && !value.Overload && !value.All)
{
if (value.LevelLayoutID != 0)
{
writer.WriteNumberValue(value.LevelLayoutID);
return;
}
tier = value.Tier;
writer.WriteStringValue(((object)(eRundownTier)(ref tier)).ToString());
return;
}
writer.WriteStartObject();
writer.WritePropertyName("Level");
if (value.LevelLayoutID != 0)
{
writer.WriteNumberValue(value.LevelLayoutID);
}
else
{
tier = value.Tier;
writer.WriteStringValue(((object)(eRundownTier)(ref tier)).ToString() + ((value.TierIndex >= 0) ? ((object)(value.TierIndex + 1)) : ""));
}
writer.WriteBoolean("Main", value.Main);
writer.WriteBoolean("Secondary", value.Secondary);
writer.WriteBoolean("Overload", value.Overload);
writer.WriteBoolean("All", value.All);
writer.WriteBoolean("AllNoBooster", value.AllNoBooster);
writer.WriteEndObject();
}
}
public static class PWJson
{
private static readonly JsonSerializerOptions _readSettings;
private static readonly JsonSerializerOptions _writeSettings;
static PWJson()
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
_readSettings = new JsonSerializerOptions
{
ReadCommentHandling = JsonCommentHandling.Skip,
IncludeFields = true,
PropertyNameCaseInsensitive = true,
WriteIndented = true,
IgnoreReadOnlyProperties = true
};
_writeSettings = new JsonSerializerOptions(_readSettings);
_readSettings.Converters.Add(new JsonStringEnumConverter());
_readSettings.Converters.Add((JsonConverter)new LocalizedTextConverter());
_readSettings.Converters.Add(new ProgressionRequirementConverter());
if (PartialDataWrapper.HasPartialData)
{
_readSettings.Converters.Add(PartialDataWrapper.PersistentIDConverter);
}
foreach (JsonConverter converter in _readSettings.Converters)
{
_writeSettings.Converters.Add(converter);
}
_writeSettings.Converters.Add(new ProgressionLockDataConverter());
}
public static T? Deserialize<T>(string json)
{
return JsonSerializer.Deserialize<T>(json, _readSettings);
}
public static object? Deserialize(Type type, string json)
{
return JsonSerializer.Deserialize(json, type, _readSettings);
}
public static string Serialize<T>(T value)
{
return JsonSerializer.Serialize(value, _writeSettings);
}
}
}
namespace ProgressionGear.ProgressionLock
{
public sealed class GearToggleData
{
public List<uint> OfflineIDs { get; set; } = new List<uint>();
public string Name { get; set; } = string.Empty;
}
public sealed class GearToggleManager
{
public static readonly GearToggleManager Current = new GearToggleManager();
private readonly Dictionary<string, List<GearToggleData>> _fileToData = new Dictionary<string, List<GearToggleData>>();
private readonly Dictionary<uint, List<uint>> _relatedIDs = new Dictionary<uint, List<uint>>();
private readonly LiveEditListener _liveEditListener;
private void FileChanged(LiveEditEventArgs e)
{
LiveEditEventArgs e2 = e;
PWLogger.Warning("LiveEdit File Changed: " + e2.FullPath);
LiveEdit.TryReadFileContent(e2.FullPath, (Action<string>)delegate(string content)
{
ReadFileContent(e2.FullPath, content);
});
}
private void FileDeleted(LiveEditEventArgs e)
{
PWLogger.Warning("LiveEdit File Removed: " + e.FullPath);
_fileToData.Remove(e.FullPath);
ResetRelatedIDs();
}
private void FileCreated(LiveEditEventArgs e)
{
LiveEditEventArgs e2 = e;
PWLogger.Warning("LiveEdit File Created: " + e2.FullPath);
LiveEdit.TryReadFileContent(e2.FullPath, (Action<string>)delegate(string content)
{
ReadFileContent(e2.FullPath, content);
});
}
private void ReadFileContent(string file, string content)
{
_fileToData.Remove(file);
List<GearToggleData> list = null;
try
{
list = PWJson.Deserialize<List<GearToggleData>>(content);
}
catch (JsonException ex)
{
PWLogger.Error("Error parsing progression lock json " + file);
PWLogger.Error(ex.Message);
}
if (list != null)
{
_fileToData[file] = list;
ResetRelatedIDs();
}
}
private GearToggleManager()
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Expected O, but got Unknown
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Expected O, but got Unknown
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Expected O, but got Unknown
string text = Path.Combine(MTFOWrapper.CustomPath, "ProgressionGear", "GearToggle");
if (!Directory.Exists(text))
{
PWLogger.Log("No GearToggle directory detected. Creating template.");
Directory.CreateDirectory(text);
StreamWriter streamWriter = File.CreateText(Path.Combine(text, "Template.json"));
streamWriter.WriteLine(PWJson.Serialize(new List<GearToggleData>
{
new GearToggleData()
}));
streamWriter.Flush();
streamWriter.Close();
}
else
{
PWLogger.Log("GearToggle directory detected.");
}
foreach (string item in Directory.EnumerateFiles(text, "*.json", SearchOption.AllDirectories))
{
string content = File.ReadAllText(item);
ReadFileContent(item, content);
}
_liveEditListener = LiveEdit.CreateListener(text, "*.json", true);
_liveEditListener.FileCreated += new LiveEditEventHandler(FileCreated);
_liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged);
_liveEditListener.FileDeleted += new LiveEditEventHandler(FileDeleted);
}
internal void Init()
{
MTFOHotReloadAPI.OnHotReload += ResetRelatedIDs;
}
public bool IsVisibleID(uint id)
{
if (_relatedIDs.TryGetValue(id, out List<uint> value))
{
return value[0] == id;
}
return true;
}
public bool HasRelatedIDs(uint id)
{
return _relatedIDs.ContainsKey(id);
}
public List<uint>? GetRelatedIDs(uint id)
{
return _relatedIDs.GetValueOrDefault(id);
}
public bool TryGetRelatedIDs(uint id, [MaybeNullWhen(false)] out List<uint> relatedIDs)
{
return _relatedIDs.TryGetValue(id, out relatedIDs);
}
public List<GearToggleData> GetData()
{
List<GearToggleData> list2 = new List<GearToggleData>(_fileToData.Values.Sum((List<GearToggleData> list) => list.Count));
IEnumerator<GearToggleData> enumerator = GetEnumerator();
while (enumerator.MoveNext())
{
list2.Add(enumerator.Current);
}
return list2;
}
public IEnumerator<GearToggleData> GetEnumerator()
{
return new DictListEnumerator<GearToggleData>(_fileToData);
}
public void RemoveFromRelatedIDs(uint id)
{
if (_relatedIDs.TryGetValue(id, out List<uint> value))
{
value.Remove(id);
if (value.Count == 1)
{
_relatedIDs.Remove(value[0]);
}
_relatedIDs.Remove(id);
}
}
public void ResetRelatedIDs()
{
_relatedIDs.Clear();
HashSet<uint> hashSet = new HashSet<uint>();
IEnumerator<GearToggleData> enumerator = GetEnumerator();
while (enumerator.MoveNext())
{
GearToggleData current = enumerator.Current;
if (current.OfflineIDs.Count <= 1)
{
continue;
}
List<uint> list = new List<uint>(current.OfflineIDs.Count);
foreach (uint offlineID in current.OfflineIDs)
{
if (hashSet.Add(offlineID))
{
list.Add(offlineID);
continue;
}
PWLogger.Warning($"Duplicate ID {offlineID} detected in toggle data. Removed from {current.Name}");
}
if (list.Count <= 1)
{
continue;
}
RemoveInvalidGear(list, current.Name);
if (list.Count <= 1)
{
continue;
}
foreach (uint item in list)
{
_relatedIDs[item] = list;
}
}
}
private void RemoveInvalidGear(List<uint> relatedIDs, string name)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)GearLockManager.Current.VanillaGearManager == (Object)null)
{
return;
}
while (relatedIDs.Count > 1)
{
foreach (var (value, dictionary) in GearLockManager.Current.GearSlots)
{
if (!dictionary.ContainsKey(relatedIDs[0]))
{
continue;
}
for (int num = relatedIDs.Count - 1; num >= 1; num--)
{
uint num2 = relatedIDs[num];
if (!dictionary.ContainsKey(num2))
{
PWLogger.Warning($"ID {num2} removed from toggle data {name} since it is not of type {value}");
relatedIDs.RemoveAt(num);
}
}
return;
}
PWLogger.Warning($"ID {relatedIDs[0]} removed from toggle data {name} since it does not exist.");
relatedIDs.RemoveAt(0);
}
}
}
public sealed class GearLockManager
{
private struct PriorityLockData
{
public int priority;
public bool locked;
public bool explicitLock;
}
private readonly HashSet<uint> _lockedGearIds = new HashSet<uint>();
internal readonly List<(InventorySlot inventorySlot, Dictionary<uint, GearIDRange> loadedGears)> GearSlots = new List<(InventorySlot, Dictionary<uint, GearIDRange>)>
{
((InventorySlot)1, new Dictionary<uint, GearIDRange>()),
((InventorySlot)2, new Dictionary<uint, GearIDRange>()),
((InventorySlot)10, new Dictionary<uint, GearIDRange>()),
((InventorySlot)3, new Dictionary<uint, GearIDRange>())
};
public static GearLockManager Current { get; private set; } = new GearLockManager();
public GearManager? VanillaGearManager { get; internal set; }
public void Init()
{
MTFOHotReloadAPI.OnHotReload += SetupAllowedGearsForActiveRundown;
}
private void ConfigRundownGears()
{
if (Configuration.DisableProgression)
{
return;
}
_lockedGearIds.Clear();
GearToggleManager.Current.ResetRelatedIDs();
IEnumerator<ProgressionLockData> enumerator = ProgressionLockManager.Current.GetEnumerator();
Dictionary<uint, PriorityLockData> dictionary = new Dictionary<uint, PriorityLockData>();
while (enumerator.MoveNext())
{
ProgressionLockData current = enumerator.Current;
foreach (uint offlineID in current.OfflineIDs)
{
PriorityLockData priorityLockData = default(PriorityLockData);
priorityLockData.priority = current.Priority;
priorityLockData.locked = IsGearLocked(current);
priorityLockData.explicitLock = IsLockExplicit(current);
PriorityLockData value = priorityLockData;
if (!dictionary.TryGetValue(offlineID, out var value2) || ((!value2.explicitLock || value.explicitLock) && value2.priority <= value.priority))
{
dictionary.Add(offlineID, value);
}
}
}
foreach (KeyValuePair<uint, PriorityLockData> item in dictionary.Where((KeyValuePair<uint, PriorityLockData> kv) => kv.Value.locked))
{
_lockedGearIds.Add(item.Key);
GearToggleManager.Current.RemoveFromRelatedIDs(item.Key);
}
}
private void ClearLoadedGears()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected I4, but got Unknown
foreach (var gearSlot in GearSlots)
{
((Il2CppArrayBase<List<GearIDRange>>)(object)VanillaGearManager.m_gearPerSlot)[(int)gearSlot.inventorySlot].Clear();
}
}
public bool IsGearAllowed(uint id)
{
return !_lockedGearIds.Contains(id);
}
private void AddGearForCurrentRundown()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected I4, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
foreach (var gearSlot in GearSlots)
{
InventorySlot item = gearSlot.inventorySlot;
Dictionary<uint, GearIDRange> item2 = gearSlot.loadedGears;
List<GearIDRange> val = ((Il2CppArrayBase<List<GearIDRange>>)(object)VanillaGearManager.m_gearPerSlot)[(int)item];
if (item2.Count == 0)
{
PWLogger.Debug($"No gear has been loaded for {item}.");
continue;
}
foreach (uint key in item2.Keys)
{
if (IsGearAllowed(key) && EOSWrapper.IsGearAllowed(key))
{
val.Add(item2[key]);
}
}
if (val.Count == 0)
{
PWLogger.Error($"No gear is allowed for {item}, there must be at least 1 allowed gear!");
val.Add(item2.First().Value);
}
}
}
private void ResetPlayerSelectedGears()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected I4, but got Unknown
VanillaGearManager.RescanFavorites();
foreach (var gearSlot in GearSlots)
{
int num = (int)gearSlot.inventorySlot;
if (((Il2CppArrayBase<GearIDRange>)(object)VanillaGearManager.m_lastEquippedGearPerSlot)[num] != null)
{
PlayerBackpackManager.EquipLocalGear(((Il2CppArrayBase<GearIDRange>)(object)VanillaGearManager.m_lastEquippedGearPerSlot)[num]);
}
else if (((Il2CppArrayBase<List<GearIDRange>>)(object)VanillaGearManager.m_favoriteGearPerSlot)[num].Count > 0)
{
PlayerBackpackManager.EquipLocalGear(((Il2CppArrayBase<List<GearIDRange>>)(object)VanillaGearManager.m_favoriteGearPerSlot)[num][0]);
}
else if (((Il2CppArrayBase<List<GearIDRange>>)(object)VanillaGearManager.m_gearPerSlot)[num].Count > 0)
{
PlayerBackpackManager.EquipLocalGear(((Il2CppArrayBase<List<GearIDRange>>)(object)VanillaGearManager.m_gearPerSlot)[num][0]);
}
}
}
private void RemoveToggleGears()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected I4, but got Unknown
foreach (var gearSlot in GearSlots)
{
List<GearIDRange> val = ((Il2CppArrayBase<List<GearIDRange>>)(object)VanillaGearManager.m_gearPerSlot)[(int)gearSlot.inventorySlot];
for (int num = val.Count - 1; num >= 0; num--)
{
if (!GearToggleManager.Current.IsVisibleID(val[num].GetOfflineID()))
{
val.RemoveAt(num);
}
}
}
}
internal void SetupAllowedGearsForActiveRundown()
{
if (ProgressionWrapper.UpdateReferences())
{
ConfigRundownGears();
ClearLoadedGears();
AddGearForCurrentRundown();
ResetPlayerSelectedGears();
RemoveToggleGears();
}
}
private static bool IsGearLocked(ProgressionLockData data)
{
if (!data.Unlock.Any() || data.Unlock.All(IsComplete))
{
if (data.Lock.Any())
{
return data.Lock.All(IsComplete);
}
return false;
}
return true;
}
private static bool IsLockExplicit(ProgressionLockData data)
{
if (!data.Unlock.All(IsComplete))
{
if (data.Lock.Any())
{
return data.Lock.All(IsComplete);
}
return false;
}
return true;
}
private static bool IsComplete(ProgressionRequirement req)
{
return ProgressionWrapper.IsComplete(req);
}
}
public sealed class ProgressionData
{
public string ExpeditionKey { get; set; } = string.Empty;
public int MainCompletionCount { get; set; }
public int SecondaryCompletionCount { get; set; }
public int ThirdCompletionCount { get; set; }
public int AllCompletionCount { get; set; }
public int NoBoosterAllClearCount { get; set; }
public ProgressionData()
{
}
public ProgressionData(string key, int main, int secondary, int third, int all, int noBooster)
{
ExpeditionKey = key;
MainCompletionCount = main;
SecondaryCompletionCount = secondary;
ThirdCompletionCount = third;
AllCompletionCount = all;
NoBoosterAllClearCount = noBooster;
}
}
public sealed class ProgressionLockData
{
public static readonly ProgressionLockData[] Template = new ProgressionLockData[2]
{
new ProgressionLockData
{
Unlock = new List<ProgressionRequirement>
{
new ProgressionRequirement
{
LevelLayoutID = 420u
},
new ProgressionRequirement
{
Tier = (eRundownTier)2
},
new ProgressionRequirement
{
LevelLayoutID = 10u,
Main = true,
Secondary = true
},
new ProgressionRequirement
{
Tier = (eRundownTier)1,
TierIndex = 1,
Main = false,
All = true
}
},
Lock = new List<ProgressionRequirement>
{
new ProgressionRequirement
{
Tier = (eRundownTier)3
}
},
OfflineIDs = new List<uint> { 0u },
Priority = 0,
Name = "Example"
},
new ProgressionLockData
{
Name = "Empty Example"
}
};
public List<ProgressionRequirement> UnlockLayoutIDs { get; set; } = new List<ProgressionRequirement>();
public List<ProgressionRequirement> UnlockTiers { get; set; } = new List<ProgressionRequirement>();
public List<ProgressionRequirement> Unlock { get; set; } = new List<ProgressionRequirement>();
public List<ProgressionRequirement> LockLayoutIDs { get; set; } = new List<ProgressionRequirement>();
public List<ProgressionRequirement> LockTiers { get; set; } = new List<ProgressionRequirement>();
public List<ProgressionRequirement> Lock { get; set; } = new List<ProgressionRequirement>();
public List<uint> OfflineIDs { get; set; } = new List<uint>();
public int Priority { get; set; }
public string Name { get; set; } = string.Empty;
}
public sealed class ProgressionLockManager
{
public static readonly ProgressionLockManager Current = new ProgressionLockManager();
private readonly Dictionary<string, List<ProgressionLockData>> _fileToData = new Dictionary<string, List<ProgressionLockData>>();
private readonly LiveEditListener _liveEditListener;
private void FileChanged(LiveEditEventArgs e)
{
LiveEditEventArgs e2 = e;
PWLogger.Warning("LiveEdit File Changed: " + e2.FullPath);
LiveEdit.TryReadFileContent(e2.FullPath, (Action<string>)delegate(string content)
{
ReadFileContent(e2.FullPath, content);
});
}
private void FileDeleted(LiveEditEventArgs e)
{
PWLogger.Warning("LiveEdit File Removed: " + e.FullPath);
_fileToData.Remove(e.FullPath);
}
private void FileCreated(LiveEditEventArgs e)
{
LiveEditEventArgs e2 = e;
PWLogger.Warning("LiveEdit File Created: " + e2.FullPath);
LiveEdit.TryReadFileContent(e2.FullPath, (Action<string>)delegate(string content)
{
ReadFileContent(e2.FullPath, content);
});
}
private void ReadFileContent(string file, string content)
{
_fileToData.Remove(file);
List<ProgressionLockData> list = null;
try
{
list = PWJson.Deserialize<List<ProgressionLockData>>(content);
}
catch (JsonException ex)
{
PWLogger.Error("Error parsing progression lock json " + file);
PWLogger.Error(ex.Message);
}
if (list == null)
{
return;
}
foreach (ProgressionLockData item in list)
{
if (!item.Unlock.Any())
{
item.Unlock.AddRange(item.UnlockLayoutIDs);
item.Unlock.AddRange(item.UnlockTiers);
item.UnlockLayoutIDs.Clear();
item.UnlockTiers.Clear();
}
if (!item.Lock.Any())
{
item.Lock.AddRange(item.LockLayoutIDs);
item.Lock.AddRange(item.LockTiers);
item.LockLayoutIDs.Clear();
item.LockTiers.Clear();
}
}
_fileToData[file] = list;
}
private ProgressionLockManager()
{
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Expected O, but got Unknown
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Expected O, but got Unknown
string text = Path.Combine(MTFOWrapper.CustomPath, "ProgressionGear", "ProgressionLocks");
if (!Directory.Exists(text))
{
PWLogger.Log("No ProgressionLocks directory detected. Creating template.");
Directory.CreateDirectory(text);
StreamWriter streamWriter = File.CreateText(Path.Combine(text, "Template.json"));
streamWriter.WriteLine(PWJson.Serialize(ProgressionLockData.Template));
streamWriter.Flush();
streamWriter.Close();
}
else
{
PWLogger.Log("ProgressionLocks directory detected.");
}
foreach (string item in Directory.EnumerateFiles(text, "*.json", SearchOption.AllDirectories))
{
string content = File.ReadAllText(item);
ReadFileContent(item, content);
}
_liveEditListener = LiveEdit.CreateListener(text, "*.json", true);
_liveEditListener.FileCreated += new LiveEditEventHandler(FileCreated);
_liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged);
_liveEditListener.FileDeleted += new LiveEditEventHandler(FileDeleted);
}
internal void Init()
{
}
public List<ProgressionLockData> GetLockData()
{
List<ProgressionLockData> list2 = new List<ProgressionLockData>(_fileToData.Values.Sum((List<ProgressionLockData> list) => list.Count));
IEnumerator<ProgressionLockData> enumerator = GetEnumerator();
while (enumerator.MoveNext())
{
list2.Add(enumerator.Current);
}
return list2;
}
public IEnumerator<ProgressionLockData> GetEnumerator()
{
return new DictListEnumerator<ProgressionLockData>(_fileToData);
}
}
public sealed class ProgressionRequirement
{
public eRundownTier Tier { get; set; } = (eRundownTier)99;
public int TierIndex { get; set; } = -1;
public uint LevelLayoutID { get; set; }
public bool Main { get; set; } = true;
public bool Secondary { get; set; }
public bool Overload { get; set; }
public bool All { get; set; }
public bool AllNoBooster { get; set; }
public bool Complete(ProgressionData data)
{
if ((!AllNoBooster || data.NoBoosterAllClearCount > 0) && (!All || data.AllCompletionCount > 0) && (!Main || data.MainCompletionCount > 0) && (!Secondary || data.SecondaryCompletionCount > 0))
{
if (Overload)
{
return data.ThirdCompletionCount > 0;
}
return true;
}
return false;
}
}
public static class ProgressionWrapper
{
private struct ExpeditionKey
{
public eRundownTier tier;
public int expIndex;
}
private static readonly Dictionary<uint, ExpeditionKey> _layoutToExpedition;
private static readonly Dictionary<eRundownTier, List<ExpeditionKey>> _tierExpeditionKeys;
private static readonly Dictionary<eRundownTier, List<ProgressionData>> _nativeProgression;
public static uint CurrentRundownID { get; private set; }
static ProgressionWrapper()
{
_layoutToExpedition = new Dictionary<uint, ExpeditionKey>();
_tierExpeditionKeys = new Dictionary<eRundownTier, List<ExpeditionKey>>
{
{
(eRundownTier)1,
new List<ExpeditionKey>()
},
{
(eRundownTier)2,
new List<ExpeditionKey>()
},
{
(eRundownTier)3,
new List<ExpeditionKey>()
},
{
(eRundownTier)4,
new List<ExpeditionKey>()
},
{
(eRundownTier)5,
new List<ExpeditionKey>()
}
};
_nativeProgression = new Dictionary<eRundownTier, List<ProgressionData>>();
CurrentRundownID = 0u;
}
private static uint ActiveRundownID()
{
string activeRundownKey = RundownManager.ActiveRundownKey;
uint result = default(uint);
if (!RundownManager.RundownProgressionReady || !RundownManager.TryGetIdFromLocalRundownKey(activeRundownKey, ref result))
{
return 0u;
}
return result;
}
public static bool UpdateReferences()
{
uint num = ActiveRundownID();
if (num == 0)
{
return false;
}
if (CurrentRundownID == num)
{
return true;
}
CurrentRundownID = num;
_layoutToExpedition.Clear();
RundownDataBlock block = GameDataBlockBase<RundownDataBlock>.GetBlock(CurrentRundownID);
AddTierLayouts((eRundownTier)1, block.TierA);
AddTierLayouts((eRundownTier)2, block.TierB);
AddTierLayouts((eRundownTier)3, block.TierC);
AddTierLayouts((eRundownTier)4, block.TierD);
AddTierLayouts((eRundownTier)5, block.TierE);
return true;
}
internal static void UpdateNativeProgression(eRundownTier tier, int expIndex, ProgressionData data)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
UpdateReferences();
if (!_nativeProgression.ContainsKey(tier))
{
_nativeProgression[tier] = new List<ProgressionData>(5);
}
List<ProgressionData> list = _nativeProgression[tier];
if (list.Count <= expIndex)
{
list.EnsureCapacity(expIndex + 1);
for (int i = list.Count; i <= expIndex; i++)
{
list.Add(new ProgressionData());
}
}
list[expIndex] = data;
}
private static void AddTierLayouts(eRundownTier tier, List<ExpeditionInTierData> dataList)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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)
_tierExpeditionKeys[tier].Clear();
for (int i = 0; i < dataList.Count; i++)
{
ExpeditionInTierData val = dataList[i];
if (val.Enabled)
{
ExpeditionKey expeditionKey = default(ExpeditionKey);
expeditionKey.tier = tier;
expeditionKey.expIndex = i;
ExpeditionKey expeditionKey2 = expeditionKey;
_layoutToExpedition.TryAdd(val.LevelLayoutData, expeditionKey2);
_tierExpeditionKeys[tier].Add(expeditionKey2);
}
}
}
private static ProgressionData GetProgressionData(uint id, eRundownTier tier, int index)
{
//IL_0008: 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)
if (LocalProgressionWrapper.HasLocalProgression)
{
return LocalProgressionWrapper.GetProgressionDataLP(id, tier, index);
}
if (_nativeProgression.Count == 0)
{
return new ProgressionData();
}
return _nativeProgression[tier][index];
}
public static bool IsComplete(ProgressionRequirement req)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Invalid comparison between Unknown and I4
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
UpdateReferences();
if (req.LevelLayoutID != 0)
{
if (!_layoutToExpedition.ContainsKey(req.LevelLayoutID))
{
return true;
}
ExpeditionKey expeditionKey = _layoutToExpedition[req.LevelLayoutID];
return req.Complete(GetProgressionData(CurrentRundownID, expeditionKey.tier, expeditionKey.expIndex));
}
if ((int)req.Tier != 99)
{
if (req.TierIndex >= 0 && req.TierIndex < _tierExpeditionKeys[req.Tier].Count)
{
return req.Complete(GetProgressionData(CurrentRundownID, req.Tier, req.TierIndex));
}
foreach (ExpeditionKey item in _tierExpeditionKeys[req.Tier])
{
if (!req.Complete(GetProgressionData(CurrentRundownID, item.tier, item.expIndex)))
{
return false;
}
}
}
return true;
}
}
}
namespace ProgressionGear.Dependencies
{
internal static class EOSWrapper
{
public const string GUID = "Inas.ExtraObjectiveSetup";
private static readonly HashSet<uint> _targetIDs;
private static bool _allow;
public static bool HasEOS { get; private set; }
static EOSWrapper()
{
_targetIDs = new HashSet<uint>();
_allow = false;
HasEOS = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("Inas.ExtraObjectiveSetup");
}
public static void CacheLocks()
{
if (HasEOS)
{
CacheLocksEOS();
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static void CacheLocksEOS()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
ExpeditionDefinition definition = ExpeditionDefinitionManager.Current.GetDefinition(ExpeditionDefinitionManager.Current.CurrentMainLevelLayout);
if (definition == null || definition.ExpeditionGears == null)
{
_allow = false;
return;
}
_allow = (int)definition.ExpeditionGears.Mode == 0;
definition.ExpeditionGears.GearIds.ForEach(delegate(uint id)
{
_targetIDs.Add(id);
});
}
public static bool IsGearAllowed(uint id)
{
if (!HasEOS)
{
return true;
}
return IsGearAllowedEOS(id);
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool IsGearAllowedEOS(uint id)
{
if (!_allow)
{
return !_targetIDs.Contains(id);
}
return _targetIDs.Contains(id);
}
}
internal static class LocalProgressionWrapper
{
public const string GUID = "Inas.LocalProgression";
public static bool HasLocalProgression { get; private set; }
static LocalProgressionWrapper()
{
HasLocalProgression = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("Inas.LocalProgression");
}
public static ProgressionData GetProgressionDataLP(uint id, eRundownTier tier, int index)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if (!HasLocalProgression)
{
return new ProgressionData();
}
ExpeditionProgressionData expeditionLP = LocalProgressionManager.Current.GetExpeditionLP(id, tier, index);
return new ProgressionData(expeditionLP.ExpeditionKey, expeditionLP.MainCompletionCount, expeditionLP.SecondaryCompletionCount, expeditionLP.ThirdCompletionCount, expeditionLP.AllClearCount, expeditionLP.NoBoosterAllClearCount);
}
}
internal static class PartialDataWrapper
{
public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks";
public static readonly bool HasPartialData;
public static JsonConverter? PersistentIDConverter { get; private set; }
static PartialDataWrapper()
{
if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value))
{
return;
}
try
{
PersistentIDConverter = (JsonConverter)Activator.CreateInstance((((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? throw new Exception("Assembly is Missing!")).GetTypes().First((Type t) => t.Name == "PersistentIDConverter") ?? throw new Exception("Unable to Find PersistentIDConverter Class"));
HasPartialData = true;
}
catch (Exception value2)
{
PWLogger.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}");
}
}
}
}