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 MoonforgedLightsAndDecor v1.0.5
MoonforgedLightsAndDecor.dll
Decompiled 4 days 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 BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] namespace Moonforged.LightsAndDecor; internal static class CandlePlugin { internal static GameObject Apply(GameObject prefab) { //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Expected O, but got Unknown //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) bool flag = ((Object)prefab).name == "M_Chandelier_Viking_2"; bool flag2 = ((Object)prefab).name == "M_Chandelier_Viking_3"; bool flag3 = ((Object)prefab).name == "M_Chandelier_Viking_4"; bool flag4 = flag || flag2; bool flag5 = ((Object)prefab).name == "M_Chandelier_Viking_1" || flag4 || flag3; if (!flag5 && ((Object)prefab).name != "M_Chandelier_Viking_Ship") { return prefab; } GameObject prefab2 = PrefabManager.Instance.GetPrefab("Candle_resin_bogwitch"); Transform val = (Object.op_Implicit((Object)(object)prefab2) ? prefab2.transform.Find("high") : null); Transform val2 = (Object.op_Implicit((Object)(object)prefab2) ? prefab2.transform.Find("full") : null); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !((Component)val).gameObject.activeSelf || !((Component)val2).gameObject.activeSelf || !Object.op_Implicit((Object)(object)((Component)val).GetComponentInChildren<Light>(true)) || !Object.op_Implicit((Object)(object)((Component)val).GetComponentInChildren<ParticleSystem>(true)) || !Object.op_Implicit((Object)(object)((Component)val2).GetComponentInChildren<Renderer>(true))) { Debug.LogWarning((object)"[Moonforged Lights and Decor] Could not find the lit Candle_resin_bogwitch visuals. Keeping the original chandelier candles."); return prefab; } List<string> list = new List<string>(); if (flag5) { int num = (flag2 ? 4 : 12); for (int i = 1; i <= num; i++) { list.Add($"Candle_{i}"); } } else { for (int j = 1; j <= 5; j++) { list.Add($"Candle_{j}_Left"); list.Add($"Candle_{j}_Right"); } } foreach (string item in list) { if ((Object)(object)prefab.transform.Find(item) == (Object)null) { Debug.LogWarning((object)("[Moonforged Lights and Decor] Missing candle mount " + item + " on " + ((Object)prefab).name + ". Keeping the original prefab.")); return prefab; } } GameObject val3 = PrefabManager.Instance.CreateClonedPrefab(((Object)prefab).name, prefab); if (!Object.op_Implicit((Object)(object)val3)) { return prefab; } Vector3 localPosition = default(Vector3); foreach (string item2 in list) { Transform val4 = val3.transform.Find(item2); GameObject val5 = new GameObject(item2); val5.layer = ((Component)val4).gameObject.layer; val5.transform.SetParent(val4.parent, false); val5.transform.localPosition = val4.localPosition; val5.transform.localRotation = val4.localRotation; val5.transform.localScale = val4.localScale; val5.transform.SetSiblingIndex(val4.GetSiblingIndex()); GameObject val6 = Object.Instantiate<GameObject>(((Component)val2).gameObject, val5.transform, false); ((Object)val6).name = ((Object)val2).name; GameObject val7 = Object.Instantiate<GameObject>(((Component)val).gameObject, val5.transform, false); ((Object)val7).name = ((Object)val).name; if (flag5) { ((Vector3)(ref localPosition))..ctor(0f, 0.025f, 0f); val6.transform.localPosition = localPosition; val7.transform.localPosition = localPosition; if (flag3) { val5.transform.localScale = val4.localScale * 0.5f; } else { Vector3 val8 = (flag4 ? new Vector3(9f / 64f, 0.375f, 9f / 64f) : new Vector3(0.375f, 0.75f, 0.375f)); val5.transform.localScale = Vector3.Scale(val4.localScale, val8); } } if (flag4 || flag3) { ParticleSystem componentInChildren = val7.GetComponentInChildren<ParticleSystem>(true); ((Component)componentInChildren).transform.localPosition = new Vector3(0f, 0.286f, 0f); MainModule main = componentInChildren.main; ((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * 0.5f; ShapeModule shape = componentInChildren.shape; ((ShapeModule)(ref shape)).enabled = false; } Light componentInChildren2 = val7.GetComponentInChildren<Light>(true); componentInChildren2.intensity = 1.35f; componentInChildren2.range = 10f; Object.DestroyImmediate((Object)(object)((Component)val4).gameObject); } return val3; } } internal static class HearthParticleShaderFix { public static void Apply(GameObject hearth, AssetBundle bundle) { RemoveFuelPuff(hearth); Dictionary<string, Material> nativeMaterials = new Dictionary<string, Material>(StringComparer.Ordinal); HashSet<GameObject> sourceRoots = new HashSet<GameObject>(); Action<GameObject, bool> collect = null; collect = delegate(GameObject root, bool particlesOnly) { if (Object.op_Implicit((Object)(object)root) && sourceRoots.Add(root)) { Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!particlesOnly || val is ParticleSystemRenderer) { Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.shader)) { string key = CleanName(((Object)val2).name); if (!nativeMaterials.ContainsKey(key)) { nativeMaterials.Add(key, val2); } } } } } SmokeSpawner[] componentsInChildren2 = root.GetComponentsInChildren<SmokeSpawner>(true); foreach (SmokeSpawner val3 in componentsInChildren2) { collect(val3.m_smokePrefab, arg2: false); } } }; string[] array = new string[3] { "hearth", "fire_pit", "SmokeBall" }; foreach (string text in array) { GameObject prefab = ZNetScene.instance.GetPrefab(text); if (Object.op_Implicit((Object)(object)prefab) && (Object)(object)prefab != (Object)(object)hearth) { collect(prefab, text != "SmokeBall"); } } if (nativeMaterials.Count == 0) { Debug.LogWarning((object)"[Moonforged Lights and Decor] Hearth materials v2: no vanilla fire materials found; no replacements performed."); return; } HashSet<GameObject> visited = new HashSet<GameObject>(); Dictionary<Material, Material> copies = new Dictionary<Material, Material>(); Action<GameObject, bool> repair = null; repair = delegate(GameObject root, bool particlesOnly) { //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)root) && visited.Add(root) && !sourceRoots.Contains(root)) { Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!particlesOnly || val is ParticleSystemRenderer) { Material[] sharedMaterials = val.sharedMaterials; bool flag = false; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if (Object.op_Implicit((Object)(object)val2)) { string text2 = CleanName(((Object)val2).name); if (!nativeMaterials.TryGetValue(text2, out var value)) { Debug.LogWarning((object)("[Moonforged Lights and Decor] Hearth materials v2: no vanilla material named '" + text2 + "' on '" + ((Object)val).name + "' (shader '" + (Object.op_Implicit((Object)(object)val2.shader) ? ((Object)val2.shader).name : "null") + "').")); } else if (!((Object)(object)val2 == (Object)(object)value)) { if (!copies.TryGetValue(value, out var value2)) { value2 = new Material(value); ((Object)value2).name = text2; copies.Add(value, value2); } sharedMaterials[j] = value2; flag = true; } } } if (flag) { val.sharedMaterials = sharedMaterials; } } } SmokeSpawner[] componentsInChildren2 = root.GetComponentsInChildren<SmokeSpawner>(true); foreach (SmokeSpawner val3 in componentsInChildren2) { repair(val3.m_smokePrefab, arg2: false); } } }; repair(hearth, arg2: true); } private static void RemoveFuelPuff(GameObject hearth) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown Fireplace[] componentsInChildren = hearth.GetComponentsInChildren<Fireplace>(true); foreach (Fireplace val in componentsInChildren) { EffectList fuelAddedEffects = val.m_fuelAddedEffects; if (fuelAddedEffects == null || fuelAddedEffects.m_effectPrefabs == null) { continue; } List<EffectData> list = new List<EffectData>(); EffectData[] effectPrefabs = fuelAddedEffects.m_effectPrefabs; foreach (EffectData val2 in effectPrefabs) { if (val2 == null || !Object.op_Implicit((Object)(object)val2.m_prefab)) { list.Add(val2); } else if (val2.m_prefab.GetComponentsInChildren<Renderer>(true).Length == 0 && val2.m_prefab.GetComponentsInChildren<ParticleSystem>(true).Length == 0) { list.Add(val2); } } val.m_fuelAddedEffects = new EffectList { m_effectPrefabs = list.ToArray() }; } } private static string CleanName(string name) { string[] array = new string[2] { " (Instance)", " (runtime hearth fix)" }; foreach (string text in array) { if (name.EndsWith(text, StringComparison.Ordinal)) { name = name.Substring(0, name.Length - text.Length); } } return name; } } public sealed class HearthSmokeController : MonoBehaviour { private sealed class SmokeParticle { public ParticleSystem System; public ParticleSystemRenderer Renderer; public bool OriginalForceOff; public float TimeRate; public float DistanceRate; } [ThreadStatic] internal static HearthSmokeController SpawnOwner; internal static readonly bool DiagnosticsEnabled = true; private int loggedPuffs; private readonly List<SmokeParticle> particles = new List<SmokeParticle>(); private HearthSmokeMode? appliedMode; internal bool DiagnosticsActive => DiagnosticsEnabled && (((Object)this).name == "M_Round_Heart" || ((Object)this).name == "M_Round_Heart_small" || ((Object)this).name == "M_Round_Heart(Clone)" || ((Object)this).name == "M_Round_Heart_small(Clone)"); internal static HearthSmokeMode CurrentMode => RelicConfigManager.HearthSmoke?.Value ?? HearthSmokeMode.Normal; internal static void LogSetup(string stage, string expectedName, GameObject hearth) { if (DiagnosticsEnabled && (!(expectedName != "M_Round_Heart") || !(expectedName != "M_Round_Heart_small"))) { SmokeSpawner[] componentsInChildren = hearth.GetComponentsInChildren<SmokeSpawner>(true); Debug.Log((object)("[Moonforged Hearth Debug] " + stage + " expected=" + expectedName + " actual=" + ((Object)hearth).name + " " + $"fireplace={(Object)(object)hearth.GetComponentInChildren<Fireplace>(true) != (Object)null} " + $"controller={(Object)(object)hearth.GetComponent<HearthSmokeController>() != (Object)null} spawners={componentsInChildren.Length}")); SmokeSpawner[] array = componentsInChildren; foreach (SmokeSpawner val in array) { Debug.Log((object)("[Moonforged Hearth Debug] " + expectedName + " spawner=" + ((Object)val).name + " " + $"activeSelf={((Component)val).gameObject.activeSelf} interval={val.m_interval} " + DescribeSmoke(val.m_smokePrefab))); } } } private static string DescribeSmoke(GameObject puff) { if (!Object.op_Implicit((Object)(object)puff)) { return "smokePrefab=missing"; } MeshRenderer component = puff.GetComponent<MeshRenderer>(); MeshFilter component2 = puff.GetComponent<MeshFilter>(); Material val = (Object.op_Implicit((Object)(object)component) ? ((Renderer)component).sharedMaterial : null); Shader val2 = (Object.op_Implicit((Object)(object)val) ? val.shader : null); return $"smoke={((Object)puff).name} script={(Object)(object)puff.GetComponent<Smoke>() != (Object)null} " + $"rigidbody={(Object)(object)puff.GetComponent<Rigidbody>() != (Object)null} meshRenderer={(Object)(object)component != (Object)null} " + "mesh=" + ((Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component2.sharedMesh)) ? ((Object)component2.sharedMesh).name : "missing") + " material=" + (Object.op_Implicit((Object)(object)val) ? ((Object)val).name : "missing") + " shader=" + (Object.op_Implicit((Object)(object)val2) ? ((Object)val2).name : "missing") + " " + string.Format("colorProperty={0}", Object.op_Implicit((Object)(object)val) && val.HasProperty("_Color")); } internal void LogPuff(HearthSmokeVisual marker, Smoke puff) { if (DiagnosticsActive && loggedPuffs < 4) { loggedPuffs++; MeshRenderer component = ((Component)puff).GetComponent<MeshRenderer>(); Debug.Log((object)($"[Moonforged Hearth Debug] {((Object)this).name} id={((Object)this).GetInstanceID()} puff={loggedPuffs}/4 " + $"mode={CurrentMode} owned={marker.IsModSmoke} " + $"rendererEnabled={Object.op_Implicit((Object)(object)component) && ((Renderer)component).enabled} " + "forceRenderingOff=" + (Object.op_Implicit((Object)(object)component) ? ((Renderer)component).forceRenderingOff.ToString() : "missing") + " " + DescribeSmoke(((Component)puff).gameObject))); } } private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) ParticleSystem[] componentsInChildren = ((Component)this).GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val in componentsInChildren) { if (IsSmoke(((Component)val).transform)) { EmissionModule emission = val.emission; ParticleSystemRenderer component = ((Component)val).GetComponent<ParticleSystemRenderer>(); particles.Add(new SmokeParticle { System = val, Renderer = component, OriginalForceOff = (Object.op_Implicit((Object)(object)component) && ((Renderer)component).forceRenderingOff), TimeRate = ((EmissionModule)(ref emission)).rateOverTimeMultiplier, DistanceRate = ((EmissionModule)(ref emission)).rateOverDistanceMultiplier }); } } ApplyMode(); } private bool IsSmoke(Transform current) { while (Object.op_Implicit((Object)(object)current) && (Object)(object)current != (Object)(object)((Component)this).transform) { if (((Object)current).name.ToLowerInvariant().Contains("smok")) { return true; } current = current.parent; } return false; } private void LateUpdate() { if (appliedMode != CurrentMode) { ApplyMode(); } foreach (SmokeParticle particle in particles) { if (Object.op_Implicit((Object)(object)particle.Renderer)) { ((Renderer)particle.Renderer).forceRenderingOff = particle.OriginalForceOff || CurrentMode == HearthSmokeMode.None; } } } private void ApplyMode() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) HearthSmokeMode currentMode = CurrentMode; float num = currentMode switch { HearthSmokeMode.Reduced => 0.25f, HearthSmokeMode.None => 0f, _ => 1f, }; foreach (SmokeParticle particle in particles) { if (Object.op_Implicit((Object)(object)particle.System)) { EmissionModule emission = particle.System.emission; ((EmissionModule)(ref emission)).rateOverTimeMultiplier = particle.TimeRate * num; ((EmissionModule)(ref emission)).rateOverDistanceMultiplier = particle.DistanceRate * num; if (Object.op_Implicit((Object)(object)particle.Renderer)) { ((Renderer)particle.Renderer).forceRenderingOff = particle.OriginalForceOff || currentMode == HearthSmokeMode.None; } if (currentMode == HearthSmokeMode.None) { particle.System.Clear(false); } } } if (DiagnosticsActive) { loggedPuffs = 0; Debug.Log((object)($"[Moonforged Hearth Debug] {((Object)this).name} id={((Object)this).GetInstanceID()} " + $"mode={currentMode} localParticleSystems={particles.Count} emissionMultiplier={num}")); } appliedMode = currentMode; } } public sealed class HearthSmokeVisual : MonoBehaviour { private static uint nextSmoke; private MeshRenderer smokeRenderer; private bool originalForceRenderingOff; private bool keepWhenReduced; internal bool IsModSmoke { get; private set; } internal void Assign(bool owned) { if (IsModSmoke && Object.op_Implicit((Object)(object)smokeRenderer)) { ((Renderer)smokeRenderer).forceRenderingOff = originalForceRenderingOff; } IsModSmoke = owned; if (owned) { smokeRenderer = ((Component)this).GetComponent<MeshRenderer>(); if (Object.op_Implicit((Object)(object)smokeRenderer)) { originalForceRenderingOff = ((Renderer)smokeRenderer).forceRenderingOff; } keepWhenReduced = ++nextSmoke % 4 == 0; ApplyVisibility(); } } internal void ApplyVisibility() { if (Object.op_Implicit((Object)(object)smokeRenderer)) { HearthSmokeMode currentMode = HearthSmokeController.CurrentMode; ((Renderer)smokeRenderer).forceRenderingOff = originalForceRenderingOff || currentMode == HearthSmokeMode.None || (currentMode == HearthSmokeMode.Reduced && !keepWhenReduced); } } } [HarmonyPatch] internal static class HearthSmokeSpawnPatch { private static IEnumerable<MethodBase> TargetMethods() { return (from method in AccessTools.GetDeclaredMethods(typeof(SmokeSpawner)) where method.Name == "Spawn" select method).Cast<MethodBase>(); } private static void Prefix(SmokeSpawner __instance, out HearthSmokeController __state) { __state = HearthSmokeController.SpawnOwner; HearthSmokeController.SpawnOwner = ((Component)__instance).GetComponentInParent<HearthSmokeController>(); } private static Exception Finalizer(Exception __exception, HearthSmokeController __state) { HearthSmokeController.SpawnOwner = __state; return __exception; } } [HarmonyPatch(typeof(Smoke), "OnEnable")] internal static class HearthSmokeOwnershipPatch { private static void Postfix(Smoke __instance) { bool flag = (Object)(object)HearthSmokeController.SpawnOwner != (Object)null; HearthSmokeVisual hearthSmokeVisual = ((Component)__instance).GetComponent<HearthSmokeVisual>(); if (Object.op_Implicit((Object)(object)hearthSmokeVisual) || flag) { if (!Object.op_Implicit((Object)(object)hearthSmokeVisual)) { hearthSmokeVisual = ((Component)__instance).gameObject.AddComponent<HearthSmokeVisual>(); } hearthSmokeVisual.Assign(flag); if (flag) { HearthSmokeController.SpawnOwner.LogPuff(hearthSmokeVisual, __instance); } } } } [HarmonyPatch(typeof(Smoke), "CustomUpdate")] internal static class HearthSmokeVisibilityPatch { private static void Postfix(Smoke __instance) { HearthSmokeVisual component = ((Component)__instance).GetComponent<HearthSmokeVisual>(); if (Object.op_Implicit((Object)(object)component) && component.IsModSmoke) { component.ApplyVisibility(); } } } public class LampColorSwitcher : MonoBehaviour, Interactable, Hoverable { private int index = 0; private int customColorPacked = 0; private const int OFF_INDEX = -1; private const int CUSTOM_INDEX = 4; private Light[] lights; private Renderer[] allRenderers; private Renderer[] bulbRenderers; private LightFlicker[] flickers; private LightLod[] lods; private ParticleSystem[] particles; private Transform[] flareObjects; private ZNetView znv; private readonly Color[] colors = (Color[])(object)new Color[4] { new Color(1f, 0.82f, 0.28f), new Color(0.22f, 0.85f, 0.32f), new Color(0.28f, 0.48f, 0.95f), new Color(0.95f, 0.3f, 0.7f) }; private readonly string[] names = new string[4] { "Yellow", "Green", "Blue", "Dvergr Pink" }; private const string ZDO_KEY = "LampColorIndex"; private const string ZDO_CUSTOM_COLOR = "LampCustomColor"; private const string ZDO_INIT = "initialized"; private void Awake() { //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) lights = ((Component)this).GetComponentsInChildren<Light>(true); allRenderers = ((Component)this).GetComponentsInChildren<Renderer>(true); bulbRenderers = Array.FindAll(allRenderers, delegate(Renderer r) { Material[] sharedMaterials = r.sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null && ((Object)val2).name.StartsWith("M_Bulb")) { return true; } } return false; }); flickers = ((Component)this).GetComponentsInChildren<LightFlicker>(true); lods = ((Component)this).GetComponentsInChildren<LightLod>(true); particles = ((Component)this).GetComponentsInChildren<ParticleSystem>(true); flareObjects = Array.FindAll(((Component)this).GetComponentsInChildren<Transform>(true), (Transform t) => (Object)(object)t != (Object)(object)((Component)this).transform && string.Equals(((Object)t).name, "flare", StringComparison.OrdinalIgnoreCase)); if (RelicConfigManager.EnableFlare != null) { RelicConfigManager.EnableFlare.SettingChanged += OnFlareSettingChanged; } ApplyFlareState(); if (RelicConfigManager.BulbBrightness != null) { RelicConfigManager.BulbBrightness.SettingChanged += OnBulbBrightnessChanged; } Collider componentInChildren = ((Component)this).GetComponentInChildren<Collider>(); if ((Object)(object)componentInChildren == (Object)null) { CapsuleCollider val = ((Component)this).gameObject.AddComponent<CapsuleCollider>(); ((Collider)val).isTrigger = true; val.radius = 0.25f; val.height = 1.2f; } znv = ((Component)this).GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)znv)) { return; } znv.Register<int, int>("SetLampState", (Action<long, int, int>)RPC_SetLampState); znv.Register<int>("RequestLampCycle", (Action<long, int>)RPC_RequestLampCycle); ZDO zDO = znv.GetZDO(); if (zDO != null) { if (znv.IsOwner() && !zDO.GetBool("initialized", false)) { index = Random.Range(0, colors.Length); customColorPacked = PackColor(RelicConfigManager.GetCustomLampColor()); zDO.Set("LampColorIndex", index); zDO.Set("LampCustomColor", customColorPacked); zDO.Set("initialized", true); } index = NormalizeIndex(zDO.GetInt("LampColorIndex", index)); customColorPacked = zDO.GetInt("LampCustomColor", PackColor(RelicConfigManager.GetCustomLampColor())); ApplyState(); } } public bool Interact(Humanoid user, bool hold, bool alt) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (hold) { return false; } if (!Object.op_Implicit((Object)(object)znv)) { return false; } ZDO zDO = znv.GetZDO(); if (zDO == null) { return false; } int num = PackColor(RelicConfigManager.GetCustomLampColor()); if (znv.IsOwner()) { CycleLamp(num); } else { znv.InvokeRPC("RequestLampCycle", new object[1] { num }); } return true; } public bool Interact(Humanoid user, bool hold) { return Interact(user, hold, alt: false); } public bool UseItem(Humanoid user, ItemData item) { return false; } private void RPC_RequestLampCycle(long sender, int requestedCustomColor) { if (Object.op_Implicit((Object)(object)znv) && znv.IsOwner()) { CycleLamp(requestedCustomColor); } } private void CycleLamp(int requestedCustomColor) { ZDO zDO = znv.GetZDO(); if (zDO != null) { if (index == -1) { index = 0; } else if (index < 4) { index++; } else { index = -1; } if (index == 4) { customColorPacked = requestedCustomColor; } zDO.Set("LampColorIndex", index); zDO.Set("LampCustomColor", customColorPacked); znv.InvokeRPC(ZNetView.Everybody, "SetLampState", new object[2] { index, customColorPacked }); ApplyState(); } } private void RPC_SetLampState(long sender, int newState, int newCustomColor) { index = NormalizeIndex(newState); customColorPacked = newCustomColor; ApplyState(); } private int NormalizeIndex(int value) { if (value == -1) { return -1; } if (value < 0 || value > 4) { return 0; } return value; } private void ApplyState() { //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) index = NormalizeIndex(index); if (index == -1) { Light[] array = lights; foreach (Light val in array) { if (Object.op_Implicit((Object)(object)val)) { ((Behaviour)val).enabled = false; } } LightFlicker[] array2 = flickers; foreach (LightFlicker val2 in array2) { if (Object.op_Implicit((Object)(object)val2)) { ((Behaviour)val2).enabled = false; } } LightLod[] array3 = lods; foreach (LightLod val3 in array3) { if (Object.op_Implicit((Object)(object)val3)) { ((Behaviour)val3).enabled = false; } } ParticleSystem[] array4 = particles; foreach (ParticleSystem val4 in array4) { if (Object.op_Implicit((Object)(object)val4)) { val4.Stop(true); ((Component)val4).gameObject.SetActive(false); } } Renderer[] array5 = bulbRenderers; foreach (Renderer val5 in array5) { Material[] materials = val5.materials; foreach (Material val6 in materials) { if (val6.HasProperty("_EmissionColor")) { val6.DisableKeyword("_EMISSION"); val6.SetColor("_EmissionColor", Color.black); } } } return; } Color val7 = ((index == 4) ? UnpackColor(customColorPacked) : colors[index]); Light[] array6 = lights; foreach (Light val8 in array6) { if (Object.op_Implicit((Object)(object)val8)) { ((Behaviour)val8).enabled = true; val8.color = val7; } } LightFlicker[] array7 = flickers; foreach (LightFlicker val9 in array7) { if (Object.op_Implicit((Object)(object)val9)) { ((Behaviour)val9).enabled = true; } } LightLod[] array8 = lods; foreach (LightLod val10 in array8) { if (Object.op_Implicit((Object)(object)val10)) { ((Behaviour)val10).enabled = true; } } ParticleSystem[] array9 = particles; foreach (ParticleSystem val11 in array9) { if (Object.op_Implicit((Object)(object)val11)) { ((Component)val11).gameObject.SetActive(true); val11.Play(); } } Renderer[] array10 = bulbRenderers; foreach (Renderer val12 in array10) { Material[] materials2 = val12.materials; foreach (Material val13 in materials2) { if (!((Object)(object)val13 == (Object)null) && ((Object)val13).name.StartsWith("M_Bulb")) { TintBulbMaterial(val13, val7); if (val13.HasProperty("_EmissionColor")) { val13.EnableKeyword("_EMISSION"); val13.SetColor("_EmissionColor", val7 * GetBulbBrightness()); } } } } ApplyFlareState(); } public string GetHoverText() { index = NormalizeIndex(index); if (index == -1) { return "[E] Turn On"; } string text = ((index == 4) ? "Custom" : names[index]); return "[E] Change color (" + text + ")"; } private static int PackColor(Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Color32 val = Color32.op_Implicit(color); return (val.r << 16) | (val.g << 8) | val.b; } private static Color UnpackColor(int packed) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) byte b = (byte)((packed >> 16) & 0xFF); byte b2 = (byte)((packed >> 8) & 0xFF); byte b3 = (byte)(packed & 0xFF); return Color32.op_Implicit(new Color32(b, b2, b3, byte.MaxValue)); } public string GetHoverName() { return "Lamp"; } public float GetHoverOffset() { return 0f; } private void OnFlareSettingChanged(object sender, EventArgs e) { ApplyFlareState(); } private void ApplyFlareState() { if (flareObjects == null) { return; } bool flag = index != -1 && (RelicConfigManager.EnableFlare == null || RelicConfigManager.EnableFlare.Value); Transform[] array = flareObjects; foreach (Transform val in array) { if (!Object.op_Implicit((Object)(object)val)) { continue; } if (!flag) { ParticleSystem[] componentsInChildren = ((Component)val).GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val2 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val2)) { val2.Stop(false, (ParticleSystemStopBehavior)0); } } } ((Component)val).gameObject.SetActive(flag); if (!flag) { continue; } ParticleSystem[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val3 in componentsInChildren2) { if (Object.op_Implicit((Object)(object)val3) && ((Component)val3).gameObject.activeInHierarchy && !val3.isPlaying) { val3.Play(false); } } } } private static float GetBulbBrightness() { return (RelicConfigManager.BulbBrightness != null) ? RelicConfigManager.BulbBrightness.Value : 1.5f; } private static void TintBulbMaterial(Material material, Color color) { //IL_0011: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0049: 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_0067: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty("_Color")) { Color val = color; val.a = material.GetColor("_Color").a; material.SetColor("_Color", val); } if (material.HasProperty("_BaseColor")) { Color val2 = color; val2.a = material.GetColor("_BaseColor").a; material.SetColor("_BaseColor", val2); } } private void OnBulbBrightnessChanged(object sender, EventArgs e) { //IL_004d: 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_0040: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (bulbRenderers == null) { return; } Color val = ((index == 4) ? UnpackColor(customColorPacked) : colors[(NormalizeIndex(index) != -1) ? NormalizeIndex(index) : 0]); Renderer[] array = bulbRenderers; foreach (Renderer val2 in array) { if (!Object.op_Implicit((Object)(object)val2)) { continue; } Material[] materials = val2.materials; foreach (Material val3 in materials) { if (!((Object)(object)val3 == (Object)null) && ((Object)val3).name.StartsWith("M_Bulb") && val3.HasProperty("_EmissionColor")) { val3.SetColor("_EmissionColor", (index == -1) ? Color.black : (val * GetBulbBrightness())); } } } } private void OnDestroy() { if (RelicConfigManager.EnableFlare != null) { RelicConfigManager.EnableFlare.SettingChanged -= OnFlareSettingChanged; } if (RelicConfigManager.BulbBrightness != null) { RelicConfigManager.BulbBrightness.SettingChanged -= OnBulbBrightnessChanged; } } } [BepInPlugin("Moonforged.LightsAndDecor", "Moonforged Lights and Decor", "1.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MoonforgedLightsAndDecor : BaseUnityPlugin { public const string PluginGUID = "Moonforged.LightsAndDecor"; public const string PluginName = "Moonforged Lights and Decor"; public const string PluginVersion = "1.0.5"; private AssetBundle relicsBundle; private Harmony bedInteractionHarmony; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) bedInteractionHarmony = new Harmony("Moonforged.LightsAndDecor.VikingBedInteraction"); bedInteractionHarmony.PatchAll(typeof(VikingBedInteractionPatch)); ApplyHearthSmokePatches(); RelicConfigManager.Init("Moonforged.LightsAndDecor", ((BaseUnityPlugin)this).Config); string platformBundleResourcePath = GetPlatformBundleResourcePath(); relicsBundle = EmbeddedAssetBundleLoader.LoadBundle(platformBundleResourcePath); if ((Object)(object)relicsBundle == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load embedded AssetBundle: " + platformBundleResourcePath)); return; } RelicRegistrar.InitConfig(((BaseUnityPlugin)this).Config); foreach (string allCategory in RelicRegistrar.GetAllCategories()) { PieceManager.Instance.AddPieceCategory(allCategory); } PrefabManager.OnPrefabsRegistered += OnPrefabsRegistered; } private void ApplyHearthSmokePatches() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("Moonforged.LightsAndDecor.HearthSmoke"); try { val.PatchAll(typeof(HearthSmokeVisibilityPatch)); val.PatchAll(typeof(HearthSmokeOwnershipPatch)); val.PatchAll(typeof(HearthSmokeSpawnPatch)); if (HearthSmokeController.DiagnosticsEnabled) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Moonforged Hearth Debug] Smoke patches installed."); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not install hearth smoke patches: " + ex)); try { val.UnpatchSelf(); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not remove partial hearth smoke patches: " + ex2)); } } } private static string GetPlatformBundleResourcePath() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 RuntimePlatform platform = Application.platform; RuntimePlatform val = platform; if ((int)val <= 1) { return "Moonforged.LightsAndDecor.mld_windows"; } return "Moonforged.LightsAndDecor.mld_windows"; } private void OnDestroy() { PrefabManager.OnPrefabsRegistered -= OnPrefabsRegistered; Harmony obj = bedInteractionHarmony; if (obj != null) { obj.UnpatchSelf(); } } private void OnPrefabsRegistered() { ((MonoBehaviour)this).StartCoroutine(DelayedRegister(relicsBundle)); } private IEnumerator DelayedRegister(AssetBundle bundle) { while ((Object)(object)ZNetScene.instance == (Object)null) { yield return null; } RelicRegistrar.RegisterAllRelics(bundle); } } public static class EmbeddedAssetBundleLoader { public static AssetBundle LoadBundle(string resourcePath) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream(resourcePath); if (stream == null) { Debug.LogError((object)("AssetBundle resource not found: " + resourcePath)); return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return AssetBundle.LoadFromMemory(memoryStream.ToArray()); } } public enum HearthSmokeMode { Normal, Reduced, None } public static class RelicConfigManager { private static ConfigFile configFile; private static readonly Dictionary<string, ConfigEntry<bool>> pieceSettings = new Dictionary<string, ConfigEntry<bool>>(); public static ConfigEntry<HearthSmokeMode> HearthSmoke { get; private set; } public static ConfigEntry<string> CustomLampColor { get; private set; } public static ConfigEntry<bool> EnableFlare { get; private set; } public static ConfigEntry<float> BulbBrightness { get; private set; } public static void Init(string modName, ConfigFile config) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown configFile = config; HearthSmoke = config.Bind<HearthSmokeMode>("Hearths", "Smoke", HearthSmokeMode.Normal, "Visual smoke for all mod fireplaces: Normal, Reduced (25% density), or None. Applies while playing. Visibility only: smoke obstruction, ventilation, fuel, warmth and damage are unchanged."); BulbBrightness = config.Bind<float>("Lamps", "BulbBrightness", 1.5f, new ConfigDescription("Bulb emission brightness, separate from ground lighting. Lower values preserve more color; higher values create stronger glow but may wash out colors. Applies immediately when changed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); EnableFlare = AddEntry(config, "Lamps", "EnableFlare", defaultValue: true, "Enable the orange flare particle effects around lamp bulbs. Disable to hide all lamp flares without changing lamp lighting or colors. Applies immediately when this setting changes."); CustomLampColor = AddEntry(config, "Lamps", "CustomLampColor", "#FF7A00", "Custom lamp color added after the built-in Yellow, Green, Blue and Dvergr Pink colors. Use HTML hex format, for example #FF7A00."); } public static bool IsPieceEnabled(string prefabName, string displayName) { if (!pieceSettings.TryGetValue(prefabName, out var value)) { value = configFile.Bind<bool>("Pieces", prefabName, true, "Show " + displayName + " in the build menu. Restart Valheim after changing. Existing placed pieces remain registered and are not deleted. Local setting; not server-synced."); pieceSettings.Add(prefabName, value); } return value.Value; } public static Color GetCustomLampColor() { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); if (CustomLampColor != null && ColorUtility.TryParseHtmlString(CustomLampColor.Value, ref result)) { return result; } return new Color(1f, 0.48f, 0f); } public static ConfigEntry<T> AddEntry<T>(ConfigFile cfg, string section, string key, T defaultValue, string description) { return cfg.Bind<T>(section, key, defaultValue, description); } } public class RelicRegistration { public string PrefabName; public string DisplayName; public RequirementConfig[] Requirements; public string Description; public string Category; public int Comfort; public RelicRegistration(string prefab, string display, RequirementConfig[] reqs, string desc, string cat, int comfort = 0) { PrefabName = prefab; DisplayName = display; Requirements = reqs; Description = desc; Category = cat; Comfort = comfort; } } public static class RelicRegistrar { private static bool wasAlreadyRegistered = false; private static ConfigEntry<string> CustomHammerTabConfig; public static readonly List<RelicRegistration> AllRegistrations = new List<RelicRegistration> { new RelicRegistration("M_Viking_Shiled_Axes", "Wall-Mounted Viking Shield and Axes", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Bronze", 2, 0, true), new RequirementConfig("Wood", 10, 0, true), new RequirementConfig("Copper", 2, 0, true) }, "", "building"), new RelicRegistration("M_Viking_Shiled_Dragons", "Wall-Mounted Viking Shield Dragons", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Bronze", 2, 0, true), new RequirementConfig("Wood", 10, 0, true), new RequirementConfig("Copper", 2, 0, true) }, "", "building"), new RelicRegistration("M_Viking_Shiled_Crows", "Wall-Mounted Viking Shield Ravens", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Bronze", 2, 0, true), new RequirementConfig("Wood", 10, 0, true), new RequirementConfig("Copper", 2, 0, true) }, "", "building"), new RelicRegistration("M_Emberwrought_Lamp", "Emberwrought Lamp", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "", "building"), new RelicRegistration("M_Wrought_Iron_Lantern_Post", "Wrought Iron Lamp Post", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "", "building"), new RelicRegistration("M_Classic_Lamp", "Classic Street Lamp", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "", "building"), new RelicRegistration("M_Japanese_Lamp", "Japanese Street Lamp", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "", "building"), new RelicRegistration("M_Classic_Double_Lamp", "Classic Double Lamp", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "Dvergr Forged Classic Iron 2x Lamp.", "building"), new RelicRegistration("M_Classic_Double_Lamp_2", "Classic Double Lamp II", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "Dvergr Forged Classic Iron 2x Lamp.", "building"), new RelicRegistration("M_Classic_Single_Lamp", "Classic Single Lamp", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "Dvergr Forged Classic Iron 1x Lamp.", "building"), new RelicRegistration("M_Chinese_Lamp", "Chinese Lamp", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "", "building"), new RelicRegistration("M_classic_quad_light", "Classic Quad Lamp", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "Dvergr Forged Classic Iron 4x Lamp.", "building"), new RelicRegistration("M_Classic_Wall_Lamp", "Classic Wall Lamp", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "Dvergr Forged Classic Iron Wall Lamp.", "building"), new RelicRegistration("M_Classic_Wall_Lamp_2", "Classic Wall Lamp II", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "Dvergr Forged Classic Iron Wall Lamp.", "building"), new RelicRegistration("M_GargoyleLamp", "Moonforged Gargoyle Wall Lamp", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Resin", 10, 0, true), new RequirementConfig("GreydwarfEye", 20, 0, true) }, "", "building"), new RelicRegistration("M_DragonLamp", "Moonforged Dragon Wall Lamp", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Silver", 10, 0, true), new RequirementConfig("Resin", 10, 0, true), new RequirementConfig("GreydwarfEye", 20, 0, true) }, "", "building"), new RelicRegistration("M_CrowLamp", "Moonforged Raven Wall Lamp", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("BlackMetal", 2, 0, true), new RequirementConfig("Resin", 10, 0, true), new RequirementConfig("GreydwarfEye", 20, 0, true) }, "", "building"), new RelicRegistration("M_Chandelier_Viking_Ship", "Viking Ship Chandelier", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Copper", 15, 0, true), new RequirementConfig("Wood", 2, 0, true), new RequirementConfig("Resin", 16, 0, true) }, "", "building"), new RelicRegistration("M_Chandelier_Viking_1", "Viking Runebound Chandelier", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Bronze", 2, 0, true), new RequirementConfig("Resin", 24, 0, true) }, "", "building"), new RelicRegistration("M_Chandelier_Viking_2", "Viking Ironthorn Chandelier", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Bronze", 2, 0, true), new RequirementConfig("Resin", 24, 0, true) }, "", "building"), new RelicRegistration("M_Chandelier_Viking_3", "Viking Hearthhook Chandelier", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Chain", 1, 0, true), new RequirementConfig("Resin", 8, 0, true) }, "", "building"), new RelicRegistration("M_Chandelier_Viking_4", "Viking Twin-Ring Chandelier", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Bronze", 2, 0, true), new RequirementConfig("Resin", 24, 0, true) }, "", "building"), new RelicRegistration("M_VikingBed", "Viking Chieftain’s Bed", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("FineWood", 20, 0, true), new RequirementConfig("WolfPelt", 5, 0, true), new RequirementConfig("LoxPelt", 5, 0, true), new RequirementConfig("IronNails", 20, 0, true) }, "", "building"), new RelicRegistration("M_Dreamkeel", "Moonforged Dreamkeel", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("WolfPelt", 1, 0, true), new RequirementConfig("LoxPelt", 2, 0, true), new RequirementConfig("IronNails", 4, 0, true) }, "", "building"), new RelicRegistration("M_LeafChair", "Moonforged Leaf Chair", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("Dandelion", 10, 0, true), new RequirementConfig("Wood", 5, 0, true) }, "", "building"), new RelicRegistration("M_FineWood_Throne", "Moonforged FineWood Throne", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("FineWood", 10, 0, true) }, "A custom decorative piece.", "furniture", 2), new RelicRegistration("M_Werewolf_Throne", "Moonforged Werewolf Throne", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("WolfPelt", 5, 0, true), new RequirementConfig("TrophyFenring", 3, 0, true), new RequirementConfig("Silver", 5, 0, true) }, "A custom decorative piece.", "furniture", 2), new RelicRegistration("M_Wolf_Throne", "Moonforged Geirrhafa`s Throne", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("WolfPelt", 5, 0, true), new RequirementConfig("Silver", 5, 0, true), new RequirementConfig("TrophyCultist", 1, 0, true) }, "A custom decorative piece.", "furniture", 2), new RelicRegistration("M_Iron_Throne", "Moonforged Iron Throne", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Iron", 10, 0, true), new RequirementConfig("BlackMetal", 10, 0, true) }, "A custom decorative piece.", "furniture", 2), new RelicRegistration("M_Classic_Iron_Bench", "Classic Iron Bench", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true) }, "Dvergr Forged Classic Iron Bench.", "furniture"), new RelicRegistration("M_PersianRug_1", "Persian Rug I", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("JuteRed", 4, 0, true), new RequirementConfig("DeerHide", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_PersianRug_2", "Persian Rug II", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("JuteRed", 2, 0, true), new RequirementConfig("DeerHide", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_PersianRug_4", "Regal Persian Rug", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("JuteRed", 2, 0, true), new RequirementConfig("DeerHide", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Jute_Stairs_Rug", "Jute Stair Rug", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("JuteRed", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Jute_Stairs_Rug_Blue", "Blue Jute Stair Rug", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("JuteBlue", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Jute_Stairs_Rug_Blue_Runed", "Runed Blue Jute Stair Rug", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("JuteBlue", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Jute_Stairs_Rug_Small", "Small Jute Stair Rug", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("JuteRed", 2, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Jute_Stairs_Runed", "Runed Jute Stair Rug", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("JuteRed", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Stairs_Rug_Wool", "Wool Stair Rug", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("DeerHide", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Stairs_Rug_Green_Runed", "Runed Green Stair Rug", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("JuteRed", 4, 0, true), new RequirementConfig("Ooze", 1, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Stairs_Rug_Green", "Green Stair Rug", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("JuteRed", 4, 0, true), new RequirementConfig("Ooze", 1, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_BlueRug", "Blue Rug", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("JuteBlue", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Red_2m_semiround_rug", "Red Semiround Rug", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("JuteRed", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_2m_semiround_rug", "Brown Semiround Rug", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("DeerHide", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Jute_Round_Red_Rug", "Round Red Jute Rug", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("JuteRed", 4, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_TrollRoundRug", "Troll Hide Round Rug", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("TrollHide", 5, 0, true), new RequirementConfig("DeerHide", 5, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_TrollHideRug", "Troll Hide Rug", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("TrollHide", 10, 0, true), new RequirementConfig("DeerHide", 5, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_TrollSemiRoundRug", "Troll Hide Semi Round Rug", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("TrollHide", 2, 0, true), new RequirementConfig("DeerHide", 5, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_TrollSemiRoundRugRuned", "Troll Hide Runed Semi Round Rug", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("TrollHide", 2, 0, true), new RequirementConfig("GreydwarfEye", 2, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_TrollPeltRug", "Troll Pelt Rug", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("TrollHide", 10, 0, true), new RequirementConfig("TrophyForestTroll", 1, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Jute_Red_Simple_Rug", "Simple Red Jute Rug", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("JuteRed", 2, 0, true), new RequirementConfig("DeerHide", 5, 0, true) }, "A custom decorative piece.", "furniture"), new RelicRegistration("M_Dragon_Rug", "Dragon Rug", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("TrophyHatchling", 2, 0, true), new RequirementConfig("FreezeGland", 2, 0, true), new RequirementConfig("WolfPelt", 5, 0, true) }, "", "building"), new RelicRegistration("M_AsianTeaSetPlate", "Tea Plate", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("FineWood", 1, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_bigplate", "Large Porcelain Plate", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_cup1", "Porcelain Tea Cup", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_justplate1", "Large Porcelain Plate II", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_justcup1", "Porcelain Tea Cup II", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_teapot", "Porcelain Teapot", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_AsianTeaPot", "Asian Teapot", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_AsianTeaCup", "Asian Tea Cup", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_AsianTeaPotLid", "Teapot Lid", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_ChineseVase", "Chinese Vase", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Crystal", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_ChineseTeaSet", "Chinese Tea Set", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_Porcelain_Teacup_tea", "Porcelain Teacup with Tea", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_Porcelain_Teapot", "Fine Porcelain Teapot", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 5, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_Metal_Teacup", "Metal Teacup", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Iron", 1, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_Metal_Teapot", "Metal Teapot", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Iron", 2, 0, true) }, "A custom decorative piece.", "clutter"), new RelicRegistration("M_BookShelf", "Ancient Root Bookshelf", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("FineWood", 2, 0, true), new RequirementConfig("RoundLog", 2, 0, true), new RequirementConfig("Resin", 4, 0, true), new RequirementConfig("ElderBark", 5, 0, true) }, "", "building"), new RelicRegistration("M_Viking_Greathall_Table", "Moonforged Viking Greathall Table", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("FineWood", 20, 0, true), new RequirementConfig("RoundLog", 10, 0, true), new RequirementConfig("Wood", 25, 0, true), new RequirementConfig("IronNails", 10, 0, true) }, "", "building"), new RelicRegistration("M_classic_bin", "Classic Garden Bin", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Wood", 4, 0, true) }, "Dvergr Forged Classic Iron Bin.", "furniture"), new RelicRegistration("M_Pirate_Ship_Cannon", "Pirate Cannon", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 10, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "", "building"), new RelicRegistration("M_Pirate_Ship_Cannon_Balls", "Cannonballs", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 10, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "", "building"), new RelicRegistration("M_M1857_12Pounder_Cannon_Cannonballs", "12-Pounder Cannonballs", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 10, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "", "building"), new RelicRegistration("M_M1857_12Pounder_Cannon", "12-Pounder Cannon", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 10, 0, true), new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "", "building"), new RelicRegistration("M_Round_Heart", "Round Heart", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 10, 0, true), new RequirementConfig("Stone", 4, 0, true), new RequirementConfig("Resin", 4, 0, true) }, "", "building"), new RelicRegistration("M_Round_Heart_small", "Small Round Heart", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 5, 0, true), new RequirementConfig("Stone", 2, 0, true), new RequirementConfig("Resin", 2, 0, true) }, "", "building") }; public static void InitConfig(ConfigFile cfg) { foreach (RelicRegistration allRegistration in AllRegistrations) { RelicConfigManager.IsPieceEnabled(allRegistration.PrefabName, allRegistration.DisplayName); } CustomHammerTabConfig = RelicConfigManager.AddEntry(cfg, "Categories", "CustomHammerTab", "Moonforged Lights and Decor", "Hammer tab name for all Moonforged Lights and Decor pieces. Enter an existing category name or any new custom category name."); } public static IEnumerable<string> GetAllCategories() { return AllRegistrations.Select((RelicRegistration r) => CategoryToTab(r.Category)).Distinct(); } private static string CategoryToTab(string category) { if (CustomHammerTabConfig != null && !string.IsNullOrWhiteSpace(CustomHammerTabConfig.Value)) { return CustomHammerTabConfig.Value.Trim(); } return "Moonforged Lights and Decor"; } public static void RegisterAllRelics(AssetBundle bundle) { if (wasAlreadyRegistered) { return; } foreach (RelicRegistration allRegistration in AllRegistrations) { RegisterRelic(bundle, allRegistration); } wasAlreadyRegistered = true; } private static void RegisterRelic(AssetBundle bundle, RelicRegistration reg) { //IL_067d: Unknown result type (might be due to invalid IL or missing references) //IL_0684: Expected O, but got Unknown //IL_069b: Unknown result type (might be due to invalid IL or missing references) //IL_06a0: Unknown result type (might be due to invalid IL or missing references) //IL_06ad: Expected O, but got Unknown //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Expected O, but got Unknown //IL_070d: Unknown result type (might be due to invalid IL or missing references) //IL_0714: Expected O, but got Unknown //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_0730: Unknown result type (might be due to invalid IL or missing references) //IL_073d: Expected O, but got Unknown //IL_074e: Unknown result type (might be due to invalid IL or missing references) //IL_0753: Unknown result type (might be due to invalid IL or missing references) //IL_0760: Expected O, but got Unknown //IL_0869: Unknown result type (might be due to invalid IL or missing references) //IL_086e: Unknown result type (might be due to invalid IL or missing references) //IL_0886: Unknown result type (might be due to invalid IL or missing references) //IL_0892: Unknown result type (might be due to invalid IL or missing references) //IL_08a4: Unknown result type (might be due to invalid IL or missing references) //IL_08ad: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Unknown result type (might be due to invalid IL or missing references) //IL_08c5: Expected O, but got Unknown //IL_08f1: Unknown result type (might be due to invalid IL or missing references) //IL_08fb: Expected O, but got Unknown if ((Object)(object)bundle == (Object)null) { return; } GameObject val = bundle.LoadAsset<GameObject>(reg.PrefabName); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("[Moonforged Lights and Decor] Missing prefab in AssetBundle: " + reg.PrefabName)); return; } ((Object)val).name = reg.PrefabName; val = CandlePlugin.Apply(val); if ((Object)(object)val.GetComponentInChildren<Fireplace>(true) != (Object)null) { HearthParticleShaderFix.Apply(val, bundle); if ((Object)(object)val.GetComponent<HearthSmokeController>() == (Object)null) { val.AddComponent<HearthSmokeController>(); } } ZNetView val2 = val.GetComponent<ZNetView>() ?? val.AddComponent<ZNetView>(); val2.m_persistent = true; val2.m_syncInitialScale = true; ZSyncTransform val3 = val.GetComponent<ZSyncTransform>() ?? val.AddComponent<ZSyncTransform>(); val3.m_syncPosition = false; val3.m_syncRotation = false; val3.m_syncScale = true; val3.m_syncBodyVelocity = false; val3.m_characterParentSync = false; Piece val4 = val.GetComponent<Piece>() ?? val.AddComponent<Piece>(); val4.m_name = reg.DisplayName; val4.m_description = reg.Description; val4.m_groundOnly = false; GameObject val5 = null; GameObject val6 = null; GameObject val7 = null; GameObject val8 = null; string text = reg.PrefabName.ToLowerInvariant(); bool flag = false; if (reg.DisplayName != null && reg.DisplayName.ToLower().Contains("window")) { flag = true; } if (reg.PrefabName.ToLower().Contains("mozaic")) { flag = true; } HashSet<string> hashSet = new HashSet<string> { "M_teapot", "M_cup1", "M_justcup1", "M_justplate1", "M_bigplate", "M_AsianTeaPot", "M_AsianTeaCup", "M_AsianTeaPotLid", "M_ChineseVase", "M_Porcelain_Teacup_tea", "M_Porcelain_Teapot" }; bool flag2 = hashSet.Contains(reg.PrefabName); bool flag3 = text.Contains("rug") || text.Contains("carpet"); bool flag4 = text.Contains("lamp") || text.Contains("lantern") || text.Contains("light"); bool flag5 = (Object)(object)val.GetComponentInChildren<Fireplace>(true) != (Object)null; bool flag6 = text.Contains("cannon"); bool flag7 = text.Contains("bench") || text.Contains("bin"); string text2 = reg.DisplayName?.ToLowerInvariant() ?? ""; bool flag8 = flag3 || text2.Contains("rug") || text2.Contains("carpet"); bool flag9 = text.StartsWith("m_chandelier_viking_", StringComparison.Ordinal); string[] usage = ((flag4 || flag5 || flag9) ? new string[1] { PieceUsages.Lighting } : (flag6 ? new string[1] { PieceUsages.Defense } : ((!(flag8 || flag7) && !text.Contains("throne") && !text.Contains("bookshelf") && !text.Contains("bed") && !text.Contains("dreamkeel") && !text.Contains("chair") && !text.Contains("table")) ? new string[1] { PieceUsages.Decor } : new string[1] { PieceUsages.Furniture }))); if (flag2) { ZNetScene instance = ZNetScene.instance; val5 = ((instance != null) ? instance.GetPrefab("vfx_Place_crystal") : null); ZNetScene instance2 = ZNetScene.instance; val6 = ((instance2 != null) ? instance2.GetPrefab("sfx_build_hammer_crystal") : null); ZNetScene instance3 = ZNetScene.instance; val8 = ((instance3 != null) ? instance3.GetPrefab("sfx_clay_pot_break") : null); } else if (flag3) { ZNetScene instance4 = ZNetScene.instance; val5 = ((instance4 != null) ? instance4.GetPrefab("vfx_Place_wood") : null); ZNetScene instance5 = ZNetScene.instance; val6 = ((instance5 != null) ? instance5.GetPrefab("sfx_build_hammer_wood") : null); ZNetScene instance6 = ZNetScene.instance; val7 = ((instance6 != null) ? instance6.GetPrefab("vfx_destroyed") : null); ZNetScene instance7 = ZNetScene.instance; val8 = ((instance7 != null) ? instance7.GetPrefab("sfx_wood_break") : null); } else { bool flag10 = flag4 || flag6 || flag7; bool flag11 = flag10; if (!flag11) { string prefabName = reg.PrefabName; bool flag12 = ((prefabName == "M_Metal_Teacup" || prefabName == "M_Metal_Teapot") ? true : false); flag11 = flag12; } if (flag11) { ZNetScene instance8 = ZNetScene.instance; val5 = ((instance8 != null) ? instance8.GetPrefab("vfx_Place_stone") : null); ZNetScene instance9 = ZNetScene.instance; val6 = ((instance9 != null) ? instance9.GetPrefab("sfx_build_hammer_metal") : null); ZNetScene instance10 = ZNetScene.instance; val7 = ((instance10 != null) ? instance10.GetPrefab("vfx_destroyed") : null); ZNetScene instance11 = ZNetScene.instance; val8 = ((instance11 != null) ? instance11.GetPrefab("sfx_metal_blocked") : null); } else if (flag) { ZNetScene instance12 = ZNetScene.instance; val5 = ((instance12 != null) ? instance12.GetPrefab("vfx_Place_crystal") : null); ZNetScene instance13 = ZNetScene.instance; val6 = ((instance13 != null) ? instance13.GetPrefab("sfx_build_hammer_crystal") : null); ZNetScene instance14 = ZNetScene.instance; val8 = ((instance14 != null) ? instance14.GetPrefab("sfx_clay_pot_break") : null); } else { ZNetScene instance15 = ZNetScene.instance; val5 = ((instance15 != null) ? instance15.GetPrefab("vfx_Place_wood") : null); ZNetScene instance16 = ZNetScene.instance; val6 = ((instance16 != null) ? instance16.GetPrefab("sfx_build_hammer_wood") : null); ZNetScene instance17 = ZNetScene.instance; val7 = ((instance17 != null) ? instance17.GetPrefab("vfx_destroyed") : null); ZNetScene instance18 = ZNetScene.instance; val8 = ((instance18 != null) ? instance18.GetPrefab("sfx_wood_break") : null); } } if (flag9) { val6 = PrefabManager.Instance.GetPrefab("sfx_build_hammer_metal") ?? val6; val8 = PrefabManager.Instance.GetPrefab("sfx_metal_blocked") ?? val8; } else { string prefabName = reg.PrefabName; if ((prefabName == "M_Round_Heart" || prefabName == "M_Round_Heart_small") ? true : false) { val6 = PrefabManager.Instance.GetPrefab("sfx_build_hammer_stone") ?? val6; val8 = PrefabManager.Instance.GetPrefab("sfx_rock_destroyed") ?? val8; } } EffectList val9 = new EffectList(); List<EffectData> list = new List<EffectData>(); if ((Object)(object)val5 != (Object)null) { list.Add(new EffectData { m_prefab = val5 }); } if ((Object)(object)val6 != (Object)null) { list.Add(new EffectData { m_prefab = val6 }); } val9.m_effectPrefabs = list.ToArray(); val4.m_placeEffect = val9; WearNTear val10 = val.GetComponent<WearNTear>() ?? val.AddComponent<WearNTear>(); val10.m_health = 1000f; val10.m_noRoofWear = true; EffectList val11 = new EffectList(); List<EffectData> list2 = new List<EffectData>(); if ((Object)(object)val7 != (Object)null) { list2.Add(new EffectData { m_prefab = val7 }); } if ((Object)(object)val8 != (Object)null) { list2.Add(new EffectData { m_prefab = val8 }); } val11.m_effectPrefabs = list2.ToArray(); val10.m_destroyedEffect = val11; if (reg.Comfort > 0) { val4.m_comfort = reg.Comfort; } Sprite val12 = bundle.LoadAsset<Sprite>(reg.PrefabName); if ((Object)(object)val12 != (Object)null) { val4.m_icon = val12; } if (flag4 && (Object)(object)val.GetComponent<LampColorSwitcher>() == (Object)null) { val.AddComponent<LampColorSwitcher>(); } if (flag) { Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true); foreach (Renderer val13 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val13)) { val13.shadowCastingMode = (ShadowCastingMode)1; val13.receiveShadows = true; } } } string craftingStation = (reg.Requirements.Any((RequirementConfig r) => r.Item.ToLower() == "iron") ? "forge" : "piece_workbench"); PieceConfig val14 = new PieceConfig { Enabled = RelicConfigManager.IsPieceEnabled(reg.PrefabName, reg.DisplayName), PieceTable = "Hammer", Category = CategoryToTab(reg.Category), Usage = usage, CraftingStation = craftingStation, Requirements = reg.Requirements }; HearthSmokeController.LogSetup($"Registering (enabled={val14.Enabled})", reg.PrefabName, val); PieceManager.Instance.AddPiece(new CustomPiece(val, false, val14)); } } [HarmonyPatch(typeof(Bed), "Interact")] internal static class VikingBedInteractionPatch { private const float MaximumDistanceFromCollider = 0.5f; private static bool Prefix(Bed __instance, Humanoid human, ref bool __result) { //IL_0063: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || (!((Object)((Component)__instance).gameObject).name.StartsWith("M_VikingBed(") && ((Object)((Component)__instance).gameObject).name != "M_VikingBed")) { return true; } if ((Object)(object)human == (Object)null) { return true; } Vector3 position = ((Component)human).transform.position; float num = 0.25f; bool flag = false; BoxCollider[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<BoxCollider>(); foreach (BoxCollider val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && ((Collider)val).enabled && !((Collider)val).isTrigger) { flag = true; Vector3 val2 = ((Collider)val).ClosestPoint(position); Vector3 val3 = val2 - position; if (((Vector3)(ref val3)).sqrMagnitude <= num) { return true; } } } if (!flag) { return true; } __result = false; return false; } }