using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HG;
using On.RoR2;
using RoR2;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("LunarsAreForever")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LunarsAreForever")]
[assembly: AssemblyTitle("LunarsAreForever")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace LunarsAreForever;
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
[BepInPlugin("Samuel17.LunarsAreForever", "LunarsAreForever", "1.0.0")]
public class Main : BaseUnityPlugin
{
public static ItemTier highlanderTier;
public void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
((ResourceAvailability)(ref ItemTierCatalog.availability)).CallWhenAvailable((Action)HighlanderTierFix);
((ResourceAvailability)(ref ItemCatalog.availability)).CallWhenAvailable((Action)NoTemporaryLunars);
}
private void HighlanderTierFix()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: 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_0033: Expected O, but got Unknown
ItemTierDef val = ItemTierCatalog.FindTierDef("Highlander");
if (Object.op_Implicit((Object)(object)val))
{
highlanderTier = val.tier;
Util.RollTemporaryItemFromItemIndex += new hook_RollTemporaryItemFromItemIndex(RollTemporaryItemFromItemIndex);
}
}
private void NoTemporaryLunars()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: 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_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
Enumerator<ItemDef> enumerator = ItemCatalog.allItemDefs.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
ItemDef current = enumerator.Current;
if ((int)current.tier == 3 && current.ContainsTag((ItemTag)31))
{
current.tags = current.tags.RemoveFromArray((ItemTag)31);
Log.Message("Removed CanBeTemporary tag from " + current.nameToken + ".");
}
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
}
private ItemIndex RollTemporaryItemFromItemIndex(orig_RollTemporaryItemFromItemIndex orig, ItemIndex itemIndex)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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)
ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
if (Object.op_Implicit((Object)(object)itemDef) && itemDef.tier == highlanderTier)
{
return (ItemIndex)(-1);
}
return orig.Invoke(itemIndex);
}
}
public static class Utils
{
public static T[] AddToArray<T>(this T[] array, params T[] items)
{
return (array ?? Enumerable.Empty<T>()).Concat(items).ToArray();
}
public static T[] RemoveFromArray<T>(this T[] array, params T[] items)
{
return (array ?? Enumerable.Empty<T>()).Except(items).ToArray();
}
}