Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LanternFrame v1.1.0
LanternFrame.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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 UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("LanternFrame")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+47bd8adc84d10f1700bfe3f5ff0708784668f6ba")] [assembly: AssemblyProduct("LanternFrame")] [assembly: AssemblyTitle("LanternFrame")] [assembly: AssemblyVersion("1.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 LanternFrame { [BepInPlugin("user.lanternframe", "Lantern Frame", "1.1.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "user.lanternframe"; internal static ConfigEntry<string> AllowedNames; internal static ConfigEntry<bool> LogItems; internal static ConfigEntry<bool> AllowVertical; internal static ConfigEntry<bool> LightShadows; internal static ConfigEntry<float> ShadowBias; internal static ConfigEntry<float> ShadowNormalBias; internal static ConfigEntry<float> LightRangeMultiplier; internal static ManualLogSource Log; private void Awake() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; AllowedNames = ((BaseUnityPlugin)this).Config.Bind<string>("General", "AllowedItems", "lantern", "Comma-separated, case-insensitive fragments. An item can be placed on the item frame if its prefab name or shared name contains one of them. Default matches the Dvergr lantern."); AllowVertical = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowOnVerticalFrame", true, "Also allow the items on the vertical item frame (the horizontal frame is always supported)."); LogItems = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LogAttachAttempts", false, "Log the prefab/shared name of every item you try to put on an item frame (helps finding the right name)."); LightShadows = ((BaseUnityPlugin)this).Config.Bind<bool>("Light", "CastShadows", true, "true: the lantern's light casts shadows so walls block it. false: no shadows at all. Restart the game after changing."); ShadowBias = ((BaseUnityPlugin)this).Config.Bind<float>("Light", "ShadowBias", 0.01f, new ConfigDescription("Shadow bias. Lower values stop light leaking through thin walls but can cause shadow acne.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); ShadowNormalBias = ((BaseUnityPlugin)this).Config.Bind<float>("Light", "ShadowNormalBias", 0.02f, new ConfigDescription("Shadow normal bias. High values (Unity's default is 0.4) let light leak through thin walls.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())); LightRangeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Light", "RangeMultiplier", 1f, new ConfigDescription("Multiplies the lantern's light range while on a frame (1 = vanilla). Lower it to reduce how far the light reaches. Restart the game after changing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>())); new Harmony("user.lanternframe").PatchAll(); } internal static bool IsHorizontal(ItemStand stand) { return ((Object)stand).name.StartsWith("itemstandh", StringComparison.OrdinalIgnoreCase); } internal static bool IsSupportedStand(ItemStand stand) { if (IsHorizontal(stand)) { return true; } if (AllowVertical.Value) { return ((Object)stand).name.StartsWith("itemstand", StringComparison.OrdinalIgnoreCase); } return false; } internal static bool IsAllowed(ItemData item) { if (item == null) { return false; } return IsAllowed(((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : "", (item.m_shared != null) ? item.m_shared.m_name : ""); } internal static bool IsAllowed(string prefab, string shared) { prefab = prefab ?? ""; shared = shared ?? ""; return (from s in AllowedNames.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries) select s.Trim() into s where s.Length > 0 select s).Any((string s) => prefab.IndexOf(s, StringComparison.OrdinalIgnoreCase) >= 0 || shared.IndexOf(s, StringComparison.OrdinalIgnoreCase) >= 0); } } [HarmonyPatch(typeof(ItemStand), "GetAttachPrefab")] internal static class ItemStandAttachPrefabPatch { private static readonly Dictionary<string, GameObject> Cache = new Dictionary<string, GameObject>(); private static readonly string[] StripOrder = new string[7] { "ConfigurableJoint", "ZSyncTransform", "Floating", "ItemDrop", "ZNetView", "Collider", "Rigidbody" }; private static readonly Vector3 HorizontalRotation = Vector3.zero; private static readonly Vector3 HorizontalPosition = Vector3.zero; private static readonly Vector3 VerticalRotation = new Vector3(90f, -90f, 0f); private static readonly Vector3 VerticalPosition = new Vector3(0f, 0.56f, 0f); private static void Postfix(GameObject item, ref GameObject __result) { ItemStand current = ItemStandSetVisualItemPatch.Current; if ((Object)(object)current == (Object)null || (Object)(object)__result == (Object)null || (Object)(object)item == (Object)null || !Plugin.IsSupportedStand(current)) { return; } ItemDrop component = item.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null) && Plugin.IsAllowed(((Object)item).name, component.m_itemData?.m_shared?.m_name)) { bool flag = Plugin.IsHorizontal(current); string key = ((Object)item).name + (flag ? "_h" : "_v"); if (!Cache.TryGetValue(key, out var value) || (Object)(object)value == (Object)null) { value = Build(__result, key, flag); Cache[key] = value; } __result = value; } } private static GameObject Build(GameObject source, string key, bool horizontal) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("LanternFrame_holder"); val.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val); GameObject val2 = Object.Instantiate<GameObject>(source, val.transform); ((Object)val2).name = key; string[] stripOrder = StripOrder; foreach (string key2 in stripOrder) { Component[] componentsInChildren = val2.GetComponentsInChildren<Component>(true); foreach (Component val3 in componentsInChildren) { if ((Object)(object)val3 != (Object)null && !(val3 is Transform) && IsKind(val3, key2)) { Object.DestroyImmediate((Object)(object)val3); } } } Transform[] componentsInChildren2 = val2.GetComponentsInChildren<Transform>(true); foreach (Transform val4 in componentsInChildren2) { if (((Object)val4).name != "SFX") { ((Component)val4).gameObject.SetActive(true); } } bool value = Plugin.LightShadows.Value; Light[] componentsInChildren3 = val2.GetComponentsInChildren<Light>(true); foreach (Light val5 in componentsInChildren3) { val5.range *= Plugin.LightRangeMultiplier.Value; val5.shadows = (LightShadows)(value ? 2 : 0); if (value) { val5.shadowStrength = 1f; val5.shadowBias = Plugin.ShadowBias.Value; val5.shadowNormalBias = Plugin.ShadowNormalBias.Value; } } LightLod[] componentsInChildren4 = val2.GetComponentsInChildren<LightLod>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Traverse val6 = Traverse.Create((object)componentsInChildren4[i]); val6.Field("m_shadowLod").SetValue((object)value); if (value) { val6.Field("m_shadowDistance").SetValue((object)Mathf.Max(val6.Field("m_shadowDistance").GetValue<float>(), 20f)); val6.Field("m_baseShadowStrength").SetValue((object)1f); } } val2.transform.localPosition = Vector3.zero; Transform val7 = val2.transform.Find("equiped"); if ((Object)(object)val7 != (Object)null) { Transform val8 = val7.Find("default"); if ((Object)(object)val8 != (Object)null) { val8.localPosition = Vector3.zero; } val7.localRotation = Quaternion.Euler(horizontal ? HorizontalRotation : VerticalRotation); val7.localPosition = (horizontal ? HorizontalPosition : VerticalPosition); } return val2; } private static bool IsKind(Component c, string key) { Type type = ((object)c).GetType(); while (type != null) { if (type.Name == key) { return true; } type = type.BaseType; } return false; } } [HarmonyPatch(typeof(ItemStand), "SetVisualItem")] internal static class ItemStandSetVisualItemPatch { internal static ItemStand Current; private static void Prefix(ItemStand __instance) { Current = __instance; } private static void Finalizer() { Current = null; } } [HarmonyPatch(typeof(ItemStand), "CanAttach")] internal static class ItemStandCanAttachPatch { private static void Postfix(ItemStand __instance, ItemData item, ref bool __result) { if (Plugin.IsSupportedStand(__instance)) { if (Plugin.LogItems.Value && item != null) { ManualLogSource log = Plugin.Log; string[] obj = new string[5] { "Attach attempt: prefab='", null, null, null, null }; GameObject dropPrefab = item.m_dropPrefab; obj[1] = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); obj[2] = "' shared='"; obj[3] = item.m_shared?.m_name; obj[4] = "'"; log.LogInfo((object)string.Concat(obj)); } if (!__result && Plugin.IsAllowed(item)) { __result = true; } } } } }