using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using GreenAlienHead.Properties;
using IL.RoR2;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using RoR2BepInExPack.GameAssetPaths.Version_1_39_0;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
[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("GreenAlienHead")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GreenAlienHead")]
[assembly: AssemblyTitle("GreenAlienHead")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GreenAlienHead
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Borbo.GreenAlienHead", "Yeah Thats Right Alien Head Is A Green Item Now", "4.0.1")]
public class Base : BaseUnityPlugin
{
public static AssetBundle iconBundle = LoadAssetBundle(Resources.gah);
private static Sprite greenAlienHeadSprite;
private float alienHeadNewCooldownFraction = 0.85f;
private ItemTier headNewTier = (ItemTier)1;
internal static ConfigFile CustomConfigFile { get; set; }
public static ConfigEntry<float> CooldownReduction { get; set; }
public static AssetBundle LoadAssetBundle(byte[] resourceBytes)
{
if (resourceBytes == null)
{
throw new ArgumentNullException("resourceBytes");
}
return AssetBundle.LoadFromMemory(resourceBytes);
}
private bool isLoaded(string modguid)
{
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
string key = pluginInfo.Key;
PluginInfo value = pluginInfo.Value;
if (key == modguid)
{
return true;
}
}
return false;
}
public void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\GreenAlienHead.cfg", true);
CooldownReduction = CustomConfigFile.Bind<float>("Green Alien Head", "Set Cooldown Reduction", (1f - alienHeadNewCooldownFraction) * 100f, "Change the cooldown reduction PERCENT of alien head.");
alienHeadNewCooldownFraction = (100f - CooldownReduction.Value) / 100f;
CharacterBody.RecalculateStats += new Manipulator(NerfAlienHeadCdr);
Base.LoadAsync<ItemDef>(RoR2_Base_AlienHead.AlienHead_asset, (Action<ItemDef>)delegate(ItemDef alienhead)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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_0021: Invalid comparison between Unknown and I4
alienhead.tier = headNewTier;
alienhead.deprecatedTier = headNewTier;
if ((int)headNewTier == 1)
{
alienhead.pickupIconSprite = iconBundle.LoadAsset<Sprite>("Assets/greenalienhead.png");
}
});
Base.LoadAsync<CraftableDef>(RoR2_DLC3_Recipes.cdAlienHead_asset, (Action<CraftableDef>)delegate(CraftableDef cdAlienHead)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//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_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_0053: Expected O, but got Unknown
//IL_0059: 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_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_0079: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
RecipeIngredient val = new RecipeIngredient();
val.pickup = (Object)(object)Addressables.LoadAssetAsync<ItemDef>((object)RoR2_Base_Syringe.Syringe_asset).WaitForCompletion();
val.type = (IngredientTypeIndex)0;
RecipeIngredient val2 = new RecipeIngredient();
val2.pickup = (Object)(object)Addressables.LoadAssetAsync<ItemDef>((object)RoR2_Base_SecondarySkillMagazine.SecondarySkillMagazine_asset).WaitForCompletion();
val2.type = (IngredientTypeIndex)0;
RecipeIngredient val3 = new RecipeIngredient();
val3.pickup = (Object)(object)Addressables.LoadAssetAsync<ItemDef>((object)RoR2_Base_FlatHealth.FlatHealth_asset).WaitForCompletion();
val3.type = (IngredientTypeIndex)0;
Recipe val4 = new Recipe();
val4.craftableDef = cdAlienHead;
val4.ingredients = (RecipeIngredient[])(object)new RecipeIngredient[2] { val, val3 };
Recipe val5 = new Recipe();
val5.craftableDef = cdAlienHead;
val5.ingredients = (RecipeIngredient[])(object)new RecipeIngredient[2] { val2, val3 };
cdAlienHead.recipes = (Recipe[])(object)new Recipe[2] { val4, val5 };
});
LanguageAPI.Add("ITEM_ALIENHEAD_DESC", $"<style=cIsUtility>Reduce skill cooldowns</style> by <style=cIsUtility>{CooldownReduction.Value}%</style> <style=cStack>(+{CooldownReduction.Value}% per stack)</style>.");
Debug.Log((object)$"Green Alien Head Initialized! Cooldowns should now be multiplied by {alienHeadNewCooldownFraction} per stack.");
}
private void NerfAlienHeadCdr(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int alienHeadLocation = 15;
val.GotoNext((MoveType)0, new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, "RoR2.RoR2Content/Items", "AlienHead"),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCountEffective"),
(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref alienHeadLocation)
});
val.GotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, alienHeadLocation)
});
val.Index -= 8;
val.Remove();
val.Emit(OpCodes.Ldc_R4, alienHeadNewCooldownFraction);
}
public static AssetReferenceT<T> LoadAsync<T>(string guid, Action<T> callback) where T : Object
{
//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_0040: Unknown result type (might be due to invalid IL or missing references)
AssetReferenceT<T> val = new AssetReferenceT<T>(guid);
AsyncOperationHandle<T> handle2 = AssetAsyncReferenceManager<T>.LoadAsset(val, (AsyncReferenceHandleUnloadType)2);
if (callback == null)
{
return val;
}
if (handle2.IsDone)
{
onCompleted(handle2);
return val;
}
handle2.Completed += onCompleted;
return val;
void onCompleted(AsyncOperationHandle<T> handle)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
if (handle.Result == null || (int)handle.Status != 1)
{
Debug.LogError((object)$"Failed to load asset [{handle.DebugName}] : {handle.OperationException}");
}
else
{
callback(handle.Result);
}
}
}
}
}
namespace GreenAlienHead.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("GreenAlienHead.Properties.Resources", typeof(Resources).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal static byte[] gah
{
get
{
object @object = ResourceManager.GetObject("gah", resourceCulture);
return (byte[])@object;
}
}
internal Resources()
{
}
}
}