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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
using WK_Transparency_Addon.Core;
[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WK_Transparency_Addon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+727e94a82ade1f2ea71d0c2a41837bb821131287")]
[assembly: AssemblyProduct("WK_Transparency_Addon")]
[assembly: AssemblyTitle("WK_Transparency_Addon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 WK_Transparency_Addon
{
[BepInPlugin("WK_Transparency_Addon", "WK_Transparency_Addon", "1.1.0")]
public class TransparencyAddon : BaseUnityPlugin
{
private bool _patched;
private static Harmony _harmony;
public static ManualLogSource Log { get; private set; }
private void Awake()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
if (_patched)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Already Patched");
}
Log = ((BaseUnityPlugin)this).Logger;
if (!Assets.Load())
{
Log.LogError((object)"Assets failed to load, aborting!");
return;
}
_harmony = new Harmony("WK_Transparency_Addon");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
SceneManager.sceneLoaded += OnSceneLoad;
Log.LogInfo((object)"Plugin WK_Transparency_Addon is loaded!");
_patched = true;
}
private static void OnSceneLoad(Scene scene, LoadSceneMode mode)
{
string name = ((Scene)(ref scene)).name;
if ((!(name == "Intro") && !(name == "Main-Menu")) || 1 == 0)
{
ModifyMaterials();
}
}
public static void ModifyMaterials()
{
GameObject val = GameObject.Find("Inventory-Root");
if (!Object.op_Implicit((Object)(object)val))
{
Log.LogWarning((object)"Could not find player in scene!");
return;
}
Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>();
foreach (Renderer val2 in componentsInChildren)
{
Log.LogInfo((object)((Object)((Component)val2).gameObject).name);
val2.material = Assets.transparentMat;
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "WK_Transparency_Addon";
public const string PLUGIN_NAME = "WK_Transparency_Addon";
public const string PLUGIN_VERSION = "1.1.0";
}
}
namespace WK_Transparency_Addon.Patches
{
[HarmonyPatch(typeof(HandItem))]
public class HandItemPatch
{
[HarmonyPatch("Initialize")]
[HarmonyPostfix]
private static void Initialize(HandItem __instance)
{
if (Object.op_Implicit((Object)(object)__instance))
{
TransparencyAddon.ModifyMaterials();
}
}
}
}
namespace WK_Transparency_Addon.Core
{
public class Assets
{
private static AssetBundle _assets;
internal static Material transparentMat;
internal static bool Load()
{
_assets = AssetBundle.LoadFromFile(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/Assets/transparency_addon_assets");
if (!Object.op_Implicit((Object)(object)_assets))
{
TransparencyAddon.Log.LogError((object)"Failed to load AssetBundle, aborting!");
return false;
}
List<bool> source = new List<bool>(1) { LoadFile<Material>(_assets, "Assets/Neb.Assets/Transparency Addon/Item_Hand_Material_Transparent.mat", out transparentMat) };
if (source.Any((bool result) => !result))
{
TransparencyAddon.Log.LogWarning((object)"Failed to load one or more assets, aborting!");
return false;
}
return true;
}
private static bool LoadFile<T>(AssetBundle assets, string path, out T loadedObject) where T : Object
{
loadedObject = assets.LoadAsset<T>(path);
if (!Object.op_Implicit((Object)(object)loadedObject))
{
TransparencyAddon.Log.LogError((object)("Failed to load '" + path + "'"));
return false;
}
return true;
}
}
}