Decompiled source of Enhanced Prefab Loader v1.1.0
BepInEx/patchers/EnhancedPrefabLoaderPrepatch.dll
Decompiled 2 weeks agousing System; using System.Collections; 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 EnhancedPrefabLoaderPrepatch.Models; using Microsoft.CodeAnalysis; using Mono.Cecil; using Newtonsoft.Json; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("EnhancedPrefabLoaderPrepatch")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("Enhanced Prefab Loader Prepatch")] [assembly: AssemblyTitle("EnhancedPrefabLoaderPrepatch")] [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] internal sealed class IsReadOnlyAttribute : Attribute { } [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 EnhancedPrefabLoaderPrepatch { public class BidirectionalDictionary<k, v> { private Dictionary<v, k> m_InverseDictionary = new Dictionary<v, k>(); public v this[k key] { get { return Dictionary[key]; } set { Dictionary[key] = value; m_InverseDictionary[value] = key; } } public Dictionary<k, v> Dictionary { get; } = new Dictionary<k, v>(); public bool TryGetValue(k key, out v value) { return Dictionary.TryGetValue(key, out value); } public bool TryGetKey(v value, out k key) { return m_InverseDictionary.TryGetValue(value, out key); } public void Clear() { Dictionary.Clear(); m_InverseDictionary.Clear(); } public void AddAll(IEnumerable<KeyValuePair<k, v>> items) { foreach (KeyValuePair<k, v> item in items) { this[item.Key] = item.Value; } } } public class FurniturePatcher { private static FurniturePatcher m_Instance; public static FurniturePatcher Instance => m_Instance ?? (m_Instance = new FurniturePatcher()); public List<string> FurnitureObjectTypes { get; private set; } = new List<string>(); private FurniturePatcher() { } public void PatchFurnitureObjectTypes(AssemblyDefinition assembly) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown BidirectionalDictionary<string, int> bidirectionalDictionary = new BidirectionalDictionary<string, int>(); TypeDefinition val = ((IEnumerable<TypeDefinition>)assembly.MainModule.Types).FirstOrDefault((Func<TypeDefinition, bool>)((TypeDefinition t) => ((MemberReference)t).Name == "EObjectType")); if (val != null) { Log.Info("EObjectType enum found. Attempting to patch in custom furniture types"); FieldDefinition val2 = ((IEnumerable<FieldDefinition>)val.Fields).FirstOrDefault((Func<FieldDefinition, bool>)((FieldDefinition t) => ((MemberReference)t).Name == "MAX")); if (val2 != null) { if (Patcher.SaveManager.FurnitureTypes != null) { foreach (string key2 in Patcher.SaveManager.FurnitureTypes.Dictionary.Keys) { if (FurnitureObjectTypes.Contains(key2)) { FieldDefinition val3 = new FieldDefinition(key2, val2.Attributes, (TypeReference)(object)val) { Constant = Patcher.SaveManager.FurnitureTypes[key2] }; Log.Info($"Adding field: {key2}, value: {Patcher.SaveManager.FurnitureTypes[key2]}"); val.Fields.Add(val3); bidirectionalDictionary[key2] = Patcher.SaveManager.FurnitureTypes[key2]; FurnitureObjectTypes.Remove(key2); } } } int i = 1000; foreach (string furnitureObjectType in FurnitureObjectTypes) { string key; for (; bidirectionalDictionary.TryGetKey(i, out key); i++) { } FieldDefinition val4 = new FieldDefinition(furnitureObjectType, val2.Attributes, (TypeReference)(object)val) { Constant = i }; Log.Info($"Adding field: {furnitureObjectType}, value: {i}"); val.Fields.Add(val4); bidirectionalDictionary[furnitureObjectType] = i; i++; } Patcher.SaveManager.FurnitureTypes = bidirectionalDictionary; Log.Info("Furniture object type patching complete"); } else { Log.Error("Could not find field EObjectType.MAX"); } } else { Log.Error("Required enum [EObjectType] not found"); } } } public static class Log { public static void Info(string message) { Console.BackgroundColor = ConsoleColor.Green; Console.WriteLine(message); Console.ResetColor(); } public static void Warn(string message) { Console.BackgroundColor = ConsoleColor.Yellow; Console.WriteLine(message); Console.ResetColor(); } public static void Error(string message) { Console.BackgroundColor = ConsoleColor.Red; Console.WriteLine(message); Console.ResetColor(); } } public class Patcher { public static IEnumerable<string> TargetDLLs { get; } = new <>z__ReadOnlySingleElementList<string>("Assembly-CSharp.dll"); public static SaveManager SaveManager { get; set; } public static void Initialize() { if (SaveManager == null) { SaveManager = new SaveManager(); } Log.Info("Enhanced Prefab Loader loading configs."); SaveManager.Load(GetBaseDirectory() + "/savedTypes"); foreach (string item in Directory.EnumerateFiles(GetBaseDirectory() ?? "", "*.json", SearchOption.AllDirectories)) { ObjectTypes objectTypes = JsonConvert.DeserializeObject<ObjectTypes>(File.ReadAllText(item)); Log.Info("Furniture Object types in " + item + ":"); objectTypes.FurnitureTypes.ForEach(Log.Info); FurniturePatcher.Instance.FurnitureObjectTypes.AddRange(objectTypes.FurnitureTypes); } } public static void Patch(AssemblyDefinition assembly) { Log.Info("Enhanced Prefab Loader patching started."); FurniturePatcher.Instance.PatchFurnitureObjectTypes(assembly); SaveManager.Save(GetBaseDirectory() + "/savedTypes"); Log.Info("Enhanced Prefab patcher PrePatching complete"); } private static string GetBaseDirectory() { return Path.GetDirectoryName(typeof(Patcher).Assembly.Location); } } public class SaveManager { public BidirectionalDictionary<string, int> FurnitureTypes { get; set; } public void Load(string filePath) { if (File.Exists(filePath)) { SaveData saveData = JsonConvert.DeserializeObject<SaveData>(File.ReadAllText(filePath)); if (FurnitureTypes == null) { BidirectionalDictionary<string, int> bidirectionalDictionary2 = (FurnitureTypes = new BidirectionalDictionary<string, int>()); } FurnitureTypes.Clear(); FurnitureTypes.AddAll(saveData.FurnitureObjectTypes); } } public void Save(string filePath) { SaveData saveData = default(SaveData); saveData.FurnitureObjectTypes = FurnitureTypes.Dictionary; SaveData saveData2 = saveData; File.WriteAllText(filePath, JsonConvert.SerializeObject((object)saveData2)); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "EnhancedPrefabLoaderPrepatch"; public const string PLUGIN_NAME = "Enhanced Prefab Loader Prepatch"; public const string PLUGIN_VERSION = "1.1.0"; } } namespace EnhancedPrefabLoaderPrepatch.Models { public struct ObjectTypes { public List<string> FurnitureTypes { get; set; } } public struct SaveData { public Dictionary<string, int> FurnitureObjectTypes { get; set; } } } [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T> { object IEnumerator.Current => _item; T IEnumerator<T>.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { if (!_moveNextCalled) { return _moveNextCalled = true; } return false; } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => 1; T IReadOnlyList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection<T>.Count => 1; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer<T>.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { if (!EqualityComparer<T>.Default.Equals(_item, (T)value)) { return -1; } return 0; } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return new Enumerator(_item); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return EqualityComparer<T>.Default.Equals(_item, item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { if (!EqualityComparer<T>.Default.Equals(_item, item)) { return -1; } return 0; } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } }
BepInEx/plugins/EnhancedPrefabLoader.dll
Decompiled 2 weeks agousing System; using System.Collections; 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.Configuration; using BepInEx.Logging; using EnhancedPrefabLoader.Models; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("EnhancedPrefabLoader")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("Enhanced Prefab Loader")] [assembly: AssemblyTitle("EnhancedPrefabLoader")] [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; } } } internal sealed class ConfigurationManagerAttributes { public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput); public bool? ShowRangeAsPercent; public Action<ConfigEntryBase> CustomDrawer; public CustomHotkeyDrawerFunc CustomHotkeyDrawer; public bool? Browsable; public string Category; public object DefaultValue; public bool? HideDefaultButton; public bool? HideSettingName; public string Description; public string DispName; public int? Order; public bool? ReadOnly; public bool? IsAdvanced; public Func<object, string> ObjToStr; public Func<string, object> StrToObj; } namespace EnhancedPrefabLoader { public class AssetBundleManager : CSingleton<AssetBundleManager> { private int m_AssetBundleLoadCount; private bool m_AssetsAdded; public Dictionary<string, Sprite> Sprites { get; private set; } = new Dictionary<string, Sprite>(); public Dictionary<string, Assembly> Assemblies { get; private set; } = new Dictionary<string, Assembly>(); public Dictionary<EObjectType, Tuple<PrefabInfo, GameObject>> Prefabs { get; private set; } = new Dictionary<EObjectType, Tuple<PrefabInfo, GameObject>>(); public bool IsLoaded { get; private set; } public bool AddOnLoadComplete { get; set; } private ManualLogSource Logger { get; } = Logger.CreateLogSource("Prefab Manager"); private AssetBundleManager() { } public void LoadAllAssetBundles() { if (IsLoaded) { return; } foreach (string file in Directory.EnumerateFiles(GetBaseDirectory() ?? "", "*.json", SearchOption.AllDirectories)) { m_AssetBundleLoadCount++; FileInfo fileInfo = new FileInfo(file); ((AsyncOperation)AssetBundle.LoadFromFileAsync(fileInfo.Directory.FullName + "/" + Path.GetFileNameWithoutExtension(fileInfo.Name))).completed += delegate(AsyncOperation operation) { AssetBundleCreateRequest val = (AssetBundleCreateRequest)(object)((operation is AssetBundleCreateRequest) ? operation : null); if (val != null) { ((MonoBehaviour)this).StartCoroutine(ProcessAssetBundle(val.assetBundle, file)); } }; } } private IEnumerator ProcessAssetBundle(AssetBundle assetBundle, string file) { AssetBundleInfo assetBundleInfo = JsonConvert.DeserializeObject<AssetBundleInfo>(File.ReadAllText(file)); foreach (SpriteInfo sprite in assetBundleInfo.Sprites) { AssetBundleRequest assetLoadRequest2 = assetBundle.LoadAssetAsync<Sprite>(sprite.Name); yield return assetLoadRequest2; Logger.LogDebug((object)("Found Sprite " + sprite.Name)); Dictionary<string, Sprite> sprites = Sprites; string name = sprite.Name; Object asset = assetLoadRequest2.asset; sprites[name] = (Sprite)(object)((asset is Sprite) ? asset : null); } foreach (AssemblyInfo assembly in assetBundleInfo.Assemblies) { Logger.LogDebug((object)("Found Assembly " + assembly.Name)); Assemblies[assembly.Name] = Assembly.LoadFrom(GetBaseDirectory() + "/" + assembly.Name); } foreach (PrefabInfo prefabInfo in assetBundleInfo.Prefabs) { AssetBundleRequest assetLoadRequest2 = assetBundle.LoadAssetAsync<GameObject>(prefabInfo.Name); yield return assetLoadRequest2; if (!Enum.TryParse<EObjectType>(prefabInfo.ObjectType, out EObjectType result)) { continue; } Logger.LogDebug((object)("Found Prefab " + prefabInfo.Name)); Dictionary<EObjectType, Tuple<PrefabInfo, GameObject>> prefabs = Prefabs; EObjectType key = result; Object asset2 = assetLoadRequest2.asset; prefabs[key] = Tuple.Create<PrefabInfo, GameObject>(prefabInfo, (GameObject)(object)((asset2 is GameObject) ? asset2 : null)); foreach (VideoClipInfo videoClipInfo in prefabInfo.VideoClips) { Component[] componentsInChildren = Prefabs[result].Item2.GetComponentsInChildren<Component>(true); object obj; if (componentsInChildren == null) { obj = null; } else { Component? obj2 = componentsInChildren.Where((Component component) => ((Object)component).name == videoClipInfo.VideoPlayerName).FirstOrDefault(); obj = ((obj2 != null) ? obj2.GetComponent<VideoPlayer>() : null); } VideoPlayer val = (VideoPlayer)obj; if (val != null) { Logger.LogDebug((object)("Found Video Source " + videoClipInfo.Name)); val.source = (VideoSource)1; val.url = GetBaseDirectory() + "/" + videoClipInfo.Name; } } } assetBundle.Unload(false); m_AssetBundleLoadCount--; if (m_AssetBundleLoadCount == 0) { IsLoaded = true; if (AddOnLoadComplete) { AddAssetsToInventory(); } } } internal void AddAssetsToInventory() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) if (m_AssetsAdded) { return; } m_AssetsAdded = true; foreach (EObjectType key in Prefabs.Keys) { Tuple<PrefabInfo, GameObject> tuple = Prefabs[key]; PrefabInfo item = tuple.Item1; Logger.LogDebug((object)("Adding asset " + item.Name)); if (!item.AddItemToFurnitureShop) { continue; } Sprites.TryGetValue(item.SpriteName, out var value); FurniturePurchaseData val = new FurniturePurchaseData { name = item.Name, description = item.Description, levelRequirement = item.LevelRequirement, price = item.Price, objectType = (EObjectType)Enum.Parse(typeof(EObjectType), item.ObjectType), icon = value }; ObjectData val2 = new ObjectData { name = item.Name, objectType = (EObjectType)Enum.Parse(typeof(EObjectType), item.ObjectType), spawnPrefab = tuple.Item2.GetComponent<InteractableObject>() }; val2.spawnPrefab.m_ObjectType = val2.objectType; int num = 0; bool flag = false; foreach (FurniturePurchaseData furniturePurchaseData in CSingleton<InventoryBase>.Instance.m_ObjectData_SO.m_FurniturePurchaseDataList) { if (furniturePurchaseData.levelRequirement > val.levelRequirement) { CSingleton<InventoryBase>.Instance.m_ObjectData_SO.m_FurniturePurchaseDataList.Insert(num, val); CSingleton<InventoryBase>.Instance.m_ObjectData_SO.m_ObjectDataList.Insert(num, val2); flag = true; break; } num++; } if (!flag) { CSingleton<InventoryBase>.Instance.m_ObjectData_SO.m_FurniturePurchaseDataList.Add(val); CSingleton<InventoryBase>.Instance.m_ObjectData_SO.m_ObjectDataList.Add(val2); } } } private string GetBaseDirectory() { return Path.GetDirectoryName(((object)this).GetType().Assembly.Location); } } public class FurnitureShopUIScreenManager : CSingleton<FurnitureShopUIScreenManager> { private bool m_IsInitialized; public void Init(ref FurnitureShopUIScreen furnitureShopUIScreen) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown if (m_IsInitialized || !CSingleton<AssetBundleManager>.Instance.IsLoaded) { return; } m_IsInitialized = true; Transform val = ((Component)furnitureShopUIScreen).transform.Find("ScreenGrp/AnimGrp/WebsiteContent_Grp/ScrollerGrp"); Transform val2 = val.Find("HorizontalLayout"); int result; int num = Math.DivRem(CSingleton<AssetBundleManager>.Instance.Prefabs.Count, 3, out result); if (result != 0) { num++; } for (int i = 0; i < num; i++) { foreach (Transform item in Object.Instantiate<Transform>(val2, val)) { Transform val3 = item; furnitureShopUIScreen.m_FurnitureShopPanelUIList.Add(((Component)val3).GetComponent<FurnitureShopPanelUI>()); } } } private void Start() { if (!m_IsInitialized) { FurnitureShopUIScreen furnitureShopUIScreen = Object.FindFirstObjectByType<FurnitureShopUIScreen>(); Init(ref furnitureShopUIScreen); } } } [BepInPlugin("EnhancedPrefabLoader", "Enhanced Prefab Loader", "1.1.0")] public class Plugin : BaseUnityPlugin { private bool m_loaded; private readonly Harmony m_Harmony = new Harmony("EnhancedPrefabLoader"); internal static ManualLogSource Logger { get; private set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Settings.Instance.Load(this); m_Harmony.PatchAll(); SceneManager.sceneLoaded += OnSceneLoad; Logger.LogInfo((object)"Plugin Enhanced Prefab Loader v:1.1.0 by GhostNarwhal is loaded!"); } private void OnDestroy() { m_Harmony.UnpatchSelf(); Logger.LogInfo((object)"Plugin Enhanced Prefab Loader is unloaded!"); } private void OnSceneLoad(Scene scene, LoadSceneMode _) { if (((Scene)(ref scene)).name == "Title") { CSingleton<AssetBundleManager>.Instance.Assemblies["GNSharedScripts"] = Assembly.LoadFrom(GetBaseDirectory() + "/Scripts.dll"); CSingleton<AssetBundleManager>.Instance.LoadAllAssetBundles(); } } private string GetBaseDirectory() { return Path.GetDirectoryName(((object)this).GetType().Assembly.Location); } } public class Settings { private static Settings m_instance; public static Settings Instance => m_instance ?? (m_instance = new Settings()); public void Load(Plugin plugin) { } private Settings() { } } public static class MyPluginInfo { public const string PLUGIN_GUID = "EnhancedPrefabLoader"; public const string PLUGIN_NAME = "Enhanced Prefab Loader"; public const string PLUGIN_VERSION = "1.1.0"; } } namespace EnhancedPrefabLoader.Patches { [HarmonyPatch(typeof(FurnitureShopUIScreen))] public class FurnitureShopUIScreenPatch { [HarmonyPatch("Init")] [HarmonyPrefix] private static void InitPrefix(ref FurnitureShopUIScreen __instance) { CSingleton<FurnitureShopUIScreenManager>.Instance.Init(ref __instance); } } [HarmonyPatch(typeof(InventoryBase))] public class InventoryBasePatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePostfix(ref InventoryBase __instance) { if (CSingleton<AssetBundleManager>.Instance.IsLoaded) { CSingleton<AssetBundleManager>.Instance.AddAssetsToInventory(); } else { CSingleton<AssetBundleManager>.Instance.AddOnLoadComplete = true; } } } } namespace EnhancedPrefabLoader.Models { public class AssemblyInfo { public string Name { get; set; } } public class AssetBundleInfo { public List<AssemblyInfo> Assemblies { get; set; } = new List<AssemblyInfo>(); public List<SpriteInfo> Sprites { get; set; } = new List<SpriteInfo>(); public List<VideoClipInfo> VideoClips { get; set; } = new List<VideoClipInfo>(); public List<PrefabInfo> Prefabs { get; set; } = new List<PrefabInfo>(); } public class PrefabInfo { public string Name { get; set; } public bool AddItemToFurnitureShop { get; set; } public string SpriteName { get; set; } public string Description { get; set; } public int LevelRequirement { get; set; } public float Price { get; set; } public string ObjectType { get; set; } public List<VideoClipInfo> VideoClips { get; set; } = new List<VideoClipInfo>(); } public class SpriteInfo { public string Name { get; set; } } public class VideoClipInfo { public string Name { get; set; } public string VideoPlayerName { get; set; } } }
BepInEx/plugins/Scripts.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("Scripts")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("Scripts")] [assembly: AssemblyTitle("Scripts")] [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 Scripts { public class CeilingHangingInteractableObject : InteractableObject { protected override void Update() { //IL_0017: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) if (!base.m_IsMovingObject) { return; } ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, base.m_TargetMoveObjectPosition, Time.deltaTime * 7.5f); bool flag = false; int mask = LayerMask.GetMask(new string[2] { "MoveStateBlockedArea", "Customer" }); if (Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, mask).Length == 0) { if (base.m_PlaceObjectInShopOnly) { if (Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, LayerMask.GetMask(new string[1] { "MoveStateValidArea" })).Length != 0) { flag = true; } } else if (base.m_PlaceObjectInShopOnly && Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, LayerMask.GetMask(new string[1] { "MoveStateValidWarehouseArea" })).Length != 0) { flag = true; } } base.m_IsMovingObjectValidState = flag; ShelfManager.SetMoveObjectPreviewModelValidState(flag); } protected override void OnPlacedMovedObject() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) CSingleton<InteractionPlayerController>.Instance.OnExitMoveObjectMode(); base.m_IsMovingObject = false; ((Component)this).gameObject.layer = base.m_OriginalLayer; ((Collider)base.m_BoxCollider).enabled = true; for (int i = 0; i < base.m_BoxColliderList.Count; i++) { ((Collider)base.m_BoxColliderList[i]).enabled = true; } int mask = LayerMask.GetMask(new string[1] { "ShopModel" }); Vector3 position = ((Component)base.m_PickupObjectMesh).transform.position; position.y += 0.2f; RaycastHit val = default(RaycastHit); if (Physics.Raycast(position, Vector3.up, ref val, 50f, mask)) { ((Component)this).transform.position = ((RaycastHit)(ref val)).point; } ((Component)base.m_MoveStateValidArea).gameObject.SetActive(true); ShelfManager.DisableMoveObjectPreviewMode(); if (Object.op_Implicit((Object)(object)base.m_BoxCollider)) { ((Component)CSingleton<ShelfManager>.Instance.m_MoveObjectCustomerBlocker).gameObject.SetActive(false); } if (!base.m_IsBoxedUp && Object.op_Implicit((Object)(object)base.m_InteractablePackagingBox_Shelf)) { if (Object.op_Implicit((Object)(object)base.m_Shelf_WorldUIGrp)) { ((Component)base.m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position; } base.m_InteractablePackagingBox_Shelf.EmptyBoxShelf(); ((InteractableObject)base.m_InteractablePackagingBox_Shelf).OnDestroyed(); } if (Object.op_Implicit((Object)(object)base.m_Shelf_WorldUIGrp) && !base.m_IsBoxedUp) { ((Component)base.m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position; ((Component)base.m_Shelf_WorldUIGrp).transform.rotation = ((Component)this).transform.rotation; } if (Object.op_Implicit((Object)(object)base.m_NavMeshCut)) { base.m_NavMeshCut.SetActive(false); base.m_NavMeshCut.SetActive(true); } } } public class CustomInteractableObject : InteractableObject { protected override void Awake() { } protected override void Update() { //IL_0017: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) if (!base.m_IsMovingObject) { return; } ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, base.m_TargetMoveObjectPosition, Time.deltaTime * 7.5f); bool flag = false; int mask = LayerMask.GetMask(new string[2] { "MoveStateBlockedArea", "Customer" }); if (Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, mask).Length == 0) { if (base.m_PlaceObjectInShopOnly) { if (Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, LayerMask.GetMask(new string[1] { "MoveStateValidArea" })).Length != 0) { flag = true; } } else if (base.m_PlaceObjectInShopOnly && Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, LayerMask.GetMask(new string[1] { "MoveStateValidWarehouseArea" })).Length != 0) { flag = true; } } base.m_IsMovingObjectValidState = flag; ShelfManager.SetMoveObjectPreviewModelValidState(flag); } protected override void OnPlacedMovedObject() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) CSingleton<InteractionPlayerController>.Instance.OnExitMoveObjectMode(); base.m_IsMovingObject = false; ((Component)this).gameObject.layer = base.m_OriginalLayer; ((Collider)base.m_BoxCollider).enabled = true; for (int i = 0; i < base.m_BoxColliderList.Count; i++) { ((Collider)base.m_BoxColliderList[i]).enabled = true; } int mask = LayerMask.GetMask(new string[1] { "ShopModel" }); Vector3 position = ((Component)base.m_PickupObjectMesh).transform.position; position.y += 0.2f; RaycastHit val = default(RaycastHit); if (Physics.Raycast(position, Vector3.down, ref val, 100f, mask)) { ((Component)this).transform.position = ((RaycastHit)(ref val)).point; } ((Component)base.m_MoveStateValidArea).gameObject.SetActive(true); ShelfManager.DisableMoveObjectPreviewMode(); if (Object.op_Implicit((Object)(object)base.m_BoxCollider)) { ((Component)CSingleton<ShelfManager>.Instance.m_MoveObjectCustomerBlocker).gameObject.SetActive(false); } if (!base.m_IsBoxedUp && Object.op_Implicit((Object)(object)base.m_InteractablePackagingBox_Shelf)) { if (Object.op_Implicit((Object)(object)base.m_Shelf_WorldUIGrp)) { ((Component)base.m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position; } base.m_InteractablePackagingBox_Shelf.EmptyBoxShelf(); ((InteractableObject)base.m_InteractablePackagingBox_Shelf).OnDestroyed(); } if (Object.op_Implicit((Object)(object)base.m_Shelf_WorldUIGrp) && !base.m_IsBoxedUp) { ((Component)base.m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position; ((Component)base.m_Shelf_WorldUIGrp).transform.rotation = ((Component)this).transform.rotation; } if (Object.op_Implicit((Object)(object)base.m_NavMeshCut)) { base.m_NavMeshCut.SetActive(false); base.m_NavMeshCut.SetActive(true); } } } public class VideoPlayerController : MonoBehaviour { public bool m_StopOnPickupObject; public VideoPlayer m_VideoPlayer; public InteractableObject m_InteractableObject; private void Update() { if (m_InteractableObject.GetIsBoxedUp() && m_VideoPlayer.isPlaying) { m_VideoPlayer.Stop(); } if (m_InteractableObject.GetIsMovingObject() && m_StopOnPickupObject && m_VideoPlayer.isPlaying) { m_VideoPlayer.Stop(); } if (!m_InteractableObject.GetIsMovingObject() && !m_InteractableObject.GetIsBoxedUp() && !m_VideoPlayer.isPlaying) { m_VideoPlayer.Play(); } } } public class WallHangingInteractableObject : InteractableObject { public float m_RaycastDistance; public bool m_IsBidirectional; private List<string> m_WallObjectNames = new List<string>(4) { "WarehousewallBlocker", "GlassdoorBlocker", "Blocker3", "Blocker5" }; protected override void Update() { //IL_0017: 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_002d: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) if (!base.m_IsMovingObject) { return; } ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, base.m_TargetMoveObjectPosition, Time.deltaTime * 7.5f); RaycastHit val = default(RaycastHit); if (Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, LayerMask.GetMask(new string[1] { "MoveStateBlockedArea" })).Length == 0) { bool num; if (!m_IsBidirectional) { num = Physics.Raycast(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.forward, ref val, m_RaycastDistance); } else { if (Physics.Raycast(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.forward, ref val, m_RaycastDistance)) { goto IL_0104; } num = Physics.Raycast(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.forward * -1f, ref val, m_RaycastDistance); } if (num) { goto IL_0104; } goto IL_012b; } base.m_IsMovingObjectValidState = false; ShelfManager.SetMoveObjectPreviewModelValidState(false); return; IL_0104: if (m_WallObjectNames.Contains(((Object)((RaycastHit)(ref val)).transform).name)) { base.m_IsMovingObjectValidState = true; ShelfManager.SetMoveObjectPreviewModelValidState(true); return; } goto IL_012b; IL_012b: base.m_IsMovingObjectValidState = false; ShelfManager.SetMoveObjectPreviewModelValidState(false); } protected override void OnPlacedMovedObject() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) CSingleton<InteractionPlayerController>.Instance.OnExitMoveObjectMode(); base.m_IsMovingObject = false; ((Component)this).gameObject.layer = base.m_OriginalLayer; ((Collider)base.m_BoxCollider).enabled = true; for (int i = 0; i < base.m_BoxColliderList.Count; i++) { ((Collider)base.m_BoxColliderList[i]).enabled = true; } ((Component)base.m_MoveStateValidArea).gameObject.SetActive(true); ShelfManager.DisableMoveObjectPreviewMode(); if (Object.op_Implicit((Object)(object)base.m_BoxCollider)) { ((Component)CSingleton<ShelfManager>.Instance.m_MoveObjectCustomerBlocker).gameObject.SetActive(false); } if (!base.m_IsBoxedUp && Object.op_Implicit((Object)(object)base.m_InteractablePackagingBox_Shelf)) { if (Object.op_Implicit((Object)(object)base.m_Shelf_WorldUIGrp)) { ((Component)base.m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position; } base.m_InteractablePackagingBox_Shelf.EmptyBoxShelf(); ((InteractableObject)base.m_InteractablePackagingBox_Shelf).OnDestroyed(); } if (Object.op_Implicit((Object)(object)base.m_Shelf_WorldUIGrp) && !base.m_IsBoxedUp) { ((Component)base.m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position; ((Component)base.m_Shelf_WorldUIGrp).transform.rotation = ((Component)this).transform.rotation; } if (Object.op_Implicit((Object)(object)base.m_NavMeshCut)) { base.m_NavMeshCut.SetActive(false); base.m_NavMeshCut.SetActive(true); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Scripts"; public const string PLUGIN_NAME = "Scripts"; public const string PLUGIN_VERSION = "1.1.0"; } }