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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("REPOITEMSCONFIGWEAPS")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("REPOITEMSCONFIGWEAPS")]
[assembly: AssemblyTitle("REPOITEMSCONFIGWEAPS")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace DafiWeaponsYesOrNo
{
[BepInPlugin("com.dafini.dafiweaponsyesorno", "DafiWEaponsYesOrNo", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("REPO.exe")]
public class DafiWEaponsYesOrNo : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <LoadAssetBundleAsync>d__19 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public DafiWEaponsYesOrNo <>4__this;
private string <fullPath>5__2;
private AssetBundleCreateRequest <bundleRequest>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadAssetBundleAsync>d__19(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<fullPath>5__2 = null;
<bundleRequest>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
int num = <>1__state;
DafiWEaponsYesOrNo dafiWEaponsYesOrNo = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<fullPath>5__2 = Path.Combine(Paths.GameRootPath, dafiWEaponsYesOrNo.assetBundlePath);
if (!File.Exists(<fullPath>5__2))
{
modLogger.LogError((object)("Asset bundle not found at: " + <fullPath>5__2));
return false;
}
modLogger.LogInfo((object)("Loading asset bundle from: " + <fullPath>5__2));
<>2__current = (object)new WaitForSeconds((float)dafiWEaponsYesOrNo.loadPriority * 0.01f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<bundleRequest>5__3 = AssetBundle.LoadFromFileAsync(<fullPath>5__2);
<>2__current = <bundleRequest>5__3;
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
if ((Object)(object)<bundleRequest>5__3.assetBundle == (Object)null)
{
modLogger.LogError((object)"Failed to load asset bundle!");
return false;
}
dafiWEaponsYesOrNo.loadedBundle = <bundleRequest>5__3.assetBundle;
modLogger.LogInfo((object)("Asset bundle loaded successfully: " + ((Object)dafiWEaponsYesOrNo.loadedBundle).name));
if (dafiWEaponsYesOrNo.debugMode)
{
string[] allAssetNames = dafiWEaponsYesOrNo.loadedBundle.GetAllAssetNames();
modLogger.LogDebug((object)$"Bundle contains {allAssetNames.Length} assets:");
string[] array = allAssetNames;
foreach (string text in array)
{
modLogger.LogDebug((object)(" - " + text));
}
}
<>2__current = dafiWEaponsYesOrNo.PreloadAssets();
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
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 <PreloadAssets>d__20 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public DafiWEaponsYesOrNo <>4__this;
private string[] <>7__wrap1;
private int <>7__wrap2;
private string <assetPath>5__4;
private AssetBundleRequest <assetRequest>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PreloadAssets>d__20(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>7__wrap1 = null;
<assetPath>5__4 = null;
<assetRequest>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
DafiWEaponsYesOrNo dafiWEaponsYesOrNo = <>4__this;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
if (<assetRequest>5__5.asset != (Object)null)
{
Dictionary<string, GameObject> loadedAssets = dafiWEaponsYesOrNo.loadedAssets;
string key = <assetPath>5__4;
Object asset = <assetRequest>5__5.asset;
loadedAssets[key] = (GameObject)(object)((asset is GameObject) ? asset : null);
if (dafiWEaponsYesOrNo.debugMode)
{
modLogger.LogDebug((object)("Preloaded asset: " + <assetPath>5__4));
}
}
<assetRequest>5__5 = null;
goto IL_0104;
}
<>1__state = -1;
string[] array = new string[2] { "assets/prefabs/customprefab1.prefab", "assets/prefabs/customprefab2.prefab" };
<>7__wrap1 = array;
<>7__wrap2 = 0;
goto IL_0119;
IL_0119:
if (<>7__wrap2 < <>7__wrap1.Length)
{
<assetPath>5__4 = <>7__wrap1[<>7__wrap2];
if (dafiWEaponsYesOrNo.loadedBundle.Contains(<assetPath>5__4))
{
<assetRequest>5__5 = dafiWEaponsYesOrNo.loadedBundle.LoadAssetAsync<GameObject>(<assetPath>5__4);
<>2__current = <assetRequest>5__5;
<>1__state = 1;
return true;
}
goto IL_0104;
}
<>7__wrap1 = null;
return false;
IL_0104:
<assetPath>5__4 = null;
<>7__wrap2++;
goto IL_0119;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public const string ModGUID = "com.dafini.dafiweaponsyesorno";
public const string ModName = "DafiWEaponsYesOrNo";
public const string ModVersion = "1.0.0";
private ConfigEntry<bool> enableAssetBundle;
private readonly string assetBundlePath = "BepInEx/plugins/YourModFolder/DafiWeapons.repobundle";
private readonly bool debugMode;
private readonly bool networkSyncEnabled = true;
private readonly int loadPriority = 100;
private AssetBundle loadedBundle;
private Dictionary<string, GameObject> loadedAssets = new Dictionary<string, GameObject>();
private Dictionary<string, Object> cachedAssets = new Dictionary<string, Object>();
private static ManualLogSource modLogger;
private Harmony harmony;
public static DafiWEaponsYesOrNo Instance { get; private set; }
private void Awake()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
Instance = this;
modLogger = ((BaseUnityPlugin)this).Logger;
modLogger.LogInfo((object)"DafiWEaponsYesOrNo v1.0.0 is loading...");
InitializeConfig();
try
{
harmony = new Harmony("com.dafini.dafiweaponsyesorno");
harmony.PatchAll(Assembly.GetExecutingAssembly());
modLogger.LogInfo((object)"Harmony patches applied successfully");
}
catch (Exception arg)
{
modLogger.LogError((object)$"Failed to apply Harmony patches: {arg}");
}
if (enableAssetBundle.Value)
{
((MonoBehaviour)this).StartCoroutine(LoadAssetBundleAsync());
}
else
{
modLogger.LogInfo((object)"Asset bundle is disabled in configuration");
}
enableAssetBundle.SettingChanged += OnAssetBundleToggled;
modLogger.LogInfo((object)"DafiWEaponsYesOrNo loaded successfully!");
}
private void InitializeConfig()
{
enableAssetBundle = ((BaseUnityPlugin)this).Config.Bind<bool>("New Items in Item Shop Toggle", "Enable Asset Bundle", false, "Enable or disable my valuables coming up as items in the Item Shop. Default is OFF.");
if (debugMode)
{
modLogger.LogDebug((object)"Configuration loaded:");
modLogger.LogDebug((object)$" - Asset Bundle Enabled: {enableAssetBundle.Value}");
modLogger.LogDebug((object)(" - Asset Bundle Path: " + assetBundlePath));
modLogger.LogDebug((object)$" - Load Priority: {loadPriority}");
modLogger.LogDebug((object)$" - Network Sync: {networkSyncEnabled}");
}
}
[IteratorStateMachine(typeof(<LoadAssetBundleAsync>d__19))]
private IEnumerator LoadAssetBundleAsync()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadAssetBundleAsync>d__19(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<PreloadAssets>d__20))]
private IEnumerator PreloadAssets()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PreloadAssets>d__20(0)
{
<>4__this = this
};
}
private void OnAssetBundleToggled(object sender, EventArgs e)
{
if (enableAssetBundle.Value && (Object)(object)loadedBundle == (Object)null)
{
modLogger.LogInfo((object)"Asset bundle enabled - loading...");
((MonoBehaviour)this).StartCoroutine(LoadAssetBundleAsync());
}
else if (!enableAssetBundle.Value && (Object)(object)loadedBundle != (Object)null)
{
UnloadAssetBundle();
}
}
private void UnloadAssetBundle()
{
if ((Object)(object)loadedBundle != (Object)null)
{
modLogger.LogInfo((object)"Unloading asset bundle...");
loadedAssets.Clear();
cachedAssets.Clear();
loadedBundle.Unload(true);
loadedBundle = null;
modLogger.LogInfo((object)"Asset bundle unloaded");
}
}
public GameObject GetLoadedAsset(string assetPath)
{
if (!enableAssetBundle.Value || (Object)(object)loadedBundle == (Object)null)
{
if (debugMode)
{
modLogger.LogWarning((object)("Cannot get asset '" + assetPath + "' - bundle not loaded"));
}
return null;
}
if (loadedAssets.ContainsKey(assetPath))
{
return loadedAssets[assetPath];
}
GameObject val = loadedBundle.LoadAsset<GameObject>(assetPath);
if ((Object)(object)val != (Object)null)
{
loadedAssets[assetPath] = val;
if (debugMode)
{
modLogger.LogDebug((object)("Loaded asset on demand: " + assetPath));
}
}
return val;
}
public T GetAsset<T>(string assetPath) where T : Object
{
if (!enableAssetBundle.Value || (Object)(object)loadedBundle == (Object)null)
{
if (debugMode)
{
modLogger.LogWarning((object)("Cannot get asset '" + assetPath + "' - bundle not loaded"));
}
return default(T);
}
if (cachedAssets.ContainsKey(assetPath))
{
Object obj = cachedAssets[assetPath];
return (T)(object)((obj is T) ? obj : null);
}
T val = loadedBundle.LoadAsset<T>(assetPath);
if ((Object)(object)val != (Object)null)
{
cachedAssets[assetPath] = (Object)(object)val;
if (debugMode)
{
modLogger.LogDebug((object)("Loaded asset on demand: " + assetPath + " (Type: " + typeof(T).Name + ")"));
}
}
return val;
}
public bool HasAsset(string assetPath)
{
if ((Object)(object)loadedBundle != (Object)null)
{
return loadedBundle.Contains(assetPath);
}
return false;
}
public string[] GetAllAssetNames()
{
if ((Object)(object)loadedBundle != (Object)null)
{
return loadedBundle.GetAllAssetNames();
}
return new string[0];
}
public GameObject SpawnPrefab(string prefabPath, Vector3 position, Quaternion rotation)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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)
GameObject loadedAsset = GetLoadedAsset(prefabPath);
if ((Object)(object)loadedAsset == (Object)null)
{
modLogger.LogError((object)("Prefab not found: " + prefabPath));
return null;
}
GameObject result;
if (networkSyncEnabled && PhotonNetwork.IsConnected)
{
result = PhotonNetwork.Instantiate(((Object)loadedAsset).name, position, rotation, (byte)0, (object[])null);
if (debugMode)
{
modLogger.LogDebug((object)("Spawned networked prefab: " + prefabPath));
}
}
else
{
result = Object.Instantiate<GameObject>(loadedAsset, position, rotation);
if (debugMode)
{
modLogger.LogDebug((object)("Spawned local prefab: " + prefabPath));
}
}
return result;
}
public GameObject InstantiateLocal(string prefabPath, Vector3 position, Quaternion rotation)
{
//IL_0029: 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)
GameObject loadedAsset = GetLoadedAsset(prefabPath);
if ((Object)(object)loadedAsset == (Object)null)
{
modLogger.LogError((object)("Prefab not found: " + prefabPath));
return null;
}
return Object.Instantiate<GameObject>(loadedAsset, position, rotation);
}
private void OnDestroy()
{
UnloadAssetBundle();
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
modLogger.LogInfo((object)"DafiWEaponsYesOrNo unloaded");
}
public static void Log(string message, LogLevel level = 16)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
if ((int)level <= 4)
{
if ((int)level != 2)
{
if ((int)level == 4)
{
ManualLogSource obj = modLogger;
if (obj != null)
{
obj.LogWarning((object)message);
}
}
}
else
{
ManualLogSource obj2 = modLogger;
if (obj2 != null)
{
obj2.LogError((object)message);
}
}
}
else if ((int)level != 16)
{
if ((int)level == 32)
{
ManualLogSource obj3 = modLogger;
if (obj3 != null)
{
obj3.LogDebug((object)message);
}
}
}
else
{
ManualLogSource obj4 = modLogger;
if (obj4 != null)
{
obj4.LogInfo((object)message);
}
}
}
}
[HarmonyPatch]
public static class AssetBundlePatches
{
}
public static class AssetManager
{
public static GameObject GetPrefab(string name)
{
return DafiWEaponsYesOrNo.Instance?.GetLoadedAsset("assets/prefabs/" + name + ".prefab");
}
public static Texture2D GetTexture(string name)
{
return DafiWEaponsYesOrNo.Instance?.GetAsset<Texture2D>("assets/textures/" + name + ".png");
}
public static AudioClip GetSound(string name)
{
return DafiWEaponsYesOrNo.Instance?.GetAsset<AudioClip>("assets/sounds/" + name + ".wav");
}
public static Material GetMaterial(string name)
{
return DafiWEaponsYesOrNo.Instance?.GetAsset<Material>("assets/materials/" + name + ".mat");
}
}
}