using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using ReviveAPI;
using RoR2;
using RoR2.ContentManagement;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ArtifactOfEternity")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ArtifactOfEternity")]
[assembly: AssemblyTitle("ArtifactOfEternity")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 ArtifactOfEternity
{
[Serializable]
[BepInPlugin("com.brynzananas.artifactofeternity", "Artifact Of Eternity", "1.0.0")]
public class ArtifactOfEternity : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static CanReviveDelegate <0>__EternityCondition;
public static OnReviveDelegate <1>__OnEternityRevive;
}
public const string ModGuid = "com.brynzananas.artifactofeternity";
public const string ModName = "Artifact Of Eternity";
public const string ModVer = "1.0.0";
public static AssetBundle assetBundle;
public static ArtifactDef artifactDef;
public static int eternityCount;
public static bool messageDisplayed;
public static bool takeItem;
public void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
object obj = <>O.<0>__EternityCondition;
if (obj == null)
{
CanReviveDelegate val = EternityCondition;
<>O.<0>__EternityCondition = val;
obj = (object)val;
}
object obj2 = <>O.<1>__OnEternityRevive;
if (obj2 == null)
{
OnReviveDelegate val2 = OnEternityRevive;
<>O.<1>__OnEternityRevive = val2;
obj2 = (object)val2;
}
ReviveAPI.AddCustomRevive((CanReviveDelegate)obj, (OnReviveDelegate)obj2);
assetBundle = AssetBundle.LoadFromFileAsync(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "assetbundles", "artifactofeternityassets")).assetBundle;
artifactDef = assetBundle.LoadAsset<ArtifactDef>("Assets/CaeliImperium/Artifacts/ArtifactOfEternity.asset");
ContentPacks.artifacts.Add(artifactDef);
ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders);
RoR2Application.onLoadFinished = (Action)Delegate.Combine(RoR2Application.onLoadFinished, new Action(AddLanguageTokens));
}
private void AddLanguageTokens()
{
AddLanguageToken(artifactDef.nameToken, "Artifact of Eternity");
AddLanguageToken(artifactDef.descriptionToken, "Players revive infinitely.");
AddLanguageToken(artifactDef.nameToken, "Артифакт вечности", "ru");
AddLanguageToken(artifactDef.descriptionToken, "Игроки возрождаются бесконечно.", "ru");
AddLanguageToken("CI_ARTIFACT_ETERNITY_MESSAGE", "It's eternity in here...");
AddLanguageToken("CI_ARTIFACT_ETERNITY_MESSAGE", "Здесь целая вечность...", "ru");
}
private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
{
addContentPackProvider.Invoke((IContentPackProvider)(object)new ContentPacks());
}
private static bool EternityCondition(CharacterMaster characterMaster)
{
return RunArtifactManager.instance.IsArtifactEnabled(artifactDef) && Object.op_Implicit((Object)(object)characterMaster.playerCharacterMasterController);
}
private static void OnEternityRevive(CharacterMaster characterMaster)
{
if (!messageDisplayed)
{
eternityCount++;
if (eternityCount > 100)
{
messageDisplayed = true;
Chat.AddMessage(Language.GetString("CI_ARTIFACT_ETERNITY_MESSAGE"));
}
}
if (!takeItem)
{
return;
}
Inventory inventory = characterMaster.inventory;
if ((Object)(object)inventory == (Object)null)
{
return;
}
List<ItemDef> list = new List<ItemDef>();
int num = 0;
for (int i = 0; i < ItemCatalog.itemCount; i++)
{
int num2 = inventory.itemStacks[i];
if (num2 <= 0)
{
continue;
}
ItemDef itemDef = ItemCatalog.GetItemDef((ItemIndex)i);
if (itemDef.canRemove)
{
for (int j = 0; j < num2; j++)
{
list.Add(itemDef);
num++;
}
}
}
if (num > 0)
{
ItemDef val = list[Random.Range(0, num)];
inventory.RemoveItem(val, 1);
}
}
public static void AddLanguageToken(string token, string output, string language)
{
Dictionary<string, string> dictionary = (Language.languagesByName.ContainsKey(language) ? Language.languagesByName[language].stringsByToken : null);
Debug.Log((object)dictionary);
if (dictionary != null)
{
if (dictionary.ContainsKey(token))
{
dictionary[token] = output;
}
else
{
dictionary.Add(token, output);
}
}
}
public static void AddLanguageToken(string token, string output)
{
AddLanguageToken(token, output, "en");
}
}
public class ContentPacks : IContentPackProvider
{
[CompilerGenerated]
private sealed class <FinalizeAsync>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public FinalizeAsyncArgs args;
public ContentPacks <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FinalizeAsync>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
if (<>1__state != 0)
{
return false;
}
<>1__state = -1;
args.ReportProgress(1f);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <GenerateContentPackAsync>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public GetContentPackAsyncArgs args;
public ContentPacks <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GenerateContentPackAsync>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
if (<>1__state != 0)
{
return false;
}
<>1__state = -1;
ContentPack.Copy(<>4__this.contentPack, args.output);
args.ReportProgress(1f);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <LoadStaticContentAsync>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public LoadStaticContentAsyncArgs args;
public ContentPacks <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadStaticContentAsync>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
if (<>1__state != 0)
{
return false;
}
<>1__state = -1;
<>4__this.contentPack.identifier = <>4__this.identifier;
<>4__this.contentPack.artifactDefs.Add(artifacts.ToArray());
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
internal ContentPack contentPack = new ContentPack();
public static List<ArtifactDef> artifacts = new List<ArtifactDef>();
public string identifier => "com.brynzananas.artifactofeternity.ContentProvider";
[IteratorStateMachine(typeof(<FinalizeAsync>d__4))]
public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FinalizeAsync>d__4(0)
{
<>4__this = this,
args = args
};
}
[IteratorStateMachine(typeof(<GenerateContentPackAsync>d__5))]
public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GenerateContentPackAsync>d__5(0)
{
<>4__this = this,
args = args
};
}
[IteratorStateMachine(typeof(<LoadStaticContentAsync>d__6))]
public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadStaticContentAsync>d__6(0)
{
<>4__this = this,
args = args
};
}
}
}