using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("MoonforgedChristmasDecorations")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MoonforgedChristmasDecorations")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.0.6.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.6.0")] namespace Moonforged.ChristmasDecorations; [RequireComponent(typeof(LineRenderer))] public class BezierRope : MonoBehaviour { public Transform pointA; public Transform pointB; [Header("Look")] public int segments = 24; public float width = 0.015f; public float sag = 0.25f; public Material material; [Header("Cloth-like motion")] public float windStrength = 0.2f; public float jiggleAmplitude = 0.02f; public float jiggleSpeed = 1f; private LineRenderer _lr; private float _seed; private void Awake() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) _lr = ((Component)this).GetComponent(); _lr.useWorldSpace = true; _lr.startWidth = width; _lr.endWidth = width; _lr.numCornerVertices = 3; _lr.numCapVertices = 3; _lr.textureMode = (LineTextureMode)0; ((Renderer)_lr).material = (Material)(((Object)(object)material != (Object)null) ? ((object)material) : ((object)new Material(Shader.Find("Sprites/Default")))); ((Renderer)_lr).material.color = Color.black; _seed = Random.Range(0f, 1000f); } private void LateUpdate() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00bc: 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) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: 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_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)pointA == (Object)null) && !((Object)(object)pointB == (Object)null)) { _lr.startWidth = width; _lr.endWidth = width; Vector3 position = pointA.position; Vector3 position2 = pointB.position; Vector3 val = (position + position2) * 0.5f; Vector3 val2 = Vector3.Lerp(position, val, 0.66f) + Vector3.down * sag; Vector3 val3 = Vector3.Lerp(position2, val, 0.66f) + Vector3.down * sag; Vector3 right = Vector3.right; if ((Object)(object)pointA != (Object)null) { right = pointA.right; } float num = Time.time + _seed; float num2 = Mathf.Sin(num * ((float)Math.PI * 2f) * Mathf.Max(0.01f, jiggleSpeed)) * jiggleAmplitude; val2 += right * windStrength * 0.5f + Vector3.up * num2 * 0.5f; val3 += right * windStrength * 1f + Vector3.down * num2 * 0.5f; int num3 = Mathf.Max(4, segments); _lr.positionCount = num3; float num4 = 1f / (float)(num3 - 1); for (int i = 0; i < num3; i++) { float num5 = (float)i * num4; Vector3 val4 = Mathf.Pow(1f - num5, 3f) * position + 3f * Mathf.Pow(1f - num5, 2f) * num5 * val2 + 3f * (1f - num5) * num5 * num5 * val3 + num5 * num5 * num5 * position2; float num6 = num5 * (1f - num5); Vector3 val5 = position2 - position; val5 = Vector3.Cross(((Vector3)(ref val5)).normalized, Vector3.up); Vector3 normalized = ((Vector3)(ref val5)).normalized; val4 += normalized * num2 * num6; _lr.SetPosition(i, val4); } } } } public class ChildLightsCycler : MonoBehaviour { public string[] lightRendererNames = new string[3] { "Light1", "Light2", "Light3" }; public float stepSeconds = 1f; public float intensity = 4.4f; private readonly List _mats = new List(); private static readonly Color[] Palette = (Color[])(object)new Color[3] { Color.red, Color.yellow, Color.blue }; private int _step; private Coroutine _runner; private void Awake() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) _mats.Clear(); for (int i = 0; i < lightRendererNames.Length; i++) { Transform val = ((Component)this).transform.Find(lightRendererNames[i]); if ((Object)(object)val == (Object)null) { continue; } Renderer component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null)) { Material sharedMaterial = component.sharedMaterial; if (!((Object)(object)sharedMaterial == (Object)null)) { sharedMaterial.EnableKeyword("_EMISSION"); sharedMaterial.SetColor("_EmissionColor", Palette[i % Palette.Length] * Mathf.LinearToGammaSpace(intensity)); sharedMaterial.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; _mats.Add(sharedMaterial); } } } } private void OnEnable() { if (_runner == null && _mats.Count > 0) { _runner = ((MonoBehaviour)this).StartCoroutine(Run()); } } private void OnDisable() { if (_runner != null) { ((MonoBehaviour)this).StopCoroutine(_runner); _runner = null; } } private IEnumerator Run() { float delay = Mathf.Max(0.05f, stepSeconds); while (true) { if (_mats.Count > 0) { ApplyStep(); } yield return (object)new WaitForSeconds(delay); } } private void ApplyStep() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _mats.Count; i++) { Material val = _mats[i]; if (!((Object)(object)val == (Object)null)) { Color val2 = Palette[(i + _step) % Palette.Length]; val.SetColor("_EmissionColor", val2 * Mathf.LinearToGammaSpace(intensity)); } } _step = (_step + 1) % Palette.Length; } } public class ChristmasLightChaser : MonoBehaviour { public enum AnimationMode { Chase, BlinkAll } public bool includeInactive = true; public Color[] defaultPalette = (Color[])(object)new Color[3] { Color.red, Color.yellow, Color.blue }; public Color[] paletteOverride; public AnimationMode mode = AnimationMode.Chase; [Min(0.01f)] public float stepSeconds = 1f; [Min(0f)] public float emissionIntensity = 4.4f; public bool affectBaseColor = false; public string[] ignoreNameContains = new string[2] { "cable", "snap" }; public List targets = new List(); private readonly List _mpbs = new List(); private int _colorId; private int _emissId; private int _step; private Coroutine _runner; private bool _liveStarted; private Color[] _palette; private void Awake() { //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown _palette = ((paletteOverride != null && paletteOverride.Length != 0) ? paletteOverride : defaultPalette); _colorId = Shader.PropertyToID("_Color"); _emissId = Shader.PropertyToID("_EmissionColor"); if (targets.Count == 0) { Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(includeInactive); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } string text = ((Object)val).name.ToLowerInvariant(); bool flag = false; for (int j = 0; j < ignoreNameContains.Length; j++) { if (text.Contains(ignoreNameContains[j])) { flag = true; break; } } if (!flag) { targets.Add(val); } } } _mpbs.Clear(); foreach (Renderer target in targets) { if (Object.op_Implicit((Object)(object)target)) { MaterialPropertyBlock val2 = new MaterialPropertyBlock(); target.GetPropertyBlock(val2); if (Object.op_Implicit((Object)(object)target.material)) { target.material.EnableKeyword("_EMISSION"); } _mpbs.Add(val2); } } } private void OnEnable() { if (_runner == null) { _runner = ((MonoBehaviour)this).StartCoroutine(Run()); } } private void OnDisable() { if (_runner != null) { ((MonoBehaviour)this).StopCoroutine(_runner); } _runner = null; _liveStarted = false; } private IEnumerator Run() { WaitForSeconds poll = new WaitForSeconds(0.2f); WaitForSeconds stepWait = new WaitForSeconds(stepSeconds); while (true) { bool hasZdo = false; ZNetView znv = ((Component)this).GetComponentInParent(); if ((Object)(object)znv != (Object)null) { hasZdo = znv.GetZDO() != null; } if (!hasZdo) { _liveStarted = false; yield return poll; continue; } if (!_liveStarted) { _liveStarted = true; _step = 0; } int n = Mathf.Max(1, _palette.Length); if (mode == AnimationMode.Chase) { for (int i = 0; i < targets.Count; i++) { Renderer r = targets[i]; if (Object.op_Implicit((Object)(object)r)) { MaterialPropertyBlock mpb = _mpbs[i]; Color c = _palette[(i + _step) % n]; if (affectBaseColor) { mpb.SetColor(_colorId, c); } mpb.SetColor(_emissId, c * Mathf.LinearToGammaSpace(emissionIntensity)); r.SetPropertyBlock(mpb); } } } else { Color c2 = _palette[_step % n]; for (int j = 0; j < targets.Count; j++) { Renderer r2 = targets[j]; if (Object.op_Implicit((Object)(object)r2)) { MaterialPropertyBlock mpb2 = _mpbs[j]; if (affectBaseColor) { mpb2.SetColor(_colorId, c2); } mpb2.SetColor(_emissId, c2 * Mathf.LinearToGammaSpace(emissionIntensity)); r2.SetPropertyBlock(mpb2); } } } _step++; yield return stepWait; } } } public static class ChristmasLightChaserInstaller { public static void InstallOn(GameObject prefabRoot, float stepSeconds, float emissionIntensity) { InstallOn(prefabRoot, stepSeconds, emissionIntensity, null, ChristmasLightChaser.AnimationMode.Chase); } public static void InstallOn(GameObject prefabRoot, float stepSeconds, float emissionIntensity, Color[] paletteOverride, ChristmasLightChaser.AnimationMode mode) { if (Object.op_Implicit((Object)(object)prefabRoot)) { ChristmasLightChaser christmasLightChaser = prefabRoot.GetComponent(); if (!Object.op_Implicit((Object)(object)christmasLightChaser)) { christmasLightChaser = prefabRoot.AddComponent(); } christmasLightChaser.includeInactive = true; christmasLightChaser.stepSeconds = stepSeconds; christmasLightChaser.emissionIntensity = emissionIntensity; christmasLightChaser.mode = mode; if (paletteOverride != null && paletteOverride.Length != 0) { christmasLightChaser.paletteOverride = paletteOverride; } christmasLightChaser.targets = CollectBulbRenderers(prefabRoot, new string[1] { "light" }, new string[6] { "cable", "wire", "string", "snap", "garland", "rope" }); } } private static List CollectBulbRenderers(GameObject root, string[] includePrefixes, string[] ignoreContains) { List list = new List(); if (!Object.op_Implicit((Object)(object)root)) { return list; } Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } string text = ((Object)((Component)val).gameObject).name.ToLowerInvariant(); bool flag = false; if (ignoreContains != null) { foreach (string value in ignoreContains) { if (!string.IsNullOrEmpty(value) && text.Contains(value)) { flag = true; break; } } } if (flag) { continue; } bool flag2 = includePrefixes == null || includePrefixes.Length == 0; if (!flag2) { foreach (string value2 in includePrefixes) { if (!string.IsNullOrEmpty(value2) && text.StartsWith(value2)) { flag2 = true; break; } } } if (flag2) { list.Add(val); } } return list; } } public class ChristmasLightsGlow : MonoBehaviour { [Header("Target renderer (child name)")] public string rendererChildName = "Christmas tree.007"; [Header("Choose how to select materials")] public bool useIndices = true; [Tooltip("Material slots that should glow (0-based)")] public int[] glowSlots = new int[3] { 2, 7, 8 }; [Tooltip("Match by material name (contains, case-insensitive)")] public string[] glowNameContains = new string[1] { "vray_Christmas Tree Set3_4.001" }; [Header("Glow settings")] public Color emissionColor = Color.yellow; public float intensity = 3f; public bool animate = false; public float cycleSeconds = 5f; private Renderer _rend; private Material[] _mats; private bool[] _shouldGlow; private void Awake() { //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)this).transform.Find(rendererChildName); if ((Object)(object)val != (Object)null) { _rend = ((Component)val).GetComponent(); } if ((Object)(object)_rend == (Object)null) { _rend = (from r in ((Component)this).GetComponentsInChildren(true) orderby (r.sharedMaterials != null) ? r.sharedMaterials.Length : 0 descending select r).FirstOrDefault(); } if ((Object)(object)_rend == (Object)null) { return; } _mats = _rend.materials; _shouldGlow = new bool[_mats.Length]; for (int num = 0; num < _mats.Length; num++) { bool flag = false; if (useIndices) { for (int num2 = 0; num2 < glowSlots.Length; num2++) { if (glowSlots[num2] == num) { flag = true; break; } } } else { string text = (((Object)(object)_mats[num] != (Object)null) ? ((Object)_mats[num]).name : ""); for (int num3 = 0; num3 < glowNameContains.Length; num3++) { if (!string.IsNullOrEmpty(glowNameContains[num3]) && text.ToLower().Contains(glowNameContains[num3].ToLower())) { flag = true; break; } } } _shouldGlow[num] = flag; if (flag && (Object)(object)_mats[num] != (Object)null) { _mats[num].EnableKeyword("_EMISSION"); Color val2 = emissionColor * Mathf.LinearToGammaSpace(intensity); _mats[num].SetColor("_EmissionColor", val2); _mats[num].globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; } } _rend.materials = _mats; } private void Update() { //IL_0083: 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_00a0: 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) if (!animate || _mats == null) { return; } float num = Mathf.Max(0.01f, cycleSeconds); float num2 = Time.time % num / num; float num3 = 0.5f + 0.5f * Mathf.Sin(num2 * (float)Math.PI * 2f); for (int i = 0; i < _mats.Length; i++) { if (_shouldGlow[i] && (Object)(object)_mats[i] != (Object)null) { Color val = emissionColor * Mathf.LinearToGammaSpace(intensity * (0.5f + num3)); _mats[i].SetColor("_EmissionColor", val); } } } } public class ConnectedLightControl : MonoBehaviour, Interactable, Hoverable { public enum LightMode { Normal, Fast5x, Fast10x, Vibrate, Off } public string prefabIdentity = ""; [Header("Connected lights")] [Min(0.05f)] public float connectionDistance = 0.35f; [Min(0.05f)] public float connectionRefreshSeconds = 0.25f; [Header("Rapid blink")] [Min(0.01f)] public float rapidBlinkSeconds = 0.03f; private const string ModeZdoKey = "mf_connected_light_mode"; private const string ModeVersionZdoKey = "mf_connected_light_version"; private static readonly List Instances = new List(); private readonly List _snapPoints = new List(); private readonly List _bulbRenderers = new List(); private readonly List _savedBulbBlocks = new List(); private readonly List _workingBulbBlocks = new List(); private ZNetView _nview; private ChristmasLightChaser _chaser; private ChildLightsCycler _cycler; private IcicleFlow _icicleFlow; private ChristmasLightsGlow _glow; private float _baseChaserStep; private float _baseCyclerStep; private float _baseFlowDripStep; private float _baseFlowPause; private float _baseFlowBatchSpacing; private float _baseFlowUpdateInterval; private float _baseGlowCycle; private bool _baseChaserEnabled; private bool _baseCyclerEnabled; private bool _baseFlowEnabled; private bool _baseGlowEnabled; private bool _baseTimingCaptured; private LightMode _mode = LightMode.Normal; private int _modeVersion; private LightMode _appliedMode = LightMode.Normal; private int _appliedVersion; private bool _hasAppliedMode; private int _groupSignature; private int _linkedLightCount = 1; private int _blinkPhase = -1; private float _nextConnectionRefresh; private int _emissionColorId; private void Awake() { _emissionColorId = Shader.PropertyToID("_EmissionColor"); EnsureNetworkView(); CacheSnapPoints(); CacheAnimationComponents(); } private void Start() { EnsureNetworkView(); CacheAnimationComponents(); CaptureBaseTiming(); CacheBulbRenderers(); ReadNetworkMode(force: true); ApplyMode(_mode, _modeVersion, persist: false, forceRestart: true); } private void OnEnable() { if (!Instances.Contains(this)) { Instances.Add(this); } _nextConnectionRefresh = 0f; _blinkPhase = -1; } private void OnDisable() { Instances.Remove(this); } private void Update() { EnsureNetworkView(); if (ReadNetworkMode(force: false)) { ApplyMode(_mode, _modeVersion, persist: false, forceRestart: true); } float time = Time.time; if (time >= _nextConnectionRefresh) { _nextConnectionRefresh = time + Mathf.Max(0.05f, connectionRefreshSeconds); RefreshLinkedGroup(); } if (_mode == LightMode.Vibrate) { UpdateRapidBlink(time); } } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } List list = GatherConnectedControls(this); list.Sort(CompareStable); int highestVersion; LightMode current = ResolveGroupMode(list, out highestVersion); LightMode nextMode = GetNextMode(current); int version = highestVersion + 1; for (int i = 0; i < list.Count; i++) { list[i].ApplyMode(nextMode, version, persist: true, forceRestart: true); } return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverName() { return string.IsNullOrEmpty(prefabIdentity) ? "Christmas Lights" : prefabIdentity; } public float GetHoverOffset() { return 0f; } public string GetHoverText() { return "[E] Change light speed\nMode: " + GetModeName(_mode) + "\nLinked lights: " + Mathf.Max(1, _linkedLightCount); } private static LightMode GetNextMode(LightMode current) { if (current >= LightMode.Off) { return LightMode.Normal; } return current + 1; } private static string GetModeName(LightMode mode) { return mode switch { LightMode.Fast5x => "5x Speed", LightMode.Fast10x => "10x Speed", LightMode.Vibrate => "Rapid Blink", LightMode.Off => "Off", _ => "Normal", }; } private void ApplyMode(LightMode mode, int version, bool persist, bool forceRestart) { bool flag = !_hasAppliedMode || _appliedMode != mode || _appliedVersion != version; LightMode lightMode = (_hasAppliedMode ? _appliedMode : LightMode.Normal); _mode = mode; _modeVersion = version; _appliedMode = mode; _appliedVersion = version; _hasAppliedMode = true; if (persist) { WriteNetworkMode(); } if (!flag && !forceRestart) { return; } CacheAnimationComponents(); CaptureBaseTiming(); CacheBulbRenderers(); bool flag2 = mode == LightMode.Vibrate || mode == LightMode.Off; bool flag3 = lightMode == LightMode.Vibrate || lightMode == LightMode.Off; if (flag2 && !flag3) { CaptureCurrentBulbState(); } if (flag2) { DisableAnimationComponents(); _blinkPhase = -1; if (mode == LightMode.Off) { SetBulbsOff(); } else { UpdateRapidBlink(Time.time); } } else { RestoreBulbState(); RestartAnimationComponents(mode switch { LightMode.Fast10x => 10f, LightMode.Fast5x => 5f, _ => 1f, }); _blinkPhase = -1; } } private void UpdateRapidBlink(float now) { int num = Mathf.FloorToInt(now / Mathf.Max(0.01f, rapidBlinkSeconds)) & 1; if (num != _blinkPhase) { _blinkPhase = num; if (num == 0) { SetBulbsOff(); } else { RestoreBulbState(); } } } private void CacheAnimationComponents() { if ((Object)(object)_chaser == (Object)null) { _chaser = ((Component)this).GetComponent(); } if ((Object)(object)_cycler == (Object)null) { _cycler = ((Component)this).GetComponent(); } if ((Object)(object)_icicleFlow == (Object)null) { _icicleFlow = ((Component)this).GetComponent(); } if ((Object)(object)_glow == (Object)null) { _glow = ((Component)this).GetComponent(); } } private void CaptureBaseTiming() { if (!_baseTimingCaptured) { if ((Object)(object)_chaser != (Object)null) { _baseChaserStep = Mathf.Max(0.01f, _chaser.stepSeconds); _baseChaserEnabled = ((Behaviour)_chaser).enabled; } if ((Object)(object)_cycler != (Object)null) { _baseCyclerStep = Mathf.Max(0.01f, _cycler.stepSeconds); _baseCyclerEnabled = ((Behaviour)_cycler).enabled; } if ((Object)(object)_icicleFlow != (Object)null) { _baseFlowDripStep = Mathf.Max(0.01f, _icicleFlow.dripStepSeconds); _baseFlowPause = Mathf.Max(0f, _icicleFlow.pauseAfterColumn); _baseFlowBatchSpacing = Mathf.Max(0f, _icicleFlow.batchSpacingSeconds); _baseFlowUpdateInterval = Mathf.Max(0.01f, _icicleFlow.minUpdateInterval); _baseFlowEnabled = ((Behaviour)_icicleFlow).enabled; } if ((Object)(object)_glow != (Object)null) { _baseGlowCycle = Mathf.Max(0.01f, _glow.cycleSeconds); _baseGlowEnabled = ((Behaviour)_glow).enabled; } _baseTimingCaptured = true; } } private void RestartAnimationComponents(float speedMultiplier) { float num = Mathf.Max(1f, speedMultiplier); if ((Object)(object)_chaser != (Object)null) { ((Behaviour)_chaser).enabled = false; _chaser.stepSeconds = Mathf.Max(0.01f, _baseChaserStep / num); ((Behaviour)_chaser).enabled = _baseChaserEnabled; } if ((Object)(object)_cycler != (Object)null) { ((Behaviour)_cycler).enabled = false; _cycler.stepSeconds = Mathf.Max(0.01f, _baseCyclerStep / num); ((Behaviour)_cycler).enabled = _baseCyclerEnabled; } if ((Object)(object)_icicleFlow != (Object)null) { ((Behaviour)_icicleFlow).enabled = false; _icicleFlow.dripStepSeconds = Mathf.Max(0.01f, _baseFlowDripStep / num); _icicleFlow.pauseAfterColumn = _baseFlowPause / num; _icicleFlow.batchSpacingSeconds = _baseFlowBatchSpacing / num; _icicleFlow.minUpdateInterval = Mathf.Max(0.01f, _baseFlowUpdateInterval / num); ((Behaviour)_icicleFlow).enabled = _baseFlowEnabled; } if ((Object)(object)_glow != (Object)null) { ((Behaviour)_glow).enabled = false; _glow.cycleSeconds = Mathf.Max(0.01f, _baseGlowCycle / num); ((Behaviour)_glow).enabled = _baseGlowEnabled; } } private void DisableAnimationComponents() { if ((Object)(object)_chaser != (Object)null) { ((Behaviour)_chaser).enabled = false; } if ((Object)(object)_cycler != (Object)null) { ((Behaviour)_cycler).enabled = false; } if ((Object)(object)_icicleFlow != (Object)null) { ((Behaviour)_icicleFlow).enabled = false; } if ((Object)(object)_glow != (Object)null) { ((Behaviour)_glow).enabled = false; } } private void CacheBulbRenderers() { if (_bulbRenderers.Count > 0) { return; } HashSet unique = new HashSet(); if ((Object)(object)_chaser != (Object)null) { for (int i = 0; i < _chaser.targets.Count; i++) { AddBulbRenderer(_chaser.targets[i], unique); } } if ((Object)(object)_cycler != (Object)null) { for (int j = 0; j < _cycler.lightRendererNames.Length; j++) { Transform val = FindChildByName(((Component)this).transform, _cycler.lightRendererNames[j]); if ((Object)(object)val != (Object)null) { AddBulbRenderer(((Component)val).GetComponent(), unique); } } } if ((Object)(object)_icicleFlow != (Object)null) { Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && ((Object)((Component)val2).gameObject).name.StartsWith(_icicleFlow.bulbNamePrefix)) { AddBulbRenderer(val2, unique); } } } if (_bulbRenderers.Count == 0) { Renderer[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(true); foreach (Renderer val3 in componentsInChildren2) { if ((Object)(object)val3 != (Object)null && ((Object)((Component)val3).gameObject).name.ToLowerInvariant().StartsWith("light")) { AddBulbRenderer(val3, unique); } } } CaptureCurrentBulbState(); } private void AddBulbRenderer(Renderer renderer, HashSet unique) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown if (!((Object)(object)renderer == (Object)null) && unique.Add(renderer)) { Material sharedMaterial = renderer.sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null) { sharedMaterial.EnableKeyword("_EMISSION"); } _bulbRenderers.Add(renderer); _savedBulbBlocks.Add(new MaterialPropertyBlock()); _workingBulbBlocks.Add(new MaterialPropertyBlock()); } } private void CaptureCurrentBulbState() { for (int i = 0; i < _bulbRenderers.Count; i++) { Renderer val = _bulbRenderers[i]; if ((Object)(object)val != (Object)null) { val.GetPropertyBlock(_savedBulbBlocks[i]); } } } private void RestoreBulbState() { for (int i = 0; i < _bulbRenderers.Count; i++) { Renderer val = _bulbRenderers[i]; if ((Object)(object)val != (Object)null) { val.SetPropertyBlock(_savedBulbBlocks[i]); } } } private void SetBulbsOff() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _bulbRenderers.Count; i++) { Renderer val = _bulbRenderers[i]; if (!((Object)(object)val == (Object)null)) { MaterialPropertyBlock val2 = _workingBulbBlocks[i]; val.GetPropertyBlock(val2); val2.SetColor(_emissionColorId, Color.black); val.SetPropertyBlock(val2); } } } private void RefreshLinkedGroup() { List list = GatherConnectedControls(this); list.Sort(CompareStable); _linkedLightCount = Mathf.Max(1, list.Count); if (list.Count == 0 || (Object)(object)list[0] != (Object)(object)this) { return; } int highestVersion; LightMode lightMode = ResolveGroupMode(list, out highestVersion); int num = CalculateGroupSignature(list); bool flag = false; for (int i = 0; i < list.Count; i++) { ConnectedLightControl connectedLightControl = list[i]; connectedLightControl._linkedLightCount = list.Count; if (connectedLightControl._groupSignature != num) { flag = true; } } for (int j = 0; j < list.Count; j++) { ConnectedLightControl connectedLightControl2 = list[j]; connectedLightControl2._groupSignature = num; bool flag2 = connectedLightControl2._mode != lightMode || connectedLightControl2._modeVersion != highestVersion; bool flag3 = !connectedLightControl2._hasAppliedMode || connectedLightControl2._appliedMode != lightMode || connectedLightControl2._appliedVersion != highestVersion; connectedLightControl2.ApplyMode(lightMode, highestVersion, flag2, flag || flag2 || flag3); } } private static LightMode ResolveGroupMode(List group, out int highestVersion) { highestVersion = 0; LightMode result = LightMode.Normal; for (int i = 0; i < group.Count; i++) { ConnectedLightControl connectedLightControl = group[i]; connectedLightControl.ReadNetworkMode(force: false); if (i == 0 || connectedLightControl._modeVersion > highestVersion) { highestVersion = connectedLightControl._modeVersion; result = connectedLightControl._mode; } } return result; } private static List GatherConnectedControls(ConnectedLightControl origin) { List list = new List(); if ((Object)(object)origin == (Object)null) { return list; } list.Add(origin); if (!origin.IsLiveInstance()) { return list; } Queue queue = new Queue(); HashSet hashSet = new HashSet(); queue.Enqueue(origin); hashSet.Add(origin); while (queue.Count > 0) { ConnectedLightControl connectedLightControl = queue.Dequeue(); for (int i = 0; i < Instances.Count; i++) { ConnectedLightControl connectedLightControl2 = Instances[i]; if (!((Object)(object)connectedLightControl2 == (Object)null) && !((Object)(object)connectedLightControl2 == (Object)(object)connectedLightControl) && !hashSet.Contains(connectedLightControl2) && ((Behaviour)connectedLightControl2).isActiveAndEnabled && connectedLightControl2.IsLiveInstance() && SamePrefab(connectedLightControl, connectedLightControl2) && AreConnected(connectedLightControl, connectedLightControl2)) { hashSet.Add(connectedLightControl2); list.Add(connectedLightControl2); queue.Enqueue(connectedLightControl2); } } } return list; } private static bool SamePrefab(ConnectedLightControl a, ConnectedLightControl b) { return !string.IsNullOrEmpty(a.prefabIdentity) && string.Equals(a.prefabIdentity, b.prefabIdentity, StringComparison.Ordinal); } private static bool AreConnected(ConnectedLightControl a, ConnectedLightControl b) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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) a.CacheSnapPoints(); b.CacheSnapPoints(); if (a._snapPoints.Count == 0 || b._snapPoints.Count == 0) { return false; } float num = Mathf.Max(a.connectionDistance, b.connectionDistance); float num2 = num * num; for (int i = 0; i < a._snapPoints.Count; i++) { for (int j = 0; j < b._snapPoints.Count; j++) { Vector3 val = a._snapPoints[i].position - b._snapPoints[j].position; if (((Vector3)(ref val)).sqrMagnitude <= num2) { return true; } } } return false; } private void CacheSnapPoints() { if (_snapPoints.Count > 0) { return; } Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)((Component)this).transform && ((Object)val).name.ToLowerInvariant().Contains("snap")) { _snapPoints.Add(val); } } } private static Transform FindChildByName(Transform root, string childName) { if ((Object)(object)root == (Object)null || string.IsNullOrEmpty(childName)) { return null; } Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null && ((Object)componentsInChildren[i]).name == childName) { return componentsInChildren[i]; } } return null; } private static int CalculateGroupSignature(List group) { int num = 17; for (int i = 0; i < group.Count; i++) { num = num * 31 + ((Object)group[i]).GetInstanceID(); } return num; } private static int CompareStable(ConnectedLightControl a, ConnectedLightControl b) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)a).transform.position; Vector3 position2 = ((Component)b).transform.position; int num = position.x.CompareTo(position2.x); if (num != 0) { return num; } num = position.z.CompareTo(position2.z); if (num != 0) { return num; } num = position.y.CompareTo(position2.y); if (num != 0) { return num; } return ((Object)a).GetInstanceID().CompareTo(((Object)b).GetInstanceID()); } private bool IsLiveInstance() { EnsureNetworkView(); return (Object)(object)_nview != (Object)null && _nview.IsValid() && _nview.GetZDO() != null; } private void EnsureNetworkView() { if ((Object)(object)_nview == (Object)null) { _nview = ((Component)this).GetComponent(); } } private bool ReadNetworkMode(bool force) { EnsureNetworkView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return false; } int num = zDO.GetInt("mf_connected_light_version", 0); if (!force && num <= _modeVersion) { return false; } int num2 = zDO.GetInt("mf_connected_light_mode", 0); if (num2 < 0 || num2 > 4) { num2 = 0; } LightMode lightMode = (LightMode)num2; bool result = _mode != lightMode || _modeVersion != num; _mode = lightMode; _modeVersion = num; return result; } private void WriteNetworkMode() { EnsureNetworkView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } if (!_nview.IsOwner()) { MethodInfo method = typeof(ZNetView).GetMethod("ClaimOwnership", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { try { method.Invoke(_nview, null); } catch { } } } ZDO zDO = _nview.GetZDO(); if (zDO != null) { zDO.Set("mf_connected_light_mode", (int)_mode); zDO.Set("mf_connected_light_version", _modeVersion); } } } public class IcicleLampFlow : MonoBehaviour, Interactable, Hoverable { public enum AnimationSelection { AllAnimations, DiagonalLeftToRight, DiagonalRightToLeft, FreezeFill, RandomDrops, FallingStars, Sparkles, DrippingSnow, CascadeChase, TwinkleBlast, MultiModeFlashing } private enum AnimationPhase { DiagonalLineLeftToRight, DiagonalLineRightToLeft, FreezeFill, RandomDrops, FallingStars, SparkleFinale, DrippingSnow, CascadeChase, TwinkleBlast, MultiModeFlashing } private class Column { public List bulbs = new List(); public List mpb = new List(); } private class RandomDrop { public int columnIndex; public int startStep; } private class FallingStar { public int centerColumn; public int startDelay; } private class LinkedMember { public IcicleLampFlow flow; public bool reverseColumns; } [Header("Target naming")] public string columnNamePrefix = "Icicle_Lamp_"; public string bulbNamePrefix = "Light_"; public string leftSnapName = "Snappoint_Left"; public string rightSnapName = "Snappoint_Right"; [Header("Look")] public Color dripColor = new Color(0.6f, 0.85f, 1f); [Min(0f)] public float emissionIntensity = 4.5f; public bool affectBaseColor = false; [Header("Timing")] [Min(0.01f)] public float raindropStepSeconds = 0.05f; [Min(0.01f)] public float diagonalLineStepSeconds = 0.1f; [Min(0.01f)] public float freezeFillStepSeconds = 0.12f; [Min(0.01f)] public float fallingStarStepSeconds = 0.06f; [Min(0.01f)] public float sparkleStepSeconds = 0.08f; [Min(0.01f)] public float drippingStepSeconds = 0.08f; [Min(0.01f)] public float cascadeStepSeconds = 0.08f; [Min(0.01f)] public float twinkleStepSeconds = 0.08f; [Min(0.01f)] public float multiModeStepSeconds = 0.08f; [Min(0f)] public float pauseBetweenAnimations = 0.6f; [Header("Random animations")] [Range(1f, 16f)] public int randomDropCount = 8; [Range(1f, 3f)] public int fallingStarCount = 3; [Range(0.01f, 1f)] public float sparkleChance = 0.12f; [Min(1f)] public int sparkleSteps = 24; [Range(1f, 5f)] public int diagonalLineCount = 3; [Min(8f)] public int twinkleBlastSteps = 48; [Min(8f)] public int multiModeStepsPerPattern = 24; [Header("Connected lamps")] [Min(0.05f)] public float connectionDistance = 0.75f; [Min(0.05f)] public float connectionRefreshSeconds = 0.25f; [Header("Advanced")] public bool includeInactive = true; [Header("Performance")] [Min(0.01f)] public float minUpdateInterval = 0.01f; [Min(0f)] public float activeDistance = 60f; private const int StarWidth = 5; private const int StarHeight = 5; private const string ModeZdoKey = "mf_icicle_animation_mode"; private const string ModeVersionZdoKey = "mf_icicle_animation_version"; private static readonly int[,] StarMask = new int[5, 5] { { 0, 0, 1, 0, 0 }, { 1, 0, 1, 0, 1 }, { 0, 1, 1, 1, 0 }, { 1, 1, 1, 1, 1 }, { 0, 1, 0, 1, 0 } }; private static readonly List Instances = new List(); private readonly List _columns = new List(); private readonly List _animationColumns = new List(); private readonly List _linkedMembers = new List(); private readonly List _randomDrops = new List(); private readonly List _fallingStars = new List(); private ZNetView _nview; private Transform _leftSnap; private Transform _rightSnap; private float _gammaIntensity; private int _colorId; private int _emissId; private float _accum; private bool _isActive; private bool _isGroupLeader = true; private AnimationSelection _selectedMode = AnimationSelection.AllAnimations; private int _modeVersion; private AnimationPhase _phase; private int _step = -1; private int _maxBulbCount; private int _diagonalLineStepCount; private int _cascadeStepCount; private int _randomDropStepCount; private int _fallingStarStepCount; private int _groupSignature; private int _linkedLampCount = 1; private float _nextStepTime; private float _nextConnectionRefresh; private void Awake() { _colorId = Shader.PropertyToID("_Color"); _emissId = Shader.PropertyToID("_EmissionColor"); _gammaIntensity = Mathf.LinearToGammaSpace(Mathf.Max(0f, emissionIntensity)); CacheSnapPoints(); BuildColumns(); UseLocalAnimationGrid(); InstallInteractionProxies(); EnsureNetworkView(); } private void Start() { EnsureNetworkView(); ReadNetworkSelection(force: true); } private void OnEnable() { if (!Instances.Contains(this)) { Instances.Add(this); } CacheSnapPoints(); InstallInteractionProxies(); PrepareMPBs(); SetLocalAllOff(); _accum = 0f; _isActive = false; _nextConnectionRefresh = 0f; } private void OnDisable() { Instances.Remove(this); SetLocalAllOff(); _isActive = false; } private void Update() { EnsureNetworkView(); ReadNetworkSelection(force: false); float time = Time.time; if (time >= _nextConnectionRefresh) { _nextConnectionRefresh = time + Mathf.Max(0.05f, connectionRefreshSeconds); RefreshLinkedGroup(time); } if (!_isGroupLeader || _animationColumns.Count == 0) { return; } if (!IsPlayerNearLinkedGroup()) { if (_isActive) { SetAllOff(); _isActive = false; } return; } if (!_isActive) { _isActive = true; ResetSequence(time); } _accum += Time.deltaTime; if (_accum < minUpdateInterval) { return; } _accum = 0f; if (!(time < _nextStepTime)) { switch (_phase) { case AnimationPhase.DiagonalLineLeftToRight: AdvanceDiagonalLine(time, reverse: false); break; case AnimationPhase.DiagonalLineRightToLeft: AdvanceDiagonalLine(time, reverse: true); break; case AnimationPhase.FreezeFill: AdvanceFreezeFill(time); break; case AnimationPhase.RandomDrops: AdvanceRandomDrops(time); break; case AnimationPhase.FallingStars: AdvanceFallingStars(time); break; case AnimationPhase.SparkleFinale: AdvanceSparkleFinale(time); break; case AnimationPhase.DrippingSnow: AdvanceDrippingSnow(time); break; case AnimationPhase.CascadeChase: AdvanceCascadeChase(time); break; case AnimationPhase.TwinkleBlast: AdvanceTwinkleBlast(time); break; case AnimationPhase.MultiModeFlashing: AdvanceMultiModeFlashing(time); break; } } } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } List list = BuildOrderedGroup(this); int highestVersion; AnimationSelection current = ResolveGroupSelection(list, out highestVersion); AnimationSelection nextSelection = GetNextSelection(current); int version = highestVersion + 1; for (int i = 0; i < list.Count; i++) { list[i].flow.ApplySelection(nextSelection, version, persist: true); } return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverName() { return "Icicle Christmas Lights"; } public float GetHoverOffset() { return 0f; } public string GetHoverText() { return "[E] Change animation\nMode: " + GetSelectionName(_selectedMode) + "\nLinked lamps: " + Mathf.Max(1, _linkedLampCount); } private void AdvanceDiagonalLine(float now, bool reverse) { _step++; if (_step < _diagonalLineStepCount) { SetDiagonalLines(_step, reverse); _nextStepTime = now + Mathf.Max(0.01f, diagonalLineStepSeconds); } else { CompletePhase((!reverse) ? AnimationPhase.DiagonalLineRightToLeft : AnimationPhase.FreezeFill, now); } } private void AdvanceFreezeFill(float now) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) _step++; if (_step < _maxBulbCount) { for (int i = 0; i < _animationColumns.Count; i++) { SetColumnThrough(_animationColumns[i], _step, dripColor); } _nextStepTime = now + Mathf.Max(0.01f, freezeFillStepSeconds); } else { CompletePhase(AnimationPhase.RandomDrops, now); } } private void AdvanceRandomDrops(float now) { _step++; if (_step == 0) { PrepareRandomDrops(); } if (_step < _randomDropStepCount) { SetRandomDrops(_step); _nextStepTime = now + Mathf.Max(0.01f, raindropStepSeconds); } else { CompletePhase(AnimationPhase.FallingStars, now); } } private void AdvanceFallingStars(float now) { _step++; if (_step == 0) { PrepareFallingStars(); } if (_step < _fallingStarStepCount) { SetFallingStars(_step); _nextStepTime = now + Mathf.Max(0.01f, fallingStarStepSeconds); } else { CompletePhase(AnimationPhase.SparkleFinale, now); } } private void AdvanceSparkleFinale(float now) { _step++; if (_step < Mathf.Max(1, sparkleSteps)) { SetRandomSparkles(); _nextStepTime = now + Mathf.Max(0.01f, sparkleStepSeconds); } else { CompletePhase(AnimationPhase.DrippingSnow, now); } } private void AdvanceDrippingSnow(float now) { _step++; int num = Mathf.Max(12, _maxBulbCount * 4 + 8); if (_step < num) { SetDrippingSnow(_step); _nextStepTime = now + Mathf.Max(0.01f, drippingStepSeconds); } else { CompletePhase(AnimationPhase.CascadeChase, now); } } private void AdvanceCascadeChase(float now) { _step++; if (_step < _cascadeStepCount) { SetCascadeChase(_step); _nextStepTime = now + Mathf.Max(0.01f, cascadeStepSeconds); } else { CompletePhase(AnimationPhase.TwinkleBlast, now); } } private void AdvanceTwinkleBlast(float now) { _step++; if (_step < Mathf.Max(8, twinkleBlastSteps)) { SetTwinkleBlast(_step); _nextStepTime = now + Mathf.Max(0.01f, twinkleStepSeconds); } else { CompletePhase(AnimationPhase.MultiModeFlashing, now); } } private void AdvanceMultiModeFlashing(float now) { _step++; int num = Mathf.Max(8, multiModeStepsPerPattern); int num2 = num * 8; if (_step < num2) { SetMultiModePattern(_step, num); _nextStepTime = now + Mathf.Max(0.01f, multiModeStepSeconds); } else { CompletePhase(AnimationPhase.DiagonalLineLeftToRight, now); } } private void CompletePhase(AnimationPhase allAnimationsNextPhase, float now) { SetAllOff(); _phase = ((_selectedMode == AnimationSelection.AllAnimations) ? allAnimationsNextPhase : GetSelectedPhase(_selectedMode)); _step = -1; _nextStepTime = now + Mathf.Max(0f, pauseBetweenAnimations); } private void ResetSequence(float now) { SetAllOff(); _randomDrops.Clear(); _fallingStars.Clear(); _phase = GetSelectedPhase(_selectedMode); _step = -1; _nextStepTime = now; } private static AnimationSelection GetNextSelection(AnimationSelection current) { if (current >= AnimationSelection.MultiModeFlashing) { return AnimationSelection.AllAnimations; } return current + 1; } private static AnimationPhase GetSelectedPhase(AnimationSelection selection) { return selection switch { AnimationSelection.DiagonalRightToLeft => AnimationPhase.DiagonalLineRightToLeft, AnimationSelection.FreezeFill => AnimationPhase.FreezeFill, AnimationSelection.RandomDrops => AnimationPhase.RandomDrops, AnimationSelection.FallingStars => AnimationPhase.FallingStars, AnimationSelection.Sparkles => AnimationPhase.SparkleFinale, AnimationSelection.DrippingSnow => AnimationPhase.DrippingSnow, AnimationSelection.CascadeChase => AnimationPhase.CascadeChase, AnimationSelection.TwinkleBlast => AnimationPhase.TwinkleBlast, AnimationSelection.MultiModeFlashing => AnimationPhase.MultiModeFlashing, _ => AnimationPhase.DiagonalLineLeftToRight, }; } private static string GetSelectionName(AnimationSelection selection) { return selection switch { AnimationSelection.DiagonalLeftToRight => "Diagonal Line Left to Right", AnimationSelection.DiagonalRightToLeft => "Diagonal Line Right to Left", AnimationSelection.FreezeFill => "Freeze Fill", AnimationSelection.RandomDrops => "Random Raindrops", AnimationSelection.FallingStars => "Falling Stars", AnimationSelection.Sparkles => "Random Sparkles", AnimationSelection.DrippingSnow => "Dripping / Falling Snow", AnimationSelection.CascadeChase => "Cascading / Chasing", AnimationSelection.TwinkleBlast => "Twinkling / Blasting", AnimationSelection.MultiModeFlashing => "8-Pattern Flashing", _ => "All Animations", }; } private void ApplySelection(AnimationSelection selection, int version, bool persist) { bool flag = _selectedMode != selection || _modeVersion != version; _selectedMode = selection; _modeVersion = version; if (persist) { WriteNetworkSelection(); } if (flag) { _isActive = false; } } private void EnsureNetworkView() { if ((Object)(object)_nview == (Object)null) { _nview = ((Component)this).GetComponent(); } } private bool ReadNetworkSelection(bool force) { EnsureNetworkView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return false; } int num = zDO.GetInt("mf_icicle_animation_version", 0); if (!force && num <= _modeVersion) { return false; } int num2 = zDO.GetInt("mf_icicle_animation_mode", 0); if (num2 < 0 || num2 > 10) { num2 = 0; } AnimationSelection animationSelection = (AnimationSelection)num2; bool flag = _selectedMode != animationSelection || _modeVersion != num; _selectedMode = animationSelection; _modeVersion = num; if (flag) { _isActive = false; } return flag; } private void WriteNetworkSelection() { EnsureNetworkView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } if (!_nview.IsOwner()) { MethodInfo method = typeof(ZNetView).GetMethod("ClaimOwnership", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { try { method.Invoke(_nview, null); } catch { } } } ZDO zDO = _nview.GetZDO(); if (zDO != null) { zDO.Set("mf_icicle_animation_mode", (int)_selectedMode); zDO.Set("mf_icicle_animation_version", _modeVersion); } } private void RefreshLinkedGroup(float now) { List list = BuildOrderedGroup(this); _linkedLampCount = Mathf.Max(1, list.Count); bool isGroupLeader = _isGroupLeader; _isGroupLeader = list.Count == 0 || (Object)(object)list[0].flow == (Object)(object)this; if (!_isGroupLeader) { if (isGroupLeader) { _isActive = false; } return; } if (!isGroupLeader) { _isActive = false; } int highestVersion; AnimationSelection animationSelection = ResolveGroupSelection(list, out highestVersion); for (int i = 0; i < list.Count; i++) { IcicleLampFlow flow = list[i].flow; if (flow._selectedMode != animationSelection || flow._modeVersion != highestVersion) { flow.ApplySelection(animationSelection, highestVersion, persist: true); } } int num = CalculateGroupSignature(list); if (num != _groupSignature) { SetAllOff(); _linkedMembers.Clear(); _linkedMembers.AddRange(list); RebuildAnimationGrid(); _groupSignature = num; _isActive = false; _nextStepTime = now; } } private static AnimationSelection ResolveGroupSelection(List group, out int highestVersion) { highestVersion = 0; AnimationSelection result = AnimationSelection.AllAnimations; for (int i = 0; i < group.Count; i++) { IcicleLampFlow flow = group[i].flow; flow.ReadNetworkSelection(force: false); if (i == 0 || flow._modeVersion > highestVersion) { highestVersion = flow._modeVersion; result = flow._selectedMode; } } return result; } private static int CalculateGroupSignature(List group) { int num = 17; for (int i = 0; i < group.Count; i++) { num = num * 31 + ((Object)group[i].flow).GetInstanceID(); num = num * 31 + (group[i].reverseColumns ? 1 : 0); } return num; } private void RebuildAnimationGrid() { _animationColumns.Clear(); for (int i = 0; i < _linkedMembers.Count; i++) { LinkedMember linkedMember = _linkedMembers[i]; if (linkedMember.reverseColumns) { for (int num = linkedMember.flow._columns.Count - 1; num >= 0; num--) { _animationColumns.Add(linkedMember.flow._columns[num]); } } else { for (int j = 0; j < linkedMember.flow._columns.Count; j++) { _animationColumns.Add(linkedMember.flow._columns[j]); } } } RecalculateAnimationGrid(); } private void UseLocalAnimationGrid() { _animationColumns.Clear(); for (int i = 0; i < _columns.Count; i++) { _animationColumns.Add(_columns[i]); } RecalculateAnimationGrid(); } private void RecalculateAnimationGrid() { _maxBulbCount = 0; _cascadeStepCount = 0; for (int i = 0; i < _animationColumns.Count; i++) { int count = _animationColumns[i].bulbs.Count; if (count > _maxBulbCount) { _maxBulbCount = count; } _cascadeStepCount += count; } int num = Mathf.Max(1, Mathf.CeilToInt((float)_animationColumns.Count * 0.5f)); int num2 = Mathf.Max(1, diagonalLineCount); _diagonalLineStepCount = _animationColumns.Count + _maxBulbCount + num * (num2 - 1); _cascadeStepCount += _animationColumns.Count + 2; } private bool IsPlayerNearLinkedGroup() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (activeDistance <= 0f) { return true; } for (int i = 0; i < _linkedMembers.Count; i++) { IcicleLampFlow flow = _linkedMembers[i].flow; if ((Object)(object)flow != (Object)null && Player.IsPlayerInRange(((Component)flow).transform.position, activeDistance)) { return true; } } return Player.IsPlayerInRange(((Component)this).transform.position, activeDistance); } private static List BuildOrderedGroup(IcicleLampFlow origin) { List list = GatherConnectedFlows(origin); list.Sort(CompareStable); List list2 = new List(); if (list.Count == 0) { return list2; } IcicleLampFlow icicleLampFlow = list[0]; for (int i = 0; i < list.Count; i++) { if (GetConnectionDegree(list[i], list) <= 1) { icicleLampFlow = list[i]; break; } } bool neighborEndpointIsRight; bool flag = (Object)(object)GetNeighborAtEndpoint(icicleLampFlow, useRightEndpoint: false, list, null, out neighborEndpointIsRight) != (Object)null; bool neighborEndpointIsRight2; bool flag2 = (Object)(object)GetNeighborAtEndpoint(icicleLampFlow, useRightEndpoint: true, list, null, out neighborEndpointIsRight2) != (Object)null || !flag; HashSet hashSet = new HashSet(); IcicleLampFlow icicleLampFlow2 = icicleLampFlow; IcicleLampFlow excluded = null; while ((Object)(object)icicleLampFlow2 != (Object)null && !hashSet.Contains(icicleLampFlow2)) { hashSet.Add(icicleLampFlow2); LinkedMember linkedMember = new LinkedMember(); linkedMember.flow = icicleLampFlow2; linkedMember.reverseColumns = !flag2; list2.Add(linkedMember); bool neighborEndpointIsRight3; IcicleLampFlow neighborAtEndpoint = GetNeighborAtEndpoint(icicleLampFlow2, flag2, list, excluded, out neighborEndpointIsRight3); if ((Object)(object)neighborAtEndpoint == (Object)null || hashSet.Contains(neighborAtEndpoint)) { break; } excluded = icicleLampFlow2; icicleLampFlow2 = neighborAtEndpoint; flag2 = !neighborEndpointIsRight3; } for (int j = 0; j < list.Count; j++) { if (!hashSet.Contains(list[j])) { LinkedMember linkedMember2 = new LinkedMember(); linkedMember2.flow = list[j]; linkedMember2.reverseColumns = false; list2.Add(linkedMember2); } } return list2; } private static List GatherConnectedFlows(IcicleLampFlow origin) { List list = new List(); if ((Object)(object)origin == (Object)null) { return list; } list.Add(origin); if (!origin.IsSceneInstance()) { return list; } Queue queue = new Queue(); HashSet hashSet = new HashSet(); queue.Enqueue(origin); hashSet.Add(origin); while (queue.Count > 0) { IcicleLampFlow icicleLampFlow = queue.Dequeue(); for (int i = 0; i < Instances.Count; i++) { IcicleLampFlow icicleLampFlow2 = Instances[i]; if (!((Object)(object)icicleLampFlow2 == (Object)null) && !((Object)(object)icicleLampFlow2 == (Object)(object)icicleLampFlow) && !hashSet.Contains(icicleLampFlow2) && ((Behaviour)icicleLampFlow2).isActiveAndEnabled && icicleLampFlow2.IsSceneInstance() && AreConnected(icicleLampFlow, icicleLampFlow2)) { hashSet.Add(icicleLampFlow2); list.Add(icicleLampFlow2); queue.Enqueue(icicleLampFlow2); } } } return list; } private static bool AreConnected(IcicleLampFlow a, IcicleLampFlow b) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_009e: Unknown result type (might be due to invalid IL or missing references) a.CacheSnapPoints(); b.CacheSnapPoints(); float num = Mathf.Max(a.connectionDistance, b.connectionDistance); float num2 = num * num; Transform[] array = (Transform[])(object)new Transform[2] { a._leftSnap, a._rightSnap }; Transform[] array2 = (Transform[])(object)new Transform[2] { b._leftSnap, b._rightSnap }; for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] == (Object)null) { continue; } for (int j = 0; j < array2.Length; j++) { if (!((Object)(object)array2[j] == (Object)null)) { Vector3 val = array[i].position - array2[j].position; if (((Vector3)(ref val)).sqrMagnitude <= num2) { return true; } } } } return false; } private static int GetConnectionDegree(IcicleLampFlow flow, List group) { HashSet hashSet = new HashSet(); bool neighborEndpointIsRight; IcicleLampFlow neighborAtEndpoint = GetNeighborAtEndpoint(flow, useRightEndpoint: false, group, null, out neighborEndpointIsRight); if ((Object)(object)neighborAtEndpoint != (Object)null) { hashSet.Add(neighborAtEndpoint); } bool neighborEndpointIsRight2; IcicleLampFlow neighborAtEndpoint2 = GetNeighborAtEndpoint(flow, useRightEndpoint: true, group, null, out neighborEndpointIsRight2); if ((Object)(object)neighborAtEndpoint2 != (Object)null) { hashSet.Add(neighborAtEndpoint2); } return hashSet.Count; } private static IcicleLampFlow GetNeighborAtEndpoint(IcicleLampFlow flow, bool useRightEndpoint, List group, IcicleLampFlow excluded, out bool neighborEndpointIsRight) { //IL_00cc: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) neighborEndpointIsRight = false; flow.CacheSnapPoints(); Transform val = (useRightEndpoint ? flow._rightSnap : flow._leftSnap); if ((Object)(object)val == (Object)null) { return null; } IcicleLampFlow result = null; float num = float.PositiveInfinity; for (int i = 0; i < group.Count; i++) { IcicleLampFlow icicleLampFlow = group[i]; if ((Object)(object)icicleLampFlow == (Object)null || (Object)(object)icicleLampFlow == (Object)(object)flow || (Object)(object)icicleLampFlow == (Object)(object)excluded) { continue; } icicleLampFlow.CacheSnapPoints(); Transform[] array = (Transform[])(object)new Transform[2] { icicleLampFlow._leftSnap, icicleLampFlow._rightSnap }; for (int j = 0; j < array.Length; j++) { Transform val2 = array[j]; if (!((Object)(object)val2 == (Object)null)) { float num2 = Mathf.Max(flow.connectionDistance, icicleLampFlow.connectionDistance); Vector3 val3 = val.position - val2.position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (!(sqrMagnitude > num2 * num2) && !(sqrMagnitude >= num)) { result = icicleLampFlow; num = sqrMagnitude; neighborEndpointIsRight = j == 1; } } } } return result; } private static int CompareStable(IcicleLampFlow a, IcicleLampFlow b) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)a).transform.position; Vector3 position2 = ((Component)b).transform.position; int num = position.x.CompareTo(position2.x); if (num != 0) { return num; } num = position.z.CompareTo(position2.z); if (num != 0) { return num; } num = position.y.CompareTo(position2.y); if (num != 0) { return num; } num = string.CompareOrdinal(((Object)((Component)a).gameObject).name, ((Object)((Component)b).gameObject).name); if (num != 0) { return num; } return ((Object)a).GetInstanceID().CompareTo(((Object)b).GetInstanceID()); } private bool IsSceneInstance() { //IL_0015: 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) int result; if ((Object)(object)((Component)this).gameObject != (Object)null) { Scene scene = ((Component)this).gameObject.scene; result = (((Scene)(ref scene)).IsValid() ? 1 : 0); } else { result = 0; } return (byte)result != 0; } private void CacheSnapPoints() { if ((Object)(object)_leftSnap == (Object)null) { _leftSnap = FindChildByName(((Component)this).transform, leftSnapName); } if ((Object)(object)_rightSnap == (Object)null) { _rightSnap = FindChildByName(((Component)this).transform, rightSnapName); } if ((Object)(object)_leftSnap == (Object)null) { _leftSnap = FindSnapPointBySide(((Component)this).transform, "left"); } if ((Object)(object)_rightSnap == (Object)null) { _rightSnap = FindSnapPointBySide(((Component)this).transform, "right"); } } private static Transform FindChildByName(Transform root, string childName) { if ((Object)(object)root == (Object)null || string.IsNullOrEmpty(childName)) { return null; } Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if ((Object)(object)val != (Object)null && string.Equals(((Object)val).name, childName, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } private static Transform FindSnapPointBySide(Transform root, string side) { if ((Object)(object)root == (Object)null || string.IsNullOrEmpty(side)) { return null; } Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { string text = ((Object)val).name.ToLowerInvariant(); if (text.Contains("snap") && text.Contains(side)) { return val; } } } return null; } private void InstallInteractionProxies() { Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)(object)((Component)this).gameObject)) { IcicleLampInteractionProxy icicleLampInteractionProxy = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); icicleLampInteractionProxy.Configure(this); } } } private void PrepareRandomDrops() { _randomDrops.Clear(); _randomDropStepCount = 0; List list = new List(); for (int i = 0; i < _animationColumns.Count; i++) { list.Add(i); } int num = Mathf.Min(Mathf.Max(1, randomDropCount), list.Count); for (int j = 0; j < num; j++) { int index = Random.Range(0, list.Count); int num2 = list[index]; list.RemoveAt(index); RandomDrop randomDrop = new RandomDrop(); randomDrop.columnIndex = num2; randomDrop.startStep = Random.Range(0, 6); _randomDrops.Add(randomDrop); int num3 = randomDrop.startStep + _animationColumns[num2].bulbs.Count; if (num3 > _randomDropStepCount) { _randomDropStepCount = num3; } } } private void PrepareFallingStars() { _fallingStars.Clear(); _fallingStarStepCount = 0; List list = new List(); int num = 2; for (int i = num; i < _animationColumns.Count - num; i++) { list.Add(i); } int num2 = 0; int num3 = Mathf.Min(Mathf.Max(1, fallingStarCount), list.Count); while (_fallingStars.Count < num3 && list.Count > 0) { int index = Random.Range(0, list.Count); FallingStar fallingStar = new FallingStar(); fallingStar.centerColumn = list[index]; fallingStar.startDelay = _fallingStars.Count * 3 + Random.Range(0, 3); _fallingStars.Add(fallingStar); for (int num4 = list.Count - 1; num4 >= 0; num4--) { if (Mathf.Abs(list[num4] - fallingStar.centerColumn) < 5) { list.RemoveAt(num4); } } if (fallingStar.startDelay > num2) { num2 = fallingStar.startDelay; } } _fallingStarStepCount = _maxBulbCount + 5 - 1 + num2; } private void SetRandomDrops(int step) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _animationColumns.Count; i++) { Column column = _animationColumns[i]; int num = -1; for (int j = 0; j < _randomDrops.Count; j++) { RandomDrop randomDrop = _randomDrops[j]; if (randomDrop.columnIndex == i) { num = step - randomDrop.startStep; break; } } if (num >= 0 && num < column.bulbs.Count) { SetColumnActive(column, num, dripColor); } else { SetColumnAll(column, Color.black); } } } private void SetFallingStars(int step) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) int num = 2; for (int i = 0; i < _animationColumns.Count; i++) { Column column = _animationColumns[i]; for (int j = 0; j < column.bulbs.Count; j++) { bool flag = false; for (int k = 0; k < _fallingStars.Count; k++) { if (flag) { break; } FallingStar fallingStar = _fallingStars[k]; int num2 = i - (fallingStar.centerColumn - num); int num3 = step - 4 - fallingStar.startDelay; int num4 = j - num3; if (num2 >= 0 && num2 < 5 && num4 >= 0 && num4 < 5 && StarMask[num4, num2] != 0) { flag = true; } } SetBulb(column, j, flag ? dripColor : Color.black); } } } private void SetRandomSparkles() { //IL_0037: 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) float num = Mathf.Clamp01(sparkleChance); for (int i = 0; i < _animationColumns.Count; i++) { Column column = _animationColumns[i]; for (int j = 0; j < column.bulbs.Count; j++) { SetBulb(column, j, (Random.value < num) ? dripColor : Color.black); } } } private void SetDiagonalLines(int step, bool reverse) { //IL_00a3: 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) int count = _animationColumns.Count; int num = Mathf.Max(1, Mathf.CeilToInt((float)count * 0.5f)); int num2 = Mathf.Max(1, diagonalLineCount); for (int i = 0; i < count; i++) { Column column = _animationColumns[i]; for (int j = 0; j < column.bulbs.Count; j++) { bool flag = false; for (int k = 0; k < num2; k++) { if (flag) { break; } int num3 = step - k * num; int num4 = num3 - j; if (reverse) { num4 = count - 1 - num4; } flag = i == num4; } SetBulb(column, j, flag ? dripColor : Color.black); } } } private void SetDrippingSnow(int step) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(6, _maxBulbCount + 5); for (int i = 0; i < _animationColumns.Count; i++) { Column column = _animationColumns[i]; int num2 = (step + i * 3) % num - 2; for (int j = 0; j < column.bulbs.Count; j++) { SetBulb(column, j, dripColor * (num2 - j) switch { 2 => 0.2f, 1 => 0.55f, 0 => 1f, _ => 0f, }); } } } private void SetCascadeChase(int step) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) int num = _animationColumns.Count + 2; if (step < num) { for (int i = 0; i < _animationColumns.Count; i++) { Column column = _animationColumns[i]; float num2 = (step - i) switch { 1 => 0.45f, 0 => 1f, _ => 0f, }; for (int j = 0; j < column.bulbs.Count; j++) { SetBulb(column, j, (j == 0) ? (dripColor * num2) : Color.black); } } return; } int num3 = step - num; int num4 = -1; int num5 = -1; for (int k = 0; k < _animationColumns.Count; k++) { int count = _animationColumns[k].bulbs.Count; if (num3 < count) { num4 = k; num5 = num3; break; } num3 -= count; } for (int l = 0; l < _animationColumns.Count; l++) { Column column2 = _animationColumns[l]; for (int m = 0; m < column2.bulbs.Count; m++) { float num6 = ((l == num4 && m == num5) ? 1f : ((l == num4 && m == num5 - 1) ? 0.45f : 0f)); SetBulb(column2, m, dripColor * num6); } } } private void SetTwinkleBlast(int step) { //IL_00a9: 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) bool flag = step / 12 % 2 == 1; for (int i = 0; i < _animationColumns.Count; i++) { Column column = _animationColumns[i]; for (int j = 0; j < column.bulbs.Count; j++) { float num; if (flag) { num = ((Mathf.Abs(step * 11 + i * 7 + j * 13) % 23 == 0) ? 1.35f : 0f); } else { float num2 = (float)step * 0.16f + (float)i * 1.37f + (float)j * 0.73f; float num3 = 0.5f + 0.5f * Mathf.Sin(num2); num = 0.05f + 0.95f * num3 * num3 * num3; } SetBulb(column, j, dripColor * num); } } } private void SetMultiModePattern(int step, int patternSteps) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Clamp(step / patternSteps, 0, 7); int num2 = step % patternSteps; switch (num) { case 0: SetEveryBulb(dripColor); break; case 1: { float num3 = ((patternSteps <= 1) ? 0f : ((float)num2 / (float)(patternSteps - 1))); float num4 = 0.1f + 0.9f * (0.5f - 0.5f * Mathf.Cos(num3 * (float)Math.PI * 2f)); SetEveryBulb(dripColor * num4); break; } case 2: SetSequentialWave(num2); break; case 3: SetHorizontalMainLineChase(num2); break; case 4: SetAlternatingStrands(num2, patternSteps); break; case 5: SetEveryBulb((num2 % 2 == 0) ? dripColor : Color.black); break; case 6: SetTwinkleBlast(num2); break; default: SetDrippingSnow(num2); break; } } private void SetSequentialWave(int step) { //IL_0037: 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) for (int i = 0; i < _animationColumns.Count; i++) { float num = 0.5f + 0.5f * Mathf.Sin((float)step * 0.55f - (float)i * 0.85f); SetColumnAll(_animationColumns[i], dripColor * (0.1f + 0.9f * num)); } } private void SetHorizontalMainLineChase(int step) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(1, _animationColumns.Count + 2); int num2 = step % num; for (int i = 0; i < _animationColumns.Count; i++) { Column column = _animationColumns[i]; float num3 = (num2 - i) switch { 2 => 0.2f, 1 => 0.55f, 0 => 1f, _ => 0f, }; for (int j = 0; j < column.bulbs.Count; j++) { SetBulb(column, j, (j == 0) ? (dripColor * num3) : Color.black); } } } private void SetAlternatingStrands(int step, int patternSteps) { //IL_003e: 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) int num = Mathf.Max(1, patternSteps / 6); bool flag = step / num % 2 == 0; for (int i = 0; i < _animationColumns.Count; i++) { bool flag2 = ((i % 2 == 0) ? flag : (!flag)); SetColumnAll(_animationColumns[i], flag2 ? dripColor : Color.black); } } private void SetEveryBulb(Color color) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _animationColumns.Count; i++) { SetColumnAll(_animationColumns[i], color); } } private void BuildColumns() { //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown _columns.Clear(); List list = new List(); Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren(includeInactive); foreach (Transform val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && (string.IsNullOrEmpty(columnNamePrefix) || ((Object)val).name.StartsWith(columnNamePrefix))) { list.Add(val); } } list.Sort((Transform a, Transform b) => string.CompareOrdinal(((Object)a).name, ((Object)b).name)); for (int num = 0; num < list.Count; num++) { Transform val2 = list[num]; Column column = new Column(); Renderer[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren(includeInactive); foreach (Renderer val3 in componentsInChildren2) { if (Object.op_Implicit((Object)(object)val3) && (string.IsNullOrEmpty(bulbNamePrefix) || ((Object)((Component)val3).gameObject).name.StartsWith(bulbNamePrefix))) { column.bulbs.Add(val3); } } if (column.bulbs.Count != 0) { column.bulbs.Sort((Renderer a, Renderer b) => string.CompareOrdinal(((Object)((Component)a).gameObject).name, ((Object)((Component)b).gameObject).name)); for (int num3 = 0; num3 < column.bulbs.Count; num3++) { column.mpb.Add(new MaterialPropertyBlock()); } _columns.Add(column); } } } private void PrepareMPBs() { for (int i = 0; i < _columns.Count; i++) { Column column = _columns[i]; for (int j = 0; j < column.bulbs.Count; j++) { Renderer val = column.bulbs[j]; if (Object.op_Implicit((Object)(object)val)) { Material sharedMaterial = val.sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null) { sharedMaterial.EnableKeyword("_EMISSION"); } val.GetPropertyBlock(column.mpb[j]); } } } } private void SetColumnActive(Column col, int activeIndex, Color onColor) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < col.bulbs.Count; i++) { SetBulb(col, i, (i == activeIndex) ? onColor : Color.black); } } private void SetColumnThrough(Column col, int activeIndex, Color onColor) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < col.bulbs.Count; i++) { SetBulb(col, i, (i <= activeIndex) ? onColor : Color.black); } } private void SetColumnAll(Column col, Color color) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < col.bulbs.Count; i++) { SetBulb(col, i, color); } } private void SetBulb(Column col, int bulbIndex, Color color) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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) Renderer val = col.bulbs[bulbIndex]; if (Object.op_Implicit((Object)(object)val)) { MaterialPropertyBlock val2 = col.mpb[bulbIndex]; if (affectBaseColor) { val2.SetColor(_colorId, color); } val2.SetColor(_emissId, color * _gammaIntensity); val.SetPropertyBlock(val2); } } private void SetAllOff() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _animationColumns.Count; i++) { SetColumnAll(_animationColumns[i], Color.black); } } private void SetLocalAllOff() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _columns.Count; i++) { SetColumnAll(_columns[i], Color.black); } } } public class IcicleLampInteractionProxy : MonoBehaviour, Interactable, Hoverable { private IcicleLampFlow _owner; public void Configure(IcicleLampFlow owner) { _owner = owner; } public bool Interact(Humanoid user, bool hold, bool alt) { IcicleLampFlow owner = GetOwner(); return (Object)(object)owner != (Object)null && owner.Interact(user, hold, alt); } public bool UseItem(Humanoid user, ItemData item) { IcicleLampFlow owner = GetOwner(); return (Object)(object)owner != (Object)null && owner.UseItem(user, item); } public string GetHoverName() { IcicleLampFlow owner = GetOwner(); return ((Object)(object)owner != (Object)null) ? owner.GetHoverName() : "Icicle Christmas Lights"; } public float GetHoverOffset() { return 0f; } public string GetHoverText() { IcicleLampFlow owner = GetOwner(); return ((Object)(object)owner != (Object)null) ? owner.GetHoverText() : ""; } private IcicleLampFlow GetOwner() { if ((Object)(object)_owner == (Object)null) { _owner = ((Component)this).GetComponentInParent(); } return _owner; } } public class WrappingBoxProxy : MonoBehaviour, Interactable, Hoverable { private WrappingBoxProcessor processor; private void Awake() { processor = ((Component)this).GetComponentInChildren(true); } public bool Interact(Humanoid user, bool hold, bool alt) { return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverName() { return "Wrapper"; } public float GetHoverOffset() { return 0f; } public string GetHoverText() { if ((Object)(object)processor != (Object)null && processor.CanWrap()) { return "Wrapper\n[E] Open\nClose box to wrap gift"; } return "Wrapper\n[E] Open\n(Add 1 gift + 1 item)"; } } public static class WrappedGiftUse { public const string KEY_PREFAB = "wrapped_prefab"; public const string KEY_STACK = "wrapped_stack"; public const string KEY_QUALITY = "wrapped_quality"; public const string KEY_VARIANT = "wrapped_variant"; public const string KEY_DURABILITY = "wrapped_durability"; public static bool OnUse(ItemData gift, Player player) { if (gift == null || (Object)(object)player == (Object)null) { return false; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return false; } Dictionary customData = gift.m_customData; if (customData == null || !customData.TryGetValue("wrapped_prefab", out var value)) { return false; } ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(value) : null); if ((Object)(object)val == (Object)null) { return false; } ItemDrop component = val.GetComponent(); if ((Object)(object)component == (Object)null) { return false; } int result = 1; int result2 = 1; int result3 = 0; float result4 = 0f; if (customData.TryGetValue("wrapped_stack", out var value2)) { int.TryParse(value2, out result); } if (customData.TryGetValue("wrapped_quality", out value2)) { int.TryParse(value2, out result2); } if (customData.TryGetValue("wrapped_variant", out value2)) { int.TryParse(value2, out result3); } if (customData.TryGetValue("wrapped_durability", out value2)) { float.TryParse(value2, NumberStyles.Float, CultureInfo.InvariantCulture, out result4); } ItemData val2 = component.m_itemData.Clone(); val2.m_dropPrefab = val; val2.m_stack = Mathf.Max(1, result); val2.m_quality = Mathf.Max(1, result2); val2.m_variant = result3; if (result4 > 0f) { val2.m_durability = result4; } if (!inventory.CanAddItem(val2, -1)) { return false; } inventory.AddItem(val2); inventory.RemoveItem(gift, 1); return true; } public static bool OnUse(ItemData gift) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return false; } return OnUse(gift, localPlayer); } } public class WrappingBoxProcessor : MonoBehaviour { private Container container; private ZNetView nview; private bool wasInUseLastFrame = false; private bool wrapInProgress = false; private Vector3 restLocalPosition; private Quaternion restLocalRotation; private Coroutine idleShakeCoroutine; private Coroutine completionAnimationCoroutine; private float nextIdleShakeTime; private const float WRAP_DELAY = 3.8f; private const float IDLE_SHAKE_MIN_DELAY = 4f; private const float IDLE_SHAKE_MAX_DELAY = 7.5f; private const float IDLE_SHAKE_DURATION = 0.45f; private const float IDLE_SHAKE_ROTATION_DEGREES = 2.25f; private const float IDLE_SHAKE_SIDE_DISTANCE = 0.003f; private const float COMPLETE_ANIMATION_DURATION = 0.9f; private const float COMPLETE_JUMP_HEIGHT = 0.05f; private const string COMPLETE_ANIMATION_RPC = "RPC_Moonforged_WrappingBoxComplete"; private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) container = ((Component)this).GetComponentInChildren(true); nview = ((Component)this).GetComponent(); restLocalPosition = ((Component)this).transform.localPosition; restLocalRotation = ((Component)this).transform.localRotation; ScheduleNextIdleShake(); if ((Object)(object)nview != (Object)null) { nview.Register("RPC_Moonforged_WrappingBoxComplete", (Action)RPC_PlayCompletionAnimation); } } private void OnDisable() { StopAllVisualAnimation(); } private void Update() { if ((Object)(object)container == (Object)null) { return; } bool flag = container.IsInUse(); UpdateIdleAnimation(flag); if ((Object)(object)nview != (Object)null && !nview.IsOwner()) { wasInUseLastFrame = flag; return; } if (wasInUseLastFrame && !flag && !wrapInProgress && CanWrap()) { ((MonoBehaviour)this).StartCoroutine(WrapSequence()); } wasInUseLastFrame = flag; } private void UpdateIdleAnimation(bool isInUse) { if (isInUse || wrapInProgress || completionAnimationCoroutine != null) { StopIdleShakeAndReset(); } else if (idleShakeCoroutine == null && Time.time >= nextIdleShakeTime) { idleShakeCoroutine = ((MonoBehaviour)this).StartCoroutine(IdleShakeRoutine()); } } private void ScheduleNextIdleShake() { nextIdleShakeTime = Time.time + Random.Range(4f, 7.5f); } private IEnumerator IdleShakeRoutine() { float elapsed = 0f; while (elapsed < 0.45f && !((Object)(object)container == (Object)null) && !container.IsInUse() && !wrapInProgress) { float normalized = elapsed / 0.45f; float envelope = Mathf.Sin(normalized * (float)Math.PI); float wave = Mathf.Sin(normalized * (float)Math.PI * 6f); float yaw = wave * envelope * 2.25f; float side = wave * envelope * 0.003f; ((Component)this).transform.localPosition = restLocalPosition + Vector3.right * side; ((Component)this).transform.localRotation = restLocalRotation * Quaternion.Euler(0f, yaw, 0f); elapsed += Time.deltaTime; yield return null; } RestoreRestTransform(); idleShakeCoroutine = null; ScheduleNextIdleShake(); } private void StopIdleShakeAndReset() { if (idleShakeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(idleShakeCoroutine); idleShakeCoroutine = null; ScheduleNextIdleShake(); } if (completionAnimationCoroutine == null) { RestoreRestTransform(); } } private void StopAllVisualAnimation() { if (idleShakeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(idleShakeCoroutine); idleShakeCoroutine = null; } if (completionAnimationCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(completionAnimationCoroutine); completionAnimationCoroutine = null; } RestoreRestTransform(); } private void RestoreRestTransform() { //IL_0008: 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) ((Component)this).transform.localPosition = restLocalPosition; ((Component)this).transform.localRotation = restLocalRotation; } private bool IsWrappingPaper(ItemData item) { if (item == null || (Object)(object)item.m_dropPrefab == (Object)null) { return false; } return ((Object)item.m_dropPrefab).name.Contains("WrappingPaper"); } private string GetGiftPrefabNameFromPaper(string paperPrefabName) { if (string.IsNullOrEmpty(paperPrefabName)) { return null; } switch (paperPrefabName) { case "M_Green_Gold_WrappingPaper": return "M_Green_Gold_Gift"; case "M_WrappingPaper_SnowFlake_Blue": return "M_SnowFlake_Blue"; case "M_WrappingPaper_SnowFlake_Red": return "M_SnowFlake_Red"; default: if (paperPrefabName.StartsWith("M_WrappingPaper_")) { return "M_Gift_" + paperPrefabName.Substring("M_WrappingPaper_".Length); } return paperPrefabName.Replace("WrappingPaper", "Gift"); } } public bool CanWrap() { List allItems = container.GetInventory().GetAllItems(); if (allItems.Count != 2) { return false; } ItemData val = null; ItemData val2 = null; foreach (ItemData item in allItems) { if (IsWrappingPaper(item)) { val = item; } else { val2 = item; } } return val != null && val2 != null; } private IEnumerator WrapSequence() { wrapInProgress = true; StopIdleShakeAndReset(); yield return ((MonoBehaviour)this).StartCoroutine(BlinkRoutine(3.8f)); Wrap(); PlayCompletionAnimationForEveryone(); SpawnTamedFX(); yield return (object)new WaitForSeconds(0.9f); SpawnBuildSmoke(); wrapInProgress = false; ScheduleNextIdleShake(); } private void PlayCompletionAnimationForEveryone() { StopIdleShakeAndReset(); if ((Object)(object)nview != (Object)null && nview.IsValid()) { nview.InvokeRPC(ZNetView.Everybody, "RPC_Moonforged_WrappingBoxComplete", new object[0]); } else { StartCompletionAnimation(); } } private void RPC_PlayCompletionAnimation(long sender) { StartCompletionAnimation(); } private void StartCompletionAnimation() { if (completionAnimationCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(completionAnimationCoroutine); completionAnimationCoroutine = null; } if (idleShakeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(idleShakeCoroutine); idleShakeCoroutine = null; } RestoreRestTransform(); completionAnimationCoroutine = ((MonoBehaviour)this).StartCoroutine(CompletionAnimationRoutine()); } private IEnumerator CompletionAnimationRoutine() { float elapsed = 0f; while (elapsed < 0.9f) { float normalized = Mathf.Clamp01(elapsed / 0.9f); float height = Mathf.Sin(normalized * (float)Math.PI) * 0.05f; float spinProgress = Mathf.SmoothStep(0f, 1f, normalized); float spin = spinProgress * 360f; ((Component)this).transform.localPosition = restLocalPosition + Vector3.up * height; ((Component)this).transform.localRotation = restLocalRotation * Quaternion.Euler(0f, spin, 0f); elapsed += Time.deltaTime; yield return null; } RestoreRestTransform(); completionAnimationCoroutine = null; ScheduleNextIdleShake(); } private void Wrap() { if ((Object)(object)ZNetScene.instance == (Object)null) { return; } Inventory inventory = container.GetInventory(); ItemData val = null; ItemData val2 = null; foreach (ItemData allItem in inventory.GetAllItems()) { if (IsWrappingPaper(allItem)) { val = allItem; } else { val2 = allItem; } } if (val == null || val2 == null) { return; } string giftPrefabNameFromPaper = GetGiftPrefabNameFromPaper(((Object)val.m_dropPrefab).name); if (string.IsNullOrEmpty(giftPrefabNameFromPaper)) { return; } GameObject prefab = ZNetScene.instance.GetPrefab(giftPrefabNameFromPaper); if (!((Object)(object)prefab == (Object)null)) { Dictionary customData = new Dictionary { { "wrapped_prefab", ((Object)val2.m_dropPrefab).name }, { "wrapped_stack", val2.m_stack.ToString() }, { "wrapped_quality", val2.m_quality.ToString() }, { "wrapped_variant", val2.m_variant.ToString() }, { "wrapped_durability", val2.m_durability.ToString(CultureInfo.InvariantCulture) } }; ItemDrop component = prefab.GetComponent(); if (!((Object)(object)component == (Object)null)) { ItemData val3 = component.m_itemData.Clone(); val3.m_dropPrefab = prefab; val3.m_stack = 1; val3.m_customData = customData; inventory.RemoveItem(val2); inventory.RemoveItem(val); inventory.AddItem(val3); } } } private IEnumerator BlinkRoutine(float duration) { Renderer[] renderers = ((Component)this).GetComponentsInChildren(true); float t = 0f; Dictionary original = new Dictionary(); Renderer[] array = renderers; foreach (Renderer r in array) { if ((Object)(object)r != (Object)null && (Object)(object)r.material != (Object)null && r.material.HasProperty("_Color") && !original.ContainsKey(r.material)) { original[r.material] = r.material.color; } } while (t < duration) { float pulse = Mathf.Sin(Time.time * 10f) * 0.7f + 1.7f; Renderer[] array2 = renderers; foreach (Renderer r2 in array2) { if ((Object)(object)r2 != (Object)null && (Object)(object)r2.material != (Object)null && r2.material.HasProperty("_Color")) { r2.material.color = original[r2.material] * pulse; } } t += Time.deltaTime; yield return null; } foreach (KeyValuePair kv in original) { if ((Object)(object)kv.Key != (Object)null) { kv.Key.color = kv.Value; } } } private void SpawnBuildSmoke() { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab("vfx_PlacePiece") : null); if ((Object)(object)val != (Object)null) { Object.Instantiate(val, ((Component)this).transform.position + Vector3.up * 0.5f, Quaternion.identity); } } private void SpawnTamedFX() { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab("fx_creature_tamed") : null); if ((Object)(object)val != (Object)null) { Object.Instantiate(val, ((Component)this).transform.position + Vector3.up * 0.5f, Quaternion.identity); } } } public static class WrappingPaperRegistrar { private struct PaperDef { public string PrefabName; public string DisplayName; public PaperDef(string prefabName, string displayName) { PrefabName = prefabName; DisplayName = displayName; } } private static bool registered; public static void Register(AssetBundle bundle) { //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Expected O, but got Unknown //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Expected O, but got Unknown //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Expected O, but got Unknown if (registered || (Object)(object)bundle == (Object)null) { return; } PaperDef[] array = new PaperDef[7] { new PaperDef("M_WrappingPaper_BlackOrange_Valheim", "Wrapping Paper (Black & Orange)"), new PaperDef("M_WrappingPaper_Red_Blue", "Wrapping Paper (Red & Blue)"), new PaperDef("M_WrappingPaper_Silver_Black", "Wrapping Paper (Silver & Black)"), new PaperDef("M_WrappingPaper_Yellow_Deco", "Wrapping Paper (Yellow Deco)"), new PaperDef("M_WrappingPaper_SnowFlake_Blue", "Wrapping Paper (SnowFlake Blue)"), new PaperDef("M_WrappingPaper_SnowFlake_Red", "Wrapping Paper (SnowFlake Red)"), new PaperDef("M_Gree_Gold_WrappingPaper", "Wrapping Paper (Green & Gold)") }; PaperDef[] array2 = array; for (int i = 0; i < array2.Length; i++) { PaperDef paperDef = array2[i]; GameObject val = bundle.LoadAsset(paperDef.PrefabName); if ((Object)(object)val == (Object)null) { continue; } ((Object)val).name = paperDef.PrefabName; ZNetView val2 = val.GetComponent() ?? val.AddComponent(); val2.m_persistent = true; val.layer = LayerMask.NameToLayer("item"); ItemDrop component = val.GetComponent(); if (!((Object)(object)component == (Object)null) && component.m_itemData?.m_shared != null) { SharedData shared = component.m_itemData.m_shared; shared.m_itemType = (ItemType)1; shared.m_maxStackSize = 100; shared.m_weight = 0.1f; shared.m_value = 0; shared.m_name = paperDef.DisplayName; shared.m_description = "Festive paper used to wrap gifts."; Sprite val3 = bundle.LoadAsset(paperDef.PrefabName); if ((Object)(object)val3 != (Object)null) { shared.m_icons = (Sprite[])(object)new Sprite[1] { val3 }; } component.m_itemData.m_dropPrefab = val; ItemManager.Instance.AddItem(new CustomItem(val, true)); ItemManager instance = ItemManager.Instance; RecipeConfig val4 = new RecipeConfig(); val4.Item = paperDef.PrefabName; val4.Amount = 1; val4.CraftingStation = "M_Wrapping_Table"; val4.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("Dandelion", 1, 0, true) }; instance.AddRecipe(new CustomRecipe(val4)); } } registered = true; } } public static class WrappedGiftItemRegistrar { private static bool registered; private static readonly string[] GiftPrefabs = new string[7] { "M_Gift_BlackOrange_Valheim", "M_Gift_Yellow_Deco", "M_Gift_Red_Blue", "M_Gree_Gold_Gift", "M_SnowFlake_Blue", "M_SnowFlake_Red", "M_Gift_Silver_Black" }; public static void Register(AssetBundle bundle) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown if (registered || (Object)(object)bundle == (Object)null) { return; } string[] giftPrefabs = GiftPrefabs; foreach (string text in giftPrefabs) { GameObject val = bundle.LoadAsset(text); if ((Object)(object)val == (Object)null) { continue; } ((Object)val).name = text; ZNetView val2 = val.GetComponent() ?? val.AddComponent(); val2.m_persistent = true; val.layer = LayerMask.NameToLayer("item"); ItemDrop component = val.GetComponent(); if (!((Object)(object)component == (Object)null) && component.m_itemData?.m_shared != null) { SharedData shared = component.m_itemData.m_shared; shared.m_itemType = (ItemType)2; shared.m_maxStackSize = 1; shared.m_weight = 1f; shared.m_value = 0; shared.m_description = "A wrapped gift. Right-click to open."; Sprite val3 = bundle.LoadAsset(text); if ((Object)(object)val3 != (Object)null) { shared.m_icons = (Sprite[])(object)new Sprite[1] { val3 }; } component.m_itemData.m_dropPrefab = val; ItemManager.Instance.AddItem(new CustomItem(val, true)); } } registered = true; } } public class DeerMarker : MonoBehaviour { public static readonly HashSet All = new HashSet(); private void OnEnable() { All.Add(this); } private void OnDisable() { All.Remove(this); } } public class ReindeerPetInteract : MonoBehaviour, Interactable, Hoverable { private Piece piece; private void Awake() { piece = ((Component)this).GetComponent(); InstallInteractionProxies(); } private void Start() { if ((Object)(object)piece == (Object)null) { piece = ((Component)this).GetComponent(); } InstallInteractionProxies(); } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold || (Object)(object)user == (Object)null) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if ((Object)(object)val == (Object)null) { return false; } GameObject val2 = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab("FreezeGland") : null); if ((Object)(object)val2 == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { val2 = ZNetScene.instance.GetPrefab("FreezeGland"); } if ((Object)(object)val2 == (Object)null) { ((Character)val).Message((MessageType)2, "The reindeer could not find a frozen booger.", 0, (Sprite)null, false); return true; } Inventory inventory = ((Humanoid)val).GetInventory(); if (inventory == null || !inventory.AddItem(val2, 1)) { ((Character)val).Message((MessageType)2, "Your inventory is full.", 0, (Sprite)null, false); return true; } ((Character)val).Message((MessageType)2, "The reindeer sneezes and gives you a frozen booger!", 0, (Sprite)null, false); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverName() { if ((Object)(object)piece == (Object)null) { piece = ((Component)this).GetComponent(); } return ((Object)(object)piece != (Object)null && !string.IsNullOrWhiteSpace(piece.m_name)) ? piece.m_name : "Santa's Reindeer"; } public float GetHoverOffset() { return 0f; } public string GetHoverText() { return GetHoverName() + "\n[E] Pet"; } private void InstallInteractionProxies() { Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)(object)((Component)this).gameObject)) { ReindeerPetInteractionProxy reindeerPetInteractionProxy = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); reindeerPetInteractionProxy.Configure(this); } } } } public class ReindeerPetInteractionProxy : MonoBehaviour, Interactable, Hoverable { private ReindeerPetInteract target; public void Configure(ReindeerPetInteract reindeer) { target = reindeer; } private void Awake() { if ((Object)(object)target == (Object)null) { target = ((Component)this).GetComponentInParent(); } } public bool Interact(Humanoid user, bool hold, bool alt) { return (Object)(object)target != (Object)null && target.Interact(user, hold, alt); } public bool UseItem(Humanoid user, ItemData item) { return (Object)(object)target != (Object)null && target.UseItem(user, item); } public string GetHoverName() { return ((Object)(object)target != (Object)null) ? target.GetHoverName() : "Santa's Reindeer"; } public float GetHoverOffset() { return 0f; } public string GetHoverText() { return ((Object)(object)target != (Object)null) ? target.GetHoverText() : ""; } } public class IcicleFlow : MonoBehaviour { public enum Axis { Auto, Y, Z } private class Column { public int columnIndex; public int batch; public int activeIndex = -1; public float nextStepTime; public List bulbs = new List(); public List mpb = new List(); } [Header("Target naming")] public string columnNamePrefix = "Icicle_Lamp_"; public string bulbNamePrefix = "Light"; [Header("Look")] public Color dripColor = new Color(0.6f, 0.85f, 1f); [Min(0f)] public float emissionIntensity = 4.5f; public bool affectBaseColor = false; [Header("Timing")] [Min(0.01f)] public float dripStepSeconds = 0.15f; [Min(0f)] public float pauseAfterColumn = 0.6f; [Min(1f)] public int batchCount = 3; [Min(0f)] public float batchSpacingSeconds = 4f; [Header("Advanced")] public bool includeInactive = true; public bool autoDetectVerticalAxis = true; public Axis verticalAxis = Axis.Auto; [Header("Performance")] [Min(0.01f)] public float minUpdateInterval = 0.05f; [Min(0f)] public float activeDistance = 60f; private readonly List _columns = new List(); private float _gammaIntensity; private int _colorId; private int _emissId; private float _accum; private bool _isActive; private void Awake() { _colorId = Shader.PropertyToID("_Color"); _emissId = Shader.PropertyToID("_EmissionColor"); _gammaIntensity = Mathf.LinearToGammaSpace(Mathf.Max(0f, emissionIntensity)); BuildColumns(); } private void OnEnable() { PrepareMPBs(); _accum = 0f; _isActive = false; } private void Update() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) if (_columns.Count == 0) { return; } if (activeDistance > 0f && !Player.IsPlayerInRange(((Component)this).transform.position, activeDistance)) { if (_isActive) { for (int i = 0; i < _columns.Count; i++) { SetColumnAll(_columns[i], Color.black); _columns[i].activeIndex = -1; } _isActive = false; } return; } if (!_isActive) { _isActive = true; ResetSequence(Time.time); } _accum += Time.deltaTime; if (_accum < minUpdateInterval) { return; } _accum = 0f; float time = Time.time; for (int j = 0; j < _columns.Count; j++) { Column column = _columns[j]; if (column.bulbs.Count != 0 && !(time < column.nextStepTime)) { if (column.activeIndex < column.bulbs.Count - 1) { column.activeIndex++; SetColumnActive(column, column.activeIndex, dripColor); column.nextStepTime = time + Mathf.Max(0.01f, dripStepSeconds); } else { SetColumnAll(column, Color.black); column.activeIndex = -1; column.nextStepTime = time + Mathf.Max(0f, pauseAfterColumn); } } } } private void ResetSequence(float now) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0f, batchSpacingSeconds); for (int i = 0; i < _columns.Count; i++) { Column column = _columns[i]; column.activeIndex = -1; column.nextStepTime = now + (float)column.batch * num; SetColumnAll(column, Color.black); } } private void BuildColumns() { //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown _columns.Clear(); List list = new List(); Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren(includeInactive); foreach (Transform val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && (string.IsNullOrEmpty(columnNamePrefix) || ((Object)val).name.StartsWith(columnNamePrefix))) { list.Add(val); } } list.Sort((Transform a, Transform b) => a.localPosition.x.CompareTo(b.localPosition.x)); for (int num = 0; num < list.Count; num++) { Transform colT = list[num]; Column column = new Column(); column.columnIndex = num; column.batch = ((batchCount > 0) ? (num % batchCount) : 0); Renderer[] componentsInChildren2 = ((Component)colT).GetComponentsInChildren(includeInactive); foreach (Renderer val2 in componentsInChildren2) { if (Object.op_Implicit((Object)(object)val2)) { string text = ((Object)((Component)val2).gameObject).name.ToLowerInvariant(); if (string.IsNullOrEmpty(bulbNamePrefix) || text.StartsWith(bulbNamePrefix.ToLowerInvariant())) { column.bulbs.Add(val2); } } } if (column.bulbs.Count != 0) { Axis axis = ResolveAxis(colT, column.bulbs); column.bulbs.Sort(delegate(Renderer a, Renderer b) { float columnAxis = GetColumnAxis(colT, ((Component)a).transform, axis); float columnAxis2 = GetColumnAxis(colT, ((Component)b).transform, axis); return -columnAxis.CompareTo(columnAxis2); }); for (int num3 = 0; num3 < column.bulbs.Count; num3++) { column.mpb.Add(new MaterialPropertyBlock()); } _columns.Add(column); } } } private Axis ResolveAxis(Transform columnRoot, List bulbs) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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) if (!autoDetectVerticalAxis) { return (verticalAxis == Axis.Auto) ? Axis.Z : verticalAxis; } float num = float.PositiveInfinity; float num2 = float.NegativeInfinity; float num3 = float.PositiveInfinity; float num4 = float.NegativeInfinity; for (int i = 0; i < bulbs.Count; i++) { Vector3 val = columnRoot.InverseTransformPoint(((Component)bulbs[i]).transform.position); if (val.y < num) { num = val.y; } if (val.y > num2) { num2 = val.y; } if (val.z < num3) { num3 = val.z; } if (val.z > num4) { num4 = val.z; } } float num5 = num2 - num; float num6 = num4 - num3; if (num5 >= num6) { return Axis.Y; } return Axis.Z; } private float GetColumnAxis(Transform columnRoot, Transform bulb, Axis axis) { //IL_0003: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) Vector3 val = columnRoot.InverseTransformPoint(bulb.position); return axis switch { Axis.Y => val.y, Axis.Z => val.z, _ => val.z, }; } private void PrepareMPBs() { for (int i = 0; i < _columns.Count; i++) { Column column = _columns[i]; for (int j = 0; j < column.bulbs.Count; j++) { Renderer val = column.bulbs[j]; if (Object.op_Implicit((Object)(object)val)) { Material sharedMaterial = val.sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null) { sharedMaterial.EnableKeyword("_EMISSION"); } val.GetPropertyBlock(column.mpb[j]); } } } } private void SetColumnActive(Column col, int activeIndex, Color onColor) { //IL_0069: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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) for (int i = 0; i < col.bulbs.Count; i++) { Renderer val = col.bulbs[i]; if (Object.op_Implicit((Object)(object)val)) { MaterialPropertyBlock val2 = col.mpb[i]; if (affectBaseColor) { val2.SetColor(_colorId, (i == activeIndex) ? onColor : Color.black); } val2.SetColor(_emissId, (i == activeIndex) ? (onColor * _gammaIntensity) : Color.black); val.SetPropertyBlock(val2); } } } private void SetColumnAll(Column col, Color c) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < col.bulbs.Count; i++) { Renderer val = col.bulbs[i]; if (Object.op_Implicit((Object)(object)val)) { MaterialPropertyBlock val2 = col.mpb[i]; if (affectBaseColor) { val2.SetColor(_colorId, c); } val2.SetColor(_emissId, c * _gammaIntensity); val.SetPropertyBlock(val2); } } } } [BepInPlugin("Moonforged.ChristmasDecorations", "Moonforged Christmas Decorations", "1.0.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MoonforgedChristmas : BaseUnityPlugin { public const string PluginGUID = "Moonforged.ChristmasDecorations"; public const string PluginName = "Moonforged Christmas Decorations"; public const string PluginVersion = "1.0.7"; private AssetBundle christmasBundle; public static ConfigEntry PlayerPreferredCategory; private void Awake() { //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.ChristmasDecorations"); val.PatchAll(); string resourcePath = "MoonforgedChristmasDecorations.christmas"; christmasBundle = EmbeddedAssetBundleLoader.LoadBundle(resourcePath); if ((Object)(object)christmasBundle == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load embedded AssetBundle."); return; } PlayerPreferredCategory = ((BaseUnityPlugin)this).Config.Bind("General", "CustomHammerTab", "Moonforged", "Set the build-menu category name where this mod's pieces should appear. You can use an existing category or create a new custom category."); PrefabManager.OnPrefabsRegistered += delegate { ((MonoBehaviour)this).StartCoroutine(DelayedRegister(christmasBundle)); }; } 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()); } } [HarmonyPatch] internal static class WrappedGiftConsumePatch { [HarmonyPatch(typeof(Player), "ConsumeItem")] [HarmonyPrefix] private static bool Player_ConsumeItem_Prefix(Player __instance, Inventory inventory, ItemData item) { if ((Object)(object)__instance == (Object)null || inventory == null || item == null) { return true; } if (!IsGift(item)) { return true; } if (WrappedGiftUse.OnUse(item, __instance)) { return false; } return true; } private static bool IsGift(ItemData item) { if (item == null || (Object)(object)item.m_dropPrefab == (Object)null) { return false; } string name = ((Object)item.m_dropPrefab).name; if (string.IsNullOrEmpty(name)) { return false; } if (name.StartsWith("M_Gift_")) { return true; } if (name.StartsWith("M_SnowFlake_")) { return true; } if (name == "M_Gree_Gold_Gift") { return true; } return false; } } [HarmonyPatch(typeof(Container), "GetHoverName")] internal static class WrappingBoxHoverNamePatch { private static void Postfix(Container __instance, ref string __result) { if (!((Object)(object)__instance == (Object)null)) { WrappingBoxProcessor componentInParent = ((Component)__instance).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null)) { __result = "Wrapper"; } } } } [HarmonyPatch(typeof(Container), "GetHoverText")] internal static class WrappingBoxHoverTextPatch { private static void Postfix(Container __instance, ref string __result) { if ((Object)(object)__instance == (Object)null) { return; } WrappingBoxProcessor componentInParent = ((Component)__instance).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null)) { if (componentInParent.CanWrap()) { __result = "Wrapper\n[E] Open\nClose box to wrap gift"; } else { __result = "Wrapper\n[E] Open\n(Add 1 gift + 1 item)"; } } } } internal static class MoonforgedBuildMenuCategory { private const string DefaultCategoryName = "Moonforged"; private static readonly int[] CandidateBits = new int[11] { 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 30 }; private static readonly HashSet RegisteredPieces = new HashSet(); private static UsageTagFlags usageTag = (UsageTagFlags)536870912; private static bool patchInstalled; internal static void Install(Harmony harmony) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown if (patchInstalled || harmony == null) { return; } Type type = AccessTools.TypeByName("ByUsagePieceList"); if (!(type == null)) { ConstructorInfo constructorInfo = AccessTools.Constructor(type, new Type[1] { typeof(string) }, false) ?? AccessTools.Constructor(type, Type.EmptyTypes, false); MethodInfo methodInfo = AccessTools.Method(typeof(MoonforgedBuildMenuCategory), "ByUsagePieceListConstructorPostfix", (Type[])null, (Type[])null); if (!(constructorInfo == null) && !(methodInfo == null)) { HarmonyMethod val = new HarmonyMethod(methodInfo) { priority = 0 }; harmony.Patch((MethodBase)constructorInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patchInstalled = true; } } } internal static void Register(Piece piece) { //IL_001b: 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) if (!((Object)(object)piece == (Object)null)) { RegisteredPieces.Add(piece); piece.m_usage = usageTag; } } private static void ByUsagePieceListConstructorPostfix(object __instance) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected I4, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) if (__instance == null) { return; } Type type = __instance.GetType(); FieldInfo fieldInfo = AccessTools.Field(type, "m_usageTags"); FieldInfo fieldInfo2 = AccessTools.Field(type, "m_usageTagDisplayNames"); if (fieldInfo == null || fieldInfo2 == null) { return; } UsageTagFlags[] array = fieldInfo.GetValue(__instance) as UsageTagFlags[]; string[] array2 = fieldInfo2.GetValue(__instance) as string[]; if (array == null || array2 == null || array.Length != array2.Length) { return; } string categoryName = GetCategoryName(); if (TryFindCategoryTag(array, array2, categoryName, out var tag)) { usageTag = tag; ApplyTagToRegisteredPieces(); return; } if (TagIsAlreadyUsed(array, usageTag)) { if (!TryChooseFreeTag(array, out var tag2)) { return; } usageTag = tag2; } ApplyTagToRegisteredPieces(); string text = categoryName; int num = array.Length; Array.Resize(ref array, num + 1); Array.Resize(ref array2, num + 1); array[num] = (UsageTagFlags)(int)usageTag; array2[num] = text; fieldInfo.SetValue(__instance, array); fieldInfo2.SetValue(__instance, array2); } private static string GetCategoryName() { if (MoonforgedChristmas.PlayerPreferredCategory == null) { return "Moonforged"; } string value = MoonforgedChristmas.PlayerPreferredCategory.Value; return string.IsNullOrWhiteSpace(value) ? "Moonforged" : value.Trim(); } private static bool TryFindCategoryTag(UsageTagFlags[] tags, string[] names, string categoryName, out UsageTagFlags tag) { for (int i = 0; i < names.Length; i++) { string a = names[i] ?? string.Empty; if (string.Equals(a, categoryName, StringComparison.OrdinalIgnoreCase)) { tag = tags[i]; return true; } } tag = (UsageTagFlags)0; return false; } private static bool TagIsAlreadyUsed(UsageTagFlags[] tags, UsageTagFlags tag) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Expected I4, but got Unknown int num = (int)tag; if (num == 0) { return true; } for (int i = 0; i < tags.Length; i++) { if (((uint)tags[i] & (uint)num) != 0) { return true; } } return false; } private static bool TryChooseFreeTag(UsageTagFlags[] tags, out UsageTagFlags tag) { for (int i = 0; i < CandidateBits.Length; i++) { int num = 1 << CandidateBits[i]; bool flag = false; for (int j = 0; j < tags.Length; j++) { if (((uint)tags[j] & (uint)num) != 0) { flag = true; break; } } if (!flag) { tag = (UsageTagFlags)num; return true; } } tag = (UsageTagFlags)0; return false; } private static void ApplyTagToRegisteredPieces() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) foreach (Piece registeredPiece in RegisteredPieces) { if ((Object)(object)registeredPiece != (Object)null) { registeredPiece.m_usage = usageTag; } } } } public class MusicBoxInteract : MonoBehaviour, Interactable, Hoverable { private const string KeyRpcName = "MoonforgedChristmas_TurnMusicBoxKey"; private const string PauseRpcName = "MoonforgedChristmas_PauseMusicBox"; private const string ResumeRpcName = "MoonforgedChristmas_ResumeMusicBox"; private const string InteractionObjectName = "MusicBoxInteraction"; private const float AnimationSeconds = 21.333f; private const float KeyDegreesPerSecond = 16.875263f; private const float FullTurn = 360f; private const float ScrewRiseSeconds = 5f; private const float ScrewRiseTurns = 5f; private const float TopSpinSeconds = 16.333f; private const float TopSpinTurns = 5f; private const float LidOpenSeconds = 0.35f; private const float LidOpenX = -135f; private const float ResetDelaySeconds = 5f; private static GameObject soundPrefab; private Piece piece; private ZNetView networkView; private Transform keyPivot; private Transform lidPivot; private Transform lidObject; private Transform movingObject; private Transform bottomPivot; private Transform topPivot; private Quaternion keyRestLocalRotation; private Quaternion lidRestLocalRotation; private Quaternion movingRestLocalRotation; private Vector3 movingRestLocalPosition; private Vector3 movingBottomLocalPosition; private Vector3 movingTopLocalPosition; private GameObject activeSoundInstance; private AudioSource[] activeSoundSources; private float degreesTravelled; private float animationElapsed; private float resetDelayElapsed; private float lastStartTime = -10f; private bool rpcRegistered; private bool interactionReady; private bool isMoving; private bool isPaused; private bool isWaitingToReset; public static void ConfigureSound(GameObject prefab) { soundPrefab = prefab; } private void Awake() { CacheComponents(); CacheTransforms(); RegisterRpc(); } private void Start() { CacheComponents(); CacheTransforms(); RegisterRpc(); TryCreateInteractionTarget(); } private void Update() { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if (!interactionReady) { CacheComponents(); RegisterRpc(); TryCreateInteractionTarget(); } if (isWaitingToReset) { resetDelayElapsed += Time.deltaTime; if (resetDelayElapsed >= 5f) { ResetAnimation(); } } else if (isMoving && !isPaused && !((Object)(object)keyPivot == (Object)null)) { float deltaTime = Time.deltaTime; animationElapsed += deltaTime; degreesTravelled = Mathf.Min(360f, degreesTravelled + 16.875263f * deltaTime); keyPivot.localRotation = keyRestLocalRotation * Quaternion.AngleAxis(0f - degreesTravelled, Vector3.right); UpdateLid(); UpdateMovingObject(); if (degreesTravelled >= 360f) { FinishAnimation(); } } } private void OnDisable() { ResetAnimation(); } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold || (Object)(object)keyPivot == (Object)null || isWaitingToReset) { return false; } if (!isMoving) { StartAnimation(); if ((Object)(object)networkView != (Object)null && networkView.IsValid()) { networkView.InvokeRPC(ZNetView.Everybody, "MoonforgedChristmas_TurnMusicBoxKey", Array.Empty()); } } else if (isPaused) { ResumeAnimation(); if ((Object)(object)networkView != (Object)null && networkView.IsValid()) { networkView.InvokeRPC(ZNetView.Everybody, "MoonforgedChristmas_ResumeMusicBox", Array.Empty()); } } else { PauseAnimation(); if ((Object)(object)networkView != (Object)null && networkView.IsValid()) { networkView.InvokeRPC(ZNetView.Everybody, "MoonforgedChristmas_PauseMusicBox", Array.Empty()); } } return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverName() { if ((Object)(object)piece == (Object)null) { piece = ((Component)this).GetComponent(); } return ((Object)(object)piece != (Object)null && !string.IsNullOrWhiteSpace(piece.m_name)) ? piece.m_name : "Christmas Music Box"; } public float GetHoverOffset() { return 0f; } public string GetHoverText() { if (isWaitingToReset) { return GetHoverName() + "\nMusic finished"; } if (isMoving && isPaused) { return GetHoverName() + "\n[E] Resume music box"; } if (isMoving) { return GetHoverName() + "\n[E] Pause music box"; } return GetHoverName() + "\n[E] Wind key"; } private void CacheComponents() { if ((Object)(object)piece == (Object)null) { piece = ((Component)this).GetComponent(); } if ((Object)(object)networkView == (Object)null) { networkView = ((Component)this).GetComponent(); } } private void CacheTransforms() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)keyPivot == (Object)null) { keyPivot = FindChildByName(((Component)this).transform, "Pivot_Key"); if ((Object)(object)keyPivot != (Object)null) { keyRestLocalRotation = keyPivot.localRotation; } } if ((Object)(object)lidPivot == (Object)null) { lidPivot = FindChildByName(((Component)this).transform, "Pivot_Lid"); if ((Object)(object)lidPivot != (Object)null) { AttachLidToPivot(); lidRestLocalRotation = lidPivot.localRotation; } } if ((Object)(object)movingObject == (Object)null) { movingObject = FindChildByName(((Component)this).transform, "Object_10.002"); if ((Object)(object)movingObject != (Object)null) { movingRestLocalRotation = movingObject.localRotation; movingRestLocalPosition = movingObject.localPosition; } } if ((Object)(object)bottomPivot == (Object)null) { bottomPivot = FindChildByName(((Component)this).transform, "Bottom_Pivot"); } if ((Object)(object)topPivot == (Object)null) { topPivot = FindChildByName(((Component)this).transform, "Top_Pivot"); } } private void RegisterRpc() { if (!rpcRegistered && !((Object)(object)networkView == (Object)null)) { networkView.Register("MoonforgedChristmas_TurnMusicBoxKey", (Action)RpcTurnKey); networkView.Register("MoonforgedChristmas_PauseMusicBox", (Action)RpcPauseAnimation); networkView.Register("MoonforgedChristmas_ResumeMusicBox", (Action)RpcResumeAnimation); rpcRegistered = true; } } private void RpcTurnKey(long sender) { if (!isMoving && Time.time - lastStartTime > 0.1f) { StartAnimation(); } } private void RpcPauseAnimation(long sender) { if (isMoving && !isPaused) { PauseAnimation(); } } private void RpcResumeAnimation(long sender) { if (isMoving && isPaused) { ResumeAnimation(); } } private void StartAnimation() { //IL_002f: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) CacheTransforms(); if (!((Object)(object)keyPivot == (Object)null) && !isMoving) { keyPivot.localRotation = keyRestLocalRotation; degreesTravelled = 0f; animationElapsed = 0f; resetDelayElapsed = 0f; lastStartTime = Time.time; isPaused = false; isWaitingToReset = false; if ((Object)(object)lidPivot != (Object)null) { lidPivot.localRotation = lidRestLocalRotation; } if ((Object)(object)movingObject != (Object)null && (Object)(object)bottomPivot != (Object)null && (Object)(object)topPivot != (Object)null) { Transform parent = movingObject.parent; movingBottomLocalPosition = (((Object)(object)parent != (Object)null) ? parent.InverseTransformPoint(bottomPivot.position) : bottomPivot.position); movingTopLocalPosition = (((Object)(object)parent != (Object)null) ? parent.InverseTransformPoint(topPivot.position) : topPivot.position); movingObject.localPosition = movingBottomLocalPosition; movingObject.localRotation = movingRestLocalRotation; } isMoving = true; PlaySound(); } } private void FinishAnimation() { isMoving = false; isPaused = false; isWaitingToReset = true; resetDelayElapsed = 0f; StopAndDestroySound(); } private void PauseAnimation() { if (!isMoving || isPaused) { return; } isPaused = true; if (activeSoundSources == null) { return; } for (int i = 0; i < activeSoundSources.Length; i++) { AudioSource val = activeSoundSources[i]; if ((Object)(object)val != (Object)null) { val.Pause(); } } } private void ResumeAnimation() { if (!isMoving || !isPaused) { return; } isPaused = false; if (activeSoundSources == null) { return; } for (int i = 0; i < activeSoundSources.Length; i++) { AudioSource val = activeSoundSources[i]; if ((Object)(object)val != (Object)null) { val.UnPause(); } } } private void ResetAnimation() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_006f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)keyPivot != (Object)null) { keyPivot.localRotation = keyRestLocalRotation; } if ((Object)(object)lidPivot != (Object)null) { lidPivot.localRotation = lidRestLocalRotation; } if ((Object)(object)movingObject != (Object)null) { movingObject.localPosition = movingRestLocalPosition; movingObject.localRotation = movingRestLocalRotation; } degreesTravelled = 0f; animationElapsed = 0f; resetDelayElapsed = 0f; isMoving = false; isPaused = false; isWaitingToReset = false; StopAndDestroySound(); } private void PlaySound() { //IL_0028: 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) if ((Object)(object)soundPrefab == (Object)null) { return; } StopAndDestroySound(); activeSoundInstance = Object.Instantiate(soundPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation); activeSoundSources = activeSoundInstance.GetComponentsInChildren(true); for (int i = 0; i < activeSoundSources.Length; i++) { AudioSource val = activeSoundSources[i]; if (!((Object)(object)val == (Object)null) && !val.isPlaying) { val.Play(); } } } private void StopAndDestroySound() { if (activeSoundSources != null) { for (int i = 0; i < activeSoundSources.Length; i++) { AudioSource val = activeSoundSources[i]; if ((Object)(object)val != (Object)null) { val.Stop(); } } } if ((Object)(object)activeSoundInstance != (Object)null) { Object.Destroy((Object)(object)activeSoundInstance); } activeSoundSources = null; activeSoundInstance = null; } private void AttachLidToPivot() { if ((Object)(object)lidPivot == (Object)null) { return; } lidObject = FindChildByName(((Component)this).transform, "Box_Top"); if (!((Object)(object)lidObject == (Object)null) && !((Object)(object)lidObject == (Object)(object)lidPivot) && !lidObject.IsChildOf(lidPivot)) { if (lidPivot.IsChildOf(lidObject)) { lidPivot.SetParent(lidObject.parent, true); } lidObject.SetParent(lidPivot, true); } } private void UpdateLid() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_005f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)lidPivot == (Object)null)) { float num = Mathf.Clamp01(animationElapsed / 0.35f); float num2 = Mathf.SmoothStep(0f, 1f, num); Quaternion val = lidRestLocalRotation * Quaternion.AngleAxis(-135f, Vector3.right); lidPivot.localRotation = Quaternion.Slerp(lidRestLocalRotation, val, num2); } } private void UpdateMovingObject() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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) //IL_00f2: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)movingObject == (Object)null) && !((Object)(object)bottomPivot == (Object)null) && !((Object)(object)topPivot == (Object)null)) { if (animationElapsed <= 5f) { float num = Mathf.Clamp01(animationElapsed / 5f); movingObject.localPosition = Vector3.Lerp(movingBottomLocalPosition, movingTopLocalPosition, num); movingObject.localRotation = movingRestLocalRotation * Quaternion.AngleAxis(-1800f * num, Vector3.up); } else { float num2 = Mathf.Clamp01((animationElapsed - 5f) / 16.333f); movingObject.localPosition = movingTopLocalPosition; movingObject.localRotation = movingRestLocalRotation * Quaternion.AngleAxis(-360f * (5f + 5f * num2), Vector3.up); } } } private void TryCreateInteractionTarget() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown if ((Object)(object)networkView == (Object)null || !networkView.IsValid()) { return; } Transform val = ((Component)this).transform.Find("MusicBoxInteraction"); if ((Object)(object)val != (Object)null) { MusicBoxInteractionProxy musicBoxInteractionProxy = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); musicBoxInteractionProxy.Configure(this); interactionReady = true; return; } GameObject val2 = new GameObject("MusicBoxInteraction"); val2.transform.SetParent(((Component)this).transform, false); int num = LayerMask.NameToLayer("piece_nonsolid"); if (num < 0) { num = LayerMask.NameToLayer("piece"); } if (num < 0) { num = ((Component)this).gameObject.layer; } val2.layer = num; BoxCollider val3 = val2.AddComponent(); ((Collider)val3).isTrigger = false; ApplyInteractionBounds(val3); MusicBoxInteractionProxy musicBoxInteractionProxy2 = val2.AddComponent(); musicBoxInteractionProxy2.Configure(this); interactionReady = true; } private void ApplyInteractionBounds(BoxCollider interactionCollider) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0016: 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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00b5: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); bool flag = false; Vector3 val = Vector3.zero; Vector3 val2 = Vector3.zero; foreach (Renderer val3 in componentsInChildren) { if ((Object)(object)val3 == (Object)null) { continue; } Bounds bounds = val3.bounds; Vector3 center = ((Bounds)(ref bounds)).center; Vector3 extents = ((Bounds)(ref bounds)).extents; for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { for (int l = -1; l <= 1; l += 2) { Vector3 val4 = center + Vector3.Scale(extents, new Vector3((float)j, (float)k, (float)l)); Vector3 val5 = ((Component)this).transform.InverseTransformPoint(val4); if (!flag) { val = val5; val2 = val5; flag = true; } else { val = Vector3.Min(val, val5); val2 = Vector3.Max(val2, val5); } } } } } if (!flag) { interactionCollider.center = new Vector3(0f, 0.5f, 0f); interactionCollider.size = new Vector3(2f, 2f, 2f); } else { interactionCollider.center = (val + val2) * 0.5f; interactionCollider.size = val2 - val + new Vector3(0.2f, 0.2f, 0.2f); } } private static Transform FindChildByName(Transform root, string childName) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null && ((Object)componentsInChildren[i]).name == childName) { return componentsInChildren[i]; } } return null; } } public class MusicBoxInteractionProxy : MonoBehaviour, Interactable, Hoverable { private MusicBoxInteract target; public void Configure(MusicBoxInteract musicBox) { target = musicBox; } private void Awake() { if ((Object)(object)target == (Object)null) { target = ((Component)this).GetComponentInParent(); } } public bool Interact(Humanoid user, bool hold, bool alt) { return (Object)(object)target != (Object)null && target.Interact(user, hold, alt); } public bool UseItem(Humanoid user, ItemData item) { return (Object)(object)target != (Object)null && target.UseItem(user, item); } public string GetHoverName() { return ((Object)(object)target != (Object)null) ? target.GetHoverName() : "Christmas Music Box"; } public float GetHoverOffset() { return 0f; } public string GetHoverText() { return ((Object)(object)target != (Object)null) ? target.GetHoverText() : ""; } } public class RainbowGlow : MonoBehaviour { public float cycleSeconds = 10f; public float emissionIntensity = 1.5f; public float lightRange = 3f; public float lightIntensity = 1.8f; private bool _active; private Material _matInstance; private Light _light; private void Start() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) _active = (Object)(object)((Component)this).GetComponentInParent() != (Object)null; if (_active) { Renderer componentInChildren = ((Component)this).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { _matInstance = componentInChildren.material; _matInstance.EnableKeyword("_EMISSION"); _matInstance.SetColor("_EmissionColor", Color.white * emissionIntensity); _matInstance.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; } _light = ((Component)this).GetComponent(); if ((Object)(object)_light == (Object)null) { _light = ((Component)this).gameObject.AddComponent(); _light.type = (LightType)2; _light.range = lightRange; _light.intensity = lightIntensity; _light.shadows = (LightShadows)0; } } } private void Update() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) if (_active && !((Object)(object)_matInstance == (Object)null) && !((Object)(object)_light == (Object)null)) { float num = Mathf.Max(0.01f, cycleSeconds); float num2 = Time.time % num / num; Color val = Color.HSVToRGB(num2, 1f, 1f); _matInstance.SetColor("_EmissionColor", val * emissionIntensity); _light.color = val; } } } public class RelicRegistration { public string PrefabName; public string DisplayName; public RequirementConfig[] Requirements; public string Description; public string Category; public int Comfort; public string CraftingStation; public RelicRegistration(string prefab, string display, RequirementConfig[] reqs, string desc, string cat, int comfort = 0, string craftingStation = "Workbench") { PrefabName = prefab; DisplayName = display; Requirements = reqs; Description = desc; Category = cat; Comfort = comfort; CraftingStation = craftingStation; } } public static class RelicRegistrar { private class ScaleEnforcer : MonoBehaviour { public Vector3 desiredScale = Vector3.one; private void Awake() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.localScale = desiredScale; } } private static bool wasAlreadyRegistered = false; private static bool _starRegistered = false; public static readonly List AllRegistrations = new List { new RelicRegistration("M_Christmas_Tree_1", "Town Square Christmas Tree", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("Wood", 30, 0, true), new RequirementConfig("Raspberry", 20, 0, true), new RequirementConfig("Blueberries", 20, 0, true), new RequirementConfig("Coal", 20, 0, true) }, "Large town square Christmas Tree, craft a Star in the workbench and place it on the top.", "building"), new RelicRegistration("M_Christmas_Tree_Small", "Small Christmas Tree", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("Wood", 10, 0, true), new RequirementConfig("Raspberry", 5, 0, true), new RequirementConfig("Blueberries", 5, 0, true), new RequirementConfig("Coal", 5, 0, true) }, "A small Christmas Tree, craft a Star in the workbench and place it on the top.", "building"), new RelicRegistration("M_Garland", "Green Christmas Garland", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 2, 0, true), new RequirementConfig("Raspberry", 2, 0, true) }, "A traditional Holiday decoration, you can link them with bows.", "building"), new RelicRegistration("M_Garland_White", "White Christmas Garland", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 2, 0, true), new RequirementConfig("Blueberries", 2, 0, true) }, "A traditional Holiday decoration, you can link them with bows.", "building"), new RelicRegistration("M_Garland_Spiral_Green", "Christmas Spiral Garland (Green)", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("PineCone", 1, 0, true) }, "They can be used arround pillars and poles.", "building"), new RelicRegistration("M_Garland_Spiral_White", "Christmas Spiral Garland (White)", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("PineCone", 1, 0, true) }, "They can be used arround pillars and poles.", "building"), new RelicRegistration("M_Christmas_Wreath", "Christmas Wreath", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("FineWood", 1, 0, true), new RequirementConfig("FirCone", 4, 0, true), new RequirementConfig("Raspberry", 10, 0, true) }, "Brings a traditional feeling in your homes.", "building"), new RelicRegistration("M_mistletoe", "Christmas Mistletoe", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 1, 0, true), new RequirementConfig("JuteRed", 1, 0, true) }, "Kiss your partner or the troll under it.", "building"), new RelicRegistration("Christmas_Lights1", "Christmas Star Lights", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 5, 0, true) }, "Nice Twinkly Star shaped Lights.", "building"), new RelicRegistration("Christmas_Lights2", "Christmas Snowflake Lights", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 5, 0, true) }, "Nice Twinkly Snowflake shaped Lights", "building"), new RelicRegistration("MChristmas_Lights1", "Christmas Lights", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Raspberry", 5, 0, true), new RequirementConfig("Blueberries", 5, 0, true), new RequirementConfig("Coal", 5, 0, true) }, "Nice Twinkly Lights", "building"), new RelicRegistration("MChristmas_LongLights1", "Christmas Long Lights", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Raspberry", 5, 0, true), new RequirementConfig("Blueberries", 5, 0, true), new RequirementConfig("Coal", 5, 0, true) }, "Nice Twinkly Lights", "building"), new RelicRegistration("M_Icicle_Lamp", "Icicle Christmas Lights", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 5, 0, true) }, "Glowing icicle light string that drips with blue light.", "building"), new RelicRegistration("MultiStar_Light", "Star Lights", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 5, 0, true) }, "Glowing Multi Star lights.", "building"), new RelicRegistration("8Meter_Town_Light", "8 Meter Town Square Light", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 5, 0, true) }, "Town Square Star Light Decoration.", "building"), new RelicRegistration("M_Snowflake", "Christmas Hanging Snowflake Model I", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 1, 0, true) }, "A Shiny Hanging Snowflake.", "building"), new RelicRegistration("M_Snowflake2", "Christmas Hanging Snowflake Model II", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 1, 0, true) }, "A Shiny Hanging Snowflake.", "building"), new RelicRegistration("M_Snowflake3", "Christmas Hanging Snowflake Model III", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 1, 0, true) }, "A Shiny Hanging Snowflake.", "building"), new RelicRegistration("M_Snowflake4", "Christmas Hanging Snowflake Model IV", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 1, 0, true) }, "A Shiny Hanging Snowflake.", "building"), new RelicRegistration("M_Golden_Bow", "Golden Christmas Bow", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("LeatherScraps", 2, 0, true), new RequirementConfig("Blueberries", 2, 0, true) }, "A nice Bow to connect your garlands.", "building"), new RelicRegistration("M_BigblueChristmasbow", "Big Blue Christmas Bow", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("LeatherScraps", 2, 0, true), new RequirementConfig("Blueberries", 2, 0, true) }, "A nice Bow to connect your garlands.", "building"), new RelicRegistration("M_BigredChristmasbow", "Big Red Christmas Bow", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("LeatherScraps", 2, 0, true), new RequirementConfig("Bloodbag", 1, 0, true) }, "A nice Bow to connect your garlands.", "building"), new RelicRegistration("M_Cozy_Yule_Cup", "Cozy Yule Hot Cocoa Cup", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("Coal", 1, 0, true) }, "", "building"), new RelicRegistration("M_Cozy_Candy_Cane_Cup", "Hot Cocoa Cup with a Candy Cane", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("Coal", 1, 0, true) }, "", "building"), new RelicRegistration("Christmas_Cups3", "Hot Cocoa Cup with a Chocolate Tree", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("Coal", 1, 0, true) }, "", "building"), new RelicRegistration("M_MilkandCookiesforSanta", "Milk and Cookies for Santa", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Resin", 1, 0, true), new RequirementConfig("Coal", 1, 0, true) }, "", "building"), new RelicRegistration("M_Gingerbread_Man", "Gingerbread Man", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Wood", 1, 0, true) }, "We finaly caught him!", "building"), new RelicRegistration("M_Christmas_Cake", "Christmas Cake on a Plate", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Stone", 1, 0, true), new RequirementConfig("Blueberries", 5, 0, true), new RequirementConfig("BarleyFlour", 1, 0, true) }, "Don`t eat it all, leave some for Santa.", "building"), new RelicRegistration("M_Christmas_Cake2", "Christmas Strawberry Cake on a Plate", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Stone", 1, 0, true), new RequirementConfig("Raspberry", 5, 0, true), new RequirementConfig("BarleyFlour", 1, 0, true) }, "Don`t eat it all, leave some for Santa.", "building"), new RelicRegistration("M_YuleLogCake", "Yule Log Cake", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("Raspberry", 5, 0, true), new RequirementConfig("BarleyFlour", 1, 0, true) }, "Is not a poop is a cake.", "building"), new RelicRegistration("M_Christmas_Celebration_Cake", "Christmas Celebration Cake", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("Raspberry", 5, 0, true), new RequirementConfig("BarleyFlour", 1, 0, true) }, "A cake.", "building"), new RelicRegistration("M_Christmas_Wine", "Bottle of Wine", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("Stone", 1, 0, true), new RequirementConfig("Raspberry", 5, 0, true) }, "Moonforged Christmas Home made Wine for you all.", "building"), new RelicRegistration("M_Red_Candy_Cane_1m", "Red Candy Cane", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("Raspberry", 1, 0, true), new RequirementConfig("Coal", 1, 0, true) }, "Candy Cane decorations.", "building"), new RelicRegistration("M_Green_Candy_Cane_1m", "Green Candy Cane", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("Dandelion", 1, 0, true) }, "Candy Cane decorations.", "building"), new RelicRegistration("M_RedGreen_Candy_Cane_1m", "Red & Green Candy Cane", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("Raspberry", 1, 0, true), new RequirementConfig("Dandelion", 1, 0, true) }, "Candy Cane decorations.", "building"), new RelicRegistration("M_Green_Red_Candy_Cane_1m", "Green & Red Candy Cane", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 1, 0, true), new RequirementConfig("Raspberry", 1, 0, true), new RequirementConfig("Dandelion", 1, 0, true) }, "Candy Cane decorations.", "building"), new RelicRegistration("M_Christmas_Stocking", "Green Christmas Stocking", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("LeatherScraps", 1, 0, true), new RequirementConfig("Bloodbag", 1, 0, true) }, "", "building"), new RelicRegistration("M_Christmas_Stocking_2", "Red Christmas Stocking", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("LeatherScraps", 2, 0, true), new RequirementConfig("Raspberry", 1, 0, true) }, "", "building"), new RelicRegistration("M_Christmas_Stocking_3", "Blue Christmas Stocking", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("LeatherScraps", 2, 0, true), new RequirementConfig("Raspberry", 1, 0, true) }, "", "building"), new RelicRegistration("M_Mitten_Left", "Left hand Mitten", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("LeatherScraps", 2, 0, true), new RequirementConfig("Raspberry", 1, 0, true) }, "", "building"), new RelicRegistration("M_Mitten_Right", "Right hand Mitten", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("LeatherScraps", 2, 0, true), new RequirementConfig("Raspberry", 1, 0, true) }, "", "building"), new RelicRegistration("M_Mitten_Left_Red", "Left hand Mitten Red", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("LeatherScraps", 2, 0, true), new RequirementConfig("Raspberry", 1, 0, true) }, "", "building"), new RelicRegistration("M_Mitten_Right_Red", "Right hand Mitten Red", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("LeatherScraps", 2, 0, true), new RequirementConfig("Raspberry", 1, 0, true) }, "", "building"), new RelicRegistration("M_Snowman", "Snowman", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 3, 0, true), new RequirementConfig("Coal", 5, 0, true), new RequirementConfig("Carrot", 1, 0, true) }, "", "building"), new RelicRegistration("M_SantaClaus", "Santa Claus", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("FineWood", 10, 0, true), new RequirementConfig("LeatherScraps", 10, 0, true), new RequirementConfig("Raspberry", 10, 0, true), new RequirementConfig("Coal", 5, 0, true) }, "Saint Nicholas", "building"), new RelicRegistration("M_Small_Santa_Claus", "Small Santa Claus Figurine", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("FineWood", 2, 0, true), new RequirementConfig("LeatherScraps", 3, 0, true), new RequirementConfig("Raspberry", 3, 0, true), new RequirementConfig("Coal", 1, 0, true) }, "He`s always watching, what a creep.", "building"), new RelicRegistration("M_SantaBag", "Santa’s Bag of Gifts", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Wood", 2, 0, true), new RequirementConfig("LeatherScraps", 10, 0, true) }, "Wonder whats inside?", "building"), new RelicRegistration("M_boot", "Santa’s Boot of Gifts and Flowers", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Wood", 2, 0, true), new RequirementConfig("Raspberry", 2, 0, true) }, "You can put gifts or flowers inside the boot.", "building"), new RelicRegistration("M_Nutcracker", "Nutcracker Figurine", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("FineWood", 1, 0, true) }, "Wooden figurine with a hinged mouth for cracking nuts.", "building"), new RelicRegistration("M_Deer", "Santa’s Reindeers", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("DeerMeat", 4, 0, true), new RequirementConfig("DeerHide", 4, 0, true) }, "Dasher, Dancer, Prancer, Vixen, Comet, Cupid, Donner, Blitzen", "building"), new RelicRegistration("M_Deer_Rudy", "Rudolph the Red-Nosed Reindeer", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("DeerMeat", 4, 0, true), new RequirementConfig("DeerHide", 4, 0, true), new RequirementConfig("Raspberry", 1, 0, true) }, "A very shiny nose. You might even say it glows.", "building"), new RelicRegistration("M_Christmas_Sled", "Santa’s Sled", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 40, 0, true), new RequirementConfig("BronzeNails", 20, 0, true), new RequirementConfig("Bronze", 5, 0, true) }, "Sanat`s Christmas Sled, you can sit in it.", "building", 0, "Forge"), new RelicRegistration("M_Christmas_Train", "Christmas Train", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("Iron", 1, 0, true) }, "A small train that runs around its track and you can ride it round and round.", "building", 0, "Forge"), new RelicRegistration("M_Christmas_Banner_1", "Santa`s Christmas Banner I", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("LeatherScraps", 6, 0, true), new RequirementConfig("FineWood", 2, 0, true), new RequirementConfig("Raspberry", 2, 0, true), new RequirementConfig("Guck", 1, 0, true) }, "Reindeers under the mistletoe", "building"), new RelicRegistration("M_Christmas_Banner_2", "Santa`s Christmas Banner II", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("LeatherScraps", 6, 0, true), new RequirementConfig("FineWood", 2, 0, true), new RequirementConfig("Raspberry", 2, 0, true), new RequirementConfig("Guck", 1, 0, true) }, "Jingle bells", "building"), new RelicRegistration("M_Christmas_Banner_4", "Santa`s Christmas Banner IV", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("LeatherScraps", 6, 0, true), new RequirementConfig("FineWood", 2, 0, true), new RequirementConfig("Raspberry", 2, 0, true), new RequirementConfig("Coal", 1, 0, true) }, "Reindeers under the evening star.", "building"), new RelicRegistration("M_Bench", "Santa`s Christmas Bench", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("Iron", 2, 0, true) }, "", "building", 0, "Forge"), new RelicRegistration("M_Christmas_Throne", "Santa`s Christmas Throne", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("FineWood", 20, 0, true), new RequirementConfig("BronzeNails", 10, 0, true), new RequirementConfig("JuteRed", 2, 0, true) }, "Sit on Santa`s lap and tell him what you want for christmas.", "building", 0, "Forge"), new RelicRegistration("M_Star", "Evening Star", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 2, 0, true) }, "Can be placed on top of the Christmas tree", "building"), new RelicRegistration("Tio_de_Nadal", "Tió de Nadal", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("RoundLog", 2, 0, true), new RequirementConfig("LeatherScraps", 2, 0, true), new RequirementConfig("Raspberry", 1, 0, true) }, "", "building"), new RelicRegistration("M_icicles", "An Icicle.", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 1, 0, true) }, "Dripping ice decoration.", "building"), new RelicRegistration("ChirstmasMozaic_1", "Snowman Stained-Glass Window.", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Crystal", 1, 0, true), new RequirementConfig("FineWood", 4, 0, true) }, "", "building"), new RelicRegistration("ChirstmasMozaic_2", "Santa`s Stained-Glass Window.", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Crystal", 1, 0, true), new RequirementConfig("FineWood", 4, 0, true) }, "", "building"), new RelicRegistration("ChristmasHouseMozaic", "Christmas Home Stained-Glass Window.", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Crystal", 1, 0, true), new RequirementConfig("FineWood", 4, 0, true) }, "", "building"), new RelicRegistration("M_Wrapping_Table", "Christmas Wrapping Table.", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Wood", 5, 0, true), new RequirementConfig("FineWood", 5, 0, true) }, "From this table you can create christmas gifts and decorations.", "building", 0, ""), new RelicRegistration("M_Box", "Christmas Music Box", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("Bronze", 1, 0, true) }, "A hand-crafted wind-up Christmas music box.", "building"), new RelicRegistration("M_Sled", "Christmas Wooden Sled Decoration", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("Bronze", 1, 0, true) }, ".", "building"), new RelicRegistration("M_Elf", "Santa`s Little Helper", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("Bronze", 1, 0, true) }, ".", "building"), new RelicRegistration("M_Elf2", "Santa`s Little Elfy", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("Bronze", 1, 0, true) }, ".", "building") }; public static IEnumerable GetAllCategories() { return AllRegistrations.Select((RelicRegistration r) => CategoryToTab(r.Category)).Distinct(); } private static string CategoryToTab(string category) { string text = category.ToLower(); string text2 = text; string text3 = text2; if (text3 == "building") { return MoonforgedChristmas.PlayerPreferredCategory.Value; } return category; } public static void RegisterAllRelics(AssetBundle bundle) { if (wasAlreadyRegistered) { return; } GameObject prefab = (((Object)(object)bundle != (Object)null) ? bundle.LoadAsset("sfx_M_Box") : null); MusicBoxInteract.ConfigureSound(prefab); GameObject soundPrefab = (((Object)(object)bundle != (Object)null) ? bundle.LoadAsset("sfx_M_Train") : null); TrainPivotRotator.ConfigureTrainSound(soundPrefab); foreach (RelicRegistration allRegistration in AllRegistrations) { RegisterRelic(bundle, allRegistration); } WrappedGiftItemRegistrar.Register(bundle); WrappingPaperRegistrar.Register(bundle); wasAlreadyRegistered = true; } private static void RegisterRelic(AssetBundle bundle, RelicRegistration reg) { //IL_00c3: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: 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_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0b73: Unknown result type (might be due to invalid IL or missing references) //IL_0b7a: Expected O, but got Unknown //IL_0b91: Unknown result type (might be due to invalid IL or missing references) //IL_0b96: Unknown result type (might be due to invalid IL or missing references) //IL_0b9e: Unknown result type (might be due to invalid IL or missing references) //IL_0baa: Expected O, but got Unknown //IL_0bbb: Unknown result type (might be due to invalid IL or missing references) //IL_0bc0: Unknown result type (might be due to invalid IL or missing references) //IL_0bc8: Unknown result type (might be due to invalid IL or missing references) //IL_0bd4: Expected O, but got Unknown //IL_0c1d: Unknown result type (might be due to invalid IL or missing references) //IL_0c24: Expected O, but got Unknown //IL_0c3b: Unknown result type (might be due to invalid IL or missing references) //IL_0c40: Unknown result type (might be due to invalid IL or missing references) //IL_0c48: Unknown result type (might be due to invalid IL or missing references) //IL_0c54: Expected O, but got Unknown //IL_0c96: Unknown result type (might be due to invalid IL or missing references) //IL_0c9b: Unknown result type (might be due to invalid IL or missing references) //IL_0ca7: Unknown result type (might be due to invalid IL or missing references) //IL_0cb9: Unknown result type (might be due to invalid IL or missing references) //IL_0cc6: Unknown result type (might be due to invalid IL or missing references) //IL_0cd5: Expected O, but got Unknown //IL_0cde: Unknown result type (might be due to invalid IL or missing references) //IL_0ce8: Expected O, but got Unknown //IL_0c65: Unknown result type (might be due to invalid IL or missing references) //IL_0c6a: Unknown result type (might be due to invalid IL or missing references) //IL_0c72: Unknown result type (might be due to invalid IL or missing references) //IL_0c7e: Expected O, but got Unknown if ((Object)(object)bundle == (Object)null) { return; } if (reg.PrefabName == "M_Star") { RegisterCraftedStar(bundle, reg); return; } GameObject val = bundle.LoadAsset(reg.PrefabName); if ((Object)(object)val == (Object)null) { return; } ((Object)val).name = reg.PrefabName; if (reg.PrefabName == "M_Wrapping_Table" && (Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } if (reg.PrefabName == "M_Deer" || reg.PrefabName == "M_Deer_Rudy") { val.transform.localScale = Vector3.one * 0.014f; ScaleEnforcer scaleEnforcer = val.GetComponent() ?? val.AddComponent(); scaleEnforcer.desiredScale = Vector3.one * 0.014f; if (!Object.op_Implicit((Object)(object)val.GetComponent())) { val.AddComponent(); } if (!Object.op_Implicit((Object)(object)val.GetComponent())) { val.AddComponent(); } } if (reg.PrefabName == "M_Christmas_Tree_1") { ChildLightsCycler childLightsCycler = val.GetComponent() ?? val.AddComponent(); childLightsCycler.lightRendererNames = new string[3] { "Light1", "Light2", "Light3" }; childLightsCycler.intensity = 4.4f; childLightsCycler.stepSeconds = 1f; } if (reg.PrefabName == "Christmas_Lights1") { ChristmasLightChaserInstaller.InstallOn(val, 1f, 4.4f); } if (reg.PrefabName == "Christmas_Lights2") { ChristmasLightChaserInstaller.InstallOn(val, 0.8f, 4.4f, (Color[])(object)new Color[2] { Color.white, Color.yellow }, ChristmasLightChaser.AnimationMode.BlinkAll); } if (reg.PrefabName == "8Meter_Town_Light") { ChristmasLightChaserInstaller.InstallOn(val, 0.8f, 4.4f, (Color[])(object)new Color[2] { Color.white, Color.yellow }, ChristmasLightChaser.AnimationMode.BlinkAll); } if (reg.PrefabName == "MChristmas_Lights1" || reg.PrefabName == "MChristmas_LongLights1") { ChristmasLightChaserInstaller.InstallOn(val, 1f, 4.4f, (Color[])(object)new Color[3] { Color.red, Color.yellow, Color.blue }, ChristmasLightChaser.AnimationMode.Chase); } if (reg.PrefabName == "M_Garland_Spiral_Green") { ChristmasLightChaserInstaller.InstallOn(val, 1f, 4.4f, (Color[])(object)new Color[3] { Color.red, Color.yellow, Color.blue }, ChristmasLightChaser.AnimationMode.Chase); } if (reg.PrefabName == "M_Garland_Spiral_White") { ChristmasLightChaserInstaller.InstallOn(val, 1f, 4.4f, (Color[])(object)new Color[3] { Color.red, Color.yellow, Color.blue }, ChristmasLightChaser.AnimationMode.Chase); } if (reg.PrefabName == "M_Icicle_Lamp") { IcicleLampFlow icicleLampFlow = val.GetComponent() ?? val.AddComponent(); icicleLampFlow.columnNamePrefix = "Icicle_Lamp_"; icicleLampFlow.bulbNamePrefix = "Light_"; icicleLampFlow.raindropStepSeconds = 0.05f; icicleLampFlow.randomDropCount = 8; icicleLampFlow.pauseBetweenAnimations = 0.6f; icicleLampFlow.connectionDistance = 0.75f; icicleLampFlow.emissionIntensity = 4.5f; icicleLampFlow.dripColor = new Color(0.6f, 0.85f, 1f); } if (reg.PrefabName == "MultiStar_Light") { IcicleFlow icicleFlow = val.GetComponent() ?? val.AddComponent(); icicleFlow.columnNamePrefix = "MultiStar_Light"; icicleFlow.bulbNamePrefix = "Light"; icicleFlow.dripStepSeconds = 0.35f; icicleFlow.pauseAfterColumn = 0.6f; icicleFlow.emissionIntensity = 4.5f; icicleFlow.dripColor = new Color(0.6f, 0.85f, 1f); icicleFlow.batchCount = 4; icicleFlow.batchSpacingSeconds = 4f; icicleFlow.autoDetectVerticalAxis = true; } if (reg.PrefabName == "M_Christmas_Tree_1" || reg.PrefabName == "Christmas_Lights1" || reg.PrefabName == "Christmas_Lights2" || reg.PrefabName == "MChristmas_Lights1" || reg.PrefabName == "MChristmas_LongLights1" || reg.PrefabName == "M_Garland_Spiral_Green" || reg.PrefabName == "M_Garland_Spiral_White" || reg.PrefabName == "MultiStar_Light" || reg.PrefabName == "8Meter_Town_Light") { ConnectedLightControl connectedLightControl = val.GetComponent() ?? val.AddComponent(); connectedLightControl.prefabIdentity = reg.PrefabName; connectedLightControl.connectionDistance = 0.35f; connectedLightControl.connectionRefreshSeconds = 0.25f; connectedLightControl.rapidBlinkSeconds = 0.03f; } if (reg.PrefabName == "M_Christmas_Sled") { SledReinsConnector sledReinsConnector = val.GetComponent() ?? val.AddComponent(); sledReinsConnector.maxDeer = 9; sledReinsConnector.sledAnchorRootName = "RopeAttach"; sledReinsConnector.deerAnchorName = "ReinAnchor"; sledReinsConnector.useSingleStart = true; sledReinsConnector.verticalLift = 0f; sledReinsConnector.lateralSpacing = 0f; sledReinsConnector.forwardSpacing = 0f; sledReinsConnector.leadExtraForward = 0f; sledReinsConnector.ropeWidth = 0.018f; sledReinsConnector.ropeSag = 0.15f; sledReinsConnector.ropeSegments = 28; sledReinsConnector.windStrength = 0.25f; sledReinsConnector.jiggleAmplitude = 0.03f; sledReinsConnector.jiggleSpeed = 1.1f; } if (reg.PrefabName == "M_Christmas_Train") { InstallTrainOrbit(val, 18f, clockwise: false); } if (reg.PrefabName == "M_Wrapping_Table") { Transform val2 = val.transform.Find("Wrapping_Box"); if ((Object)(object)val2 != (Object)null) { GameObject gameObject = ((Component)val2).gameObject; if ((Object)(object)gameObject.GetComponent() == (Object)null) { gameObject.AddComponent(); } } EnsureWrappingTableCraftEffects(val); } ZNetView val3 = val.GetComponent() ?? val.AddComponent(); val3.m_persistent = true; val3.m_syncInitialScale = true; if (!Object.op_Implicit((Object)(object)val.GetComponent())) { val.AddComponent(); } Piece val4 = val.GetComponent() ?? val.AddComponent(); val4.m_name = reg.DisplayName; val4.m_description = reg.Description; val4.m_groundOnly = false; if (StockingGiftStorage.IsStockingPrefabName(reg.PrefabName)) { StockingGiftStorage.Install(val); } if (reg.PrefabName == "M_Box" && (Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } Sprite val5 = bundle.LoadAsset(reg.PrefabName); if ((Object)(object)val5 != (Object)null) { val4.m_icon = val5; } HashSet hashSet = new HashSet { "M_Gift_BlackOrange_Valheim", "M_Gift_Yellow_Deco", "M_Gift_Red_Blue", "M_SnowFlake_Blue", "M_SnowFlake_Red", "M_Garland", "M_Garland_White", "M_Garland_Spiral_Green", "M_Garland_Spiral_White", "M_Gingerbread_Man" }; HashSet hashSet2 = new HashSet { "M_Cozy_Yule_Cup", "M_Cozy_Candy_Cane_Cup", "Christmas_Cups3", "M_Christmas_Cake", "M_Christmas_Cake2", "M_icicles", "M_Snowflake", "M_Snowflake2", "M_Snowflake3", "M_Snowflake4", "M_YuleLogCake" }; HashSet hashSet3 = new HashSet { "M_BigredChristmasbow", "M_BigblueChristmasbow", "M_Small_Santa_Claus", "M_Christmas_Wine", "M_MilkandCookiesforSanta", "M_boot", "8Meter_Town_Light", "MultiStar_Light", "Christmas_Lights1", "Christmas_Lights2", "MChristmas_Lights1", "MChristmas_LongLights1", "M_Icicle_Lamp" }; HashSet hashSet4 = new HashSet { "M_Red_Candy_Cane_1m", "M_Green_Candy_Cane_1m", "M_RedGreen_Candy_Cane_1m", "M_Green_Red_Candy_Cane_1m" }; HashSet hashSet5 = new HashSet { "M_Christmas_Sled", "M_Christmas_Train", "M_Bench" }; string prefabName = reg.PrefabName; GameObject val6 = null; ZNetScene instance = ZNetScene.instance; GameObject val7 = ((instance != null) ? instance.GetPrefab("sfx_build_hammer_default") : null); GameObject val8 = null; ZNetScene instance2 = ZNetScene.instance; GameObject val9 = ((instance2 != null) ? instance2.GetPrefab("sfx_wood_destroyed") : null); if (hashSet.Contains(prefabName)) { ZNetScene instance3 = ZNetScene.instance; val7 = ((instance3 != null) ? instance3.GetPrefab("sfx_build_hammer_default") : null); ZNetScene instance4 = ZNetScene.instance; val9 = ((instance4 != null) ? instance4.GetPrefab("sfx_wood_destroyed") : null); } else if (hashSet2.Contains(prefabName) || hashSet3.Contains(prefabName)) { ZNetScene instance5 = ZNetScene.instance; val7 = ((instance5 != null) ? instance5.GetPrefab("sfx_build_hammer_crystal") : null); ZNetScene instance6 = ZNetScene.instance; val9 = ((instance6 != null) ? instance6.GetPrefab("sfx_clay_pot_break") : null); } else if (hashSet4.Contains(prefabName)) { ZNetScene instance7 = ZNetScene.instance; val6 = ((instance7 != null) ? instance7.GetPrefab("vfx_Place_stone") : null); ZNetScene instance8 = ZNetScene.instance; val7 = ((instance8 != null) ? instance8.GetPrefab("sfx_build_hammer_metal") : null); ZNetScene instance9 = ZNetScene.instance; val8 = ((instance9 != null) ? instance9.GetPrefab("vfx_destroyed") : null); ZNetScene instance10 = ZNetScene.instance; val9 = ((instance10 != null) ? instance10.GetPrefab("sfx_metal_blocked") : null); } else if (hashSet5.Contains(prefabName)) { ZNetScene instance11 = ZNetScene.instance; val6 = ((instance11 != null) ? instance11.GetPrefab("vfx_Place_stone") : null); ZNetScene instance12 = ZNetScene.instance; val7 = ((instance12 != null) ? instance12.GetPrefab("sfx_build_hammer_metal") : null); ZNetScene instance13 = ZNetScene.instance; val8 = ((instance13 != null) ? instance13.GetPrefab("vfx_destroyed") : null); ZNetScene instance14 = ZNetScene.instance; val9 = ((instance14 != null) ? instance14.GetPrefab("sfx_metal_blocked") : null); } EffectList val10 = new EffectList(); List list = new List(); if ((Object)(object)val6 != (Object)null) { list.Add(new EffectData { m_prefab = val6, m_enabled = true }); } if ((Object)(object)val7 != (Object)null) { list.Add(new EffectData { m_prefab = val7, m_enabled = true }); } val10.m_effectPrefabs = list.ToArray(); val4.m_placeEffect = val10; WearNTear val11 = val.GetComponent() ?? val.AddComponent(); val11.m_health = Mathf.Max(val11.m_health, 1000f); val11.m_noRoofWear = true; EffectList val12 = new EffectList(); List list2 = new List(); if ((Object)(object)val8 != (Object)null) { list2.Add(new EffectData { m_prefab = val8, m_enabled = true }); } if ((Object)(object)val9 != (Object)null) { list2.Add(new EffectData { m_prefab = val9, m_enabled = true }); } val12.m_effectPrefabs = list2.ToArray(); val11.m_destroyedEffect = val12; PieceConfig val13 = new PieceConfig { PieceTable = "Hammer", Category = CategoryToTab(reg.Category), CraftingStation = reg.CraftingStation, Requirements = reg.Requirements }; PieceManager.Instance.AddPiece(new CustomPiece(val, false, val13)); } private static void EnsureWrappingTableCraftEffects(GameObject wrappingTablePrefab) { if (!((Object)(object)wrappingTablePrefab == (Object)null)) { CraftingStation val = wrappingTablePrefab.GetComponent() ?? wrappingTablePrefab.AddComponent(); val.m_name = "Wrapping Table"; ZNetScene instance = ZNetScene.instance; GameObject sfx = ((instance != null) ? instance.GetPrefab("sfx_gui_craftitem_workbench") : null); ZNetScene instance2 = ZNetScene.instance; GameObject sfx2 = ((instance2 != null) ? instance2.GetPrefab("sfx_gui_craftitem_workbench_end") : null); GameObject vfx = null; GameObject vfx2 = null; EffectList value = MakeEffectList(vfx, sfx); EffectList value2 = MakeEffectList(vfx2, sfx2); TrySetEffectListField(val, "m_craftItemEffects", value); TrySetEffectListField(val, "m_craftItemEffect", value); TrySetEffectListField(val, "m_craftDoneEffects", value2); TrySetEffectListField(val, "m_craftItemDoneEffects", value2); TrySetEffectListField(val, "m_craftItemDoneEffect", value2); TrySetEffectListField(val, "m_repairItemEffects", value); TrySetEffectListField(val, "m_repairItemEffect", value); } } private static void TrySetEffectListField(object target, string fieldName, EffectList value) { if (target != null && !string.IsNullOrEmpty(fieldName) && value != null) { FieldInfo field = target.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(field == null) && !(field.FieldType != typeof(EffectList))) { field.SetValue(target, value); } } } private static EffectList MakeEffectList(GameObject vfx, GameObject sfx) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown EffectList val = new EffectList(); List list = new List(); if ((Object)(object)vfx != (Object)null) { list.Add(new EffectData { m_prefab = vfx, m_enabled = true }); } if ((Object)(object)sfx != (Object)null) { list.Add(new EffectData { m_prefab = sfx, m_enabled = true }); } val.m_effectPrefabs = list.ToArray(); return val; } private static void RegisterCraftedStar(AssetBundle bundle, RelicRegistration reg) { //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Expected O, but got Unknown //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Expected O, but got Unknown //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Expected O, but got Unknown if (_starRegistered) { return; } GameObject val = bundle.LoadAsset(reg.PrefabName); if ((Object)(object)val == (Object)null) { return; } ((Object)val).name = reg.PrefabName; ZNetView val2 = val.GetComponent() ?? val.AddComponent(); val2.m_persistent = true; val2.m_syncInitialScale = true; if (!Object.op_Implicit((Object)(object)val.GetComponent())) { Rigidbody val3 = val.AddComponent(); val3.useGravity = true; val3.isKinematic = false; val3.mass = 1f; } if (!Object.op_Implicit((Object)(object)val.GetComponent())) { SphereCollider val4 = val.AddComponent(); ((Collider)val4).isTrigger = false; val4.radius = 0.25f; } val.layer = LayerMask.NameToLayer("item"); ItemDrop component = val.GetComponent(); if (!((Object)(object)component == (Object)null) && component.m_itemData != null && component.m_itemData.m_shared != null) { SharedData shared = component.m_itemData.m_shared; shared.m_itemType = (ItemType)13; Transform val5 = val.transform.Find("attach"); GameObject val6 = null; if ((Object)(object)val5 != (Object)null) { Transform val7 = val5.Find("Star"); val6 = (((Object)(object)val7 != (Object)null) ? ((Component)val7).gameObject : ((Component)val5).gameObject); } else { Transform val8 = val.transform.Find("Star"); val6 = (((Object)(object)val8 != (Object)null) ? ((Component)val8).gameObject : null); } if ((Object)(object)val6 != (Object)null && (Object)(object)val6.GetComponent() == (Object)null) { val6.AddComponent(); } component.m_itemData.m_dropPrefab = val; Sprite val9 = bundle.LoadAsset(reg.PrefabName); if ((Object)(object)val9 != (Object)null) { shared.m_icons = (Sprite[])(object)new Sprite[1] { val9 }; } if (!string.IsNullOrEmpty(reg.DisplayName)) { shared.m_name = reg.DisplayName; } if (!string.IsNullOrEmpty(reg.Description)) { shared.m_description = reg.Description; } ItemManager.Instance.AddItem(new CustomItem(val, true)); ItemManager.Instance.AddRecipe(new CustomRecipe(new RecipeConfig { Item = reg.PrefabName, Amount = 1, CraftingStation = (string.IsNullOrEmpty(reg.CraftingStation) ? "Workbench" : reg.CraftingStation), Requirements = reg.Requirements })); _starRegistered = true; } } private static void InstallTrainOrbit(GameObject prefab, float degreesPerSecond = 18f, bool clockwise = true) { //IL_0028: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_00bd: Expected O, but got Unknown //IL_00cf: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00ad: Unknown result type (might be due to invalid IL or missing references) Transform transform = prefab.transform; Transform val = transform.Find("TrackCenter"); if (!Object.op_Implicit((Object)(object)val)) { Vector3 position = transform.position; Transform val2 = transform.Find("track") ?? transform.Find("Track"); if (Object.op_Implicit((Object)(object)val2)) { Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren(true); if (componentsInChildren.Length != 0) { Bounds bounds = componentsInChildren[0].bounds; for (int i = 1; i < componentsInChildren.Length; i++) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds); } position = ((Bounds)(ref bounds)).center; } } GameObject val3 = new GameObject("TrackCenter"); val = val3.transform; val.SetParent(transform, true); val.position = position; val.rotation = Quaternion.identity; } Transform val4 = val.Find("pivot") ?? val.Find("OrbitPivot"); if (!Object.op_Implicit((Object)(object)val4)) { GameObject val5 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val5).name = "pivot"; val4 = val5.transform; val4.SetParent(val, true); val4.position = val.position; val4.rotation = Quaternion.identity; val4.localScale = Vector3.one * 0.05f; Collider component = val5.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { Object.Destroy((Object)(object)component); } } TrainPivotRotator trainPivotRotator = prefab.GetComponent() ?? prefab.AddComponent(); trainPivotRotator.ConfigurePivot(val4); trainPivotRotator.degreesPerSecond = (clockwise ? Mathf.Abs(degreesPerSecond) : (0f - Mathf.Abs(degreesPerSecond))); } } public class SledReinsConnector : MonoBehaviour { private class RopeEntry { public Transform deerRoot; public Transform deerAnchor; public Transform sledAnchor; public BezierRope rope; } [Header("Hierarchy names")] public string sledAnchorRootName = "RopeAttach"; public string deerAnchorName = "ReinAnchor"; [Header("Deer selection")] public int maxDeer = 9; public float searchRadius = 20f; public float refreshSeconds = 1f; [Header("Anchor layout (local to RopeAttach)")] public bool useSingleStart = true; public Vector3 baseLocal = new Vector3(0f, 0f, 0f); public float verticalLift = 0f; public float lateralSpacing = 0.45f; public float forwardSpacing = 0.85f; public float leadExtraForward = 0.6f; [Header("Rope look")] public float ropeWidth = 0.018f; public float ropeSag = 0.35f; public int ropeSegments = 28; [Header("Cloth-like sway")] public float windStrength = 0.25f; public float jiggleAmplitude = 0.03f; public float jiggleSpeed = 1.1f; public Material ropeMaterial; private Transform _sledRoot; private readonly List _sledAnchors = new List(); private readonly List _ropes = new List(); private float _nextRefresh; private void Awake() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_00ac: Unknown result type (might be due to invalid IL or missing references) _sledRoot = FindChildRecursive(((Component)this).transform, sledAnchorRootName); if ((Object)(object)_sledRoot == (Object)null) { GameObject val = new GameObject(sledAnchorRootName); _sledRoot = val.transform; _sledRoot.SetParent(((Component)this).transform, false); _sledRoot.localPosition = Vector3.zero; _sledRoot.localRotation = Quaternion.identity; } for (int i = 0; i < 9; i++) { Transform transform = new GameObject("SledAnchor_" + i).transform; transform.SetParent(_sledRoot, false); transform.localPosition = ComputeAnchorLocal(i, 9); _sledAnchors.Add(transform); } } private void OnEnable() { _nextRefresh = 0f; } private void OnDisable() { ClearRopes(); } private void Update() { if (Time.time >= _nextRefresh) { BuildOrUpdateLinks(); _nextRefresh = Time.time + Mathf.Max(0.25f, refreshSeconds); } } private void BuildOrUpdateLinks() { //IL_0015: 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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown List source = FindDeerRoots(); Vector3 pos = ((Component)this).transform.position; Vector3 fwd = ((Component)this).transform.forward; Vector3 right = ((Component)this).transform.right; source = (from t in source.Where(delegate(Transform t) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) int result; if (Object.op_Implicit((Object)(object)t)) { Vector3 val6 = fwd; Vector3 val7 = t.position - pos; result = ((Vector3.Dot(val6, ((Vector3)(ref val7)).normalized) > 0.05f) ? 1 : 0); } else { result = 0; } return (byte)result != 0; }) orderby Vector3.Dot(fwd, t.position - pos), Mathf.Abs(Vector3.Dot(right, t.position - pos)) select t).ToList(); Transform val = ((IEnumerable)source).FirstOrDefault((Func)delegate(Transform t) { string text = ((Object)t).name.ToLowerInvariant(); return text.Contains("rudy") || text.Contains("rudolph"); }); if ((Object)(object)val != (Object)null) { source.Remove(val); source.Add(val); } int num = Mathf.Clamp(maxDeer, 0, 9); if (source.Count > num) { source.RemoveRange(num, source.Count - num); } bool flag = _ropes.Count == source.Count; if (flag) { for (int num2 = 0; num2 < _ropes.Count; num2++) { RopeEntry ropeEntry = _ropes[num2]; Transform val2 = source[num2]; if (ropeEntry == null || (Object)(object)ropeEntry.deerRoot == (Object)null || (Object)(object)val2 == (Object)null || ((Object)ropeEntry.deerRoot).GetInstanceID() != ((Object)val2).GetInstanceID()) { flag = false; break; } } } if (!flag) { ClearRopes(); for (int num3 = 0; num3 < source.Count; num3++) { _sledAnchors[num3].localPosition = ComputeAnchorLocal(num3, source.Count); Transform val3 = ResolveDeerAnchor(source[num3]); GameObject val4 = new GameObject("Rope_" + num3); val4.transform.SetParent(((Component)this).transform, false); BezierRope bezierRope = val4.AddComponent(); bezierRope.pointA = _sledAnchors[num3]; bezierRope.pointB = val3; bezierRope.width = ropeWidth; bezierRope.sag = ropeSag; bezierRope.segments = ropeSegments; bezierRope.material = ropeMaterial; bezierRope.windStrength = windStrength; bezierRope.jiggleAmplitude = jiggleAmplitude; bezierRope.jiggleSpeed = jiggleSpeed; RopeEntry ropeEntry2 = new RopeEntry(); ropeEntry2.deerRoot = source[num3]; ropeEntry2.deerAnchor = val3; ropeEntry2.sledAnchor = _sledAnchors[num3]; ropeEntry2.rope = bezierRope; _ropes.Add(ropeEntry2); } return; } for (int num4 = 0; num4 < _ropes.Count; num4++) { _sledAnchors[num4].localPosition = ComputeAnchorLocal(num4, _ropes.Count); Transform val5 = ResolveDeerAnchor(_ropes[num4].deerRoot); if ((Object)(object)val5 != (Object)(object)_ropes[num4].deerAnchor) { _ropes[num4].deerAnchor = val5; _ropes[num4].rope.pointB = val5; } } } private List FindDeerRoots() { //IL_000d: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Vector3 position = ((Component)this).transform.position; foreach (DeerMarker item in DeerMarker.All) { if (Object.op_Implicit((Object)(object)item)) { Transform transform = ((Component)item).transform; if (Vector3.Distance(transform.position, position) <= searchRadius) { list.Add(transform); } } } return list; } private Transform ResolveDeerAnchor(Transform deerRoot) { if ((Object)(object)deerRoot == (Object)null) { return null; } Transform val = FindChildRecursive(deerRoot, deerAnchorName); if ((Object)(object)val != (Object)null) { return val; } Transform val2 = FindChildContains(deerRoot, "Head"); if ((Object)(object)val2 == (Object)null) { val2 = FindChildContains(deerRoot, "Neck"); } if ((Object)(object)val2 != (Object)null) { return val2; } return deerRoot; } private Transform FindChildRecursive(Transform root, string exact) { if ((Object)(object)root == (Object)null) { return null; } for (int i = 0; i < root.childCount; i++) { Transform child = root.GetChild(i); if (((Object)child).name == exact) { return child; } Transform val = FindChildRecursive(child, exact); if ((Object)(object)val != (Object)null) { return val; } } return null; } private Transform FindChildContains(Transform root, string contains) { if ((Object)(object)root == (Object)null) { return null; } string value = contains.ToLowerInvariant(); for (int i = 0; i < root.childCount; i++) { Transform child = root.GetChild(i); if (((Object)child).name.ToLowerInvariant().Contains(value)) { return child; } Transform val = FindChildContains(child, contains); if ((Object)(object)val != (Object)null) { return val; } } return null; } private Vector3 ComputeAnchorLocal(int index, int total) { //IL_001b: 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_002b: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b5: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (useSingleStart) { return Vector3.zero; } Vector3 val = baseLocal + Vector3.up * verticalLift; if (total >= 9 && index == total - 1) { int num = 4; return val + Vector3.forward * ((float)num * forwardSpacing + leadExtraForward); } int num2 = index / 2; float num3 = ((index % 2 == 1) ? 1f : (-1f)); val += Vector3.forward * ((float)num2 * forwardSpacing); return val + Vector3.right * (num3 * lateralSpacing); } private void ClearRopes() { for (int i = 0; i < _ropes.Count; i++) { RopeEntry ropeEntry = _ropes[i]; if (ropeEntry != null && (Object)(object)ropeEntry.rope != (Object)null) { Object.Destroy((Object)(object)((Component)ropeEntry.rope).gameObject); } } _ropes.Clear(); } } public class StockingGiftStorage : MonoBehaviour { private const string VisualZdoKey = "mf_stocking_visual_full"; private const string EmptyVisualName = "Visual_Empty"; private const string FullVisualName = "Visual_Full"; private Container container; private ZNetView nview; private GameObject emptyVisual; private GameObject fullVisual; private float nextCheckTime; private float nextInvalidItemMessageTime; public static bool IsStockingPrefabName(string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return false; } return prefabName.IndexOf("Stocking_", StringComparison.OrdinalIgnoreCase) >= 0 || string.Equals(prefabName, "M_Christmas_Stocking", StringComparison.OrdinalIgnoreCase); } public static void Install(GameObject prefab) { if (!((Object)(object)prefab == (Object)null)) { Container target = prefab.GetComponent() ?? prefab.AddComponent(); SetContainerField(target, "m_name", "Christmas Stocking"); SetContainerField(target, "m_width", 2); SetContainerField(target, "m_height", 1); SetContainerField(target, "m_autoDestroyEmpty", false); SetContainerField(target, "m_usePrefabName", false); if ((Object)(object)prefab.GetComponent() == (Object)null) { prefab.AddComponent(); } } } private static void SetContainerField(Container target, string fieldName, object value) { if (!((Object)(object)target == (Object)null)) { FieldInfo field = typeof(Container).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(target, value); } } } private void Awake() { container = ((Component)this).GetComponent(); nview = ((Component)this).GetComponent(); CacheVisuals(); } private void Start() { RefreshStorageState(); } private void Update() { if (!(Time.time < nextCheckTime)) { nextCheckTime = Time.time + 0.1f; RefreshStorageState(); } } public string GetDisplayName() { Piece component = ((Component)this).GetComponent(); return ((Object)(object)component != (Object)null && !string.IsNullOrWhiteSpace(component.m_name)) ? component.m_name : "Christmas Stocking"; } public string GetStorageHoverText() { return GetDisplayName() + "\n[E] Open\n" + GetStoredGiftCount() + "/2 wrapped gifts"; } private void RefreshStorageState() { if ((Object)(object)container == (Object)null) { container = ((Component)this).GetComponent(); } if ((Object)(object)container == (Object)null) { return; } if ((Object)(object)nview == (Object)null) { nview = ((Component)this).GetComponent(); } CacheVisuals(); Inventory inventory = container.GetInventory(); if (inventory != null) { if ((Object)(object)nview != (Object)null && nview.IsValid() && nview.IsOwner()) { ReturnInvalidItems(inventory); } int num = CountWrappingTableGifts(inventory.GetAllItems()); UpdateVisualState(num > 0); } } private int GetStoredGiftCount() { if ((Object)(object)container == (Object)null) { container = ((Component)this).GetComponent(); } Inventory val = (((Object)(object)container != (Object)null) ? container.GetInventory() : null); return (val != null) ? CountWrappingTableGifts(val.GetAllItems()) : 0; } private void CacheVisuals() { if ((Object)(object)emptyVisual == (Object)null) { Transform val = FindChildByName(((Component)this).transform, "Visual_Empty"); if ((Object)(object)val != (Object)null) { emptyVisual = ((Component)val).gameObject; } } if ((Object)(object)fullVisual == (Object)null) { Transform val2 = FindChildByName(((Component)this).transform, "Visual_Full"); if ((Object)(object)val2 != (Object)null) { fullVisual = ((Component)val2).gameObject; } } } private void UpdateVisualState(bool hasGift) { bool flag = hasGift; if ((Object)(object)nview != (Object)null && nview.IsValid()) { ZDO zDO = nview.GetZDO(); if (zDO != null) { int num = (hasGift ? 1 : 0); if (nview.IsOwner()) { if (zDO.GetInt("mf_stocking_visual_full", -1) != num) { zDO.Set("mf_stocking_visual_full", num); } } else { flag = zDO.GetInt("mf_stocking_visual_full", num) == 1; } } } if ((Object)(object)emptyVisual != (Object)null && emptyVisual.activeSelf == flag) { emptyVisual.SetActive(!flag); } if ((Object)(object)fullVisual != (Object)null && fullVisual.activeSelf != flag) { fullVisual.SetActive(flag); } } private void ReturnInvalidItems(Inventory stockingInventory) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory == null) { return; } List list = new List(stockingInventory.GetAllItems()); bool flag = false; for (int i = 0; i < list.Count; i++) { ItemData val = list[i]; if (val != null && !((Object)(object)val.m_dropPrefab == (Object)null) && !IsWrappingTableGift(val)) { ItemData val2 = val.Clone(); if (inventory.CanAddItem(val2, -1) && inventory.AddItem(val2)) { stockingInventory.RemoveItem(val); flag = true; } } } if (flag && Time.time >= nextInvalidItemMessageTime) { nextInvalidItemMessageTime = Time.time + 1f; ((Character)localPlayer).Message((MessageType)2, "Only gifts made at the wrapping table can be placed in a Christmas stocking.", 0, (Sprite)null, false); } } private static int CountWrappingTableGifts(List items) { int num = 0; for (int i = 0; i < items.Count; i++) { if (IsWrappingTableGift(items[i])) { num += Mathf.Max(1, items[i].m_stack); } } return num; } private static bool IsWrappingTableGift(ItemData item) { if (!IsGiftPrefab(item) || item.m_customData == null) { return false; } Dictionary customData = item.m_customData; string value; return customData.TryGetValue("wrapped_prefab", out value) && !string.IsNullOrEmpty(value) && customData.ContainsKey("wrapped_stack") && customData.ContainsKey("wrapped_quality") && customData.ContainsKey("wrapped_variant") && customData.ContainsKey("wrapped_durability"); } private static bool IsGiftPrefab(ItemData item) { if (item == null || (Object)(object)item.m_dropPrefab == (Object)null) { return false; } string name = ((Object)item.m_dropPrefab).name; if (string.IsNullOrEmpty(name)) { return false; } return name.StartsWith("M_Gift_", StringComparison.Ordinal) || name.StartsWith("M_SnowFlake_", StringComparison.Ordinal) || name == "M_Gree_Gold_Gift"; } private static Transform FindChildByName(Transform root, string childName) { if ((Object)(object)root == (Object)null || string.IsNullOrEmpty(childName)) { return null; } Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if ((Object)(object)val != (Object)null && string.Equals(((Object)val).name, childName, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } } [HarmonyPatch(typeof(Container), "GetHoverName")] internal static class StockingGiftStorageHoverNamePatch { private static void Postfix(Container __instance, ref string __result) { if (!((Object)(object)__instance == (Object)null)) { StockingGiftStorage component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { __result = component.GetDisplayName(); } } } } [HarmonyPatch(typeof(Container), "GetHoverText")] internal static class StockingGiftStorageHoverTextPatch { private static void Postfix(Container __instance, ref string __result) { if (!((Object)(object)__instance == (Object)null)) { StockingGiftStorage component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { __result = component.GetStorageHoverText(); } } } } [DisallowMultipleComponent] public class TrainPivotRotator : MonoBehaviour, Hoverable, Interactable { private const string StartRpcName = "MoonforgedChristmas_StartTrain"; private const string StopRpcName = "MoonforgedChristmas_StopTrain"; private const float RunDurationSeconds = 31.378f; private static GameObject trainSoundPrefab; public float degreesPerSecond = 10f; private Piece piece; private ZNetView networkView; private Transform trainPivot; private GameObject activeSoundInstance; private AudioSource activeAudioSource; private float runElapsed; private bool rpcReady; private bool isMoving; public static void ConfigureTrainSound(GameObject soundPrefab) { trainSoundPrefab = soundPrefab; } public void ConfigurePivot(Transform pivot) { trainPivot = pivot; } private void Awake() { piece = ((Component)this).GetComponent(); networkView = ((Component)this).GetComponent(); ResolvePivot(); TryRegisterRpcs(); } private void Update() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)piece == (Object)null) { piece = ((Component)this).GetComponent(); } if ((Object)(object)networkView == (Object)null) { networkView = ((Component)this).GetComponent(); } TryRegisterRpcs(); if ((Object)(object)trainPivot == (Object)null) { ResolvePivot(); } if (isMoving && !((Object)(object)trainPivot == (Object)null)) { float num = Mathf.Max(0f, 31.378f - runElapsed); float num2 = Mathf.Min(Time.deltaTime, num); trainPivot.Rotate(Vector3.up, degreesPerSecond * num2, (Space)0); runElapsed += Time.deltaTime; if (runElapsed >= 31.378f) { StopTrain(); } } } private void TryRegisterRpcs() { if (!rpcReady && !((Object)(object)networkView == (Object)null)) { networkView.Register("MoonforgedChristmas_StartTrain", (Action)RpcStartTrain); networkView.Register("MoonforgedChristmas_StopTrain", (Action)RpcStopTrain); rpcReady = true; } } private void OnDisable() { StopTrain(); } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold || (Object)(object)trainPivot == (Object)null) { return false; } if (isMoving) { StopTrain(); if ((Object)(object)networkView != (Object)null && networkView.IsValid()) { networkView.InvokeRPC(ZNetView.Everybody, "MoonforgedChristmas_StopTrain", Array.Empty()); } } else { StartTrain(); if ((Object)(object)networkView != (Object)null && networkView.IsValid()) { networkView.InvokeRPC(ZNetView.Everybody, "MoonforgedChristmas_StartTrain", Array.Empty()); } } return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverText() { return GetHoverName() + (isMoving ? "\n[E] Stop train" : "\n[E] Start train"); } public string GetHoverName() { return ((Object)(object)piece != (Object)null && !string.IsNullOrWhiteSpace(piece.m_name)) ? piece.m_name : "Christmas Train"; } public float GetHoverOffset() { return 0f; } private void RpcStartTrain(long sender) { if (!isMoving) { StartTrain(); } } private void RpcStopTrain(long sender) { if (isMoving) { StopTrain(); } } private void StartTrain() { if (!((Object)(object)trainPivot == (Object)null) && !isMoving) { runElapsed = 0f; isMoving = true; PlayTrainSound(); } } private void PlayTrainSound() { //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) if (!((Object)(object)trainSoundPrefab == (Object)null) && !((Object)(object)trainPivot == (Object)null)) { activeSoundInstance = Object.Instantiate(trainSoundPrefab, trainPivot.position, Quaternion.identity); activeAudioSource = activeSoundInstance.GetComponent(); if ((Object)(object)activeAudioSource == (Object)null) { activeAudioSource = activeSoundInstance.GetComponentInChildren(true); } if ((Object)(object)activeAudioSource != (Object)null) { activeAudioSource.Stop(); activeAudioSource.playOnAwake = false; activeAudioSource.loop = false; activeAudioSource.Play(); } Object.Destroy((Object)(object)activeSoundInstance, 31.478f); } } private void StopTrain() { if ((Object)(object)activeAudioSource != (Object)null) { activeAudioSource.Stop(); } if ((Object)(object)activeSoundInstance != (Object)null) { Object.Destroy((Object)(object)activeSoundInstance); } activeAudioSource = null; activeSoundInstance = null; runElapsed = 0f; isMoving = false; } private void ResolvePivot() { Transform val = FindDeepChild(((Component)this).transform, "TrackCenter"); if (!((Object)(object)val == (Object)null)) { trainPivot = val.Find("pivot") ?? val.Find("OrbitPivot"); } } private static Transform FindDeepChild(Transform parent, string childName) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if ((Object)(object)parent == (Object)null) { return null; } foreach (Transform item in parent) { Transform val = item; if (string.Equals(((Object)val).name, childName, StringComparison.OrdinalIgnoreCase)) { return val; } Transform val2 = FindDeepChild(val, childName); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } }