using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.UI;
using ProjectM.WeaponCoating;
using Stunlock.Core;
using Stunlock.Localization;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PotionDuration")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Configurable duration for V Rising potions, elixirs and imbuements (weapon coatings)")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+f4a8e7f38af16b8d1f51d79710c318bcbf5dc344")]
[assembly: AssemblyProduct("PotionDuration")]
[assembly: AssemblyTitle("PotionDuration")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PotionDuration
{
[BepInPlugin("PotionDuration", "PotionDuration", "1.1.1")]
public class Plugin : BasePlugin
{
internal static ManualLogSource Logger;
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<bool> DumpBuffs;
internal static ConfigEntry<int> PotionMinutes;
internal static ConfigEntry<int> ElixirMinutes;
internal static ConfigEntry<int> ImbuementMinutes;
internal static ConfigEntry<string> Include;
internal static ConfigEntry<string> Exclude;
internal static bool IsServer;
private Harmony _harmony;
public override void Load()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Expected O, but got Unknown
Logger = ((BasePlugin)this).Log;
Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Set to false to turn the mod off (everything stays as in the base game).");
AcceptableValueRange<int> val = new AcceptableValueRange<int>(1, 1440);
PotionMinutes = ((BasePlugin)this).Config.Bind<int>("Duration", "PotionMinutes", 120, new ConfigDescription("Duration in minutes for potions and brews (base game 60).\nExamples: 30 = 30 min (50% shorter than the base game)\n 120 = 2 h (100% longer; the default)\n 240 = 4 h (300% longer, 4x the base game)\nAny value from 1 to 1440 (24 h); a value outside that range is set to the nearest limit.\nPlayers: use the same minutes as the server, or the tooltips show the wrong time.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
ElixirMinutes = ((BasePlugin)this).Config.Bind<int>("Duration", "ElixirMinutes", 120, new ConfigDescription("Duration in minutes for elixirs (base game 60).\nExamples: 30 = 30 min (50% shorter than the base game)\n 120 = 2 h (100% longer; the default)\n 240 = 4 h (300% longer, 4x the base game)\nAny value from 1 to 1440 (24 h); a value outside that range is set to the nearest limit.\nPlayers: use the same minutes as the server, or the tooltips show the wrong time.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
ImbuementMinutes = ((BasePlugin)this).Config.Bind<int>("Duration", "ImbuementMinutes", 120, new ConfigDescription("Duration in minutes for imbuements (weapon coatings) (base game 60).\nExamples: 30 = 30 min (50% shorter than the base game)\n 120 = 2 h (100% longer; the default)\n 240 = 4 h (300% longer, 4x the base game)\nAny value from 1 to 1440 (24 h); a value outside that range is set to the nearest limit.\nPlayers: use the same minutes as the server, or the tooltips show the wrong time.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
Include = ((BasePlugin)this).Config.Bind<string>("Selection", "Include", "", "Comma-separated buff names to treat as potions too (or as elixirs, if the name contains 'Elixir'). The buff must last 60 minutes in the base game.");
Exclude = ((BasePlugin)this).Config.Bind<string>("Selection", "Exclude", "", "Comma-separated buff or imbuement (weapon coating) names to leave unchanged.");
DumpBuffs = ((BasePlugin)this).Config.Bind<bool>("Discovery", "DumpBuffs", false, "Write every timed buff (name, ID, duration) to BepInEx/config/PotionDuration/buffs.csv at start, to find buff names.");
bool flag = (IsServer = Paths.ProcessName.Equals("VRisingServer", StringComparison.OrdinalIgnoreCase));
if (flag)
{
_harmony = Harmony.CreateAndPatchAll(typeof(ServerReadyPatch), "PotionDuration");
}
else
{
((BasePlugin)this).AddComponent<ClientWorldWatcher>();
((BasePlugin)this).AddComponent<ImbuementIconFixer>();
_harmony = Harmony.CreateAndPatchAll(typeof(CoatingServerTimePatch), "PotionDuration");
}
ManualLogSource log = ((BasePlugin)this).Log;
bool flag2 = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(86, 8, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("PotionDuration");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.1.1");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded on ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(flag ? "server" : "client");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("(Enabled=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(Enabled.Value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", PotionMinutes=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(PotionMinutes.Value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", ElixirMinutes=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(ElixirMinutes.Value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("ImbuementMinutes=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(ImbuementMinutes.Value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", DumpBuffs=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(DumpBuffs.Value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
}
log.LogInfo(val2);
}
public override bool Unload()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
internal static void OnGameDataReady(World world)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
if (!Enabled.Value)
{
return;
}
try
{
if (DumpBuffs.Value)
{
BuffDump.Write(world);
}
Dictionary<string, string> changedBuffs = DurationPatcher.Apply(world);
if (!IsServer)
{
TooltipPatcher.Apply(world, changedBuffs);
ImbuementIconFixer.ClientWorld = world;
}
}
catch (Exception ex)
{
ManualLogSource logger = Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(42, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Game-data-ready handler failed in world ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(world.Name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
logger.LogError(val);
}
}
}
[HarmonyPatch(typeof(SpawnTeamSystem_OnPersistenceLoad), "OnUpdate")]
internal static class ServerReadyPatch
{
private static bool _done;
private static void Postfix(SpawnTeamSystem_OnPersistenceLoad __instance)
{
if (_done)
{
return;
}
World world = ((ComponentSystemBase)__instance).World;
if (world != null && !(world.Name != "Server"))
{
PrefabCollectionSystem existingSystemManaged = world.GetExistingSystemManaged<PrefabCollectionSystem>();
if (existingSystemManaged != null && existingSystemManaged.GameDataInitialized)
{
_done = true;
Plugin.OnGameDataReady(world);
}
}
}
}
public class ClientWorldWatcher : MonoBehaviour
{
private readonly HashSet<ulong> _seen = new HashSet<ulong>();
private readonly HashSet<ulong> _done = new HashSet<ulong>();
private float _next;
public ClientWorldWatcher(IntPtr ptr)
: base(ptr)
{
}
private void Update()
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
if (Time.unscaledTime < _next)
{
return;
}
_next = Time.unscaledTime + 1f;
List<World> s_AllWorlds = World.s_AllWorlds;
bool flag = default(bool);
for (int i = 0; i < s_AllWorlds.Count; i++)
{
World val = s_AllWorlds[i];
if (val == null || !val.IsCreated || _done.Contains(val.SequenceNumber))
{
continue;
}
PrefabCollectionSystem existingSystemManaged = val.GetExistingSystemManaged<PrefabCollectionSystem>();
if (existingSystemManaged == null)
{
continue;
}
if (_seen.Add(val.SequenceNumber))
{
ManualLogSource logger = Plugin.Logger;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(44, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("World ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(val.Name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<ulong>(val.SequenceNumber);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") has prefabs; waiting for game data");
}
logger.LogInfo(val2);
}
if (existingSystemManaged.GameDataInitialized)
{
_done.Add(val.SequenceNumber);
Plugin.OnGameDataReady(val);
}
}
}
}
[HarmonyPatch(typeof(BuffBarParentSystem), "AddWeaponCoatingExpireEntry")]
internal static class CoatingServerTimePatch
{
internal static double ServerTime = -1.0;
internal static double RealTimeAt;
private static void Postfix(ServerTime serverTime)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
ServerTime = serverTime.Time;
RealTimeAt = Time.realtimeSinceStartupAsDouble;
}
}
public class ImbuementIconFixer : MonoBehaviour
{
private class Overlay
{
public BuffBarEntry Entry;
public GameObject Text;
public GameObject Ring;
public LocalizedText Label;
public Image RingImage;
public string LastText;
}
private const float VanillaSeconds = 3600f;
internal static World ClientWorld;
internal static readonly HashSet<int> CoatingGuids = new HashSet<int>();
private readonly Dictionary<IntPtr, Overlay> _overlays = new Dictionary<IntPtr, Overlay>();
private readonly List<IntPtr> _gone = new List<IntPtr>();
private float _nextScan;
private string _hoursFormat;
public ImbuementIconFixer(IntPtr ptr)
: base(ptr)
{
}
private void LateUpdate()
{
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Expected O, but got Unknown
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.Enabled.Value || CoatingGuids.Count == 0)
{
return;
}
try
{
World clientWorld = ClientWorld;
if (clientWorld == null || !clientWorld.IsCreated || CoatingServerTimePatch.ServerTime < 0.0)
{
return;
}
PrefabGUID prefabGUID;
if (Time.unscaledTime >= _nextScan)
{
_nextScan = Time.unscaledTime + 1f;
Il2CppReferenceArray<Object> val = Object.FindObjectsOfType(Il2CppType.Of<BuffBarEntry>());
for (int i = 0; i < ((Il2CppArrayBase<Object>)(object)val).Length; i++)
{
BuffBarEntry val2 = ((Il2CppObjectBase)((Il2CppArrayBase<Object>)(object)val)[i]).TryCast<BuffBarEntry>();
if (!((Object)(object)val2 == (Object)null) && !_overlays.ContainsKey(((Il2CppObjectBase)val2).Pointer))
{
HashSet<int> coatingGuids = CoatingGuids;
prefabGUID = val2.PrefabGUID;
if (coatingGuids.Contains(((PrefabGUID)(ref prefabGUID)).GuidHash) && !((Object)(object)val2.TimeLeft == (Object)null) && !((Object)(object)val2.Progress == (Object)null))
{
_overlays[((Il2CppObjectBase)val2).Pointer] = CreateOverlay(val2);
}
}
}
}
if (_overlays.Count == 0)
{
return;
}
EntityManager entityManager = clientWorld.EntityManager;
ComponentType val3 = default(ComponentType);
((ComponentType)(ref val3))..ctor(Il2CppType.Of<Coatable>(), (AccessMode)1);
double num = CoatingServerTimePatch.ServerTime + (Time.realtimeSinceStartupAsDouble - CoatingServerTimePatch.RealTimeAt);
float val4 = (float)Plugin.ImbuementMinutes.Value * 60f;
foreach (KeyValuePair<IntPtr, Overlay> overlay2 in _overlays)
{
overlay2.Deconstruct(out var key, out var value);
IntPtr item = key;
Overlay overlay = value;
BuffBarEntry entry = overlay.Entry;
if ((Object)(object)entry == (Object)null || (Object)(object)overlay.Text == (Object)null || (Object)(object)overlay.Ring == (Object)null)
{
_gone.Add(item);
continue;
}
float num2 = 0f;
HashSet<int> coatingGuids2 = CoatingGuids;
prefabGUID = entry.PrefabGUID;
bool flag = coatingGuids2.Contains(((PrefabGUID)(ref prefabGUID)).GuidHash) && ((EntityManager)(ref entityManager)).Exists(entry.Entity) && ((EntityManager)(ref entityManager)).HasComponent(entry.Entity, val3);
if (flag)
{
num2 = (float)(((EntityManager)(ref entityManager)).GetComponentData<Coatable>(entry.Entity).CoatingExpireTime - num);
flag = num2 > 3600f;
}
if (overlay.Text.activeSelf != flag)
{
overlay.Text.SetActive(flag);
}
if (overlay.Ring.activeSelf != flag)
{
overlay.Ring.SetActive(flag);
}
if (flag)
{
string text = Hours(entry, Mathf.CeilToInt(num2 / 3600f));
if (text != overlay.LastText)
{
overlay.Label.ForceSet(text);
overlay.LastText = text;
}
overlay.RingImage.fillAmount = Mathf.Clamp01(1f - num2 / Math.Max(val4, num2));
}
}
foreach (IntPtr item2 in _gone)
{
_overlays.Remove(item2);
}
_gone.Clear();
}
catch (Exception ex)
{
ManualLogSource logger = Plugin.Logger;
bool flag2 = default(bool);
BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Imbuement icon fix failed: ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<Exception>(ex);
}
logger.LogError(val5);
((Behaviour)this).enabled = false;
}
}
private static Overlay CreateOverlay(BuffBarEntry e)
{
Overlay obj = new Overlay
{
Entry = e,
Ring = Copy(((Component)e.Progress).gameObject, "PotionDuration_Progress")
};
obj.RingImage = obj.Ring.GetComponent<Image>();
obj.Text = Copy(((Component)e.TimeLeft).gameObject, "PotionDuration_TimeLeft");
obj.Label = obj.Text.GetComponent<LocalizedText>();
return obj;
}
private static GameObject Copy(GameObject original, string name)
{
GameObject obj = Object.Instantiate<GameObject>(original, original.transform.parent);
((Object)obj).name = name;
obj.transform.SetSiblingIndex(original.transform.GetSiblingIndex() + 1);
obj.SetActive(false);
return obj;
}
private string Hours(BuffBarEntry e, int hours)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
if (_hoursFormat == null)
{
try
{
_hoursFormat = Localization.Get(e.LKey_Hours, false) ?? "";
}
catch
{
_hoursFormat = "";
}
}
if (_hoursFormat.Contains("{value}"))
{
return _hoursFormat.Replace("{value}", hours.ToString());
}
if (_hoursFormat.Contains("{0}"))
{
return _hoursFormat.Replace("{0}", hours.ToString());
}
return hours + "h";
}
}
internal static class DurationPatcher
{
private const float VanillaSeconds = 3600f;
private static readonly Regex PotionName = new Regex("^AB_Consumable_\\w*Potion_T\\d+_Buff$");
private static readonly Regex ElixirName = new Regex("^AB_Elixir_\\w+_Buff$");
private static string Classify(string name, HashSet<string> include, HashSet<string> exclude)
{
if (exclude.Contains(name))
{
return null;
}
if (ElixirName.IsMatch(name))
{
return "elixir";
}
if (PotionName.IsMatch(name))
{
return "potion";
}
if (include.Contains(name))
{
if (!name.Contains("Elixir", StringComparison.OrdinalIgnoreCase))
{
return "potion";
}
return "elixir";
}
return null;
}
private static HashSet<string> NameList(string value)
{
return new HashSet<string>(value.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries), StringComparer.Ordinal);
}
public static Dictionary<string, string> Apply(World world)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_041e: Unknown result type (might be due to invalid IL or missing references)
//IL_0425: Expected O, but got Unknown
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Expected O, but got Unknown
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Expected O, but got Unknown
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Expected O, but got Unknown
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = world.EntityManager;
PrefabCollectionSystem existingSystemManaged = world.GetExistingSystemManaged<PrefabCollectionSystem>();
PrefabLookupMap prefabLookupMap = existingSystemManaged._PrefabLookupMap;
NativeParallelHashMap<PrefabGUID, Entity> prefabGuidToEntityMap = existingSystemManaged._PrefabGuidToEntityMap;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<Buff>(), (AccessMode)1);
ComponentType val2 = default(ComponentType);
((ComponentType)(ref val2))..ctor(Il2CppType.Of<LifeTime>(), (AccessMode)0);
HashSet<string> hashSet = NameList(Plugin.Include.Value);
HashSet<string> exclude = NameList(Plugin.Exclude.Value);
Dictionary<string, float> dictionary2 = new Dictionary<string, float>
{
["potion"] = (float)Plugin.PotionMinutes.Value * 60f,
["elixir"] = (float)Plugin.ElixirMinutes.Value * 60f
};
int num = 0;
int num2 = 0;
int num3 = 0;
HashSet<string> foundIncludes = new HashSet<string>();
NativeArray<PrefabGUID> keyArray = existingSystemManaged._PrefabDataLookup.GetKeyArray(AllocatorHandle.op_Implicit((Allocator)2));
bool flag = default(bool);
try
{
string text = default(string);
Entity val4 = default(Entity);
for (int i = 0; i < keyArray.Length; i++)
{
PrefabGUID val3 = keyArray[i];
if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetName(val3, ref text) || text == null)
{
continue;
}
string text2 = Classify(text, hashSet, exclude);
if (text2 == null)
{
continue;
}
if (hashSet.Contains(text))
{
foundIncludes.Add(text);
}
if (!prefabGuidToEntityMap.TryGetValue(val3, ref val4))
{
num3++;
ManualLogSource logger = Plugin.Logger;
BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(41, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Not converted at start, left vanilla: ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" (");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(((PrefabGUID)(ref val3)).GuidHash);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(")");
}
logger.LogWarning(val5);
continue;
}
if (!((EntityManager)(ref entityManager)).HasComponent(val4, val) || !((EntityManager)(ref entityManager)).HasComponent(val4, val2))
{
num2++;
ManualLogSource logger2 = Plugin.Logger;
BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(40, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Skipped ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text2);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" (");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(((PrefabGUID)(ref val3)).GuidHash);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("): no Buff/LifeTime component");
}
logger2.LogWarning(val5);
continue;
}
LifeTime componentData = ((EntityManager)(ref entityManager)).GetComponentData<LifeTime>(val4);
if (componentData.Duration != 3600f)
{
num2++;
ManualLogSource logger3 = Plugin.Logger;
BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(39, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Skipped ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text2);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" (");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(((PrefabGUID)(ref val3)).GuidHash);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("): vanilla duration ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(componentData.Duration);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("s, not ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(3600f);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("s");
}
logger3.LogWarning(val5);
continue;
}
float duration = componentData.Duration;
componentData.Duration = dictionary2[text2];
((EntityManager)(ref entityManager)).SetComponentData<LifeTime>(val4, componentData);
num++;
dictionary[text] = text2;
ManualLogSource logger4 = Plugin.Logger;
BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(20, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Changed ");
((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(text2);
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" (");
((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<int>(((PrefabGUID)(ref val3)).GuidHash);
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("): ");
((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<float>(duration);
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("s -> ");
((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<float>(componentData.Duration);
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("s");
}
logger4.LogInfo(val6);
}
}
finally
{
keyArray.Dispose();
}
foreach (string item in hashSet.Where((string n) => !foundIncludes.Contains(n)))
{
ManualLogSource logger5 = Plugin.Logger;
BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(37, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Include entry not found or excluded: ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(item);
}
logger5.LogWarning(val5);
}
string text3 = $"[{world.Name}] {num} buff prefabs changed (potions {Plugin.PotionMinutes.Value} min, elixirs {Plugin.ElixirMinutes.Value} min), {num2} skipped, {num3} not converted at start";
if (num == 0)
{
Plugin.Logger.LogWarning((object)(text3 + ". Nothing matched: a game patch may have renamed the buffs; re-run DumpBuffs."));
}
else
{
Plugin.Logger.LogInfo((object)text3);
}
ApplyCoatings(world, exclude, dictionary);
return dictionary;
}
private static void ApplyCoatings(World world, HashSet<string> exclude, Dictionary<string, string> changed)
{
//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_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: 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)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Expected O, but got Unknown
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Expected O, but got Unknown
//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_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = world.EntityManager;
PrefabCollectionSystem existingSystemManaged = world.GetExistingSystemManaged<PrefabCollectionSystem>();
PrefabLookupMap prefabLookupMap = existingSystemManaged._PrefabLookupMap;
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<WeaponCoating>(), (AccessMode)0);
float expireDuration = (float)Plugin.ImbuementMinutes.Value * 60f;
int num = 0;
int num2 = 0;
NativeKeyValueArrays<PrefabGUID, Entity> keyValueArrays = existingSystemManaged._PrefabGuidToEntityMap.GetKeyValueArrays(AllocatorHandle.op_Implicit((Allocator)2));
try
{
bool flag = default(bool);
for (int i = 0; i < keyValueArrays.Length; i++)
{
Entity val2 = keyValueArrays.Values[i];
if (!((EntityManager)(ref entityManager)).HasComponent(val2, val))
{
continue;
}
string text = ((PrefabLookupMap)(ref prefabLookupMap)).GetName(keyValueArrays.Keys[i]) ?? "";
WeaponCoating componentData = ((EntityManager)(ref entityManager)).GetComponentData<WeaponCoating>(val2);
string text2 = ((PrefabLookupMap)(ref prefabLookupMap)).GetName(componentData.BuffId) ?? "";
if (exclude.Contains(text))
{
continue;
}
PrefabGUID val4;
if (componentData.ExpireDuration != 3600f)
{
num2++;
ManualLogSource logger = Plugin.Logger;
BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(48, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Skipped imbuement ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (");
val4 = keyValueArrays.Keys[i];
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(((PrefabGUID)(ref val4)).GuidHash);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("): vanilla duration ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(componentData.ExpireDuration);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("s, not ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(3600f);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("s");
}
logger.LogWarning(val3);
continue;
}
float expireDuration2 = componentData.ExpireDuration;
componentData.ExpireDuration = expireDuration;
((EntityManager)(ref entityManager)).SetComponentData<WeaponCoating>(val2, componentData);
num++;
HashSet<int> coatingGuids = ImbuementIconFixer.CoatingGuids;
val4 = keyValueArrays.Keys[i];
coatingGuids.Add(((PrefabGUID)(ref val4)).GuidHash);
changed[text] = "coating";
if (text2 != "")
{
changed[text2] = "coating";
}
ManualLogSource logger2 = Plugin.Logger;
BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(36, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Changed imbuement ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" (");
val4 = keyValueArrays.Keys[i];
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(((PrefabGUID)(ref val4)).GuidHash);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", buff ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text2);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("): ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(expireDuration2);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("s -> ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(componentData.ExpireDuration);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("s");
}
logger2.LogInfo(val5);
}
}
finally
{
keyValueArrays.Dispose();
}
string text3 = $"[{world.Name}] {num} imbuements (weapon coatings) changed ({Plugin.ImbuementMinutes.Value} min), {num2} skipped";
if (num == 0)
{
Plugin.Logger.LogWarning((object)(text3 + ". No imbuement found: a game patch may have changed how weapon coatings work."));
}
else
{
Plugin.Logger.LogInfo((object)text3);
}
}
}
internal static class TooltipPatcher
{
private const string VanillaMinutes = "60";
private static string Normalize(string s)
{
return s.Replace("_", "").ToLowerInvariant().Replace("spotion", "potion");
}
public unsafe static void Apply(World world, Dictionary<string, string> changedBuffs)
{
//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_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0335: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Expected O, but got Unknown
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Expected O, but got Unknown
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Expected O, but got Unknown
//IL_038d: Unknown result type (might be due to invalid IL or missing references)
//IL_038f: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = world.EntityManager;
PrefabCollectionSystem existingSystemManaged = world.GetExistingSystemManaged<PrefabCollectionSystem>();
PrefabLookupMap prefabLookupMap = existingSystemManaged._PrefabLookupMap;
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<LocalizedStringBuilderParameter>(), (AccessMode)0);
Dictionary<string, string> dictionary = new Dictionary<string, string>();
foreach (KeyValuePair<string, string> changedBuff in changedBuffs)
{
dictionary[Normalize(Regex.Replace(changedBuff.Key, "^(AB_|Item_)(Consumable_)?|_Buff$", ""))] = changedBuff.Value;
}
Dictionary<string, string> dictionary2 = new Dictionary<string, string>
{
["potion"] = Plugin.PotionMinutes.Value.ToString(),
["elixir"] = Plugin.ElixirMinutes.Value.ToString(),
["coating"] = Plugin.ImbuementMinutes.Value.ToString()
};
int num = 0;
int num2 = 0;
int num3 = 0;
NativeKeyValueArrays<PrefabGUID, Entity> keyValueArrays = existingSystemManaged._PrefabGuidToEntityMap.GetKeyValueArrays(AllocatorHandle.op_Implicit((Allocator)2));
try
{
bool flag = default(bool);
for (int i = 0; i < keyValueArrays.Length; i++)
{
Entity val2 = keyValueArrays.Values[i];
if (!((EntityManager)(ref entityManager)).HasComponent(val2, val))
{
continue;
}
num++;
DynamicBuffer<LocalizedStringBuilderParameter> buffer = ((EntityManager)(ref entityManager)).GetBuffer<LocalizedStringBuilderParameter>(val2, false);
string text = null;
string text2 = null;
for (int j = 0; j < buffer.Length; j++)
{
LocalizedStringBuilderParameter val3 = buffer[j];
string text3 = ((object)(*(FixedString128Bytes*)(&val3.Key))/*cast due to .constrained prefix*/).ToString();
if (!text3.Contains("duration", StringComparison.OrdinalIgnoreCase))
{
continue;
}
if (text == null)
{
text = ((PrefabLookupMap)(ref prefabLookupMap)).GetName(keyValueArrays.Keys[i]) ?? "";
string n = Normalize(text);
text2 = dictionary.Keys.FirstOrDefault((string s) => n.Contains(s));
}
string text4 = ((object)(*(FixedString128Bytes*)(&val3.Value))/*cast due to .constrained prefix*/).ToString();
BepInExInfoLogInterpolatedStringHandler val4;
if (text2 == null)
{
if (!(text4 != "60"))
{
num3++;
ManualLogSource logger = Plugin.Logger;
val4 = new BepInExInfoLogInterpolatedStringHandler(61, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Tooltip ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text3);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" = ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text4);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": no changed buff matches this name; left vanilla");
}
logger.LogInfo(val4);
}
continue;
}
if (text4 != "60")
{
ManualLogSource logger2 = Plugin.Logger;
BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(32, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Tooltip ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text3);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" = \"");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text4);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("\", not ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>("60");
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("; left as is");
}
logger2.LogWarning(val5);
continue;
}
val3.Value = new FixedString128Bytes(dictionary2[dictionary[text2]]);
buffer[j] = val3;
num2++;
ManualLogSource logger3 = Plugin.Logger;
val4 = new BepInExInfoLogInterpolatedStringHandler(15, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Tooltip ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text3);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text4);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" -> ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<FixedString128Bytes>(val3.Value);
}
logger3.LogInfo(val4);
}
}
}
finally
{
keyValueArrays.Dispose();
}
string text5 = $"[{world.Name}] tooltips: {num2} duration values changed, {num3} other 60-minute values left vanilla, {num} prefabs with description parameters";
if (num2 == 0)
{
Plugin.Logger.LogWarning((object)(text5 + ". No potion/elixir/imbuement tooltip changed."));
}
else
{
Plugin.Logger.LogInfo((object)text5);
}
}
}
internal static class BuffDump
{
public static void Write(World world)
{
//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_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Expected O, but got Unknown
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = world.EntityManager;
PrefabCollectionSystem existingSystemManaged = world.GetExistingSystemManaged<PrefabCollectionSystem>();
PrefabLookupMap prefabLookupMap = existingSystemManaged._PrefabLookupMap;
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<Buff>(), (AccessMode)1);
ComponentType val2 = default(ComponentType);
((ComponentType)(ref val2))..ctor(Il2CppType.Of<LifeTime>(), (AccessMode)1);
List<string> list = new List<string>();
NativeParallelHashMap<PrefabGUID, Entity> prefabGuidToEntityMap = existingSystemManaged._PrefabGuidToEntityMap;
NativeKeyValueArrays<PrefabGUID, Entity> keyValueArrays = prefabGuidToEntityMap.GetKeyValueArrays(AllocatorHandle.op_Implicit((Allocator)2));
try
{
for (int i = 0; i < keyValueArrays.Length; i++)
{
PrefabGUID val3 = keyValueArrays.Keys[i];
Entity val4 = keyValueArrays.Values[i];
if (((EntityManager)(ref entityManager)).HasComponent(val4, val) && ((EntityManager)(ref entityManager)).HasComponent(val4, val2))
{
LifeTime componentData = ((EntityManager)(ref entityManager)).GetComponentData<LifeTime>(val4);
Buff componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<Buff>(val4);
string s = ((PrefabLookupMap)(ref prefabLookupMap)).GetName(val3) ?? "";
list.Add($"{Csv(s)},{((PrefabGUID)(ref val3)).GuidHash},{componentData.Duration},{componentData.EndAction},{componentData2.BuffType},{componentData2.BuffEffectType}");
}
}
}
finally
{
keyValueArrays.Dispose();
}
string text = Path.Combine(Paths.ConfigPath, "PotionDuration");
Directory.CreateDirectory(text);
string text2 = Path.Combine(text, "buffs.csv");
File.WriteAllLines(text2, new string[1] { "name,guid,duration_s,end_action,buff_type,buff_effect_type" }.Concat(list.OrderBy<string, string>((string r) => r, StringComparer.OrdinalIgnoreCase)));
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(82, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("DumpBuffs: ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(list.Count);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" timed buff prefabs written to ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text2);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("(prefab entities ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(prefabGuidToEntityMap.Count());
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", prefab GUIDs known ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(existingSystemManaged._PrefabDataLookup.Count());
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(")");
}
logger.LogInfo(val5);
}
private static string Csv(string s)
{
if (s.IndexOfAny(new char[2] { ',', '"' }) >= 0)
{
return "\"" + s.Replace("\"", "\"\"") + "\"";
}
return s;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "PotionDuration";
public const string PLUGIN_NAME = "PotionDuration";
public const string PLUGIN_VERSION = "1.1.1";
}
}