using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("MistsofAvalor")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Mists of Avalor: Procedural Labyrinth Dimension")] [assembly: AssemblyFileVersion("0.1.11.0")] [assembly: AssemblyInformationalVersion("0.1.11+272d11ecfb195f66ec9380a7f0dc86b9cf9145a2")] [assembly: AssemblyProduct("MistsofAvalor")] [assembly: AssemblyTitle("MistsofAvalor")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.11.0")] [module: UnverifiableCode] namespace MistsofAvalor; public enum AvalorAtmoKind { Mist, Torch } public class AvalorAtmoProp : MonoBehaviour { public AvalorAtmoKind Kind; public const string AlwaysLitKey = "AvalorAlwaysLit"; private ParticleSystem[] _systems; private ParticleSystemRenderer[] _psRenderers; private Light[] _lights; private float[] _baseRate; private MinMaxGradient[] _baseColor; private float[] _baseIntensity; private ZNetView _nview; private float _bias; private float _timer; private bool _ready; private float _lastBright = -1f; private float _pendingBright = -1f; private float _lastIntensity = -1f; public const float AlwaysLitFloor = 0.55f; private void Start() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0066: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) _systems = ((Component)this).GetComponentsInChildren(true); _psRenderers = ((Component)this).GetComponentsInChildren(true); _lights = ((Component)this).GetComponentsInChildren(true); _nview = ((Component)this).GetComponent(); _baseRate = new float[_systems.Length]; for (int i = 0; i < _systems.Length; i++) { float[] baseRate = _baseRate; int num = i; EmissionModule emission = _systems[i].emission; MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime; baseRate[num] = ((MinMaxCurve)(ref rateOverTime)).constant; } _bias = PositionBias(((Component)this).transform.position); if (Kind == AvalorAtmoKind.Torch) { TintGreen(); } _baseColor = (MinMaxGradient[])(object)new MinMaxGradient[_systems.Length]; for (int j = 0; j < _systems.Length; j++) { if ((Object)(object)_systems[j] != (Object)null) { MinMaxGradient[] baseColor = _baseColor; int num2 = j; MainModule main = _systems[j].main; baseColor[num2] = ((MainModule)(ref main)).startColor; } } _baseIntensity = new float[_lights.Length]; for (int k = 0; k < _lights.Length; k++) { if ((Object)(object)_lights[k] != (Object)null) { _baseIntensity[k] = _lights[k].intensity; } } _ready = true; Apply(force: true); } private void Update() { if (_ready) { _timer += Time.deltaTime; if (!(_timer < 1f)) { _timer = 0f; Apply(force: false); } } } private void Apply(bool force) { //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) bool flag = (Object)(object)_nview != (Object)null && _nview.IsValid() && _nview.GetZDO() != null && _nview.GetZDO().GetInt("AvalorAlwaysLit", 0) == 1; float num = 1f; float num2; if (Kind == AvalorAtmoKind.Mist) { num2 = MistFraction(MistsofAvalorPlugin.MistConfig.Value); } else { LightingLevel value = MistsofAvalorPlugin.LightingConfig.Value; num = (flag ? Mathf.Max(TorchIntensityFor(value), 0.55f) : TorchIntensityFor(value)); num2 = ((flag || value != LightingLevel.None) ? 1f : 0f); } bool flag2 = num2 > 0f && _bias < num2; if (!flag2 && flag) { flag2 = true; } bool flag3 = Kind == AvalorAtmoKind.Torch && (force || !Mathf.Approximately(num, _lastIntensity)); for (int i = 0; i < _lights.Length; i++) { if (!((Object)(object)_lights[i] == (Object)null)) { if (((Behaviour)_lights[i]).enabled != flag2) { ((Behaviour)_lights[i]).enabled = flag2; } if (flag3) { _lights[i].intensity = _baseIntensity[i] * num; } } } if (flag3) { _lastIntensity = num; } for (int j = 0; j < _systems.Length; j++) { ParticleSystem val = _systems[j]; if ((Object)(object)val == (Object)null) { continue; } if (flag2) { EmissionModule emission = val.emission; float num3 = ((Kind == AvalorAtmoKind.Mist) ? Mathf.Lerp(0.15f, 1f, num2) : 1f); ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(_baseRate[j] * num3); if (!((EmissionModule)(ref emission)).enabled) { ((EmissionModule)(ref emission)).enabled = true; } if (Kind == AvalorAtmoKind.Mist && _baseColor != null) { float num4 = AvalorCryptEnvZone.MistBrightnessFor(MistsofAvalorPlugin.LightingConfig.Value); if (force || !Mathf.Approximately(num4, _lastBright)) { MainModule main = val.main; ((MainModule)(ref main)).startColor = Dim(_baseColor[j], num4); _pendingBright = num4; } } if (!val.isPlaying) { val.Play(false); } } else if (val.isPlaying) { val.Stop(false, (ParticleSystemStopBehavior)0); } } for (int k = 0; k < _psRenderers.Length; k++) { if ((Object)(object)_psRenderers[k] != (Object)null) { ((Renderer)_psRenderers[k]).enabled = flag2; } } if (_pendingBright >= 0f) { _lastBright = _pendingBright; _pendingBright = -1f; } } private static MinMaxGradient Dim(MinMaxGradient src, float f) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_002c: 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) //IL_000c: 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_0019: 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_0024: Unknown result type (might be due to invalid IL or missing references) if ((int)((MinMaxGradient)(ref src)).mode == 2) { return new MinMaxGradient(Scale(((MinMaxGradient)(ref src)).colorMin, f), Scale(((MinMaxGradient)(ref src)).colorMax, f)); } return new MinMaxGradient(Scale(((MinMaxGradient)(ref src)).color, f)); } private static Color Scale(Color c, float f) { //IL_0000: 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_0010: 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) return new Color(c.r * f, c.g * f, c.b * f, c.a * f); } private void TintGreen() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_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_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_0065: 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_006c: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0073: Invalid comparison between Unknown and I4 //IL_0096: 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_009c: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Color avalorGreen = AvalorCryptEnvZone.AvalorGreen; Light[] lights = _lights; foreach (Light val in lights) { if (!((Object)(object)val == (Object)null)) { val.color = avalorGreen; } } ParticleSystem[] systems = _systems; foreach (ParticleSystem val2 in systems) { if ((Object)(object)val2 == (Object)null) { continue; } MainModule main = val2.main; MinMaxGradient startColor = ((MainModule)(ref main)).startColor; ParticleSystemGradientMode mode = ((MinMaxGradient)(ref startColor)).mode; if ((int)mode != 0) { if ((int)mode == 2) { ((MainModule)(ref main)).startColor = new MinMaxGradient(Recolor(((MinMaxGradient)(ref startColor)).colorMin, avalorGreen), Recolor(((MinMaxGradient)(ref startColor)).colorMax, avalorGreen)); } else { ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Recolor(((MinMaxGradient)(ref startColor)).color, avalorGreen)); } } else { ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Recolor(((MinMaxGradient)(ref startColor)).color, avalorGreen)); } } } private static Color Recolor(Color src, Color green) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) float num = Mathf.Max(0.15f, ((Color)(ref src)).grayscale); Color result = green * num; result.a = src.a; return result; } private static float PositionBias(Vector3 p) { //IL_0000: 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_0023: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.RoundToInt(p.x * 4f); int num2 = Mathf.RoundToInt(p.y * 4f); int num3 = Mathf.RoundToInt(p.z * 4f); int num4 = (num * 73856093) ^ (num2 * 19349663) ^ (num3 * 83492791); int num5 = (num4 ^ (num4 >>> 13)) * -2048144789; return (float)((uint)(num5 ^ (num5 >>> 16)) % 100000u) / 100000f; } public static float MistFraction(MistDensity d) { return d switch { MistDensity.None => 0f, MistDensity.Little => 0.05f, MistDensity.Normal => 0.25f, MistDensity.More => 0.55f, MistDensity.Most => 1f, _ => 0.25f, }; } public static float TorchIntensityFor(LightingLevel l) { return l switch { LightingLevel.None => 0f, LightingLevel.Some => 0.38f, LightingLevel.More => 0.68f, LightingLevel.Most => 1f, _ => 0.38f, }; } } public class AvalorCryptEnvZone : MonoBehaviour { private const string CryptEnv = "Crypt"; private float timer; private bool forcing; public static bool DebugBright = false; public static readonly Color AvalorGreen = new Color(0.3f, 1f, 0.55f); private static readonly Color FogGreen = new Color(0.1f, 0.26f, 0.19f); private const float GreenTint = 0.45f; private const float GreenBoost = 1.15f; private static readonly Color BaseAmbient = new Color(0.42f, 0.46f, 0.44f); private int _paintedFrame = -1; private bool _reportedFight; private bool _paintedWanted; private float _paintedDensity; private readonly List _suppressed = new List(); private static readonly FieldInfo CurrentPSystemsField = AccessTools.Field(typeof(EnvMan), "m_currentPSystems"); private void Update() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) bool flag = (Object)(object)Player.m_localPlayer != (Object)null && AvalorRegion.InSkyMaze(((Component)Player.m_localPlayer).transform.position); bool flag2 = !forcing && flag; timer += Time.deltaTime; if (timer < 1f && !flag2) { return; } timer = 0f; if ((Object)(object)EnvMan.instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { forcing = false; } else if (flag) { if (!forcing && MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"[Avalor] Entered sky maze - forcing 'Crypt' environment (overriding biome)."); } EnvMan.instance.SetForceEnvironment("Crypt"); forcing = true; } else if (forcing) { if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"[Avalor] Left sky maze - releasing forced environment."); } EnvMan.instance.SetForceEnvironment(""); forcing = false; } } private void OnEnable() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown Camera.onPreRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreRender, (Delegate?)new CameraCallback(OnAnyCameraPreRender)); } private void OnDisable() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown Camera.onPreRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreRender, (Delegate?)new CameraCallback(OnAnyCameraPreRender)); } private void OnAnyCameraPreRender(Camera cam) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (Time.frameCount != _paintedFrame) { _paintedFrame = Time.frameCount; if (!_reportedFight && _paintedWanted && (Object)(object)Player.m_localPlayer != (Object)null && AvalorRegion.InSkyMaze(((Component)Player.m_localPlayer).transform.position) && (!RenderSettings.fog || RenderSettings.fogDensity < _paintedDensity * 0.5f)) { _reportedFight = true; Logger.LogWarning((object)"[Avalor][FAIL] something else is clearing the labyrinth's fog after our LateUpdate (a de-misting mod, most likely). Re-asserting it at render time, so the maze keeps its mist - but if the fog still looks wrong, that mod is the reason."); } Paint(); } } private void LateUpdate() { Paint(); } private void Paint() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_00d9: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { RestoreEnvParticles(); _paintedWanted = false; return; } if (!AvalorRegion.InSkyMaze(((Component)Player.m_localPlayer).transform.position)) { RestoreEnvParticles(); _paintedWanted = false; return; } if (DebugBright) { RenderSettings.ambientLight = new Color(0.9f, 0.9f, 0.9f); RenderSettings.fogDensity = 0f; _paintedWanted = false; return; } MistDensity value = MistsofAvalorPlugin.MistConfig.Value; bool flag = (RenderSettings.fog = value != MistDensity.None); if (flag) { RenderSettings.fogMode = (FogMode)3; RenderSettings.fogColor = FogGreen; RenderSettings.fogDensity = FogDensityFor(value); } _paintedWanted = flag; _paintedDensity = (flag ? FogDensityFor(value) : 0f); ApplyEnvParticles(flag); float num = AmbientScaleFor(MistsofAvalorPlugin.LightingConfig.Value); Color val = BaseAmbient * num; RenderSettings.ambientLight = Color.Lerp(val, AvalorGreen * ((Color)(ref val)).grayscale * 1.15f, 0.45f); } private void ApplyEnvParticles(bool wanted) { if (wanted) { RestoreEnvParticles(); } else { if ((Object)(object)EnvMan.instance == (Object)null || CurrentPSystemsField == null || !(CurrentPSystemsField.GetValue(EnvMan.instance) is GameObject[] array)) { return; } GameObject[] array2 = array; foreach (GameObject val in array2) { if (!((Object)(object)val == (Object)null) && val.activeSelf) { val.SetActive(false); if (!_suppressed.Contains(val)) { _suppressed.Add(val); } } } } } private void RestoreEnvParticles() { if (_suppressed.Count == 0) { return; } foreach (GameObject item in _suppressed) { if ((Object)(object)item != (Object)null) { item.SetActive(true); } } _suppressed.Clear(); } public static float FogDensityFor(MistDensity d) { return d switch { MistDensity.None => 0f, MistDensity.Little => 0.0016f, MistDensity.Normal => 0.0055f, MistDensity.More => 0.016f, MistDensity.Most => 0.042f, _ => 0.0055f, }; } public static float MistBrightnessFor(LightingLevel l) { return Mathf.Lerp(0.18f, 1f, AmbientScaleFor(l)); } public static float AmbientScaleFor(LightingLevel l) { return l switch { LightingLevel.None => 0.04f, LightingLevel.Some => 0.38f, LightingLevel.More => 0.7f, LightingLevel.Most => 1f, _ => 0.38f, }; } private void OnDestroy() { RestoreEnvParticles(); if (!forcing) { return; } forcing = false; try { if ((Object)(object)EnvMan.instance != (Object)null) { EnvMan.instance.SetForceEnvironment(""); } } catch { } } } public class AvalorExitCompass : MonoBehaviour { public static ConfigEntry CompassX; public static ConfigEntry CompassY; public static ConfigEntry CompassSize; public static ConfigEntry CompassOpacity; public static ConfigEntry CompassTilt; public static ConfigEntry CompassAdjustKey; private GameObject _uiRoot; private RectTransform _rootRt; private CanvasGroup _group; private RectTransform _disc; private RectTransform _blip; private RectTransform _blipStem; private RectTransform _player; private RectTransform[] _ring; private RectTransform[] _spokes; private Text _label; private Text _hint; private Font _valheimFont; private const float RefreshInterval = 1f; private float _timer = 1f; private Vector3 _exit; private bool _haveExit; private const float RimRange = 120f; private const int RingSegments = 56; private bool _adjusting; private bool _dragging; private Vector2 _dragOffset; private bool _dirty; private float _builtSize = -1f; private float _builtSquash = -1f; private float Squash => Mathf.Max(0.12f, Mathf.Sin(CompassTilt.Value * ((float)Math.PI / 180f))); private void Awake() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) ConfigFile config = ((BaseUnityPlugin)MistsofAvalorPlugin.Instance).Config; CompassX = config.Bind("Compass", "PositionX", -640f, "Horizontal offset of the exit compass from the centre of the screen, in pixels. Set by dragging it; you should not need to edit this by hand."); CompassY = config.Bind("Compass", "PositionY", -397f, "Vertical offset of the exit compass from the centre of the screen, in pixels. Set by dragging it; you should not need to edit this by hand."); CompassSize = config.Bind("Compass", "Size", 190f, new ConfigDescription("Diameter of the exit compass disc in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange(90f, 460f), Array.Empty())); CompassOpacity = config.Bind("Compass", "Opacity", 0.55f, new ConfigDescription("How solid the compass is. Low values keep it as a ghost over the labyrinth; 1 is fully opaque.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 1f), Array.Empty())); CompassTilt = config.Bind("Compass", "TiltDegrees", 60f, new ConfigDescription("The angle the disc is viewed from, in degrees above the horizontal. 90 is a flat top-down circle; lower lays the view down further and squashes it into a wider ellipse. 60 is the default raked view.", (AcceptableValueBase)(object)new AcceptableValueRange(15f, 90f), Array.Empty())); CompassAdjustKey = config.Bind("Compass", "AdjustKey", new KeyboardShortcut((KeyCode)308, Array.Empty()), "Hold this to move and resize the compass. While held: drag it with the left mouse button, or nudge it with the arrow keys, and resize with the mouse wheel or +/-."); } private void LateUpdate() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if (MistsofAvalorPlugin.ExitCompass == null || !MistsofAvalorPlugin.ExitCompass.Value) { Hide(); return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)Hud.instance == (Object)null) { Hide(); return; } if (!AvalorRegion.InSkyMaze(((Component)localPlayer).transform.position)) { Hide(); return; } _timer += Time.deltaTime; if (_timer >= 1f) { _timer = 0f; _haveExit = AvalorMobDirector.TryFindExit(out _exit); if (!_haveExit && AvalorNet.Role == AvalorNet.NetRole.Client) { AvalorNet.SendQuery(1); if (AvalorNet.TryGetFreshAnswer(1, 30f, out var found, out var pos) && found) { _haveExit = true; _exit = pos; } } } if (!_haveExit) { Hide(); return; } if ((Object)(object)_uiRoot == (Object)null) { CreateUI(); } if (!((Object)(object)_uiRoot == (Object)null)) { if (!_uiRoot.activeSelf) { _uiRoot.SetActive(true); } HandleAdjust(); ApplyLayout(); DrawBearing(localPlayer); } } private void HandleAdjust() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: 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_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: 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_0285: Expected O, but got Unknown //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028a: 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_02ac: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = CompassAdjustKey.Value; bool flag = ((KeyboardShortcut)(ref value)).IsPressed(); if (flag && !_adjusting) { _adjusting = true; } else if (!flag && _adjusting) { _adjusting = false; _dragging = false; if (_dirty) { _dirty = false; ((BaseUnityPlugin)MistsofAvalorPlugin.Instance).Config.Save(); } } if (_adjusting) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; float num = ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) ? 12f : 2f); if (Input.GetKey((KeyCode)276)) { ConfigEntry compassX = CompassX; compassX.Value -= num; _dirty = true; } if (Input.GetKey((KeyCode)275)) { ConfigEntry compassX2 = CompassX; compassX2.Value += num; _dirty = true; } if (Input.GetKey((KeyCode)274)) { ConfigEntry compassY = CompassY; compassY.Value -= num; _dirty = true; } if (Input.GetKey((KeyCode)273)) { ConfigEntry compassY2 = CompassY; compassY2.Value += num; _dirty = true; } float num2 = 0f; if (Input.GetKey((KeyCode)61) || Input.GetKey((KeyCode)270)) { num2 += 1.5f; } if (Input.GetKey((KeyCode)45) || Input.GetKey((KeyCode)269)) { num2 -= 1.5f; } num2 += Input.GetAxis("Mouse ScrollWheel") * 220f; if (Mathf.Abs(num2) > 0.001f) { CompassSize.Value = Mathf.Clamp(CompassSize.Value + num2, 90f, 460f); _dirty = true; RebuildRose(); } Canvas componentInParent = _uiRoot.GetComponentInParent(); Camera val = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null); if (Input.GetMouseButtonDown(0) && RectTransformUtility.RectangleContainsScreenPoint(_rootRt, Vector2.op_Implicit(Input.mousePosition), val)) { _dragging = true; Vector2 val2 = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Transform)_rootRt).parent, Vector2.op_Implicit(Input.mousePosition), val, ref val2); _dragOffset = val2 - _rootRt.anchoredPosition; } if (Input.GetMouseButtonUp(0)) { _dragging = false; } Vector2 val3 = default(Vector2); if (_dragging && RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Transform)_rootRt).parent, Vector2.op_Implicit(Input.mousePosition), val, ref val3)) { Vector2 val4 = val3 - _dragOffset; CompassX.Value = val4.x; CompassY.Value = val4.y; _dirty = true; } } } private void ApplyLayout() { //IL_011b: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00bf: 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_00f4: Unknown result type (might be due to invalid IL or missing references) float value = CompassSize.Value; if (Mathf.Abs(_builtSize - value) > 0.5f || Mathf.Abs(_builtSquash - Squash) > 0.001f) { RebuildRose(); } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(CompassX.Value, CompassY.Value); Transform parent = ((Transform)_rootRt).parent; RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val2 != (Object)null) { Rect rect = val2.rect; if (((Rect)(ref rect)).width > 1f) { rect = val2.rect; if (((Rect)(ref rect)).height > 1f) { rect = val2.rect; float num = ((Rect)(ref rect)).width * 0.5f; rect = val2.rect; float num2 = ((Rect)(ref rect)).height * 0.5f; val.x = Mathf.Clamp(val.x, 0f - num + 30f, num - 30f); val.y = Mathf.Clamp(val.y, 0f - num2 + 30f, num2 - 30f); } } } _rootRt.anchoredPosition = val; _rootRt.sizeDelta = new Vector2(value, value * Squash + 46f); _group.alpha = (_adjusting ? Mathf.Max(0.9f, CompassOpacity.Value) : CompassOpacity.Value); ((Behaviour)_hint).enabled = _adjusting; } private void DrawBearing(Player p) { //IL_0001: 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_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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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) //IL_0164: 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_0093: 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_01a9: Unknown result type (might be due to invalid IL or missing references) Vector3 val = _exit - ((Component)p).transform.position; Vector2 val2 = new Vector2(val.x, val.z); float magnitude = ((Vector2)(ref val2)).magnitude; Vector3 forward = (((Object)(object)Utils.GetMainCamera() != (Object)null) ? ((Component)Utils.GetMainCamera()).transform : ((Component)p).transform).forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { forward = Vector3.forward; } Vector3 val3 = val; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = forward; } float num = Vector3.SignedAngle(forward, val3, Vector3.up) * ((float)Math.PI / 180f); float num2 = CompassSize.Value * 0.5f; float num3 = num2 * Mathf.Clamp01(magnitude / 120f); num3 = Mathf.Max(num3, num2 * 0.06f); float num4 = Mathf.Sin(num) * num3; float num5 = Mathf.Cos(num) * num3 * Squash; float num6 = Mathf.Clamp(val.y * (num2 / 120f), (0f - num2) * 0.5f, num2 * 0.5f); _blip.anchoredPosition = new Vector2(num4, num5 + num6); _blipStem.anchoredPosition = new Vector2(num4, num5 + num6 * 0.5f); _blipStem.sizeDelta = new Vector2(2f, Mathf.Abs(num6)); ((Component)_blipStem).gameObject.SetActive(Mathf.Abs(num6) > 3f); string arg = ""; if (val.y > 3f) { arg = " above"; } else if (val.y < -3f) { arg = " below"; } _label.text = $"The Way Out {magnitude:F0}m{arg}"; } private void Hide() { if ((Object)(object)_uiRoot != (Object)null && _uiRoot.activeSelf) { _uiRoot.SetActive(false); } } private void CreateUI() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_00b8: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: 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_0300: Unknown result type (might be due to invalid IL or missing references) //IL_031f: 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_0371: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Hud.instance == (Object)null) && !((Object)(object)Hud.instance.m_rootObject == (Object)null)) { Text componentInChildren = Hud.instance.m_rootObject.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { _valheimFont = componentInChildren.font; } Font font = (((Object)(object)_valheimFont != (Object)null) ? _valheimFont : Resources.GetBuiltinResource("Arial.ttf")); _uiRoot = new GameObject("AvalorExitCompass"); _uiRoot.transform.SetParent(Hud.instance.m_rootObject.transform, false); _rootRt = _uiRoot.AddComponent(); _rootRt.anchorMin = new Vector2(0.5f, 0.5f); _rootRt.anchorMax = new Vector2(0.5f, 0.5f); _rootRt.pivot = new Vector2(0.5f, 0.5f); _group = _uiRoot.AddComponent(); _group.interactable = false; _group.blocksRaycasts = false; GameObject val = new GameObject("Disc"); val.transform.SetParent(_uiRoot.transform, false); _disc = val.AddComponent(); _disc.anchorMin = new Vector2(0.5f, 0.5f); _disc.anchorMax = new Vector2(0.5f, 0.5f); _disc.pivot = new Vector2(0.5f, 0.5f); _disc.anchoredPosition = new Vector2(0f, 14f); _ring = (RectTransform[])(object)new RectTransform[56]; for (int i = 0; i < 56; i++) { _ring[i] = Quad("Ring" + i, (Transform)(object)_disc, Ink(0.55f)); } _spokes = (RectTransform[])(object)new RectTransform[4]; for (int j = 0; j < 4; j++) { _spokes[j] = Quad("Spoke" + j, (Transform)(object)_disc, Ink(0.38f)); } _player = Quad("Player", (Transform)(object)_disc, Ink(0.95f)); _player.sizeDelta = new Vector2(7f, 7f); ((Transform)_player).localRotation = Quaternion.Euler(0f, 0f, 45f); _blipStem = Quad("BlipStem", (Transform)(object)_disc, Ink(0.45f)); _blip = Quad("Blip", (Transform)(object)_disc, new Color(0.62f, 1f, 0.78f, 1f)); _blip.sizeDelta = new Vector2(11f, 11f); ((Transform)_blip).localRotation = Quaternion.Euler(0f, 0f, 45f); _label = Label("Label", _uiRoot.transform, new Vector2(0f, 0f), 15, font); _hint = Label("Hint", _uiRoot.transform, new Vector2(0f, 0f), 12, font); ((Graphic)_hint).color = new Color(0.62f, 1f, 0.78f, 0.9f); _hint.text = "drag • arrows nudge • wheel / +- resize"; ((Behaviour)_hint).enabled = false; RebuildRose(); _uiRoot.SetActive(false); } } private void RebuildRose() { //IL_007c: 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_009e: 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_00ec: 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_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) if (_ring != null) { float value = CompassSize.Value; float num = value * 0.5f; float squash = Squash; _builtSize = value; _builtSquash = squash; for (int i = 0; i < 56; i++) { float num2 = (float)i / 56f * (float)Math.PI * 2f; float num3 = Mathf.Sin(num2) * num; float num4 = Mathf.Cos(num2) * num * squash; float num5 = Mathf.Cos(num2) * num; float num6 = (0f - Mathf.Sin(num2)) * num * squash; Vector2 val = new Vector2(num5, num6); float num7 = ((Vector2)(ref val)).magnitude * ((float)Math.PI / 28f); _ring[i].anchoredPosition = new Vector2(num3, num4); _ring[i].sizeDelta = new Vector2(Mathf.Max(num7, 2f), 2f); ((Transform)_ring[i]).localRotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(num6, num5) * 57.29578f); } for (int j = 0; j < 4; j++) { float num8 = (float)j * (float)Math.PI * 0.5f; float num9 = ((j == 0) ? 0.7f : 0.82f); float num10 = Mathf.Sin(num8) * num; float num11 = Mathf.Cos(num8) * num * squash; float num12 = num * (1f - num9); _spokes[j].anchoredPosition = new Vector2(num10 * (num9 + (1f - num9) * 0.5f), num11 * (num9 + (1f - num9) * 0.5f)); _spokes[j].sizeDelta = new Vector2(2f, Mathf.Max(num12 * ((j == 0) ? (squash + 0.3f) : squash), 3f)); ((Transform)_spokes[j]).localRotation = Quaternion.Euler(0f, 0f, (0f - num8) * 57.29578f); ((Graphic)((Component)_spokes[j]).GetComponent()).color = Ink((j == 0) ? 0.8f : 0.34f); } if ((Object)(object)_label != (Object)null) { ((RectTransform)((Component)_label).transform).anchoredPosition = new Vector2(0f, (0f - num) * squash - 4f); } if ((Object)(object)_hint != (Object)null) { ((RectTransform)((Component)_hint).transform).anchoredPosition = new Vector2(0f, num * squash + 30f); } } } private static Color Ink(float a) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0019: Unknown result type (might be due to invalid IL or missing references) Color avalorGreen = AvalorCryptEnvZone.AvalorGreen; return new Color(avalorGreen.r, avalorGreen.g, avalorGreen.b, a); } private static RectTransform Quad(string name, Transform parent, Color colour) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0025: 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_004f: 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_0075: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent(); obj.anchorMin = new Vector2(0.5f, 0.5f); obj.anchorMax = new Vector2(0.5f, 0.5f); obj.pivot = new Vector2(0.5f, 0.5f); obj.sizeDelta = new Vector2(2f, 2f); Image obj2 = val.AddComponent(); ((Graphic)obj2).color = colour; ((Graphic)obj2).raycastTarget = false; return obj; } private static Text Label(string name, Transform parent, Vector2 pos, int fontSize, Font font) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0025: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_00a5: 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_00e5: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent(); obj.anchorMin = new Vector2(0.5f, 0.5f); obj.anchorMax = new Vector2(0.5f, 0.5f); obj.pivot = new Vector2(0.5f, 0.5f); obj.anchoredPosition = pos; obj.sizeDelta = new Vector2(360f, 22f); Text obj2 = val.AddComponent(); obj2.font = font; obj2.fontSize = fontSize; obj2.alignment = (TextAnchor)4; ((Graphic)obj2).color = new Color(0.86f, 0.94f, 0.88f, 0.92f); ((Graphic)obj2).raycastTarget = false; Shadow obj3 = val.AddComponent(); obj3.effectColor = new Color(0f, 0f, 0f, 0.85f); obj3.effectDistance = new Vector2(1f, -1f); return obj2; } } public class AvalorPortalEnvZone : MonoBehaviour { private const float OuterRadius = 32f; private const float InnerRadius = 14f; private static readonly Color GloomFog = new Color(0.16f, 0.34f, 0.25f); private const float GloomFogDensity = 0.028f; private const float AmbientDarken = 0.75f; private const float GreenTint = 0.55f; private bool _haveBase; private Color _baseFog; private Color _baseAmbient; private float _baseDensity; private bool _baseFogEnabled; private void LateUpdate() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } Vector3 position = ((Component)Player.m_localPlayer).transform.position; if (position.x > 25000f) { return; } float num = Vector3.Distance(position, ((Component)this).transform.position); float num2 = Mathf.Clamp01(Mathf.InverseLerp(32f, 14f, num)); if (num2 <= 0f) { _baseFog = RenderSettings.fogColor; _baseAmbient = RenderSettings.ambientLight; _baseDensity = RenderSettings.fogDensity; _baseFogEnabled = RenderSettings.fog; _haveBase = true; return; } if (!_haveBase) { _baseFog = RenderSettings.fogColor; _baseAmbient = RenderSettings.ambientLight; _baseDensity = RenderSettings.fogDensity; _baseFogEnabled = RenderSettings.fog; _haveBase = true; } num2 = Mathf.SmoothStep(0f, 1f, num2); RenderSettings.fog = true; RenderSettings.fogColor = Color.Lerp(_baseFog, GloomFog, num2); RenderSettings.fogDensity = Mathf.Lerp(_baseFogEnabled ? _baseDensity : 0f, 0.028f, num2); Color val = _baseAmbient * 0.75f; Color val2 = AvalorCryptEnvZone.AvalorGreen * ((Color)(ref val)).grayscale * 1.5f; RenderSettings.ambientLight = Color.Lerp(_baseAmbient, Color.Lerp(val, val2, 0.55f), num2); } } public class AvalorPortalRuneVFX : MonoBehaviour { public Color Colour = new Color(0.3f, 1f, 0.55f); public float GateWidth = 3.2f; public float GateHeight = 7f; [NonSerialized] public float Charge; private ParticleSystem _veil; private ParticleSystem _motes; private LineRenderer _ringA; private LineRenderer _ringB; private LineRenderer _sigil; private LineRenderer _sigilInner; private LineRenderer[] _spokes; private ParticleSystem _sigilRunes; private float _spin; private const int RingSegments = 64; private static Texture2D _atlasTex; private static Texture2D _softTex; private void Start() { //IL_000d: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_atlasTex == (Object)null) { _atlasTex = AvalorRuneTexture.GenerateRuneAtlas(Color.white); } if ((Object)(object)_softTex == (Object)null) { _softTex = AvalorRuneTexture.GenerateSoftTrail(Color.white); } Texture2D atlasTex = _atlasTex; Texture2D softTex = _softTex; Material orCreateRuneMaterial = AvalorRuneMaterial.GetOrCreateRuneMaterial(atlasTex, Colour); Material orCreateRuneMaterial2 = AvalorRuneMaterial.GetOrCreateRuneMaterial(softTex, Colour); if ((Object)(object)orCreateRuneMaterial == (Object)null || (Object)(object)orCreateRuneMaterial2 == (Object)null) { Logger.LogWarning((object)"[Avalor] rune VFX: no usable particle shader - portal keeps vanilla effects only."); ((Behaviour)this).enabled = false; return; } BuildVeil(orCreateRuneMaterial); BuildRings(orCreateRuneMaterial2); BuildSigil(orCreateRuneMaterial2, orCreateRuneMaterial); BuildMotes(orCreateRuneMaterial); } private void BuildVeil(Material mat) { //IL_001c: 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_005b: 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_0087: 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_00c3: 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_00e0: 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) //IL_0125: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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) GameObject val = Child("RuneVeil", new Vector3(0f, GateHeight * 0.42f, 0f)); _veil = val.AddComponent(); MainModule main = _veil.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = true; ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.15f, 0.5f); ((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.6f, 3.2f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.22f, 0.55f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Colour); ((MainModule)(ref main)).maxParticles = 220; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0; ((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f); EmissionModule emission = _veil.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(26f); ShapeModule shape = _veil.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5; ((ShapeModule)(ref shape)).scale = new Vector3(GateWidth * 0.82f, GateHeight * 0.72f, 0.12f); VelocityOverLifetimeModule velocityOverLifetime = _veil.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(-0.06f, 0.06f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.25f, 0.75f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(-0.06f, 0.06f); FadeInOut(_veil); Atlas(_veil); ParticleSystemRenderer component = val.GetComponent(); component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).material = mat; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; } private void BuildRings(Material glow) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_00ea: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) float num = GateWidth * 0.44f; _ringA = BuildCircle("RuneRingA", new Vector3(0f, GateHeight * 0.45f, 0f), num, glow, 0.055f, vertical: true); _ringB = BuildCircle("RuneRingB", new Vector3(0f, GateHeight * 0.45f, 0f), num * 0.68f, glow, 0.04f, vertical: true); _spokes = (LineRenderer[])(object)new LineRenderer[4]; for (int i = 0; i < _spokes.Length; i++) { LineRenderer val = Child("RuneSpoke" + i, new Vector3(0f, GateHeight * 0.45f, 0f)).AddComponent(); float num2 = (float)Math.PI / (float)_spokes.Length * (float)i; Vector3 val2 = new Vector3(Mathf.Cos(num2), Mathf.Sin(num2), 0f) * (num * 0.68f); Line(val, glow, 0.03f, (Vector3[])(object)new Vector3[2] { -val2, val2 }); _spokes[i] = val; } } private void BuildSigil(Material glow, Material runeMat) { //IL_0023: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00bc: 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_00e8: 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) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) float num = GateWidth * 0.85f; _sigil = BuildCircle("SigilOuter", new Vector3(0f, 0.06f, 0f), num, glow, 0.07f, vertical: false); _sigilInner = BuildCircle("SigilInner", new Vector3(0f, 0.06f, 0f), num * 0.62f, glow, 0.05f, vertical: false); GameObject val = Child("SigilRunes", new Vector3(0f, 0.35f, 0f)); _sigilRunes = val.AddComponent(); MainModule main = _sigilRunes.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = true; ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.4f, 2.6f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.3f, 0.5f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Colour); ((MainModule)(ref main)).maxParticles = 90; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0; EmissionModule emission = _sigilRunes.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(14f); ShapeModule shape = _sigilRunes.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10; ((ShapeModule)(ref shape)).radius = num * 0.9f; ((ShapeModule)(ref shape)).radiusThickness = 0f; ((ShapeModule)(ref shape)).rotation = new Vector3(90f, 0f, 0f); FadeInOut(_sigilRunes); Atlas(_sigilRunes); ParticleSystemRenderer component = val.GetComponent(); component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).material = runeMat; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; } private void BuildMotes(Material mat) { //IL_0015: 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) //IL_0054: 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_0080: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) GameObject val = Child("RuneMotes", new Vector3(0f, 0.2f, 0f)); _motes = val.AddComponent(); MainModule main = _motes.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = true; ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.3f, 0.9f); ((MainModule)(ref main)).startLifetime = new MinMaxCurve(3f, 6f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.1f, 0.26f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Colour); ((MainModule)(ref main)).maxParticles = 120; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.02f); EmissionModule emission = _motes.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(10f); ShapeModule shape = _motes.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10; ((ShapeModule)(ref shape)).radius = GateWidth * 0.9f; ((ShapeModule)(ref shape)).rotation = new Vector3(90f, 0f, 0f); FadeInOut(_motes); Atlas(_motes); ParticleSystemRenderer component = val.GetComponent(); component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).material = mat; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; } private void Update() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_01b2: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0212: 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_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) Charge = Mathf.Max(0f, Charge - Time.deltaTime * 1.4f); float num = Mathf.Clamp01(Charge); _spin += Time.deltaTime * (18f + 150f * num); if ((Object)(object)_ringA != (Object)null) { ((Component)_ringA).transform.localRotation = Quaternion.Euler(0f, 0f, _spin); } if ((Object)(object)_ringB != (Object)null) { ((Component)_ringB).transform.localRotation = Quaternion.Euler(0f, 0f, (0f - _spin) * 1.6f); } if (_spokes != null) { LineRenderer[] spokes = _spokes; foreach (LineRenderer val in spokes) { if ((Object)(object)val != (Object)null) { ((Component)val).transform.localRotation = Quaternion.Euler(0f, 0f, (0f - _spin) * 1.6f); } } } if ((Object)(object)_sigil != (Object)null) { ((Component)_sigil).transform.localRotation = Quaternion.Euler(0f, (0f - _spin) * 0.5f, 0f); } if ((Object)(object)_sigilInner != (Object)null) { ((Component)_sigilInner).transform.localRotation = Quaternion.Euler(0f, _spin * 0.8f, 0f); } if ((Object)(object)_sigilRunes != (Object)null) { ((Component)_sigilRunes).transform.localRotation = Quaternion.Euler(0f, (0f - _spin) * 0.5f, 0f); } if ((Object)(object)_veil != (Object)null) { EmissionModule emission = _veil.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(26f + 120f * num); MainModule main = _veil.main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Colour * (1f + 1.6f * num)); } if ((Object)(object)_sigilRunes != (Object)null) { EmissionModule emission2 = _sigilRunes.emission; ((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(14f + 50f * num); } float num2 = 1f + 1.8f * num; Width(_ringA, 0.055f * num2); Width(_ringB, 0.04f * num2); Width(_sigil, 0.07f * num2); Width(_sigilInner, 0.05f * num2); if (_spokes != null) { LineRenderer[] spokes = _spokes; for (int i = 0; i < spokes.Length; i++) { Width(spokes[i], 0.03f * num2); } } } public void Discharge() { if ((Object)(object)_veil != (Object)null) { _veil.Emit(70); } if ((Object)(object)_motes != (Object)null) { _motes.Emit(45); } if ((Object)(object)_sigilRunes != (Object)null) { _sigilRunes.Emit(40); } Charge = 1f; } private GameObject Child(string name, Vector3 localPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GameObject val = new GameObject(name) { layer = ((Component)this).gameObject.layer }; val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = localPos; return val; } private LineRenderer BuildCircle(string name, Vector3 pos, float radius, Material mat, float width, bool vertical) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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) //IL_0056: Unknown result type (might be due to invalid IL or missing references) LineRenderer val = Child(name, pos).AddComponent(); Vector3[] array = (Vector3[])(object)new Vector3[65]; for (int i = 0; i <= 64; i++) { float num = (float)Math.PI / 32f * (float)i; float num2 = Mathf.Cos(num) * radius; float num3 = Mathf.Sin(num) * radius; array[i] = (vertical ? new Vector3(num2, num3, 0f) : new Vector3(num2, 0f, num3)); } Line(val, mat, width, array); return val; } private void Line(LineRenderer lr, Material mat, float width, Vector3[] pts) { //IL_0039: 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) lr.useWorldSpace = false; lr.loop = false; ((Renderer)lr).material = mat; lr.positionCount = pts.Length; lr.SetPositions(pts); float startWidth = (lr.endWidth = width); lr.startWidth = startWidth; lr.startColor = Colour; lr.endColor = Colour; ((Renderer)lr).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)lr).receiveShadows = false; lr.alignment = (LineAlignment)0; } private static void Width(LineRenderer lr, float w) { if (!((Object)(object)lr == (Object)null)) { float startWidth = (lr.endWidth = w); lr.startWidth = startWidth; } } private static void FadeInOut(ParticleSystem ps) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_0034: 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) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_009c: 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_00ae: Unknown result type (might be due to invalid IL or missing references) ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val = new Gradient(); val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[4] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(1f, 0.25f), new GradientAlphaKey(1f, 0.65f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val); } private static void Atlas(ParticleSystem ps) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) TextureSheetAnimationModule textureSheetAnimation = ps.textureSheetAnimation; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled = true; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesX = 4; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesY = 4; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).animation = (ParticleSystemAnimationType)0; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).timeMode = (ParticleSystemAnimationTimeMode)0; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).startFrame = new MinMaxCurve(0f, 16f); ((TextureSheetAnimationModule)(ref textureSheetAnimation)).frameOverTime = new MinMaxCurve(0f); } } public static class AvalorRuneMaterial { private static readonly Dictionary _materialCache = new Dictionary(); private static bool _initialized = false; private static void Init() { if (!_initialized) { _initialized = true; Logger.LogInfo((object)"[Avalor] rune VFX: Seeking glowing, additive, unlit shaders worthy of Avalor."); } } private unsafe static long MakeCacheKey(Shader shader, Texture2D tex, Color color) { int num = (((Object)(object)shader != (Object)null) ? ((Object)shader).GetInstanceID() : 0); int num2 = (((Object)(object)tex != (Object)null) ? ((Object)tex).GetInstanceID() : 0); int hashCode = ((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).GetHashCode(); return (long)((ulong)((long)num << 32) ^ ((ulong)(uint)num2 << 16) ^ (uint)hashCode); } public static Material GetOrCreateRuneMaterial(Texture2D runeTex, Color color) { //IL_01cd: 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_01e6: 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_0172: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) Init(); Shader val = Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Legacy Shaders/Particles/Alpha Blended") ?? Shader.Find("Particles/Alpha Blended") ?? Shader.Find("Particles/Additive"); if ((Object)(object)val == (Object)null) { float num = float.MinValue; Material[] array = Resources.FindObjectsOfTypeAll(); foreach (Material val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.shader == (Object)null)) { Shader shader = val2.shader; string text = ((Object)shader).name.ToLower(); float num2 = 0f; if (text.Contains("particle")) { num2 += 3f; } if (text.Contains("add")) { num2 += 3f; } if (text.Contains("unlit")) { num2 += 2f; } if (text.Contains("transparent")) { num2 += 1.5f; } if ((val2.HasProperty("_Color") || val2.HasProperty("_TintColor")) && num2 > num) { num = num2; val = shader; } } } } if ((Object)(object)val == (Object)null) { Logger.LogError((object)"[Avalor] rune VFX: No glowing shader found. The runes refuse to shine."); return null; } long key = MakeCacheKey(val, runeTex, color); if (_materialCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Material val3 = new Material(val); if ((Object)(object)runeTex != (Object)null) { if (val3.HasProperty("_MainTex")) { val3.SetTexture("_MainTex", (Texture)(object)runeTex); } if (val3.HasProperty("_BaseMap")) { val3.SetTexture("_BaseMap", (Texture)(object)runeTex); } try { val3.mainTexture = (Texture)(object)runeTex; } catch { } } if (val3.HasProperty("_Color")) { val3.SetColor("_Color", color); } if (val3.HasProperty("_TintColor")) { val3.SetColor("_TintColor", color); } if (val3.HasProperty("_EmissionColor")) { val3.SetColor("_EmissionColor", color * 1.5f); } val3.SetInt("_SrcBlend", 1); val3.SetInt("_DstBlend", 1); val3.SetInt("_ZWrite", 0); val3.DisableKeyword("_ALPHATEST_ON"); val3.EnableKeyword("_ALPHABLEND_ON"); val3.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val3.renderQueue = 3000; _materialCache[key] = val3; Logger.LogInfo((object)("[Avalor] rune VFX: Forged glowing additive rune material from '" + ((Object)val).name + "'.")); return val3; } public static void ClearCache() { _materialCache.Clear(); _initialized = false; } } public static class AvalorRuneTexture { private const int Size = 128; public unsafe static Texture2D GenerateRune(Color color) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) int runeIndex = Mathf.Abs(((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).GetHashCode()) % 16; return GenerateRune(color, runeIndex); } public static Texture2D GenerateRuneAtlas(Color color) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) int num = 128; Texture2D val = new Texture2D(512, 512, (TextureFormat)4, true); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0f, 0f, 0f); Color[] array = (Color[])(object)new Color[512 * 512]; for (int i = 0; i < array.Length; i++) { array[i] = val2; } val.SetPixels(array); for (int j = 0; j < 16; j++) { int num2 = j % 4; int num3 = 3 - j / 4; DrawRuneOntoAtlas(val, color, j, num2 * num, num3 * num, num); } val.Apply(true); return val; } public static Texture2D GenerateSoftTrail(Color color) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0097: 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_00a3: 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) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)1; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(64f, 64f); float num = 64f; Color val3 = default(Color); for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num2 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), val2) / num; float num3 = Mathf.Clamp01(1f - num2); num3 = Mathf.SmoothStep(0f, 1f, num3); num3 = Mathf.Pow(num3, 1.6f); ((Color)(ref val3))..ctor(color.r, color.g, color.b, color.a * num3); val.SetPixel(j, i, val3); } } val.Apply(true); return val; } public static Texture2D GenerateStreak(Color color) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_00b1: 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_00bd: 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) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)1; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(64f, 64f); float num = 64f; Color val3 = default(Color); for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num2 = Mathf.Abs((float)i + 0.5f - val2.y) / num; float num3 = Mathf.Abs((float)j + 0.5f - val2.x) / (num * 0.6f); float num4 = Mathf.Clamp01(1f - num3); float num5 = Mathf.SmoothStep(1f, 0f, num2); num4 *= Mathf.Pow(num5, 0.9f); ((Color)(ref val3))..ctor(color.r, color.g, color.b, color.a * num4); val.SetPixel(j, i, val3); } } val.Apply(true); return val; } public static Texture2D GenerateBlend(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0060: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) Texture2D val = GenerateSoftTrail(color); Texture2D val2 = GenerateRune(color); Texture2D val3 = new Texture2D(128, 128, (TextureFormat)4, false); ((Texture)val3).filterMode = (FilterMode)1; Color val4 = default(Color); for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { Color pixel = val.GetPixel(j, i); Color pixel2 = val2.GetPixel(j, i); float num = Mathf.Clamp01(pixel.a + pixel2.a * 0.65f); ((Color)(ref val4))..ctor(color.r, color.g, color.b, color.a * num); val3.SetPixel(j, i, val4); } } val3.Apply(true); return val3; } private static void DrawRuneOntoAtlas(Texture2D tex, Color color, int runeIndex, int offsetX, int offsetY, int size) { //IL_001b: 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_0033: 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_0051: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023f: 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_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0296: 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_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_0599: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0633: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_0667: Unknown result type (might be due to invalid IL or missing references) //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_0689: Unknown result type (might be due to invalid IL or missing references) //IL_069a: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_06cd: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_0701: Unknown result type (might be due to invalid IL or missing references) //IL_0712: Unknown result type (might be due to invalid IL or missing references) //IL_0723: Unknown result type (might be due to invalid IL or missing references) //IL_0734: Unknown result type (might be due to invalid IL or missing references) //IL_0745: Unknown result type (might be due to invalid IL or missing references) //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_0779: Unknown result type (might be due to invalid IL or missing references) //IL_078a: Unknown result type (might be due to invalid IL or missing references) //IL_079b: Unknown result type (might be due to invalid IL or missing references) //IL_07ac: Unknown result type (might be due to invalid IL or missing references) //IL_07bd: Unknown result type (might be due to invalid IL or missing references) //IL_07ce: Unknown result type (might be due to invalid IL or missing references) //IL_07df: Unknown result type (might be due to invalid IL or missing references) //IL_07f0: Unknown result type (might be due to invalid IL or missing references) Color c = default(Color); ((Color)(ref c))..ctor(color.r * 0.6f, color.g * 0.6f, color.b * 0.6f, 0.6f); Color c2 = default(Color); ((Color)(ref c2))..ctor(color.r, color.g, color.b, 1f); float scale = (float)size / 128f; switch (runeIndex) { case 0: DrawLineLocal(20, 20, 108, 108, c, 6); DrawLineLocal(108, 20, 20, 108, c, 6); DrawLineLocal(20, 20, 108, 108, c2, 3); DrawLineLocal(108, 20, 20, 108, c2, 3); break; case 1: DrawLineLocal(64, 16, 64, 112, c, 6); DrawLineLocal(64, 64, 32, 96, c, 5); DrawLineLocal(64, 64, 96, 96, c, 5); DrawLineLocal(64, 16, 64, 112, c2, 3); DrawLineLocal(64, 64, 32, 96, c2, 2); DrawLineLocal(64, 64, 96, 96, c2, 2); break; case 2: DrawLineLocal(40, 20, 40, 108, c, 6); DrawLineLocal(40, 96, 96, 112, c, 5); DrawLineLocal(40, 72, 96, 88, c, 5); DrawLineLocal(40, 20, 40, 108, c2, 3); DrawLineLocal(40, 96, 96, 112, c2, 2); DrawLineLocal(40, 72, 96, 88, c2, 2); break; case 3: DrawLineLocal(40, 20, 40, 112, c, 6); DrawLineLocal(40, 96, 88, 112, c, 5); DrawLineLocal(88, 112, 88, 80, c, 5); DrawLineLocal(88, 80, 40, 96, c, 5); DrawLineLocal(40, 20, 40, 112, c2, 3); DrawLineLocal(40, 96, 88, 112, c2, 2); DrawLineLocal(88, 112, 88, 80, c2, 2); DrawLineLocal(88, 80, 40, 96, c2, 2); break; case 4: DrawLineLocal(64, 16, 64, 112, c, 8); DrawLineLocal(64, 16, 64, 112, c2, 4); break; case 5: DrawLineLocal(64, 16, 64, 112, c, 6); DrawLineLocal(64, 40, 32, 72, c, 5); DrawLineLocal(64, 40, 96, 72, c, 5); DrawLineLocal(64, 16, 64, 112, c2, 3); DrawLineLocal(64, 40, 32, 72, c2, 2); DrawLineLocal(64, 40, 96, 72, c2, 2); break; case 6: DrawLineLocal(36, 16, 36, 112, c, 6); DrawLineLocal(92, 16, 92, 112, c, 6); DrawLineLocal(36, 36, 92, 92, c, 5); DrawLineLocal(36, 16, 36, 112, c2, 3); DrawLineLocal(92, 16, 92, 112, c2, 3); DrawLineLocal(36, 36, 92, 92, c2, 2); break; case 7: DrawLineLocal(80, 20, 40, 20, c, 5); DrawLineLocal(80, 20, 40, 64, c, 5); DrawLineLocal(40, 64, 80, 108, c, 5); DrawLineLocal(80, 108, 40, 108, c, 5); DrawLineLocal(80, 20, 40, 20, c2, 2); DrawLineLocal(80, 20, 40, 64, c2, 2); DrawLineLocal(40, 64, 80, 108, c2, 2); DrawLineLocal(80, 108, 40, 108, c2, 2); break; case 8: DrawLineLocal(64, 16, 64, 112, c, 6); DrawLineLocal(96, 96, 32, 32, c, 5); DrawLineLocal(64, 16, 64, 112, c2, 3); DrawLineLocal(96, 96, 32, 32, c2, 2); break; case 9: DrawLineLocal(32, 48, 32, 112, c, 6); DrawLineLocal(96, 48, 96, 112, c, 6); DrawLineLocal(32, 48, 64, 16, c, 5); DrawLineLocal(64, 16, 96, 48, c, 5); DrawLineLocal(32, 48, 32, 112, c2, 3); DrawLineLocal(96, 48, 96, 112, c2, 3); DrawLineLocal(32, 48, 64, 16, c2, 2); DrawLineLocal(64, 16, 96, 48, c2, 2); break; case 10: DrawLineLocal(48, 16, 48, 112, c, 6); DrawLineLocal(48, 80, 96, 48, c, 5); DrawLineLocal(48, 16, 48, 112, c2, 3); DrawLineLocal(48, 80, 96, 48, c2, 2); break; case 11: DrawLineLocal(64, 112, 96, 72, c, 5); DrawLineLocal(96, 72, 64, 32, c, 5); DrawLineLocal(64, 32, 32, 72, c, 5); DrawLineLocal(32, 72, 64, 112, c, 5); DrawLineLocal(32, 72, 16, 16, c, 5); DrawLineLocal(96, 72, 112, 16, c, 5); DrawLineLocal(64, 112, 96, 72, c2, 2); DrawLineLocal(96, 72, 64, 32, c2, 2); DrawLineLocal(64, 32, 32, 72, c2, 2); DrawLineLocal(32, 72, 64, 112, c2, 2); DrawLineLocal(32, 72, 16, 16, c2, 2); DrawLineLocal(96, 72, 112, 16, c2, 2); break; case 12: DrawLineLocal(20, 20, 64, 64, c, 5); DrawLineLocal(20, 108, 64, 64, c, 5); DrawLineLocal(108, 20, 64, 64, c, 5); DrawLineLocal(108, 108, 64, 64, c, 5); DrawLineLocal(20, 20, 64, 64, c2, 2); DrawLineLocal(20, 108, 64, 64, c2, 2); DrawLineLocal(108, 20, 64, 64, c2, 2); DrawLineLocal(108, 108, 64, 64, c2, 2); break; case 13: DrawLineLocal(36, 16, 36, 112, c, 6); DrawLineLocal(36, 96, 80, 80, c, 5); DrawLineLocal(80, 80, 36, 64, c, 5); DrawLineLocal(36, 64, 80, 48, c, 5); DrawLineLocal(80, 48, 36, 32, c, 5); DrawLineLocal(36, 16, 36, 112, c2, 3); DrawLineLocal(36, 96, 80, 80, c2, 2); DrawLineLocal(80, 80, 36, 64, c2, 2); DrawLineLocal(36, 64, 80, 48, c2, 2); DrawLineLocal(80, 48, 36, 32, c2, 2); break; case 14: DrawLineLocal(32, 16, 32, 112, c, 6); DrawLineLocal(96, 16, 96, 112, c, 6); DrawLineLocal(32, 112, 96, 64, c, 5); DrawLineLocal(96, 112, 32, 64, c, 5); DrawLineLocal(32, 16, 32, 112, c2, 3); DrawLineLocal(96, 16, 96, 112, c2, 3); DrawLineLocal(32, 112, 96, 64, c2, 2); DrawLineLocal(96, 112, 32, 64, c2, 2); break; case 15: DrawLineLocal(64, 16, 108, 64, c, 6); DrawLineLocal(108, 64, 64, 112, c, 6); DrawLineLocal(64, 112, 20, 64, c, 6); DrawLineLocal(20, 64, 64, 16, c, 6); DrawLineLocal(64, 16, 108, 64, c2, 3); DrawLineLocal(108, 64, 64, 112, c2, 3); DrawLineLocal(64, 112, 20, 64, c2, 3); DrawLineLocal(20, 64, 64, 16, c2, 3); break; } void DrawLineLocal(int x0, int y0, int x1, int y1, Color c3, int thickness) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) DrawLineAtlas(tex, offsetX + (int)((float)x0 * scale), offsetY + (int)((float)y0 * scale), offsetX + (int)((float)x1 * scale), offsetY + (int)((float)y1 * scale), c3, thickness, 512); } } public static Texture2D GenerateRune(Color color, int runeIndex) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_003d: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0079: 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) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: 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_01e8: 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_0208: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_063a: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_065a: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_067f: Unknown result type (might be due to invalid IL or missing references) //IL_068f: Unknown result type (might be due to invalid IL or missing references) //IL_069f: Unknown result type (might be due to invalid IL or missing references) //IL_06af: Unknown result type (might be due to invalid IL or missing references) //IL_06bf: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_06df: Unknown result type (might be due to invalid IL or missing references) //IL_06ef: Unknown result type (might be due to invalid IL or missing references) //IL_06ff: Unknown result type (might be due to invalid IL or missing references) //IL_0714: Unknown result type (might be due to invalid IL or missing references) //IL_0724: Unknown result type (might be due to invalid IL or missing references) //IL_0734: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_0754: Unknown result type (might be due to invalid IL or missing references) //IL_0764: Unknown result type (might be due to invalid IL or missing references) //IL_0774: Unknown result type (might be due to invalid IL or missing references) //IL_0784: Unknown result type (might be due to invalid IL or missing references) //IL_0799: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_07b9: Unknown result type (might be due to invalid IL or missing references) //IL_07c9: Unknown result type (might be due to invalid IL or missing references) //IL_07d9: Unknown result type (might be due to invalid IL or missing references) //IL_07e9: Unknown result type (might be due to invalid IL or missing references) //IL_07f9: Unknown result type (might be due to invalid IL or missing references) //IL_0809: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, true); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0f, 0f, 0f); Color c = default(Color); ((Color)(ref c))..ctor(color.r * 0.6f, color.g * 0.6f, color.b * 0.6f, 0.6f); Color c2 = default(Color); ((Color)(ref c2))..ctor(color.r, color.g, color.b, 1f); Color[] array = (Color[])(object)new Color[16384]; for (int i = 0; i < array.Length; i++) { array[i] = val2; } val.SetPixels(array); switch (runeIndex) { case 0: DrawLine(val, 20, 20, 108, 108, c, 6); DrawLine(val, 108, 20, 20, 108, c, 6); DrawLine(val, 20, 20, 108, 108, c2, 3); DrawLine(val, 108, 20, 20, 108, c2, 3); break; case 1: DrawLine(val, 64, 16, 64, 112, c, 6); DrawLine(val, 64, 64, 32, 96, c, 5); DrawLine(val, 64, 64, 96, 96, c, 5); DrawLine(val, 64, 16, 64, 112, c2, 3); DrawLine(val, 64, 64, 32, 96, c2, 2); DrawLine(val, 64, 64, 96, 96, c2, 2); break; case 2: DrawLine(val, 40, 20, 40, 108, c, 6); DrawLine(val, 40, 96, 96, 112, c, 5); DrawLine(val, 40, 72, 96, 88, c, 5); DrawLine(val, 40, 20, 40, 108, c2, 3); DrawLine(val, 40, 96, 96, 112, c2, 2); DrawLine(val, 40, 72, 96, 88, c2, 2); break; case 3: DrawLine(val, 40, 20, 40, 112, c, 6); DrawLine(val, 40, 96, 88, 112, c, 5); DrawLine(val, 88, 112, 88, 80, c, 5); DrawLine(val, 88, 80, 40, 96, c, 5); DrawLine(val, 40, 20, 40, 112, c2, 3); DrawLine(val, 40, 96, 88, 112, c2, 2); DrawLine(val, 88, 112, 88, 80, c2, 2); DrawLine(val, 88, 80, 40, 96, c2, 2); break; case 4: DrawLine(val, 64, 16, 64, 112, c, 8); DrawLine(val, 64, 16, 64, 112, c2, 4); break; case 5: DrawLine(val, 64, 16, 64, 112, c, 6); DrawLine(val, 64, 40, 32, 72, c, 5); DrawLine(val, 64, 40, 96, 72, c, 5); DrawLine(val, 64, 16, 64, 112, c2, 3); DrawLine(val, 64, 40, 32, 72, c2, 2); DrawLine(val, 64, 40, 96, 72, c2, 2); break; case 6: DrawLine(val, 36, 16, 36, 112, c, 6); DrawLine(val, 92, 16, 92, 112, c, 6); DrawLine(val, 36, 36, 92, 92, c, 5); DrawLine(val, 36, 16, 36, 112, c2, 3); DrawLine(val, 92, 16, 92, 112, c2, 3); DrawLine(val, 36, 36, 92, 92, c2, 2); break; default: DrawLine(val, 80, 20, 40, 20, c, 5); DrawLine(val, 80, 20, 40, 64, c, 5); DrawLine(val, 40, 64, 80, 108, c, 5); DrawLine(val, 80, 108, 40, 108, c, 5); DrawLine(val, 80, 20, 40, 20, c2, 2); DrawLine(val, 80, 20, 40, 64, c2, 2); DrawLine(val, 40, 64, 80, 108, c2, 2); DrawLine(val, 80, 108, 40, 108, c2, 2); break; case 8: DrawLine(val, 64, 16, 64, 112, c, 6); DrawLine(val, 96, 96, 32, 32, c, 5); DrawLine(val, 64, 16, 64, 112, c2, 3); DrawLine(val, 96, 96, 32, 32, c2, 2); break; case 9: DrawLine(val, 32, 48, 32, 112, c, 6); DrawLine(val, 96, 48, 96, 112, c, 6); DrawLine(val, 32, 48, 64, 16, c, 5); DrawLine(val, 64, 16, 96, 48, c, 5); DrawLine(val, 32, 48, 32, 112, c2, 3); DrawLine(val, 96, 48, 96, 112, c2, 3); DrawLine(val, 32, 48, 64, 16, c2, 2); DrawLine(val, 64, 16, 96, 48, c2, 2); break; case 10: DrawLine(val, 48, 16, 48, 112, c, 6); DrawLine(val, 48, 80, 96, 48, c, 5); DrawLine(val, 48, 16, 48, 112, c2, 3); DrawLine(val, 48, 80, 96, 48, c2, 2); break; case 11: DrawLine(val, 64, 112, 96, 72, c, 5); DrawLine(val, 96, 72, 64, 32, c, 5); DrawLine(val, 64, 32, 32, 72, c, 5); DrawLine(val, 32, 72, 64, 112, c, 5); DrawLine(val, 32, 72, 16, 16, c, 5); DrawLine(val, 96, 72, 112, 16, c, 5); DrawLine(val, 64, 112, 96, 72, c2, 2); DrawLine(val, 96, 72, 64, 32, c2, 2); DrawLine(val, 64, 32, 32, 72, c2, 2); DrawLine(val, 32, 72, 64, 112, c2, 2); DrawLine(val, 32, 72, 16, 16, c2, 2); DrawLine(val, 96, 72, 112, 16, c2, 2); break; case 12: DrawLine(val, 20, 20, 64, 64, c, 5); DrawLine(val, 20, 108, 64, 64, c, 5); DrawLine(val, 108, 20, 64, 64, c, 5); DrawLine(val, 108, 108, 64, 64, c, 5); DrawLine(val, 20, 20, 64, 64, c2, 2); DrawLine(val, 20, 108, 64, 64, c2, 2); DrawLine(val, 108, 20, 64, 64, c2, 2); DrawLine(val, 108, 108, 64, 64, c2, 2); break; case 13: DrawLine(val, 36, 16, 36, 112, c, 6); DrawLine(val, 36, 96, 80, 80, c, 5); DrawLine(val, 80, 80, 36, 64, c, 5); DrawLine(val, 36, 64, 80, 48, c, 5); DrawLine(val, 80, 48, 36, 32, c, 5); DrawLine(val, 36, 16, 36, 112, c2, 3); DrawLine(val, 36, 96, 80, 80, c2, 2); DrawLine(val, 80, 80, 36, 64, c2, 2); DrawLine(val, 36, 64, 80, 48, c2, 2); DrawLine(val, 80, 48, 36, 32, c2, 2); break; case 14: DrawLine(val, 32, 16, 32, 112, c, 6); DrawLine(val, 96, 16, 96, 112, c, 6); DrawLine(val, 32, 112, 96, 64, c, 5); DrawLine(val, 96, 112, 32, 64, c, 5); DrawLine(val, 32, 16, 32, 112, c2, 3); DrawLine(val, 96, 16, 96, 112, c2, 3); DrawLine(val, 32, 112, 96, 64, c2, 2); DrawLine(val, 96, 112, 32, 64, c2, 2); break; case 15: DrawLine(val, 64, 16, 108, 64, c, 6); DrawLine(val, 108, 64, 64, 112, c, 6); DrawLine(val, 64, 112, 20, 64, c, 6); DrawLine(val, 20, 64, 64, 16, c, 6); DrawLine(val, 64, 16, 108, 64, c2, 3); DrawLine(val, 108, 64, 64, 112, c2, 3); DrawLine(val, 64, 112, 20, 64, c2, 3); DrawLine(val, 20, 64, 64, 16, c2, 3); break; } val.Apply(true); return val; } private static void DrawLineAtlas(Texture2D tex, int x0, int y0, int x1, int y1, Color c, int thickness, int atlasSize) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Abs(x1 - x0); int num2 = Mathf.Abs(y1 - y0); int num3 = ((x0 < x1) ? 1 : (-1)); int num4 = ((y0 < y1) ? 1 : (-1)); int num5 = num - num2; while (true) { DrawCircleAtlas(tex, x0, y0, thickness, c, atlasSize); if (x0 != x1 || y0 != y1) { int num6 = 2 * num5; if (num6 > -num2) { num5 -= num2; x0 += num3; } if (num6 < num) { num5 += num; y0 += num4; } continue; } break; } } private static void DrawCircleAtlas(Texture2D tex, int cx, int cy, int r, Color c, int atlasSize) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) for (int i = -r; i <= r; i++) { for (int j = -r; j <= r; j++) { if (j * j + i * i <= r * r) { int num = cx + j; int num2 = cy + i; if (num >= 0 && num < atlasSize && num2 >= 0 && num2 < atlasSize) { tex.SetPixel(num, num2, c); } } } } } private static void DrawLine(Texture2D tex, int x0, int y0, int x1, int y1, Color c, int thickness) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Abs(x1 - x0); int num2 = Mathf.Abs(y1 - y0); int num3 = ((x0 < x1) ? 1 : (-1)); int num4 = ((y0 < y1) ? 1 : (-1)); int num5 = num - num2; while (true) { DrawCircle(tex, x0, y0, thickness, c); if (x0 != x1 || y0 != y1) { int num6 = 2 * num5; if (num6 > -num2) { num5 -= num2; x0 += num3; } if (num6 < num) { num5 += num; y0 += num4; } continue; } break; } } private static void DrawCircle(Texture2D tex, int cx, int cy, int r, Color c) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) for (int i = -r; i <= r; i++) { for (int j = -r; j <= r; j++) { if (j * j + i * i <= r * r) { int num = cx + j; int num2 = cy + i; if (num >= 0 && num < 128 && num2 >= 0 && num2 < 128) { tex.SetPixel(num, num2, c); } } } } } } public class AvalorResetCommand : ConsoleCommand { public override string Name => "avalor_reset"; public override string Help => "Forcefully deletes and regenerates a brand new Avalor labyrinth."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => true; public override bool OnlyServer => true; public override void Run(string[] args) { if (!RouteToServer(remote: false)) { if ((Object)(object)AvalorMazeGenerator.Instance == (Object)null) { Logger.LogWarning((object)"[Avalor][FAIL] avalor_reset: there is no maze generator on this machine, so there is nothing to reset. The labyrinth is unchanged."); AvalorNet.Print("No Avalor labyrinth on this machine - nothing was reset."); } else { Logger.LogInfo((object)$"[Avalor] avalor_reset running locally (role={AvalorNet.Role})."); AvalorResetManager.Instance?.ForceResetMaze(); AvalorNet.Print("Avalor Labyrinth regenerating..."); } } } internal static bool RouteToServer(bool remote) { if (AvalorNet.Role != AvalorNet.NetRole.Client) { return false; } if (AvalorNet.RequestMazeReset(remote)) { AvalorNet.Print("Asked the server to reset the labyrinth - watch the SERVER log for the result. Everyone inside is evacuated first."); } else { AvalorNet.Print("Could not reach the server to request a maze reset. Nothing was changed."); } return true; } } public class AvalorRemoteResetCommand : ConsoleCommand { public override string Name => "avalor_remote_reset"; public override string Help => "Forcefully deletes and regenerates the Avalor labyrinth from anywhere in the world."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => true; public override bool OnlyServer => true; public override void Run(string[] args) { if (!AvalorResetCommand.RouteToServer(remote: true)) { if ((Object)(object)AvalorMazeGenerator.Instance == (Object)null) { Logger.LogWarning((object)"[Avalor][FAIL] avalor_remote_reset: there is no maze generator on this machine, so there is nothing to reset. The labyrinth is unchanged."); AvalorNet.Print("No Avalor labyrinth on this machine - nothing was reset."); } else { Logger.LogInfo((object)$"[Avalor] avalor_remote_reset running locally (role={AvalorNet.Role})."); AvalorResetManager.Instance?.ForceResetMaze(remote: true); AvalorNet.Print("Avalor Labyrinth regenerating remotely..."); } } } } public class AvalorSpawnPortalCommand : ConsoleCommand { public override string Name => "avalor_spawn_portal"; public override string Help => "Spawns a Decrepit Avalor Portal in front of the player."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => true; public override bool OnlyServer => false; public override void Run(string[] args) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_007e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer != (Object)null) { Vector3 val = ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 3f; val.y = ((Component)Player.m_localPlayer).transform.position.y; GameObject prefab = ZNetScene.instance.GetPrefab("Avalor_OverworldPortal"); if ((Object)(object)prefab != (Object)null) { Object.Instantiate(prefab, val, ((Component)Player.m_localPlayer).transform.rotation); AvalorNet.Print("Avalor Portal spawned at crosshair."); } } } } public class AvalorIlluminateCommand : ConsoleCommand { public override string Name => "avalor_illuminate"; public override string Help => "Toggles debug full-bright lighting inside the maze (for layout inspection)."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => false; public override bool OnlyServer => false; public override void Run(string[] args) { AvalorCryptEnvZone.DebugBright = !AvalorCryptEnvZone.DebugBright; Logger.LogInfo((object)("Avalor debug lighting toggled: " + (AvalorCryptEnvZone.DebugBright ? "BRIGHT" : "dark"))); AvalorNet.Print(AvalorCryptEnvZone.DebugBright ? "Avalor debug lighting: ON (maze forced full-bright for inspection)." : "Avalor debug lighting: OFF (crypt darkness restored)."); } } public class AvalorTpCommand : ConsoleCommand { public override string Name => "avalor_tp"; public override string Help => "Teleports the player directly to the Avalor labyrinth dimension."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => true; public override bool OnlyServer => false; public override void Run(string[] args) { if ((Object)(object)Player.m_localPlayer != (Object)null) { Logger.LogInfo((object)"Teleporting player to Avalor via console."); AvalorPortal.TeleportToAvalor(Player.m_localPlayer); AvalorNet.Print("Entering the Mists of Avalor..."); } else { AvalorNet.Print("No Player found. You must be in-game to use this command."); } } } public class AvalorRemoveAllCommand : ConsoleCommand { public override string Name => "avalor_remove_all"; public override string Help => "Completely removes all Avalor structures (maze and overworld portal)."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => true; public override bool OnlyServer => true; public override void Run(string[] args) { //IL_0051: 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) Logger.LogInfo((object)"Avalor: Removing all mod assets from the world..."); if ((Object)(object)AvalorResetManager.Instance != (Object)null) { AvalorResetManager.Instance.WipeSkyZoneAfterEvacuation("avalor_remove_all"); } Vector3 val = default(Vector3); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetLocationIcon("StartTemple", ref val)) { if (!ZoneSystem.instance.IsZoneLoaded(val)) { AvalorNet.Print("[Avalor][FAIL] the Start Temple zone is not loaded on this machine (a dedicated server only loads terrain near the world origin), so the portal-area decor could not be swept. The maze itself WAS removed. Run this again from a client standing near the temple to clear the decor."); return; } int num = 0; Collider[] array = Physics.OverlapSphere(val, 100f); for (int i = 0; i < array.Length; i++) { ZNetView componentInParent = ((Component)array[i]).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null) && componentInParent.IsValid()) { string text = Utils.GetPrefabName(((Component)componentInParent).gameObject).ToLower(); if (!text.Contains("bossstone") && !text.Contains("starttemple") && !text.Contains("runestone") && !text.Contains("tombstone") && (text.StartsWith("avalor_") || text.Contains("paved_road") || text.Contains("stone_floor") || text.Contains("stone_wall") || text.Contains("vfx_swamp_mist") || text.Contains("groundtorch") || text == "sign" || text.Contains("swamptree") || text.Contains("mountaingravestone") || text.Contains("statueevil") || text.Contains("giant_skull") || text.Contains("bonefragments") || text.Contains("rock_3") || text.Contains("rock_4") || text.Contains("pinetree") || text.Contains("pickable_mushroom"))) { componentInParent.ClaimOwnership(); ZNetScene.instance.Destroy(((Component)componentInParent).gameObject); num++; } } } if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)$"[Avalor] avalor_remove_all: cleared {num} portal-area object(s)."); } } AvalorNet.Print("All Avalor assets removed from the world."); } } public class AvalorGenerateAllCommand : ConsoleCommand { public override string Name => "avalor_generate_all"; public override string Help => "Rebuilds BOTH the Avalor Overworld Portal and the labyrinth itself (run this after avalor_remove_all)."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => true; public override bool OnlyServer => true; public override void Run(string[] args) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_0094: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC("wubarrk.mistsofavalor.EnsureMaze", Array.Empty()); Logger.LogInfo((object)"[Avalor] avalor_generate_all: asked the server to forge the labyrinth if it is missing."); } else { Logger.LogWarning((object)"[Avalor][FAIL] avalor_generate_all: no routed RPC channel - the LABYRINTH was NOT rebuilt (the gate below still is). Do not teleport or fly into the sky region until it exists: there is no floor there."); AvalorNet.Print("[Avalor][FAIL] could not ask the server to rebuild the labyrinth - do NOT fly or teleport into the maze region, there is no floor."); } Vector3 val = default(Vector3); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetLocationIcon("StartTemple", ref val)) { if (!ZoneSystem.instance.IsZoneLoaded(val)) { AvalorNet.Print("[Avalor][FAIL] the Start Temple zone is not loaded on this machine (a dedicated server only loads terrain near the world origin). Run avalor_generate_all from a client standing near the temple - the siting needs real physics under it."); return; } Logger.LogInfo((object)"Avalor Labyrinth: Forcing portal generation..."); GameObject val2 = new GameObject("AvalorTempSpawner"); val2.transform.position = val; val2.transform.rotation = Quaternion.identity; GameObject[] array = Resources.FindObjectsOfTypeAll(); foreach (GameObject val3 in array) { if (((Object)val3).name.StartsWith("StartTemple")) { Scene scene = val3.scene; if (((Scene)(ref scene)).isLoaded) { val2.transform.rotation = val3.transform.rotation; break; } } } val2.AddComponent(); AvalorNet.Print("Avalor gate generation initiated, and the labyrinth requested from the server. Give the maze a few seconds to forge before entering it."); } else { AvalorNet.Print("Failed to locate StartTemple - the overworld GATE was not rebuilt. The labyrinth was still requested from the server; enter it through a portal, not by flying."); } } } public class AvalorTpGraveCommand : ConsoleCommand { public override string Name => "avalor_tp_grave"; public override string Help => "Teleports you onto your nearest tombstone (in the maze or overworld) so you can loot it in place. The surest way to recover a grave."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => false; public override bool OnlyServer => false; public override void Run(string[] args) { //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_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) //IL_0088: 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_0091: 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) //IL_00ac: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { AvalorNet.Print("You must be in-game."); return; } Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { AvalorNet.Print("Could not read the world object table."); return; } int stableHashCode = StringExtensionMethods.GetStableHashCode("Player_tombstone"); Vector3 position = ((Component)localPlayer).transform.position; Vector3 val = Vector3.zero; float num = float.MaxValue; int num2 = 0; foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value != null && value.GetPrefab() == stableHashCode) { num2++; Vector3 position2 = value.GetPosition(); Vector3 val2 = position2 - position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = position2; } } } if (AvalorNet.Role == AvalorNet.NetRole.Client && (Object)(object)AvalorMazeGenerator.Instance != (Object)null) { AvalorNet.Print((num2 == 0) ? "No grave in local view - asking the server for your nearest tombstone..." : "Checking with the server for your nearest tombstone..."); AvalorNet.SendQuery(2); ((MonoBehaviour)AvalorMazeGenerator.Instance).StartCoroutine(TpWhenAnswered(localPlayer, val, num2)); } else if (num2 == 0) { AvalorNet.Print("No tombstones exist in this world."); } else { TeleportToGrave(localPlayer, val, num2); } } private static IEnumerator TpWhenAnswered(Player p, Vector3 localBest, int localCount) { //IL_000e: 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) float t = 0f; while (t < 5f) { if (AvalorNet.TryGetFreshAnswer(2, 6f, out var found, out var pos)) { if (found) { if ((Object)(object)p != (Object)null) { TeleportToGrave(p, pos, -1); } } else if (localCount > 0) { AvalorNet.Print("The server reports no tombstones exist - your game still lists one at " + $"{localBest:F0}, which is out of date. Ask an admin to run " + "avalor_recover_graves if a grave is genuinely missing."); } else { AvalorNet.Print("The server reports no tombstones exist in this world."); } yield break; } t += Time.deltaTime; yield return null; } if (localCount > 0 && (Object)(object)p != (Object)null) { AvalorNet.Print("No answer from the server - falling back to what your own game last saw. If the grave is not there, ask an admin to run avalor_recover_graves."); TeleportToGrave(p, localBest, localCount); } else { AvalorNet.Print("No answer from the server about your grave - try again."); } } private static void TeleportToGrave(Player p, Vector3 best, int count) { //IL_0010: 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) //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) //IL_0042: 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_0084: Unknown result type (might be due to invalid IL or missing references) Avalor_TombstoneToGraveyard_Patch.SuppressUntil = Time.time + 30f; AvalorSafePlatform.Drop(best, 8f, 12f); ((Character)p).TeleportTo(best + new Vector3(0f, 1.5f, 0f), ((Component)p).transform.rotation, true); string arg = ((count >= 0) ? $" ({count} grave(s) in the world.)" : " (located by the server.)"); Logger.LogInfo((object)$"[Avalor] avalor_tp_grave: teleported player to tombstone at {best:F0}."); AvalorNet.Print($"Teleporting onto your grave at {best:F0}. Press [E] Take All.{arg}"); } } public class AvalorRecoverGravesCommand : ConsoleCommand { public override string Name => "avalor_recover_graves"; public override string Help => "Finds player graves that have fallen out of the world or been buried and re-seats them at the overworld graveyard. Runs automatically on world load; this forces it now."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => false; public override bool OnlyServer => true; public override void Run(string[] args) { if (AvalorNet.Role == AvalorNet.NetRole.Client) { if (AvalorNet.RequestGraveRecovery()) { AvalorNet.Print("Asked the server to recover lost graves - watch the SERVER log for the result (it lists every grave it found and what it did). Then use avalor_tp_grave."); } else { AvalorNet.Print("Could not reach the server to request a grave recovery."); } } else { int num = AvalorGraveGuard.Sweep("avalor_recover_graves", verbose: true); AvalorNet.Print((num > 0) ? $"Recovered {num} lost grave(s) to the overworld graveyard. Use avalor_tp_grave to reach yours." : "No lost graves found - every grave in this world is somewhere reachable. (See the log for the full list.)"); } } } public class AvalorGatherGravesCommand : ConsoleCommand { public override string Name => "avalor_gather_graves"; public override string Help => "Moves EVERY player grave in the world to the overworld graveyard, reachable or not. For lost graves only, use avalor_recover_graves."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => false; public override bool OnlyServer => true; public override void Run(string[] args) { if (AvalorNet.Role == AvalorNet.NetRole.Client) { if (AvalorNet.RequestGraveGather()) { AvalorNet.Print("Asked the server to gather every grave to the graveyard - watch the SERVER log for the result (it lists every grave and where it went). Then use avalor_tp_grave."); } else { AvalorNet.Print("Could not reach the server to request a grave gather."); } } else { int num = AvalorGraveGuard.GatherAll("avalor_gather_graves"); AvalorNet.Print((num > 0) ? $"Moved {num} grave(s) to the overworld graveyard. Use avalor_tp_grave to reach yours." : "No graves were moved - either they are all already at the graveyard, or there is no graveyard portal yet. (See the log for the full list.)"); } } } public class AvalorFixStonesCommand : ConsoleCommand { public override string Name => "avalor_fix_stones"; public override string Help => "Restores a missing sacrificial altar and/or its flanking boulders at the Start Temple."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => true; public override bool OnlyServer => true; public override void Run(string[] args) { //IL_002b: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_012c: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_01e4: 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_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0256: 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_027d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetLocationIcon("StartTemple", ref val)) { if (!ZoneSystem.instance.IsZoneLoaded(val)) { AvalorNet.Print("[Avalor][FAIL] the Start Temple zone is not loaded on this machine (a dedicated server only loads terrain near the world origin) - running blind here would duplicate the altar. Run avalor_fix_stones from a client standing near the temple."); return; } Logger.LogInfo((object)"Avalor Labyrinth: Repairing missing sacrificial stones..."); bool flag = false; Collider[] array = Physics.OverlapSphere(val, 30f); for (int i = 0; i < array.Length; i++) { ZNetView componentInParent = ((Component)array[i]).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && Utils.GetPrefabName(((Component)componentInParent).gameObject).ToLower().Contains("bossstone")) { flag = true; break; } } bool flag2 = false; if (!flag) { GameObject prefab = ZNetScene.instance.GetPrefab("BossStone_Eikthyr"); if ((Object)(object)prefab != (Object)null) { Quaternion val2 = Quaternion.identity; GameObject[] array2 = Resources.FindObjectsOfTypeAll(); foreach (GameObject val3 in array2) { if (((Object)val3).name.StartsWith("StartTemple")) { Scene scene = val3.scene; if (((Scene)(ref scene)).isLoaded) { val2 = val3.transform.rotation; break; } } } Vector3 val4 = val; float y = default(float); if (ZoneSystem.instance.GetGroundHeight(val4, ref y)) { val4.y = y; } Object.Instantiate(prefab, val4, val2); flag2 = true; Logger.LogInfo((object)"avalor_fix_stones: Restored missing BossStone_Eikthyr altar at StartTemple."); } else { Logger.LogWarning((object)"avalor_fix_stones: BossStone_Eikthyr prefab not found - cannot restore missing altar."); } } GameObject prefab2 = ZNetScene.instance.GetPrefab("Rock_3"); int num = 0; if ((Object)(object)prefab2 != (Object)null) { array = Physics.OverlapSphere(val, 30f); for (int i = 0; i < array.Length; i++) { ZNetView componentInParent2 = ((Component)array[i]).GetComponentInParent(); if (!((Object)(object)componentInParent2 != (Object)null) || !Utils.GetPrefabName(((Component)componentInParent2).gameObject).ToLower().Contains("bossstone")) { continue; } Vector3 val5 = ((Component)componentInParent2).transform.position - ((Component)componentInParent2).transform.forward * 1.5f; bool flag3 = false; Collider[] array3 = Physics.OverlapSphere(val5, 2f); for (int j = 0; j < array3.Length; j++) { ZNetView componentInParent3 = ((Component)array3[j]).GetComponentInParent(); if ((Object)(object)componentInParent3 != (Object)null && Utils.GetPrefabName(((Component)componentInParent3).gameObject) == "Rock_3") { flag3 = true; break; } } if (!flag3) { Object.Instantiate(prefab2, val5, ((Component)componentInParent2).transform.rotation).transform.localScale = new Vector3(1.5f, 2.5f, 1.5f); num++; } } } string arg = (flag2 ? "Sacrificial altar restored. " : ""); AvalorNet.Print($"{arg}Successfully restored {num} flanking boulders!"); } else { AvalorNet.Print("Failed to locate StartTemple!"); } } } public static class AvalorInspect { private const string CombinedSuffix = "_Combined"; public static bool CutawayActive { get; private set; } public static bool HideWallsToo { get; private set; } public static void SetCutaway(bool on, bool hideWalls) { CutawayActive = on; HideWallsToo = hideWalls; Apply(); } public static int Apply() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) int num = 0; MeshRenderer[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (MeshRenderer val in array) { if ((Object)(object)val == (Object)null) { continue; } GameObject gameObject = ((Component)val).gameObject; if (((Object)gameObject).name.EndsWith("_Combined") && AvalorRegion.InSkyMaze(gameObject.transform.position)) { bool flag = ((Object)gameObject).name.Contains("Wall"); bool flag2 = CutawayActive && (!flag || HideWallsToo); if (((Renderer)val).enabled != !flag2) { ((Renderer)val).enabled = !flag2; num++; } } } return num; } } public class AvalorInspectDriver : MonoBehaviour { private float _timer; private void Update() { if (!AvalorInspect.CutawayActive) { return; } if ((Object)(object)Player.m_localPlayer == (Object)null) { AvalorInspect.SetCutaway(on: false, hideWalls: false); return; } _timer += Time.deltaTime; if (!(_timer < 1f)) { _timer = 0f; AvalorInspect.Apply(); } } } public class AvalorOpenCommand : ConsoleCommand { public override string Name => "avalor_open"; public override string Help => "Cutaway view of the maze for inspection. 'avalor_open' hides floors+ceilings and leaves the wall lattice (a floor plan from above - use with fly). 'avalor_open walls' hides the walls too. 'avalor_open off' restores. Local to you only."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => false; public override bool OnlyServer => false; public override void Run(string[] args) { string text = ((args != null && args.Length != 0) ? args[0].ToLower() : ""); if (text == "off") { AvalorInspect.SetCutaway(on: false, hideWalls: false); AvalorNet.Print("Avalor cutaway OFF - maze restored."); return; } bool flag = text == "walls" || text == "all"; bool num = flag || !AvalorInspect.CutawayActive; AvalorInspect.SetCutaway(num, flag); if (!num) { AvalorNet.Print("Avalor cutaway OFF - maze restored."); } else { AvalorNet.Print(flag ? "Avalor cutaway ON (walls hidden too) - only props, chests and portals remain. Use 'fly'." : "Avalor cutaway ON - floors and ceilings hidden, wall lattice remains. Use 'fly'. 'avalor_open walls' to strip the walls, 'avalor_open off' to restore."); } } } public class AvalorTpEndCommand : ConsoleCommand { public override string Name => "avalor_tp_end"; public override string Help => "Teleports you to the labyrinth's escape portal (the deepest point of the maze), next to the prize chest."; public override bool IsCheat => true; public override bool IsSecret => false; public override bool IsNetwork => false; public override bool OnlyServer => false; public override void Run(string[] args) { //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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0095: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { AvalorNet.Print("You must be in-game."); return; } Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { AvalorNet.Print("Could not read the world object table."); return; } int stableHashCode = StringExtensionMethods.GetStableHashCode("Avalor_ExitPortal"); int stableHashCode2 = StringExtensionMethods.GetStableHashCode("Avalor_OverworldPortal"); Vector3 best = Vector3.zero; bool flag = false; foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value == null) { continue; } int prefab = value.GetPrefab(); if (prefab == stableHashCode || prefab == stableHashCode2) { Vector3 position = value.GetPosition(); if (AvalorRegion.InSkyMaze(position)) { best = position; flag = true; break; } } } if (!flag) { if (AvalorNet.Role == AvalorNet.NetRole.Client && (Object)(object)AvalorMazeGenerator.Instance != (Object)null) { AvalorNet.Print("Exit not in local view - asking the server where it is..."); AvalorNet.SendQuery(1); ((MonoBehaviour)AvalorMazeGenerator.Instance).StartCoroutine(TpWhenAnswered(localPlayer)); } else { AvalorNet.Print("No maze exit portal found - has the labyrinth been generated? Try avalor_reset."); } } else { TeleportToExit(localPlayer, best); } } private static IEnumerator TpWhenAnswered(Player p) { float t = 0f; while (t < 5f) { if (AvalorNet.TryGetFreshAnswer(1, 6f, out var found, out var pos)) { if (!found) { AvalorNet.Print("The server reports no maze exit exists - has the labyrinth been generated?"); } else if ((Object)(object)p != (Object)null) { TeleportToExit(p, pos); } yield break; } t += Time.deltaTime; yield return null; } AvalorNet.Print("No answer from the server about the maze exit - try again."); } private static void TeleportToExit(Player p, Vector3 best) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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) Vector3 val = ExitLanding(best); AvalorSafePlatform.Drop(val, 10f, 12f); Vector3 val2 = best - val; val2.y = 0f; Quaternion val3 = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? Quaternion.LookRotation(val2) : ((Component)p).transform.rotation); AvalorPortalWalkTrigger.Suppress(); bool flag = !AvalorRegion.InSkyMaze(((Component)p).transform.position); ((Character)p).TeleportTo(val + new Vector3(0f, 1.5f, 0f), val3, flag); MonoBehaviour val4 = (MonoBehaviour)(((Object)(object)MistsofAvalorPlugin.Instance != (Object)null) ? ((object)MistsofAvalorPlugin.Instance) : ((object)AvalorMazeGenerator.Instance)); if ((Object)(object)val4 != (Object)null) { val4.StartCoroutine(HoldGateShutUntilLanded(p)); } else { Logger.LogWarning((object)"[Avalor][FAIL] no MonoBehaviour to hold the exit gate shut across the teleport - if the maze sends you home a second after arriving, that is why."); } AvalorNet.Print($"Teleporting to the maze exit at {best:F0}. The blackmetal prize chest is beside it."); Logger.LogInfo((object)($"[Avalor] avalor_tp_end: teleported player to maze exit {best:F0} " + $"(standing at {val:F0}).")); } private static IEnumerator HoldGateShutUntilLanded(Player p) { float t = 0f; while ((Object)(object)p != (Object)null && t < 30f) { AvalorPortalWalkTrigger.Suppress(); if (!((Character)p).IsTeleporting()) { AvalorPortalWalkTrigger.Suppress(); yield break; } t += Time.deltaTime; yield return null; } AvalorPortalWalkTrigger.Suppress(); } private static Vector3 ExitLanding(Vector3 exitPos) { //IL_0000: 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_000a: 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_0018: Unknown result type (might be due to invalid IL or missing references) if (AvalorMazeGrid.TryFindOpenNeighbour(exitPos, out var neighbourCenter)) { return neighbourCenter; } if (AvalorMazeGrid.TryGetCell(exitPos, out var _, out var cellCenter)) { return cellCenter; } return exitPos; } } public static class AvalorPluginLookup { public static bool TryFind(string guid, out PluginInfo info) { info = null; if (string.IsNullOrEmpty(guid)) { return false; } if (Chainloader.PluginInfos.TryGetValue(guid, out info) && info != null) { return true; } foreach (KeyValuePair pluginInfo in Chainloader.PluginInfos) { if (string.Equals(pluginInfo.Key, guid, StringComparison.OrdinalIgnoreCase)) { info = pluginInfo.Value; return info != null; } } info = null; return false; } public static bool IsLoaded(string guid) { PluginInfo info; return TryFind(guid, out info); } public static Version VersionOf(string guid) { if (!TryFind(guid, out var info)) { return null; } if (info.Metadata == null) { return null; } return info.Metadata.Version; } } public static class AvalorStealthCompat { private const string SoMGuid = "wubarrk.shadowsofmidgard"; private const string SoMExemptionType = "ShadowsOfMidgard.StealthExemption"; private static readonly Version SoMExemptRelease = new Version(2, 0, 0); public const float TendInterval = 0.2f; private static bool _probed; private static readonly HashSet _tracked = new HashSet(); private static bool _warnedAboutStamps; public static bool AnyTracked => _tracked.Count > 0; public static void EnsureProbed() { if (_probed) { return; } _probed = true; PluginInfo info; bool flag = AvalorPluginLookup.TryFind("wubarrk.shadowsofmidgard", out info); Version version = ((flag && info.Metadata != null) ? info.Metadata.Version : null); bool flag2 = AccessTools.TypeByName("ShadowsOfMidgard.StealthExemption") != null; if (!flag && !flag2) { Logger.LogInfo((object)"[Avalor][OK] Shadows of Midgard is not installed. Avalor's mobs still carry the SoMStealthExempt flag - it costs one ZDO int and it is what makes the labyrinth's creatures legible to any mod that cares."); return; } if (!flag2) { Logger.LogError((object)("[Avalor][FAIL] Shadows of Midgard " + Describe(version) + " is installed but does not expose ShadowsOfMidgard.StealthExemption, so it will apply its stealth model to Avalorian mobs. Expect maze mobs that will not initiate combat until you hit them first - SoM gates all attacks below its own Alerted state. UPDATE SHADOWS OF MIDGARD TO 2.0.0 OR LATER; Avalor's old workaround for this was removed in 0.1.2 because it made maze mobs sense you through solid stone.")); return; } string text = ((version != null && version < SoMExemptRelease) ? (Describe(version) + " (a 2.0 beta)") : Describe(version)); Logger.LogInfo((object)("[Avalor][OK] Shadows of Midgard " + text + " found, and it exposes StealthExemption - it will read SoMStealthExempt off every Avalorian mob and run vanilla AI for them. Nothing else is required on Avalor's side.")); if (!flag) { Logger.LogWarning((object)"[Avalor][FAIL] ...but no loaded plugin declares the GUID wubarrk.shadowsofmidgard (matched ignoring case). Something other than a stock Shadows of Midgard is providing that type - a repack or a renamed build. The exemption still works; the version above cannot be trusted."); } } private static string Describe(Version version) { if (!(version != null)) { return "(version unreported)"; } return "v" + version; } public static void Register(Character c) { if (!((Object)(object)c == (Object)null)) { _tracked.Add(c); } } public static void TendAll() { PruneTracked(); if (_tracked.Count == 0) { return; } int num = 0; foreach (Character item in _tracked) { ZNetView component = ((Component)item).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner()) { ZDO zDO = component.GetZDO(); if (zDO != null && zDO.GetInt("SoMStealthExempt", 0) != 1) { zDO.Set("SoMStealthExempt", 1); num++; } ReassertHunt(item); } } if (num > 0) { ReportRestamped(num); } } private static void ReassertHunt(Character c) { try { BaseAI component = ((Component)c).GetComponent(); if (!((Object)(object)component == (Object)null)) { ZNetView component2 = ((Component)c).GetComponent(); if ((Object)(object)component2 != (Object)null && component2.GetZDO() != null && component2.GetZDO().GetInt("AvalorWarden", 0) == 1) { component.Alert(); } else { AvalorMobDirector.MakeItHunt(((Component)c).gameObject); } } } catch (Exception ex) { Logger.LogWarning((object)("[Avalor][FAIL] could not re-assert hunting on a maze mob: " + ex.Message)); } } private static void ReportRestamped(int count) { if (!_warnedAboutStamps) { _warnedAboutStamps = true; Logger.LogWarning((object)($"[Avalor][FAIL] {count} maze mob(s) were missing the SoMStealthExempt " + "flag and have been re-stamped - their Character.Awake ran before ZNetView was ready. Harmless once repaired, but they were invisible to a stealth mod's exemption until now.")); } else if (MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)$"[Avalor] re-stamped {count} maze mob(s) missing SoMStealthExempt."); } } private static void PruneTracked() { _tracked.RemoveWhere(delegate(Character c) { if ((Object)(object)c == (Object)null || c.IsDead()) { return true; } ZNetView component = ((Component)c).GetComponent(); return (Object)(object)component == (Object)null || !component.IsValid(); }); } } public class AvalorHuntPinner : MonoBehaviour { private float _timer; private void Update() { AvalorStealthCompat.EnsureProbed(); if (AvalorStealthCompat.AnyTracked) { _timer += Time.deltaTime; if (!(_timer < 0.2f)) { _timer = 0f; AvalorStealthCompat.TendAll(); } } } } internal static class AvalorDiagLog { private class Sink : ILogListener, IDisposable { public void LogEvent(object sender, LogEventArgs args) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (args != null && args.Data != null) { string text = args.Data.ToString(); if (text.IndexOf("Avalor", StringComparison.OrdinalIgnoreCase) >= 0) { Write($"[{args.Level}] {text}"); } } } public void Dispose() { } } private const string FolderName = "MistsofAvalor"; private const string FileName = "Avalor_diag.log"; private const long MaxBytes = 8388608L; private static string _path; private static bool _failed; private static readonly object _gate = new object(); public static void Init(string pluginVersion) { try { _path = ResolvePath(); FileInfo fileInfo = new FileInfo(_path); if (fileInfo.Exists && fileInfo.Length > 8388608) { string text = _path + ".1"; if (File.Exists(text)) { File.Delete(text); } File.Move(_path, text); } File.AppendAllText(_path, Environment.NewLine + "================================================================" + Environment.NewLine + $" Mists of Avalor v{pluginVersion} - session started {DateTime.Now:yyyy-MM-dd HH:mm:ss}" + Environment.NewLine + " profile: " + ProfileName() + Environment.NewLine + "================================================================" + Environment.NewLine, Encoding.UTF8); Logger.Listeners.Add((ILogListener)(object)new Sink()); Logger.LogInfo((object)("[Avalor] diagnostics are also being appended to " + _path + " - that file survives a relaunch, unlike LogOutput.log.")); } catch (Exception ex) { _failed = true; Logger.LogWarning((object)("[Avalor][FAIL] could not open the persistent diagnostic log, so this session will only be recorded in LogOutput.log (which the next launch will overwrite): " + ex.Message)); } } private static string ResolvePath() { try { string text = Path.Combine(Paths.ConfigPath, "MistsofAvalor"); Directory.CreateDirectory(text); return Path.Combine(text, "Avalor_diag.log"); } catch { return Path.Combine(Paths.BepInExRootPath, "Avalor_diag.log"); } } private static string ProfileName() { try { DirectoryInfo parent = Directory.GetParent(Paths.BepInExRootPath); return (parent != null) ? (parent.Name + " (" + parent.FullName + ")") : Paths.BepInExRootPath; } catch { return "unknown"; } } private static void Write(string line) { if (_failed || _path == null) { return; } try { lock (_gate) { File.AppendAllText(_path, $"{DateTime.Now:HH:mm:ss} {line}{Environment.NewLine}", Encoding.UTF8); } } catch { _failed = true; } } } internal static class AvalorGraveGuard { private const float SkyRegionX = 25000f; private const float BuriedMargin = 2f; private const float VoidFloor = -50f; private const float SweepPeriod = 60f; private const float StartupGrace = 20f; private static bool s_running; private static bool s_warnedNoGraveyard; private const float PadRadius = 22f; private static bool Dbg { get { if (MistsofAvalorPlugin.DebugLogging != null) { return MistsofAvalorPlugin.DebugLogging.Value; } return false; } } internal static bool Running => s_running; internal static float GraveLift() { return 0.45f; } internal static bool TryGroundHeight(Vector3 p, out float height) { //IL_0012: 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) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(p, ref height)) { return true; } if (WorldGenerator.instance != null) { height = WorldGenerator.instance.GetHeight(p.x, p.z); return true; } height = 0f; return false; } internal static bool TryPadGroundHeight(Vector3 gate, Vector3 p, out float height) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) //IL_0030: 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_004f: 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) if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(p, ref height)) { return true; } float num = p.x - gate.x; float num2 = p.z - gate.z; if (num * num + num2 * num2 <= 484f) { height = gate.y; return true; } return TryGroundHeight(p, out height); } private static bool IsLost(Vector3 pos, Vector3 gate, bool haveGate, out string why) { //IL_0000: 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_0029: 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_004a: 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) //IL_0054: 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) if (pos.x > 25000f) { why = "in the sky realm (in, under or falling past the labyrinth)"; return true; } if (pos.y < -50f) { why = $"below the world at y={pos.y:F0}"; return true; } if ((haveGate ? TryPadGroundHeight(gate, pos, out var height) : TryGroundHeight(pos, out height)) && pos.y < height - 2f) { why = $"buried {height - pos.y:F1}m under the terrain"; return true; } why = null; return false; } internal static int Sweep(string reason, bool verbose = false) { //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: 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_0214: 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_023d: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { Logger.LogWarning((object)("[Avalor][FAIL] grave sweep (" + reason + "): not the server - refusing. Run it on the host, or use avalor_tp_grave to reach a grave directly.")); return 0; } Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { Logger.LogWarning((object)("[Avalor][FAIL] grave sweep (" + reason + "): the world object table is not readable - no graves were checked. Nothing was changed.")); return 0; } int stableHashCode = StringExtensionMethods.GetStableHashCode("Player_tombstone"); List list = new List(); foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value != null && value.GetPrefab() == stableHashCode) { list.Add(value); } } if (!AvalorMazeGenerator.TryGetGraveyardPortal(out var pos)) { int num = 0; foreach (ZDO item2 in list) { if (IsLost(item2.GetPosition(), Vector3.zero, haveGate: false, out var _)) { num++; } } if (num > 0) { Logger.LogWarning((object)($"[Avalor][FAIL] grave sweep ({reason}): {num} grave(s) are lost " + "and there is NO graveyard portal to move them to. Nothing was touched and no items were lost - build/visit the overworld gate, then run avalor_recover_graves.")); } if (verbose || !s_warnedNoGraveyard) { s_warnedNoGraveyard = true; Logger.LogInfo((object)("[Avalor] grave sweep (" + reason + "): no graveyard portal yet (a fresh world " + $"builds it when the first player reaches spawn). {list.Count} grave(s) " + "in the world, none stranded - nothing to do. Silent until this changes.")); } return 0; } if (s_warnedNoGraveyard) { s_warnedNoGraveyard = false; Logger.LogInfo((object)($"[Avalor] grave sweep ({reason}): graveyard portal found at {pos:F0} - " + "lost graves can be recovered again.")); } int num2 = 0; int num3 = 0; foreach (ZDO item3 in list) { Vector3 position = item3.GetPosition(); if (!IsLost(position, pos, haveGate: true, out var why2)) { num3++; if (verbose) { Logger.LogInfo((object)$"[Avalor] grave {item3.m_uid} at {position:F0} - reachable, left alone."); } continue; } Logger.LogWarning((object)($"[Avalor][FAIL] LOST GRAVE {item3.m_uid} at {position:F0} - {why2}. Recovering it " + "to the overworld graveyard. Its items were never deleted.")); if (Reseat(item3, pos, out var target)) { num2++; Logger.LogInfo((object)$"[Avalor] grave {item3.m_uid} recovered: {position:F0} -> {target:F0}."); } else { Logger.LogWarning((object)$"[Avalor][FAIL] grave {item3.m_uid} at {position:F0} could NOT be re-seated - it is still where it was and avalor_tp_grave will reach it."); } } if (num2 > 0 || verbose) { Logger.LogInfo((object)($"[Avalor] grave sweep ({reason}): {list.Count} grave(s) in the world, " + $"{num3} reachable, {num2} recovered.")); } else if (Dbg) { Logger.LogInfo((object)$"[Avalor] grave sweep ({reason}): {list.Count} grave(s), all reachable."); } return num2; } internal static int GatherAll(string reason) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_012b: 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_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { Logger.LogWarning((object)("[Avalor][FAIL] grave gather (" + reason + "): not the server - refusing. Run it on the host.")); return 0; } Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { Logger.LogWarning((object)("[Avalor][FAIL] grave gather (" + reason + "): the world object table is not readable - no graves were checked. Nothing was changed.")); return 0; } if (!AvalorMazeGenerator.TryGetGraveyardPortal(out var pos)) { Logger.LogWarning((object)("[Avalor][FAIL] grave gather (" + reason + "): there is NO graveyard portal to move graves to. Nothing was touched and no items were lost - build/visit the overworld gate, then run avalor_gather_graves again.")); return 0; } int stableHashCode = StringExtensionMethods.GetStableHashCode("Player_tombstone"); List list = new List(); foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value != null && value.GetPrefab() == stableHashCode) { list.Add(value); } } int num = 0; int num2 = 0; foreach (ZDO item2 in list) { Vector3 position = item2.GetPosition(); float num3 = position.x - pos.x; float num4 = position.z - pos.z; Vector3 target; if (num3 * num3 + num4 * num4 <= 484f) { num2++; Logger.LogInfo((object)$"[Avalor] grave {item2.m_uid} at {position:F0} is already at the graveyard - left alone."); } else if (Reseat(item2, pos, out target)) { num++; Logger.LogInfo((object)$"[Avalor] grave {item2.m_uid} gathered: {position:F0} -> {target:F0}. Its items were never touched."); } else { Logger.LogWarning((object)($"[Avalor][FAIL] grave {item2.m_uid} at {position:F0} could NOT be moved - it is " + "still where it was and avalor_tp_grave will reach it.")); } } Logger.LogInfo((object)($"[Avalor] grave gather ({reason}): {list.Count} grave(s) in the world, " + $"{num} moved to the graveyard, {num2} already there.")); return num; } internal static bool Reseat(ZDO zdo, Vector3 graveyard, out Vector3 target) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0032: 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_004a: 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_0082: 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) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) target = Vector3.zero; if (zdo == null || ZDOMan.instance == null) { return false; } try { if (!zdo.IsOwner()) { zdo.SetOwner(ZDOMan.GetSessionID()); } target = Avalor_TombstoneToGraveyard_Patch.PlotFor(graveyard); zdo.SetPosition(target); zdo.Set(ZDOVars.s_spawnPoint, target); if ((Object)(object)ZNetScene.instance != (Object)null) { GameObject val = ZNetScene.instance.FindInstance(zdo.m_uid); if ((Object)(object)val != (Object)null) { val.transform.position = target; Rigidbody component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.position = target; component.linearVelocity = Vector3.zero; component.angularVelocity = Vector3.zero; } } } return true; } catch (Exception ex) { Logger.LogError((object)("[Avalor][FAIL] grave re-seat threw - the grave is UNCHANGED and still holds every item; avalor_tp_grave will reach it: " + ex.Message)); return false; } } internal static IEnumerator SweepForever() { yield return (object)new WaitForSeconds(20f); Sweep("world load", verbose: true); while (true) { yield return (object)new WaitForSeconds(60f); Sweep("periodic"); } } internal static void MarkStopped() { s_running = false; s_warnedNoGraveyard = false; } internal static void MarkRunning() { s_running = true; } } internal class AvalorGraveGuardDriver : MonoBehaviour { private bool m_started; private void Update() { if (!((Object)(object)ZNet.instance != (Object)null) || ZDOMan.instance == null) { if (m_started) { m_started = false; AvalorGraveGuard.MarkStopped(); ((MonoBehaviour)this).StopAllCoroutines(); } } else if (!m_started && ZNet.instance.IsServer()) { m_started = true; AvalorGraveGuard.MarkRunning(); ((MonoBehaviour)this).StartCoroutine(AvalorGraveGuard.SweepForever()); } } } public static class AvalorNet { public enum NetRole { Unknown, DedicatedServer, PlayerHost, Client } public struct PlayerPresence { public Vector3 pos; public Quaternion rot; public long ownerUid; } private struct CachedAnswer { public bool found; public Vector3 pos; public float at; } private static bool? _headless; private static NetRole _role = NetRole.Unknown; private const string Ns = "wubarrk.mistsofavalor."; public const string EnsureMazeRPC = "wubarrk.mistsofavalor.EnsureMaze"; public const string EvacuateRPC = "wubarrk.mistsofavalor.Evacuate"; public const string RelocateGraveRPC = "wubarrk.mistsofavalor.RelocateGrave"; public const string QueryRPC = "wubarrk.mistsofavalor.Query"; public const string AnswerRPC = "wubarrk.mistsofavalor.Answer"; public const string RequestPortalSiteRPC = "wubarrk.mistsofavalor.ReqPortalSite"; public const string GrantPortalSiteRPC = "wubarrk.mistsofavalor.GrantPortalSite"; public const string PortalSitedRPC = "wubarrk.mistsofavalor.PortalSited"; public const string RecoverGravesRPC = "wubarrk.mistsofavalor.RecoverGraves"; public const string GatherGravesRPC = "wubarrk.mistsofavalor.GatherGraves"; public const string ResetMazeRPC = "wubarrk.mistsofavalor.ResetMaze"; public const int QueryExit = 1; public const int QueryNearestGrave = 2; private static ZRoutedRpc _registeredOn; private static readonly Dictionary _answers = new Dictionary(); private static readonly Dictionary _lastQuerySent = new Dictionary(); private const float PortalClaimTimeout = 120f; private static long _portalClaimHolder; private static float _portalClaimAt; public static bool IsHeadless { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 if (!_headless.HasValue) { _headless = (int)SystemInfo.graphicsDeviceType == 4; } return _headless.Value; } } public static NetRole Role { get { if (_role == NetRole.Unknown && (Object)(object)ZNet.instance != (Object)null) { _role = ((!ZNet.instance.IsServer()) ? NetRole.Client : (IsHeadless ? NetRole.DedicatedServer : NetRole.PlayerHost)); } return _role; } } public static bool IsServerRole { get { if (Role != NetRole.DedicatedServer) { return Role == NetRole.PlayerHost; } return true; } } public static bool PortalGrantAnswered { get; private set; } public static bool PortalSiteGranted { get; private set; } public static void Print(string msg) { Console instance = Console.instance; if (instance != null) { instance.Print(msg); } Logger.LogInfo((object)("[Avalor][cmd] " + msg)); } public static void EnsureRegistered() { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance == null || instance == _registeredOn) { return; } _registeredOn = instance; _role = NetRole.Unknown; _answers.Clear(); _lastQuerySent.Clear(); _portalClaimHolder = 0L; PortalGrantAnswered = false; PortalSiteGranted = false; NetRole role = Role; bool isServerRole = IsServerRole; RegisterSafe(instance, "wubarrk.mistsofavalor.Evacuate", delegate(ZRoutedRpc r) { r.Register("wubarrk.mistsofavalor.Evacuate", (Action)RPC_Evacuate); }); RegisterSafe(instance, "wubarrk.mistsofavalor.Answer", delegate(ZRoutedRpc r) { r.Register("wubarrk.mistsofavalor.Answer", (Action)RPC_Answer); }); RegisterSafe(instance, "wubarrk.mistsofavalor.GrantPortalSite", delegate(ZRoutedRpc r) { r.Register("wubarrk.mistsofavalor.GrantPortalSite", (Action)RPC_GrantPortalSite); }); if (isServerRole) { RegisterSafe(instance, "wubarrk.mistsofavalor.EnsureMaze", delegate(ZRoutedRpc r) { r.Register("wubarrk.mistsofavalor.EnsureMaze", (Action)RPC_EnsureMaze); }); RegisterSafe(instance, "wubarrk.mistsofavalor.RelocateGrave", delegate(ZRoutedRpc r) { r.Register("wubarrk.mistsofavalor.RelocateGrave", (Action)Avalor_TombstoneToGraveyard_Patch.ServerRelocateGrave); }); RegisterSafe(instance, "wubarrk.mistsofavalor.Query", delegate(ZRoutedRpc r) { r.Register("wubarrk.mistsofavalor.Query", (Action)RPC_Query); }); RegisterSafe(instance, "wubarrk.mistsofavalor.ReqPortalSite", delegate(ZRoutedRpc r) { r.Register("wubarrk.mistsofavalor.ReqPortalSite", (Action)RPC_RequestPortalSite); }); RegisterSafe(instance, "wubarrk.mistsofavalor.PortalSited", delegate(ZRoutedRpc r) { r.Register("wubarrk.mistsofavalor.PortalSited", (Action)RPC_PortalSited); }); RegisterSafe(instance, "wubarrk.mistsofavalor.RecoverGraves", delegate(ZRoutedRpc r) { r.Register("wubarrk.mistsofavalor.RecoverGraves", (Action)RPC_RecoverGraves); }); RegisterSafe(instance, "wubarrk.mistsofavalor.GatherGraves", delegate(ZRoutedRpc r) { r.Register("wubarrk.mistsofavalor.GatherGraves", (Action)RPC_GatherGraves); }); RegisterSafe(instance, "wubarrk.mistsofavalor.ResetMaze", delegate(ZRoutedRpc r) { r.Register("wubarrk.mistsofavalor.ResetMaze", (Action)RPC_ResetMaze); }); } Logger.LogInfo((object)(string.Format("[Avalor][net] topology={0} - RPCs registered ({1} handlers) ", role, isServerRole ? "SERVER+client" : "client") + $"headless={IsHeadless} " + $"activeArea={(((Object)(object)ZoneSystem.instance != (Object)null) ? ZoneSystem.instance.m_activeArea : (-1))}")); } private static void RegisterSafe(ZRoutedRpc rpc, string name, Action register) { try { register(rpc); } catch (Exception ex) { Logger.LogError((object)("[Avalor][FAIL] could not register routed RPC '" + name + "' - most likely a name collision with another mod. The feature behind it will not work this session. Reason: " + ex.Message)); } } public static List GetMazePlayers(float radius = 300f) { //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_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_0040: 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) //IL_0056: 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_0060: 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) List list = new List(); if ((Object)(object)ZNet.instance == (Object)null) { return list; } Vector3 mazeCenter = AvalorMazeGenerator.MazeCenter; foreach (ZDO allCharacterZDO in ZNet.instance.GetAllCharacterZDOS()) { if (allCharacterZDO != null) { Vector3 position = allCharacterZDO.GetPosition(); if (InMazeAirspace(position, mazeCenter, radius)) { list.Add(new PlayerPresence { pos = position, rot = allCharacterZDO.GetRotation(), ownerUid = allCharacterZDO.GetOwner() }); } } } return list; } public static bool AnyPlayersInMaze(float radius = 400f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) Vector3 mazeCenter = AvalorMazeGenerator.MazeCenter; if ((Object)(object)ZNet.instance != (Object)null) { foreach (ZDO allCharacterZDO in ZNet.instance.GetAllCharacterZDOS()) { if (allCharacterZDO != null && InMazeAirspace(allCharacterZDO.GetPosition(), mazeCenter, radius)) { return true; } } foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer != null && InMazeAirspace(peer.m_refPos, mazeCenter, radius)) { return true; } } } if ((Object)(object)Player.m_localPlayer != (Object)null && InMazeAirspace(((Component)Player.m_localPlayer).transform.position, mazeCenter, radius)) { return true; } return false; } private static bool InMazeAirspace(Vector3 p, Vector3 center, float radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!AvalorRegion.InSkyMaze(p)) { return false; } float num = p.x - center.x; float num2 = p.z - center.z; return num * num + num2 * num2 < radius * radius; } private static void RPC_RecoverGraves(long sender) { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { Logger.LogWarning((object)("[Avalor][FAIL] grave recovery: RecoverGraves arrived on a machine that is " + $"not the server (asked by {sender}) - ignoring. No grave was changed.")); return; } int num = AvalorGraveGuard.Sweep($"avalor_recover_graves from {sender}", verbose: true); Logger.LogInfo((object)$"[Avalor] grave recovery requested by {sender}: {num} grave(s) recovered."); } public static bool RequestGraveRecovery() { if (ZRoutedRpc.instance == null) { Logger.LogWarning((object)"[Avalor][FAIL] grave recovery: no routed RPC channel - cannot reach the server. Nothing was changed; graves are still where they are."); return false; } ZRoutedRpc.instance.InvokeRoutedRPC("wubarrk.mistsofavalor.RecoverGraves", Array.Empty()); return true; } private static void RPC_GatherGraves(long sender) { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { Logger.LogWarning((object)("[Avalor][FAIL] grave gather: GatherGraves arrived on a machine that is not " + $"the server (asked by {sender}) - ignoring. No grave was changed.")); return; } int num = AvalorGraveGuard.GatherAll($"avalor_gather_graves from {sender}"); Logger.LogInfo((object)$"[Avalor] grave gather requested by {sender}: {num} grave(s) moved to the graveyard."); } public static bool RequestGraveGather() { if (ZRoutedRpc.instance == null) { Logger.LogWarning((object)"[Avalor][FAIL] grave gather: no routed RPC channel - cannot reach the server. Nothing was changed; graves are still where they are."); return false; } ZRoutedRpc.instance.InvokeRoutedRPC("wubarrk.mistsofavalor.GatherGraves", Array.Empty()); return true; } private static void RPC_ResetMaze(long sender, bool remote) { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { Logger.LogWarning((object)("[Avalor][FAIL] maze reset: ResetMaze arrived on a machine that is not the " + $"server (asked by {sender}) - ignoring. The labyrinth is unchanged.")); return; } if ((Object)(object)AvalorResetManager.Instance == (Object)null) { Logger.LogWarning((object)($"[Avalor][FAIL] maze reset requested by {sender}, but there is no reset " + "manager on this server - nothing was done. The labyrinth is unchanged.")); return; } Logger.LogInfo((object)($"[Avalor] maze reset requested by {sender} (remote={remote}) - running it on the " + "SERVER, where the ZDOs are owned.")); AvalorResetManager.Instance.ForceResetMaze(remote); } public static bool RequestMazeReset(bool remote) { if (ZRoutedRpc.instance == null) { Logger.LogWarning((object)"[Avalor][FAIL] maze reset: no routed RPC channel - cannot reach the server. The labyrinth is unchanged."); return false; } ZRoutedRpc.instance.InvokeRoutedRPC("wubarrk.mistsofavalor.ResetMaze", new object[1] { remote }); return true; } private static void RPC_EnsureMaze(long sender) { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } AvalorMazeGenerator instance = AvalorMazeGenerator.Instance; if (!((Object)(object)instance == (Object)null) && !instance.IsGenerating) { if (AvalorMazeGenerator.MazeExistsInWorld()) { instance.RecoverSpawnedZDOs(); return; } Logger.LogInfo((object)$"[Avalor] no labyrinth standing - forging it server-side (requested by {sender})."); ((MonoBehaviour)instance).StartCoroutine(instance.GenerateMaze()); } } private static void RPC_Evacuate(long sender) { //IL_0015: 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_0085: 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_008e: 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_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) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && AvalorRegion.InSkyMaze(((Component)localPlayer).transform.position)) { ((Character)localPlayer).Message((MessageType)2, "The mists tear you free - the labyrinth is being reforged!", 0, (Sprite)null); AvalorPortalWalkTrigger.Suppress(); Vector3 val2 = default(Vector3); Vector3 val = (Vector3)(((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetLocationIcon("StartTemple", ref val2)) ? (val2 + new Vector3(0f, 1.5f, 0f)) : new Vector3(0f, 50f, 0f)); ((Character)localPlayer).TeleportTo(val, ((Component)localPlayer).transform.rotation, false); Logger.LogInfo((object)"[Avalor] evacuated the local player from the labyrinth (maze reset incoming)."); } } public static void SendQuery(int kind) { if (ZRoutedRpc.instance != null && (!_lastQuerySent.TryGetValue(kind, out var value) || !(Time.realtimeSinceStartup - value < 2f))) { _lastQuerySent[kind] = Time.realtimeSinceStartup; ZRoutedRpc.instance.InvokeRoutedRPC("wubarrk.mistsofavalor.Query", new object[1] { kind }); } } public static bool TryGetFreshAnswer(int kind, float maxAge, out bool found, out Vector3 pos) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) found = false; pos = Vector3.zero; if (!_answers.TryGetValue(kind, out var value)) { return false; } if (Time.realtimeSinceStartup - value.at > maxAge) { return false; } found = value.found; pos = value.pos; return true; } private static void RPC_Answer(long sender, int kind, bool found, Vector3 pos) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) _answers[kind] = new CachedAnswer { found = found, pos = pos, at = Time.realtimeSinceStartup }; } private static void RPC_Query(long sender, int kind) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_003c: 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) if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer() && ZRoutedRpc.instance != null) { bool flag = false; Vector3 pos = Vector3.zero; switch (kind) { case 1: flag = AvalorMobDirector.TryFindExit(out pos); break; case 2: flag = TryFindNearestTombstone(GetAskerPosition(sender), out pos); break; } ZRoutedRpc.instance.InvokeRoutedRPC(sender, "wubarrk.mistsofavalor.Answer", new object[3] { kind, flag, pos }); if (MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)$"[Avalor][net] answered query kind={kind} for {sender}: found={flag} pos={pos:F0}"); } } } private static Vector3 GetAskerPosition(long sender) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) ZNetPeer peer = ZNet.instance.GetPeer(sender); if (peer != null) { return peer.m_refPos; } if ((Object)(object)Player.m_localPlayer != (Object)null) { return ((Component)Player.m_localPlayer).transform.position; } return Vector3.zero; } private static bool TryFindNearestTombstone(Vector3 from, out Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) pos = Vector3.zero; Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { return false; } int stableHashCode = StringExtensionMethods.GetStableHashCode("Player_tombstone"); float num = float.MaxValue; bool result = false; foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value != null && value.GetPrefab() == stableHashCode) { Vector3 val = value.GetPosition() - from; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; pos = value.GetPosition(); result = true; } } } return result; } public static void RequestPortalSite() { PortalGrantAnswered = false; PortalSiteGranted = false; ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC("wubarrk.mistsofavalor.ReqPortalSite", Array.Empty()); } } public static void NotifyPortalSited() { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC("wubarrk.mistsofavalor.PortalSited", Array.Empty()); } } public static void ServerMarkPortalSiting() { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { _portalClaimHolder = ZDOMan.GetSessionID(); _portalClaimAt = Time.realtimeSinceStartup; } } public static bool TryFindOverworldPortalNearTemple(out Vector3 pos, out ZDO zdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00a2: 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_0092: Unknown result type (might be due to invalid IL or missing references) pos = Vector3.zero; zdo = null; Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { return false; } Vector3 zero = Vector3.zero; bool flag = (Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetLocationIcon("StartTemple", ref zero); int stableHashCode = StringExtensionMethods.GetStableHashCode("Avalor_OverworldPortal"); foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value != null && value.GetPrefab() == stableHashCode) { Vector3 position = value.GetPosition(); if (!(position.x >= 25000f) && (!flag || !(Vector3.Distance(position, zero) > 150f))) { pos = position; zdo = value; return true; } } } return false; } private static void RPC_RequestPortalSite(long sender) { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || ZRoutedRpc.instance == null) { return; } bool num = MistsofAvalorPlugin.SpawnPortalAtStart == null || MistsofAvalorPlugin.SpawnPortalAtStart.Value; Vector3 pos; ZDO zdo; bool flag = TryFindOverworldPortalNearTemple(out pos, out zdo); if (!num) { if (flag && zdo != null) { if (!zdo.IsOwner()) { zdo.SetOwner(ZDOMan.GetSessionID()); } ZDOMan.instance.DestroyZDO(zdo); Logger.LogInfo((object)"[Avalor] SpawnPortalAtStart is OFF - removed the existing overworld portal."); } Grant(sender, granted: false, "config off"); } else if (flag) { Grant(sender, granted: false, "portal already exists"); } else { float realtimeSinceStartup = Time.realtimeSinceStartup; if (_portalClaimHolder != 0L && _portalClaimHolder != sender && realtimeSinceStartup - _portalClaimAt < 120f) { Grant(sender, granted: false, "another machine is siting it"); return; } _portalClaimHolder = sender; _portalClaimAt = realtimeSinceStartup; Grant(sender, granted: true, "granted"); } } private static void Grant(long sender, bool granted, string why) { Logger.LogInfo((object)string.Format("[Avalor] portal-siting request from {0}: {1} ({2}).", sender, granted ? "GRANTED" : "denied", why)); ZRoutedRpc.instance.InvokeRoutedRPC(sender, "wubarrk.mistsofavalor.GrantPortalSite", new object[1] { granted }); } private static void RPC_PortalSited(long sender) { if (sender == _portalClaimHolder) { _portalClaimHolder = 0L; } Logger.LogInfo((object)$"[Avalor] portal siting finished by {sender} - claim released."); } private static void RPC_GrantPortalSite(long sender, bool granted) { PortalGrantAnswered = true; PortalSiteGranted = granted; } } public class AvalorResetManager : MonoBehaviour { public static ConfigEntry ResetTimerHours; private float lastGeneratedTime; private float checkTimer; public static AvalorResetManager Instance { get; private set; } private void Awake() { //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_0048: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown Instance = this; ResetTimerHours = ((BaseUnityPlugin)MistsofAvalorPlugin.Instance).Config.Bind("General", "MazeResetIntervalHours", 24f, new ConfigDescription("How often (in real hours) the maze regenerates automatically.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 720f), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); } public void MarkGenerated() { lastGeneratedTime = Time.realtimeSinceStartup; } private void Update() { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } checkTimer += Time.deltaTime; if (!(checkTimer < 60f)) { checkTimer = 0f; if (lastGeneratedTime != 0f && !(ResetTimerHours.Value <= 0f) && (Time.realtimeSinceStartup - lastGeneratedTime) / 3600f >= ResetTimerHours.Value) { TryResetMaze(); } } } private void TryResetMaze() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!AvalorNet.AnyPlayersInMaze()) { if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"Avalor Reset Timer reached. No players inside. Regenerating maze."); } WipeSkyZone(AvalorMazeGenerator.MazeCenter, 2000f); AvalorMazeGenerator instance = AvalorMazeGenerator.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(AvalorMazeGenerator.Instance.GenerateMaze()); } } else if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"Avalor Reset Timer reached, but players are inside. Waiting..."); } } public void ForceResetMaze(bool remote = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_0025: Unknown result type (might be due to invalid IL or missing references) Vector3 mazeCenter = AvalorMazeGenerator.MazeCenter; if ((Object)(object)Player.m_localPlayer != (Object)null && !remote && Vector3.Distance(((Component)Player.m_localPlayer).transform.position, mazeCenter) > 2000f) { ((Character)Player.m_localPlayer).Message((MessageType)2, "You must be inside Avalor to run avalor_reset!", 0, (Sprite)null); Logger.LogWarning((object)"avalor_reset failed: Player is too far away. The maze zone is not loaded."); return; } bool flag = AvalorNet.AnyPlayersInMaze(); bool flag2 = ZRoutedRpc.instance != null; if (flag && flag2) { Logger.LogInfo((object)("[Avalor] maze reset with players inside - broadcasting evacuation first " + $"(decided by {AvalorNet.Role}, remote={remote}).")); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "wubarrk.mistsofavalor.Evacuate", Array.Empty()); ((MonoBehaviour)this).StartCoroutine(WipeAfterEvacuation(remote)); } else if (flag && !flag2) { Logger.LogWarning((object)"[Avalor][FAIL] maze reset: players ARE inside but there is no routed RPC channel to evacuate them with. Wiping anyway would drop them into the void, so the reset is ABANDONED. Try again once the world is fully joined."); } else { Logger.LogInfo((object)($"[Avalor] maze reset: no players detected inside (decided by {AvalorNet.Role}, " + $"remote={remote}) - wiping without an evacuation broadcast. If someone WAS in " + "there, this is the line that got it wrong.")); DoForceReset(remote); } } private IEnumerator WipeAfterEvacuation(bool remote) { yield return (object)new WaitForSeconds(3.5f); for (float waited = 3.5f; waited < 10f; waited += 1f) { if (!AvalorNet.AnyPlayersInMaze()) { break; } yield return (object)new WaitForSeconds(1f); } DoForceReset(remote); } private void DoForceReset(bool remote) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"Forcing Maze Reset! Wiping zone safely..."); } WipeSkyZone(AvalorMazeGenerator.MazeCenter, 2000f); if (!((Object)(object)AvalorMazeGenerator.Instance != (Object)null)) { return; } ((MonoBehaviour)AvalorMazeGenerator.Instance).StopAllCoroutines(); ((MonoBehaviour)AvalorMazeGenerator.Instance).StartCoroutine(AvalorMazeGenerator.Instance.GenerateMaze(delegate { //IL_0015: 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_003e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer != (Object)null && !remote) { AvalorSafePlatform.Drop(AvalorMazeGenerator.StartLocation, 10f, 10f); ((Character)Player.m_localPlayer).TeleportTo(AvalorMazeGenerator.StartLocation, ((Component)Player.m_localPlayer).transform.rotation, true); ((Character)Player.m_localPlayer).Message((MessageType)2, "Maze reset! Teleported to start.", 0, (Sprite)null); } else if ((Object)(object)Player.m_localPlayer != (Object)null && remote) { ((Character)Player.m_localPlayer).Message((MessageType)2, "Maze reset remotely! You have not been teleported.", 0, (Sprite)null); } })); } public void WipeSkyZoneAfterEvacuation(string what) { ((MonoBehaviour)this).StartCoroutine(WipeSkyZoneAfterEvacuationRoutine(what)); } private IEnumerator WipeSkyZoneAfterEvacuationRoutine(string what) { if (AvalorNet.AnyPlayersInMaze()) { if (ZRoutedRpc.instance == null) { Logger.LogWarning((object)("[Avalor][FAIL] " + what + ": players are in the labyrinth and there is no routed RPC channel to evacuate them with. ABANDONED - wiping would have dropped them into the void.")); yield break; } Logger.LogInfo((object)("[Avalor] " + what + " with players inside - broadcasting evacuation first " + $"(decided by {AvalorNet.Role}).")); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "wubarrk.mistsofavalor.Evacuate", Array.Empty()); yield return (object)new WaitForSeconds(3.5f); for (float waited = 3.5f; waited < 10f; waited += 1f) { if (!AvalorNet.AnyPlayersInMaze()) { break; } yield return (object)new WaitForSeconds(1f); } } else { Logger.LogInfo((object)("[Avalor] " + what + ": no players detected in the labyrinth's airspace " + $"(decided by {AvalorNet.Role}) - wiping without an evacuation broadcast.")); } WipeSkyZone(AvalorMazeGenerator.MazeCenter, 2000f); } public void WipeSkyZone(Vector3 center, float radius) { //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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNetScene.instance == (Object)null || ZDOMan.instance == null) { return; } AvalorMazeGenerator instance = AvalorMazeGenerator.Instance; if (instance != null) { ((MonoBehaviour)instance).StopAllCoroutines(); } AvalorMazeGenerator.Instance?.spawnedZDOs.Clear(); AvalorMobDirector.Instance?.OnMazeWiped(); AvalorHuntEnforcer.Forget(); int stableHashCode = StringExtensionMethods.GetStableHashCode("Player"); int stableHashCode2 = StringExtensionMethods.GetStableHashCode("Player_tombstone"); bool flag = radius > 0f; Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); List list = new List(); if (zDODictionary != null) { foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value == null) { continue; } Vector3 position = value.GetPosition(); if (!(position.x <= 25000f) && (!flag || !(Vector3.Distance(position, center) > radius))) { int prefab = value.GetPrefab(); if (prefab != stableHashCode && prefab != stableHashCode2) { list.Add(value); } } } } long sessionID = ZDOMan.GetSessionID(); foreach (ZDO item2 in list) { ZNetView val = ZNetScene.instance.FindInstance(item2); if ((Object)(object)val != (Object)null) { val.ClaimOwnership(); ZNetScene.instance.Destroy(((Component)val).gameObject); continue; } if (!item2.IsOwner()) { item2.SetOwner(sessionID); } ZDOMan.instance.DestroyZDO(item2); } int num = 0; ZNetView[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (ZNetView val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).GetComponent() != (Object)null)) { Vector3 position2 = ((Component)val2).transform.position; if (!(position2.x <= 25000f) && (!flag || !(Vector3.Distance(position2, center) > radius))) { ZNetScene.instance.Destroy(((Component)val2).gameObject); num++; } } } if (MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)$"[Avalor] WipeSkyZone cleared {list.Count} ZDO(s) + {num} loaded straggler(s) in the sky region."); } } } internal static class AvalorSafePlatform { private static Material _donor; private static bool _donorResolved; private static readonly string[] DonorPrefabs = new string[4] { "Avalor_MegaFloor", "stone_wall_2x2", "rock4_coast", "StoneBlock_Fracture" }; public static GameObject Drop(Vector3 feetPos, float size, float lifetime) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //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_0044: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val).name = "AvalorSafePlatform"; val.transform.position = feetPos - new Vector3(0f, 0.5f, 0f); val.transform.localScale = new Vector3(size, 1f, size); int num = LayerMask.NameToLayer("static_solid"); if (num >= 0) { val.layer = num; } MeshRenderer component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Material val2 = ResolveDonor(); if ((Object)(object)val2 != (Object)null) { ((Renderer)component).sharedMaterial = val2; } else { ((Renderer)component).enabled = false; } ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; } Object.Destroy((Object)(object)val, lifetime); return val; } private static Material ResolveDonor() { if (_donorResolved) { return _donor; } _donorResolved = true; if ((Object)(object)ZNetScene.instance == (Object)null) { _donorResolved = false; return null; } string[] donorPrefabs = DonorPrefabs; foreach (string text in donorPrefabs) { GameObject prefab = ZNetScene.instance.GetPrefab(text); if ((Object)(object)prefab == (Object)null) { continue; } MeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (MeshRenderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Renderer)val).sharedMaterial == (Object)null) && !((Object)(object)((Renderer)val).sharedMaterial.shader == (Object)null)) { _donor = ((Renderer)val).sharedMaterial; if (MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)("[Avalor] safe platform borrowed material '" + ((Object)_donor).name + "' (shader '" + ((Object)_donor.shader).name + "') from " + text + ".")); } return _donor; } } } Logger.LogWarning((object)"[Avalor][FAIL] no donor material found for the arrival safety platform - rendering it INVISIBLE so it cannot show up as a magenta block. It still catches the player; only the visual is lost."); return null; } } [HarmonyPatch(typeof(ZoneSystem), "PlaceVegetation")] public static class Avalor_SkyRegionNoVegetation_Patch { private static int _skipped; public static bool Prefix(Vector3 zoneCenterPos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (zoneCenterPos.x <= 25000f) { return true; } if (MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value && ++_skipped % 25 == 1) { Logger.LogInfo((object)$"[Avalor] skipped Ashlands vegetation for {_skipped} sky-region zone(s)."); } return false; } } [HarmonyPatch(typeof(Player), "AddKnownBiome")] public static class Avalor_NoAshlandsDiscovery_Patch { public static bool Prefix(Player __instance) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || !AvalorRegion.InSkyMaze(((Component)__instance).transform.position)) { return true; } if (MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"[Avalor] suppressed the biome-discovered card inside the sky maze (the labyrinth is not the Ashlands, whatever the heightmap underneath says)."); } return false; } } public static class AvalorRegion { public const float SkyRegionX = 25000f; public static bool InSkyMaze(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return p.x > 25000f; } } public enum DifficultyLevel { Easy, Normal, Hardcore } public enum ClutterDensity { None, Normal, High, Higher, Extreme } public enum MazeComplexity { Normal, Hard, Extreme } public enum LightingLevel { None, Some, More, Most } public enum MistDensity { None, Little, Normal, More, Most } [BepInPlugin("wubarrk.mistsofavalor", "Mists of Avalor", "0.1.11")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class MistsofAvalorPlugin : BaseUnityPlugin { public const string PluginGUID = "wubarrk.mistsofavalor"; public const string PluginName = "Mists of Avalor"; public const string PluginVersion = "0.1.11"; public static ConfigEntry DifficultyConfig; public static ConfigEntry ClutterConfig; public static ConfigEntry ComplexityConfig; public static ConfigEntry LightingConfig; public static ConfigEntry MistConfig; public static ConfigEntry SpawnPortalAtStart; public static ConfigEntry DebugLogging; public static ConfigEntry ExitCompass; private readonly Harmony harmony = new Harmony("wubarrk.mistsofavalor"); public static MistsofAvalorPlugin Instance { get; private set; } private void Awake() { //IL_0010: 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_001d: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: 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_01d6: Unknown result type (might be due to invalid IL or missing references) Instance = this; AvalorDiagLog.Init("0.1.11"); ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; DifficultyConfig = ((BaseUnityPlugin)this).Config.Bind("General", "Difficulty", DifficultyLevel.Normal, new ConfigDescription("Sets the difficulty of the Avalor Labyrinth (Easy, Normal, Hardcore).", (AcceptableValueBase)null, new object[1] { val })); ClutterConfig = ((BaseUnityPlugin)this).Config.Bind("General", "ClutterDensity", ClutterDensity.Normal, new ConfigDescription("Density of debris scattered in the OPEN floor of the corridors (None disables open-floor scatter; the wall bases/faces are always dressed regardless). None, Normal, High, Higher, Extreme.", (AcceptableValueBase)null, new object[1] { val })); ComplexityConfig = ((BaseUnityPlugin)this).Config.Bind("General", "MazeComplexity", MazeComplexity.Normal, new ConfigDescription("Sets the size and complexity of the Labyrinth (Normal = 20x20, Hard = 40x40, Extreme = 60x60). Applies on the next maze generation.", (AcceptableValueBase)null, new object[1] { val })); LightingConfig = ((BaseUnityPlugin)this).Config.Bind("General", "LightingLevel", LightingLevel.Some, new ConfigDescription("Controls how BRIGHTLY the crypt torches burn AND how dark the crypt is. None = PITCH BLACK (torches out, near-zero ambient - bring your own light); Some = heavy gloom; More/Most = progressively brighter. Applies instantly, no regeneration needed - the same torches are always there, only their brightness changes.", (AcceptableValueBase)null, new object[1] { val })); MistConfig = ((BaseUnityPlugin)this).Config.Bind("General", "MistDensity", MistDensity.Little, new ConfigDescription("Controls the fog inside the maze (None, Little, Normal, More, Most). Fog applies instantly; the number of mist props on the next generation.", (AcceptableValueBase)null, new object[1] { val })); SpawnPortalAtStart = ((BaseUnityPlugin)this).Config.Bind("General", "SpawnPortalAtStart", true, new ConfigDescription("Spawns a decrepit Avalor Portal near the starting Sacrificial Stones.", (AcceptableValueBase)null, new object[1] { val })); DebugLogging = ((BaseUnityPlugin)this).Config.Bind("General", "DebugLogging", true, "Enable to show debug logs in the console. On by default during the open beta so bug reports arrive with diagnostics already captured; turn it off if the log noise bothers you. Local to your own client - not server-synced."); ExitCompass = ((BaseUnityPlugin)this).Config.Bind("General", "ExitCompass", true, "Show a faint compass to the labyrinth's exit while you are inside it. Turn this OFF if you would rather be properly lost. Local to your own client - not server-synced."); AvalorWeapons.RegisterLocalization(); AvalorAssetManager.Init(); GameObject val2 = new GameObject("MistsOfAvalor_Managers"); Object.DontDestroyOnLoad((Object)val2); val2.AddComponent(); val2.AddComponent(); val2.AddComponent(); val2.AddComponent(); val2.AddComponent(); val2.AddComponent(); val2.AddComponent(); val2.AddComponent(); val2.AddComponent(); val2.AddComponent(); val2.AddComponent(); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorResetCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorRemoteResetCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorSpawnPortalCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorFixStonesCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorIlluminateCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorTpCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorRemoveAllCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorGenerateAllCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorTpGraveCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorRecoverGravesCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorGatherGravesCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorOpenCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AvalorTpEndCommand()); ApplyPatch(typeof(Avalor_GlobalMazeEnemyDifficulty_Patch), "In-maze enemy health buff (+20%) + sub-boss/boss replication"); ApplyPatch(typeof(Avalor_TombstoneToGraveyard_Patch), "Maze-death tombstone -> graveyard relocation"); ApplyPatch(typeof(Avalor_NoBuildZone_Patch), "No-build protection (maze + portal clearing)"); ApplyPatch(typeof(Avalor_SkyRegionNoVegetation_Patch), "Skip Ashlands vegetation under the sky maze (FPS)"); ApplyPatch(typeof(Avalor_NoAshlandsDiscovery_Patch), "Suppress the 'Ashlands discovered' card inside the maze"); ApplyPatch(typeof(Avalor_GreatswordVitality_Patch), "Avalorian Greatsword +100 health / +100 stamina"); ApplyPatch(typeof(Avalor_HideBladeRecipes_Patch), "Avalor blades hidden from the crafting lists"); Logger.LogInfo((object)"Mists of Avalor loaded successfully."); } private void ApplyPatch(Type patchType, string feature) { try { harmony.CreateClassProcessor(patchType).Patch(); if (DebugLogging != null && DebugLogging.Value) { Logger.LogInfo((object)("[Avalor] Patch applied OK: " + feature)); } } catch (Exception ex) { Logger.LogError((object)("!!! AVALOR PATCH FAILED - FEATURE LOST: \"" + feature + "\". The mod will keep running WITHOUT it. Reason: " + ex)); } } private void OnDestroy() { harmony.UnpatchSelf(); } } [HarmonyPatch(typeof(Character), "Awake")] public static class Avalor_GlobalMazeEnemyDifficulty_Patch { public const float AVALORIAN_HEALTH_BUFF = 1.2f; public const string HPBuffAppliedZDOKey = "Avalor_HPBuffed"; public static void Postfix(Character __instance) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || __instance.IsPlayer()) { return; } ZNetView component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid() || component.GetZDO() == null) { return; } ZDO zDO = component.GetZDO(); if (((Component)__instance).transform.position.x > 25000f && component.IsOwner() && zDO.GetInt("Avalor_HPBuffed", 0) == 0) { zDO.Set("Avalor_HPBuffed", 1); __instance.SetMaxHealth(__instance.GetMaxHealth() * 1.2f); __instance.SetHealth(__instance.GetMaxHealth()); } bool flag = AvalorRegion.InSkyMaze(((Component)__instance).transform.position) && !__instance.IsTamed(); if (flag && component.IsOwner() && zDO.GetInt("SoMStealthExempt", 0) != 1) { zDO.Set("SoMStealthExempt", 1); } int num; if (!flag) { num = ((zDO.GetInt("SoMStealthExempt", 0) == 1) ? 1 : 0); if (num == 0) { goto IL_00fc; } } else { num = 1; } AvalorStealthCompat.Register(__instance); goto IL_00fc; IL_00fc: bool flag2 = zDO.GetInt("AvalorWarden", 0) == 1; if (num != 0 && !flag2) { AvalorHuntEnforcer.Enqueue(((Component)__instance).gameObject); } int num2 = zDO.GetInt("AvalorSubBoss", 0); if (num2 > 0) { AvalorMobModifier.ApplyLocalMutations(((Component)__instance).gameObject, num2 - 1, (MistsofAvalorPlugin.DifficultyConfig == null) ? DifficultyLevel.Normal : MistsofAvalorPlugin.DifficultyConfig.Value); } if (flag2) { __instance.m_name = "$enemy_avalor_warden"; AvalorBossBar.Instance?.Track(__instance, "$enemy_avalor_warden", "The Avalorian Warden", AvalorMobDirector.WardenBarColour, priority: true); AvalorMobDirector.ApplyWardenLocal(((Component)__instance).gameObject, __instance); } else if (zDO.GetInt("AvalorRevenant", 0) == 1) { __instance.m_name = "$enemy_avalor_revenant"; AvalorBossBar.Instance?.Track(__instance, "$enemy_avalor_revenant", "Avalorian Revenant", AvalorCryptEnvZone.AvalorGreen); } else if (flag && num2 == 0) { AvalorianName.Apply(__instance); } } catch (Exception ex) { Logger.LogError((object)("[Avalor] enemy-buff patch threw (skipped this spawn, no harm): " + ex.Message)); } } } [HarmonyPatch(typeof(TombStone), "Awake")] public static class Avalor_TombstoneToGraveyard_Patch { public static float SuppressUntil; private const int GravePlotRows = 4; private const int GravePlotCount = 16; private const float GravePlotInnerLateral = 7f; private const float GravePlotOuterLateral = 9f; private static bool Dbg { get { if (MistsofAvalorPlugin.DebugLogging != null) { return MistsofAvalorPlugin.DebugLogging.Value; } return false; } } public static void Postfix(TombStone __instance) { try { if (!((Object)(object)__instance == (Object)null) && !(Time.time < SuppressUntil)) { ((MonoBehaviour)__instance).StartCoroutine(RelocateWhenReady(__instance)); } } catch (Exception ex) { Logger.LogError((object)("[Avalor] tombstone-relocation start threw - grave LEFT where it died, fully recoverable (NO lost items): " + ex.Message)); } } private static IEnumerator RelocateWhenReady(TombStone ts) { ZNetView znv = null; float t = 0f; while (t < 3f) { if ((Object)(object)ts == (Object)null) { yield break; } znv = ((Component)ts).GetComponent(); if ((Object)(object)znv != (Object)null && znv.IsValid() && znv.GetZDO() != null) { break; } t += Time.deltaTime; yield return null; } if ((Object)(object)ts == (Object)null || (Object)(object)znv == (Object)null || !znv.IsValid() || znv.GetZDO() == null) { if (Dbg) { Logger.LogWarning((object)"[Avalor] grave relocation: ZDO never became valid - leaving grave where it died."); } yield break; } Vector3 position = znv.GetZDO().GetPosition(); if (position.x <= 25000f) { if (Dbg) { Logger.LogInfo((object)$"[Avalor] grave relocation: death at {position:F0} is in the overworld (x<=25000) - left in place."); } yield break; } if (ZRoutedRpc.instance == null) { Logger.LogWarning((object)"[Avalor][FAIL] grave relocation: no routed RPC channel - grave LEFT in the maze (recoverable via avalor_tp_grave)."); yield break; } ZRoutedRpc.instance.InvokeRoutedRPC("wubarrk.mistsofavalor.RelocateGrave", new object[1] { znv.GetZDO().m_uid }); if (Dbg) { Logger.LogInfo((object)$"[Avalor] maze grave at {position:F0} - asked the server to relocate it to the graveyard."); } } internal static void ServerRelocateGrave(long sender, ZDOID graveId) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { Logger.LogWarning((object)("[Avalor][FAIL] grave relocation: RelocateGrave arrived on a machine that " + $"is not the server (asked by {sender}) - ignoring. The grave stays where it " + "died and is recoverable with avalor_tp_grave.")); } else if ((Object)(object)MistsofAvalorPlugin.Instance != (Object)null) { ((MonoBehaviour)MistsofAvalorPlugin.Instance).StartCoroutine(RelocateGraveWhenPresent(sender, graveId)); } else { DoRelocateGrave(sender, graveId, (ZDOMan.instance != null) ? ZDOMan.instance.GetZDO(graveId) : null); } } private static IEnumerator RelocateGraveWhenPresent(long sender, ZDOID graveId) { //IL_000e: 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) float deadline = Time.realtimeSinceStartup + 15f; ZDO zdo = null; while (Time.realtimeSinceStartup < deadline) { zdo = ((ZDOMan.instance != null) ? ZDOMan.instance.GetZDO(graveId) : null); if (zdo != null) { break; } yield return (object)new WaitForSeconds(0.5f); } if (zdo == null) { Logger.LogWarning((object)($"[Avalor][FAIL] grave relocation: the grave ZDO {graveId} never reached the " + $"server's table within {15f:F0}s (asked by {sender}). It was probably " + "looted or destroyed first; if not, the grave is still in the maze and avalor_tp_grave will take the player straight to it.")); } else { DoRelocateGrave(sender, graveId, zdo); } } private static void DoRelocateGrave(long sender, ZDOID graveId, ZDO zdo) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_009b: 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_0062: 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_00dc: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0113: Unknown result type (might be due to invalid IL or missing references) try { if (zdo == null) { Logger.LogWarning((object)($"[Avalor][FAIL] grave relocation: no ZDO for {graveId} (asked by " + $"{sender}) - grave left where it died, recoverable via avalor_tp_grave.")); return; } Vector3 position = zdo.GetPosition(); if (position.x <= 25000f) { if (Dbg) { Logger.LogInfo((object)($"[Avalor] grave relocation: {graveId} is already in the overworld " + $"at {position:F0} - nothing to do (asked by {sender}).")); } return; } if (!TryGetGraveyard(out var pos)) { Logger.LogWarning((object)"[Avalor][FAIL] grave relocation: graveyard portal NOT found in the server's ZDO table - grave LEFT in the maze (never risk losing it)."); return; } if (!AvalorGraveGuard.Reseat(zdo, pos, out var target)) { Logger.LogWarning((object)($"[Avalor][FAIL] grave relocation: could not re-seat {graveId} - it is " + "STILL IN THE MAZE with every item intact. avalor_tp_grave reaches it, and the grave sweep will retry within a minute.")); return; } Logger.LogInfo((object)$"[Avalor] grave relocated (server): maze {position:F0} -> graveyard {target:F0} (portal at {pos:F0}, asked by {sender})."); if ((Object)(object)MistsofAvalorPlugin.Instance != (Object)null) { ((MonoBehaviour)MistsofAvalorPlugin.Instance).StartCoroutine(HoldGraveAt(graveId, pos, target)); } } catch (Exception ex) { Logger.LogError((object)("[Avalor] tombstone-relocation threw - grave LEFT where it died, fully recoverable (NO lost items): " + ex.Message)); } } private static IEnumerator HoldGraveAt(ZDOID graveId, Vector3 graveyard, Vector3 target) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0016: Unknown result type (might be due to invalid IL or missing references) float deadline = Time.realtimeSinceStartup + 6f; while (Time.realtimeSinceStartup < deadline) { yield return (object)new WaitForSeconds(0.5f); ZDO val = ((ZDOMan.instance != null) ? ZDOMan.instance.GetZDO(graveId) : null); if (val == null) { break; } Vector3 position = val.GetPosition(); Vector3 val2 = position - target; if (!(((Vector3)(ref val2)).sqrMagnitude <= 9f)) { Logger.LogWarning((object)($"[Avalor][FAIL] grave {graveId} drifted back to {position:F0} after being moved " + $"to {target:F0} - the owning machine overwrote the move. Re-asserting.")); if (AvalorGraveGuard.Reseat(val, graveyard, out var target2)) { target = target2; } } } } private static Vector3 FindFreePlot(Vector3 center) { //IL_0000: 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_0018: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) List pts = CollectGravePlots(center, 22f); List pts2 = CollectDecorBlockers(center, 26f); if (!SiteAxes(center, out var forward, out var perp)) { float num = Random.Range(0f, (float)Math.PI * 2f); Vector3 val = center + new Vector3(Mathf.Cos(num) * 11f, 0f, Mathf.Sin(num) * 11f); val.y = PlotHeight(center, val); return val; } for (int i = 0; i < 16; i++) { bool flag = i % 2 == 0; int num2 = i / 2; float num3 = ((num2 < 4) ? 7f : 9f) * (flag ? 1f : (-1f)); float num4 = 8f + (float)(num2 % 4) * 3.5f; Vector3 val2 = center + perp * num3 - forward * num4; if (Clear(val2, pts, 2.2f) && Clear(val2, pts2, 3.2f)) { val2.y = PlotHeight(center, val2); return val2; } } Vector3 val3 = center + forward * 12f + perp * ((Random.value < 0.5f) ? 6f : (-6f)); val3.y = PlotHeight(center, val3); return val3; } private static bool SiteAxes(Vector3 portal, out Vector3 forward, out Vector3 perp) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0038: 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_003a: 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) //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_006b: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) forward = Vector3.forward; perp = Vector3.right; Vector3 val = default(Vector3); if ((Object)(object)ZoneSystem.instance == (Object)null || !ZoneSystem.instance.GetLocationIcon("StartTemple", ref val)) { return false; } Vector3 val2 = portal - val; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 1f) { return false; } forward = ((Vector3)(ref val2)).normalized; Vector3 val3 = Vector3.Cross(forward, Vector3.up); perp = ((Vector3)(ref val3)).normalized; return true; } private static float PlotHeight(Vector3 portal, Vector3 plot) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) float num = AvalorGraveGuard.GraveLift(); if (AvalorGraveGuard.TryPadGroundHeight(portal, plot, out var height)) { return height + num; } return portal.y + num; } internal static Vector3 PlotFor(Vector3 graveyard) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return FindFreePlot(graveyard); } private static bool Clear(Vector3 cand, List pts, float minDist) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_001b: 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) //IL_0028: Unknown result type (might be due to invalid IL or missing references) float num = minDist * minDist; foreach (Vector3 pt in pts) { float num2 = cand.x - pt.x; float num3 = cand.z - pt.z; if (num2 * num2 + num3 * num3 < num) { return false; } } return true; } private static List CollectGravePlots(Vector3 center, float radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return CollectByPrefab(center, radius, new string[2] { "Player_tombstone", "MountainGraveStone01" }); } private static List CollectDecorBlockers(Vector3 center, float radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return CollectByPrefab(center, radius, new string[3] { "Avalor_OverworldPortal", "SwampTree1", "stone_wall_2x2" }); } private static List CollectByPrefab(Vector3 center, float radius, string[] names) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_008c: 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_009a: 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_00b6: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { return list; } HashSet hashSet = new HashSet(); foreach (string text in names) { hashSet.Add(StringExtensionMethods.GetStableHashCode(text)); } float num = radius * radius; foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value == null || !hashSet.Contains(value.GetPrefab())) { continue; } Vector3 position = value.GetPosition(); if (!(position.x >= 25000f)) { float num2 = position.x - center.x; float num3 = position.z - center.z; if (num2 * num2 + num3 * num3 <= num) { list.Add(position); } } } return list; } private static bool TryGetGraveyard(out Vector3 pos) { return AvalorMazeGenerator.TryGetGraveyardPortal(out pos); } } [HarmonyPatch(typeof(Player), "PlacePiece", new Type[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })] public static class Avalor_NoBuildZone_Patch { private const float PortalGuardRadius = 28f; private static Vector3 s_graveyard = Vector3.zero; private static float s_lastScan = -999f; public static bool Prefix(Player __instance, Vector3 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { if (IsProtected(pos)) { if (__instance != null) { ((Character)__instance).Message((MessageType)2, "The mists reject your works here.", 0, (Sprite)null); } return false; } } catch (Exception ex) { Logger.LogError((object)("[Avalor] no-build patch threw (allowing this placement): " + ex.Message)); } return true; } private static bool IsProtected(Vector3 pos) { //IL_0000: 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_003f: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) if (pos.x > 25000f) { return true; } if (Time.time - s_lastScan > 30f) { s_lastScan = Time.time; if (TryFindOverworldPortal(out var pos2)) { s_graveyard = pos2; } } if (s_graveyard != Vector3.zero && Vector3.Distance(pos, s_graveyard) < 28f) { return true; } return false; } private static bool TryFindOverworldPortal(out Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) pos = Vector3.zero; Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { return false; } int stableHashCode = StringExtensionMethods.GetStableHashCode("Avalor_OverworldPortal"); foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value != null && value.GetPrefab() == stableHashCode && value.GetPosition().x < 25000f) { pos = value.GetPosition(); return true; } } return false; } } public class AvalorBladeRunes : MonoBehaviour { public static readonly Color DarkAvalorGreen = new Color(0.1f, 0.62f, 0.26f); public Color Colour = DarkAvalorGreen; private static Texture2D _atlasTex; private const float BladeStart = 0.32f; public static void Attach(GameObject weapon, Color colour) { //IL_0062: 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_006b: 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_00dc: 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) if ((Object)(object)weapon == (Object)null) { return; } Dictionary dictionary = new Dictionary(); MeshFilter[] componentsInChildren = weapon.GetComponentsInChildren(true); foreach (MeshFilter val in componentsInChildren) { if (!((Object)(object)val.sharedMesh == (Object)null)) { Transform val2 = ((Component)val).transform.parent; if ((Object)(object)val2 == (Object)null || !val2.IsChildOf(weapon.transform)) { val2 = weapon.transform; } Bounds bounds = val.sharedMesh.bounds; Vector3 size = ((Bounds)(ref bounds)).size; float magnitude = ((Vector3)(ref size)).magnitude; if (!dictionary.TryGetValue(val2, out var value) || magnitude > value) { dictionary[val2] = magnitude; } } } foreach (KeyValuePair item in dictionary) { if (!((Object)(object)((Component)item.Key).GetComponent() != (Object)null)) { ((Component)item.Key).gameObject.AddComponent().Colour = colour; } } if (dictionary.Count == 0) { Logger.LogWarning((object)("[Avalor][FAIL] '" + ((Object)weapon).name + "' has no mesh to hang runes on - the blade will carry NO rune effect.")); } } private void Start() { //IL_003a: 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_0066: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_008a: 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_009f: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0167: Unknown result type (might be due to invalid IL or missing references) MeshFilter val = LargestMeshHere(); if ((Object)(object)val == (Object)null) { ((Behaviour)this).enabled = false; return; } if ((Object)(object)_atlasTex == (Object)null) { _atlasTex = AvalorRuneTexture.GenerateRuneAtlas(Color.white); } Material orCreateRuneMaterial = AvalorRuneMaterial.GetOrCreateRuneMaterial(_atlasTex, Colour); if ((Object)(object)orCreateRuneMaterial == (Object)null) { Logger.LogWarning((object)"[Avalor][FAIL] rune VFX: no usable particle shader - the blade keeps its vanilla look only."); ((Behaviour)this).enabled = false; return; } Matrix4x4 val2 = ((Component)this).transform.worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix; Bounds bounds = val.sharedMesh.bounds; int num = LongestAxis(((Bounds)(ref bounds)).size); Vector3 val3 = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(((Bounds)(ref bounds)).center); Vector3 val4 = Axis(num); Vector3 val5 = ((Bounds)(ref bounds)).extents; Vector3 val6 = ((Matrix4x4)(ref val2)).MultiplyVector(val4 * ((Vector3)(ref val5))[num]); Vector3 val7 = val3 + val6; Vector3 val8 = val3 - val6; bool num2 = ((Vector3)(ref val7)).sqrMagnitude <= ((Vector3)(ref val8)).sqrMagnitude; Vector3 val9 = (num2 ? val7 : val8); Vector3 span = (num2 ? val8 : val7) - val9; if (((Vector3)(ref span)).sqrMagnitude < 1E-08f) { ((Behaviour)this).enabled = false; return; } int num3 = SecondAxis(((Bounds)(ref bounds)).size, num); Vector3 val10 = Axis(num3); val5 = ((Bounds)(ref bounds)).size; val5 = ((Matrix4x4)(ref val2)).MultiplyVector(val10 * ((Vector3)(ref val5))[num3]); float magnitude = ((Vector3)(ref val5)).magnitude; BuildEmitter(orCreateRuneMaterial, val9, span, magnitude); } private void BuildEmitter(Material mat, Vector3 grip, Vector3 span, float width) { //IL_0010: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_004a: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_006b: 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_0097: 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_00ba: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Expected O, but got Unknown //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: 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_022f: 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_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0258: 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_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) float num = ((Vector3)(ref span)).magnitude * 0.68f; Vector3 normalized = ((Vector3)(ref span)).normalized; GameObject val = new GameObject("AvalorBladeRunes"); val.layer = ((Component)this).gameObject.layer; val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = grip + span * 0.65999997f; val.transform.localRotation = Quaternion.FromToRotation(Vector3.up, normalized); ParticleSystem val2 = val.AddComponent(); float num2 = Mathf.Clamp(width * 0.55f, 0.03f, 0.14f); MainModule main = val2.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = true; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.8f, 1.9f); ((MainModule)(ref main)).startSize = new MinMaxCurve(num2 * 0.6f, num2 * 1.4f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0f, 0.12f); ((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.35f); ((MainModule)(ref main)).maxParticles = 70; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.white); ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(9f); ((EmissionModule)(ref emission)).rateOverDistance = MinMaxCurve.op_Implicit(7f); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5; ((ShapeModule)(ref shape)).scale = new Vector3(width * 0.55f, num, width * 0.55f); ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[4] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(1f, 0.12f), new GradientAlphaKey(0.55f, 0.55f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3); TextureSheetAnimationModule textureSheetAnimation = val2.textureSheetAnimation; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled = true; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesX = 4; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesY = 4; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).animation = (ParticleSystemAnimationType)0; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).timeMode = (ParticleSystemAnimationTimeMode)0; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).startFrame = new MinMaxCurve(0f, 16f); ((TextureSheetAnimationModule)(ref textureSheetAnimation)).frameOverTime = new MinMaxCurve(0f); ParticleSystemRenderer component = val.GetComponent(); component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).material = mat; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; } private MeshFilter LargestMeshHere() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) MeshFilter result = null; float num = 0f; MeshFilter[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (MeshFilter val in componentsInChildren) { if (!((Object)(object)val.sharedMesh == (Object)null)) { Bounds bounds = val.sharedMesh.bounds; Vector3 size = ((Bounds)(ref bounds)).size; float magnitude = ((Vector3)(ref size)).magnitude; if (magnitude > num) { num = magnitude; result = val; } } } return result; } private static int LongestAxis(Vector3 s) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!(s.x >= s.y) || !(s.x >= s.z)) { if (!(s.y >= s.z)) { return 2; } return 1; } return 0; } private static int SecondAxis(Vector3 s, int main) { int num = (main + 1) % 3; int num2 = (main + 2) % 3; if (!(((Vector3)(ref s))[num] >= ((Vector3)(ref s))[num2])) { return num2; } return num; } private static Vector3 Axis(int i) { //IL_0013: 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_0007: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(i switch { 1 => Vector3.up, 0 => Vector3.right, _ => Vector3.forward, }); } } public static class AvalorLootManager { private static readonly string[] PoolCommon = new string[9] { "Coins", "Amber", "AmberPearl", "Iron", "Silver", "Crystal", "SurtlingCore", "LinenThread", "Ruby" }; private static readonly string[] PoolMid = new string[13] { "BlackMetal", "Eitr", "YggdrasilWood", "ScaleHide", "Carapace", "Mandible", "Wisp", "Softtissue", "BlackCore", "MoltenCore", "BlackMarble", "Bilebag", "SurtlingCore" }; private static readonly HashSet BulkMaterials = new HashSet { "SurtlingCore", "Iron", "Silver", "BlackMetal", "Grausten", "BlackMarble", "YggdrasilWood", "LinenThread", "Sulfur", "Flametal", "FlametalOre", "Carapace", "ScaleHide", "AskHide" }; private static readonly string[] PoolDeep = new string[14] { "GemstoneRed", "GemstoneBlue", "GemstoneGreen", "Flametal", "FlametalOre", "AskHide", "Grausten", "Sulfur", "ProustitePowder", "CelestialFeather", "VoltureEgg", "BonemawSerpentScale", "MorgenHeart", "Jade" }; private const int CoinsPerRollMin = 40; private const int CoinsPerRollMax = 220; public static void PopulateChest(Container container, DifficultyLevel diff, int tier, float depth01, Random rnd) { if ((Object)(object)container == (Object)null || container.GetInventory() == null) { return; } if (rnd == null) { rnd = new Random(); } depth01 = Mathf.Clamp01(depth01); int multiplier = GetMultiplier(diff); int num = 2 + tier + Mathf.RoundToInt(depth01 * 3f); List list = BuildPool(tier, depth01); if (list.Count == 0) { return; } HashSet hashSet = new HashSet(); for (int i = 0; i < num; i++) { string text = null; for (int j = 0; j < 8; j++) { string text2 = list[rnd.Next(list.Count)]; if (hashSet.Add(text2)) { text = text2; break; } } if (text != null) { if (text == "Coins") { int num2 = rnd.Next(40, 221) * multiplier; num2 = Mathf.RoundToInt((float)num2 * Mathf.Lerp(1f, 3f, depth01)); AddItemSafe(container, "Coins", num2); } else { AddItemSafe(container, text, Quantity(rnd, multiplier, depth01, BulkMaterials.Contains(text))); } } } if (tier >= 3) { AddItemSafe(container, "Avalor_RecallRune", 1); } else if (rnd.NextDouble() < 0.1) { AddItemSafe(container, "Avalor_RecallRune", 1); } } private static List BuildPool(int tier, float depth01) { List list = new List(PoolCommon); if (tier >= 2 || depth01 > 0.25f) { list.AddRange(PoolMid); if (depth01 > 0.55f) { list.AddRange(PoolMid); } } if (tier >= 3 || depth01 > 0.6f) { list.AddRange(PoolDeep); if (depth01 > 0.8f) { list.AddRange(PoolDeep); } } return list; } private static int Quantity(Random rnd, int multi, float depth01, bool bulk) { float num = (float)((bulk ? rnd.Next(8, 25) : ((rnd.NextDouble() < 0.2) ? rnd.Next(1, 3) : rnd.Next(3, 6))) * multi) * Mathf.Lerp(1f, 2f, depth01); return Mathf.Max(1, Mathf.RoundToInt(num)); } public static void PopulateTier1Chest(Container container, DifficultyLevel diff) { PopulateChest(container, diff, 1, 0.15f, null); } public static void PopulateTier2Chest(Container container, DifficultyLevel diff) { PopulateChest(container, diff, 2, 0.5f, null); } public static void PopulateTier3Chest(Container container, DifficultyLevel diff) { PopulateChest(container, diff, 3, 0.85f, null); } public static bool AddGuaranteed(Container container, string prefabName, int amount = 1) { if ((Object)(object)container == (Object)null || container.GetInventory() == null) { return false; } ZNetScene instance = ZNetScene.instance; if ((Object)(object)((instance != null) ? instance.GetPrefab(prefabName) : null) == (Object)null) { return false; } AddItemSafe(container, prefabName, amount); return true; } private static int GetMultiplier(DifficultyLevel diff) { return diff switch { DifficultyLevel.Normal => 2, DifficultyLevel.Hardcore => 3, _ => 1, }; } private static void AddItemSafe(Container container, string prefabName, int amount) { if (amount <= 0) { return; } ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(prefabName) : null); if ((Object)(object)val == (Object)null) { return; } ItemDrop component = val.GetComponent(); if ((Object)(object)component == (Object)null) { return; } ItemData val2 = component.m_itemData.Clone(); int num = Mathf.Max(1, val2.m_shared.m_maxStackSize); int num2 = amount; while (num2 > 0) { ItemData val3 = component.m_itemData.Clone(); val3.m_stack = Mathf.Min(num2, num); val3.m_dropPrefab = val; if (container.GetInventory().AddItem(val3)) { num2 -= val3.m_stack; continue; } break; } } } public static class AvalorWeapons { public const string GreatswordPrefab = "Avalor_Greatsword"; private const string GreatswordDonor = "THSwordKrom"; public const float BonusHealth = 100f; public const float BonusStamina = 100f; private const float SpiritFromPhysical = 0.25f; public static void RegisterLocalization() { try { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "item_avalor_greatsword"; localization.AddTranslation(ref text, "Avalorian Greatsword"); text = "item_avalor_greatsword_desc"; localization.AddTranslation(ref text, "Raised from the deeps of the labyrinth for the one who walked back out of it. The runes cut along its length hold a green fire that will not dry, and it beads and falls from the edge wherever the blade is carried.\n\nVigour of the Conqueror\n+" + Mathf.RoundToInt(100f) + " maximum health\n+" + Mathf.RoundToInt(100f) + " maximum stamina\nWhile the greatsword is wielded.\n\nCannot be forged. Repaired at a forge."); text = "enemy_avalor_revenant"; localization.AddTranslation(ref text, "Avalorian Revenant"); text = "enemy_avalor_warden"; localization.AddTranslation(ref text, "The Avalorian Warden"); Logger.LogInfo((object)"[Avalor] blade localization registered."); } catch (Exception ex) { Logger.LogError((object)("[Avalor] RegisterLocalization failed: " + ex)); } } public static void Register() { CreateGreatsword(); } private static void CreateGreatsword() { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateClonedPrefab("Avalor_Greatsword", "THSwordKrom"); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)"[Avalor][FAIL] donor 'THSwordKrom' missing - greatsword NOT created."); return; } ItemDrop component = val.GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogWarning((object)"[Avalor][FAIL] greatsword donor has no ItemDrop - greatsword NOT created."); return; } SharedData shared = component.m_itemData.m_shared; shared.m_name = "$item_avalor_greatsword"; shared.m_description = "$item_avalor_greatsword_desc"; ScaleDamage(ref shared.m_damages, 1.12f); ScaleDamage(ref shared.m_damagesPerLevel, 1.12f); ElementalToSpirit(ref shared.m_damages, 2.76f, 0.25f); ElementalToSpirit(ref shared.m_damagesPerLevel, 2.76f, 0.25f); shared.m_attackForce *= 1.2f; shared.m_maxDurability *= 1.25f; shared.m_durabilityPerLevel *= 1.25f; shared.m_maxQuality = 4; AvalorBladeRunes.Attach(val, AvalorBladeRunes.DarkAvalorGreen); TintWeaponGreen(val); AddBladeGlow(val); ItemManager.Instance.AddItem(new CustomItem(val, false)); AddRepairOnlyRecipe("Avalor_Greatsword", component); Logger.LogInfo((object)("[Avalor] Avalor_Greatsword registered (donor THSwordKrom): " + $"slash {shared.m_damages.m_slash:F1}, blunt {shared.m_damages.m_blunt:F1}, " + $"pierce {shared.m_damages.m_pierce:F1}, spirit {shared.m_damages.m_spirit:F1}.")); } catch (Exception ex) { Logger.LogError((object)("[Avalor] CreateGreatsword failed: " + ex)); } } private static void AddBladeGlow(GameObject weapon) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) AvalorBladeRunes[] componentsInChildren = weapon.GetComponentsInChildren(true); foreach (AvalorBladeRunes avalorBladeRunes in componentsInChildren) { if (!((Object)(object)((Component)avalorBladeRunes).GetComponent() != (Object)null)) { Light obj = ((Component)avalorBladeRunes).gameObject.AddComponent(); obj.type = (LightType)2; obj.color = AvalorCryptEnvZone.AvalorGreen; obj.range = 3.5f; obj.intensity = 1.1f; obj.shadows = (LightShadows)0; ((Behaviour)obj).enabled = true; } } } private static void AddRepairOnlyRecipe(string prefabName, ItemDrop drop) { //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_009c: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown try { GameObject prefab = PrefabManager.Instance.GetPrefab("forge"); CraftingStation val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent() : null); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("[Avalor][FAIL] forge station not found - " + prefabName + " will NOT be repairable.")); return; } Recipe val2 = ScriptableObject.CreateInstance(); ((Object)val2).name = "Recipe_" + prefabName; val2.m_item = drop; val2.m_amount = 1; val2.m_enabled = true; val2.m_craftingStation = val; val2.m_repairStation = val; val2.m_minStationLevel = 1; val2.m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_resItem = drop, m_amount = 1, m_amountPerLevel = 1, m_recover = false } }; ItemManager.Instance.AddRecipe(new CustomRecipe(val2, false, false)); } catch (Exception ex) { Logger.LogError((object)("[Avalor] AddRepairOnlyRecipe(" + prefabName + ") failed: " + ex)); } } public static bool IsAvalorBlade(string prefabName) { return prefabName == "Avalor_Greatsword"; } private static void ScaleDamage(ref DamageTypes d, float f) { d.m_damage *= f; d.m_slash *= f; d.m_pierce *= f; d.m_blunt *= f; } private static void ElementalToSpirit(ref DamageTypes d, float f, float physicalFallback) { float num = d.m_fire + d.m_frost + d.m_lightning + d.m_poison; if (num > 0f) { d.m_fire = 0f; d.m_frost = 0f; d.m_lightning = 0f; d.m_poison = 0f; d.m_spirit += num * f; } else { float num2 = d.m_damage + d.m_slash + d.m_pierce + d.m_blunt; if (!(num2 <= 0f)) { d.m_spirit += num2 * physicalFallback; } } } private static void TintWeaponGreen(GameObject weapon) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0094: Invalid comparison between Unknown and I4 //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00a7: 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) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) Color avalorGreen = AvalorCryptEnvZone.AvalorGreen; LightFlicker[] componentsInChildren = weapon.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } LightLod[] componentsInChildren2 = weapon.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } Light[] componentsInChildren3 = weapon.GetComponentsInChildren(true); foreach (Light obj in componentsInChildren3) { obj.color = avalorGreen; ((Behaviour)obj).enabled = true; } ParticleSystem[] componentsInChildren4 = weapon.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { MainModule main = componentsInChildren4[i].main; MinMaxGradient startColor = ((MainModule)(ref main)).startColor; if ((int)((MinMaxGradient)(ref startColor)).mode == 2) { ((MainModule)(ref main)).startColor = new MinMaxGradient(Recolor(((MinMaxGradient)(ref startColor)).colorMin, avalorGreen), Recolor(((MinMaxGradient)(ref startColor)).colorMax, avalorGreen)); } else { ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Recolor(((MinMaxGradient)(ref startColor)).color, avalorGreen)); } } } private static Color Recolor(Color src, Color green) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) float num = Mathf.Max(0.15f, ((Color)(ref src)).grayscale); Color result = green * num; result.a = src.a; return result; } } [HarmonyPatch(typeof(InventoryGui), "UpdateRecipeList")] public static class Avalor_HideBladeRecipes_Patch { public static void Prefix(List recipes) { try { recipes?.RemoveAll((Recipe r) => (Object)(object)r != (Object)null && (Object)(object)r.m_item != (Object)null && AvalorWeapons.IsAvalorBlade(((Object)((Component)r.m_item).gameObject).name)); } catch (Exception ex) { Logger.LogError((object)("[Avalor] blade recipe hide patch threw: " + ex.Message)); } } } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] public static class Avalor_GreatswordVitality_Patch { public static void Postfix(Player __instance, ref float hp, ref float stamina) { try { if (!((Object)(object)__instance == (Object)null)) { ItemData currentWeapon = ((Humanoid)__instance).GetCurrentWeapon(); if (currentWeapon != null && !((Object)(object)currentWeapon.m_dropPrefab == (Object)null) && !(((Object)currentWeapon.m_dropPrefab).name != "Avalor_Greatsword")) { hp += 100f; stamina += 100f; } } } catch (Exception ex) { Logger.LogError((object)("[Avalor] greatsword vitality patch threw (stats unchanged this tick): " + ex.Message)); } } } public class AvalorMazeChunkRenderer : MonoBehaviour { public const float CellSize = 6f; public const float FloorHeight = 4f; private static int s_activeBuilds; private const int MaxConcurrentBuilds = 4; private bool _holdingSlot; private void Start() { if (!AvalorNet.IsHeadless) { ((MonoBehaviour)this).StartCoroutine(BuildRoutine()); } } private IEnumerator BuildRoutine() { ZNetView component = ((Component)this).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid() || component.GetZDO() == null) { yield break; } byte[] byteArray = component.GetZDO().GetByteArray("Avalor_ChunkData", (byte[])null); if (byteArray == null || byteArray.Length == 0) { yield break; } int num = component.GetZDO().GetInt("Avalor_ChunkWidth", 5); int num2 = component.GetZDO().GetInt("Avalor_ChunkDepth", 5); int num3 = component.GetZDO().GetInt("Avalor_ChunkFloors", 3); GameObject[] wallPrefabs = (GameObject[])(object)new GameObject[3] { ZNetScene.instance.GetPrefab("Avalor_CompositeWall"), ZNetScene.instance.GetPrefab("Avalor_CompositeWallB"), ZNetScene.instance.GetPrefab("Avalor_CompositeWallC") }; GameObject[] floorPrefabs = (GameObject[])(object)new GameObject[3] { ZNetScene.instance.GetPrefab("Avalor_CompositeFloor"), ZNetScene.instance.GetPrefab("Avalor_CompositeFloorB"), ZNetScene.instance.GetPrefab("Avalor_CompositeFloorC") }; GameObject ceilPrefab = ZNetScene.instance.GetPrefab("Avalor_CompositeCeiling"); GameObject stairPrefab = ZNetScene.instance.GetPrefab("Avalor_CompositeStairTile"); List[] wallMats = new List[3] { new List(), new List(), new List() }; List[] floorMats = new List[3] { new List(), new List(), new List() }; List ceilMats = new List(); List stairMats = new List(); HashSet seen = new HashSet(); float num4 = 3f; int num5 = 0; Vector3 val = default(Vector3); for (int i = 0; i < num3; i++) { for (int j = 0; j < num; j++) { for (int k = 0; k < num2; k++) { if (num5 >= byteArray.Length) { break; } byte num6 = byteArray[num5++]; bool flag = (num6 & 1) != 0; bool flag2 = (num6 & 2) != 0; bool flag3 = (num6 & 4) != 0; bool flag4 = (num6 & 8) != 0; bool num7 = (num6 & 0x40) != 0; float num8 = ((float)j - (float)(num - 1) / 2f) * 6f; float num9 = ((float)k - (float)(num2 - 1) / 2f) * 6f; ((Vector3)(ref val))..ctor(num8, (float)i * 4f, num9); if (flag4) { AddWall(wallMats, seen, val + new Vector3(num4, 0f, 0f), 90); } if (flag) { AddWall(wallMats, seen, val + new Vector3(0f, 0f, num4), 0); } if (flag2) { AddWall(wallMats, seen, val + new Vector3(0f, 0f, 0f - num4), 0); } if (flag3) { AddWall(wallMats, seen, val + new Vector3(0f - num4, 0f, 0f), 270); } bool num10 = !num7 || i == 0; int num11 = Variant(((long)Mathf.RoundToInt(val.x * 100f) * 73856093L) ^ ((long)Mathf.RoundToInt(val.y * 100f) * 19349663L) ^ ((long)Mathf.RoundToInt(val.z * 100f) * 83492791L), floorMats.Length); if (num10) { floorMats[num11].Add(Matrix4x4.TRS(val, Quaternion.identity, Vector3.one)); } if (num10 && i > 0) { ceilMats.Add(Matrix4x4.TRS(val, Quaternion.identity, Vector3.one)); } if (i == num3 - 1) { Vector3 val2 = val + new Vector3(0f, 4f, 0f); floorMats[num11].Add(Matrix4x4.TRS(val2, Quaternion.identity, Vector3.one)); ceilMats.Add(Matrix4x4.TRS(val2, Quaternion.identity, Vector3.one)); } if (!num7) { continue; } float num12 = Mathf.Atan2(4f, 6f) * 57.29578f; float num13 = Mathf.Sqrt(52f) / 6f; float num14 = 0f; if (i > 0) { int num15 = ((i - 1) * num + j) * num2 + k; if (num15 >= 0 && num15 < byteArray.Length) { byte b = byteArray[num15]; if ((b & 2) == 0) { num14 = 0f; } else if ((b & 1) == 0) { num14 = 180f; } else if ((b & 4) == 0) { num14 = 90f; } else if ((b & 8) == 0) { num14 = -90f; } } } if ((Object)(object)stairPrefab != (Object)null) { stairMats.Add(Matrix4x4.TRS(val + new Vector3(0f, -4f, 0f), Quaternion.Euler(0f, num14, 0f), Vector3.one)); } else { floorMats[num11].Add(Matrix4x4.TRS(val + new Vector3(0f, -2f, 0f), Quaternion.Euler(0f, num14, 0f) * Quaternion.Euler(0f - num12, 0f, 0f), new Vector3(1f, 1f, num13))); } } } } float waitStart = Time.realtimeSinceStartup; while (s_activeBuilds >= 4 && Time.realtimeSinceStartup - waitStart < 5f) { yield return null; } s_activeBuilds++; _holdingSlot = true; try { for (int v = 0; v < wallPrefabs.Length; v++) { if (!((Object)(object)wallPrefabs[v] == (Object)null) && wallMats[v].Count != 0) { Mesh wm = null; MeshCollider wc = null; yield return AvalorAssetManager.CombineTileMeshesThreaded(wallPrefabs[v], ((Component)this).gameObject, wallMats[v], delegate(Mesh m, MeshCollider c) { wm = m; wc = c; }); yield return BakeAndAssign(wm, wc); } } for (int v = 0; v < floorPrefabs.Length; v++) { if (!((Object)(object)floorPrefabs[v] == (Object)null) && floorMats[v].Count != 0) { Mesh fm = null; MeshCollider fc = null; yield return AvalorAssetManager.CombineTileMeshesThreaded(floorPrefabs[v], ((Component)this).gameObject, floorMats[v], delegate(Mesh m, MeshCollider c) { fm = m; fc = c; }); yield return BakeAndAssign(fm, fc); } } if ((Object)(object)stairPrefab != (Object)null && stairMats.Count > 0) { Mesh sm = null; MeshCollider sc = null; yield return AvalorAssetManager.CombineTileMeshesThreaded(stairPrefab, ((Component)this).gameObject, stairMats, delegate(Mesh m, MeshCollider c) { sm = m; sc = c; }); yield return BakeAndAssign(sm, sc); } if ((Object)(object)ceilPrefab != (Object)null && ceilMats.Count > 0) { Mesh cm = null; MeshCollider cc = null; yield return AvalorAssetManager.CombineTileMeshesThreaded(ceilPrefab, ((Component)this).gameObject, ceilMats, delegate(Mesh m, MeshCollider c) { cm = m; cc = c; }); yield return BakeAndAssign(cm, cc); } } finally { AvalorMazeChunkRenderer avalorMazeChunkRenderer = this; if (avalorMazeChunkRenderer._holdingSlot) { s_activeBuilds--; avalorMazeChunkRenderer._holdingSlot = false; } } } private static void AddWall(List[] mats, HashSet seen, Vector3 pos, int yaw) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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) long num = ((long)Mathf.RoundToInt(pos.x * 100f) * 73856093L) ^ ((long)Mathf.RoundToInt(pos.y * 100f) * 19349663L) ^ ((long)Mathf.RoundToInt(pos.z * 100f) * 83492791L) ^ (yaw % 180); if (seen.Add(num)) { mats[Variant(num, mats.Length)].Add(Matrix4x4.TRS(pos, Quaternion.Euler(0f, (float)yaw, 0f), Vector3.one)); } } private static int Variant(long key, int count) { if (count <= 1) { return 0; } long num = key * -7046029254386353131L; return (int)((ulong)(num ^ (num >>> 29)) % (ulong)count); } private void OnDestroy() { if (_holdingSlot) { s_activeBuilds--; _holdingSlot = false; } } private IEnumerator BakeAndAssign(Mesh mesh, MeshCollider collider) { if ((Object)(object)mesh == (Object)null || (Object)(object)collider == (Object)null) { yield break; } int meshId = ((Object)mesh).GetInstanceID(); bool baked = false; bool flag; try { ThreadPool.QueueUserWorkItem(delegate { try { Physics.BakeMesh(meshId, false); } catch { } baked = true; }); flag = true; } catch { flag = false; } if (flag) { float guard = 0f; while (!baked && guard < 5f) { guard += Time.deltaTime; yield return null; } } if ((Object)(object)collider != (Object)null) { collider.sharedMesh = mesh; } } } public class AvalorMazeGenerator : MonoBehaviour { private struct MazeCell { public bool visited; public bool wallTop; public bool wallBottom; public bool wallRight; public bool wallLeft; public bool wallCeiling; public bool wallFloor; public int distance; public MazeCell() { visited = false; wallTop = true; wallBottom = true; wallRight = true; wallLeft = true; wallCeiling = true; wallFloor = true; distance = 0; } } public static readonly Vector3 MazeCenter = new Vector3(30000f, 500f, 30000f); public const float SkyWipeRadius = 2000f; private static readonly Quaternion ClutterTurn = Quaternion.Euler(0f, 90f, 0f); public List spawnedZDOs = new List(); private static FieldInfo s_zdoDictField; private const float FloorSurface = 0.1f; private const float ChestSeat = 0.02f; private const float WallDecorDrop = 0.55f; private float mazeSpan; public static AvalorMazeGenerator Instance { get; private set; } public bool IsGenerating { get; private set; } public static Vector3 StartLocation { get; private set; } internal static Dictionary GetZDODictionary() { if (ZDOMan.instance == null) { return null; } try { if (s_zdoDictField == null) { s_zdoDictField = typeof(ZDOMan).GetField("m_objectsByID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } return s_zdoDictField?.GetValue(ZDOMan.instance) as Dictionary; } catch (Exception ex) { Logger.LogError((object)("Avalor: ZDOMan reflection failed: " + ex.Message)); return null; } } public static bool MazeExistsInWorld() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (ZDOMan.instance == null || (Object)(object)ZoneSystem.instance == (Object)null) { return false; } if ((Object)(object)Instance != (Object)null && Instance.spawnedZDOs.Count > 0) { return true; } Dictionary zDODictionary = GetZDODictionary(); if (zDODictionary != null) { foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value != null && value.GetPosition().x > 25000f && value.GetInt("AvalorMazePiece", 0) == 1) { return true; } } } return false; } public static bool TryGetGraveyardPortal(out Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) //IL_00a0: 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) pos = Vector3.zero; Dictionary zDODictionary = GetZDODictionary(); if (zDODictionary == null) { return false; } int stableHashCode = StringExtensionMethods.GetStableHashCode("Avalor_OverworldPortal"); Vector3 zero = Vector3.zero; bool flag = (Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetLocationIcon("StartTemple", ref zero); float num = float.MaxValue; bool flag2 = false; foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value == null || value.GetPrefab() != stableHashCode) { continue; } Vector3 position = value.GetPosition(); if (position.x >= 25000f) { continue; } float num2 = (flag ? Vector3.Distance(position, zero) : 0f); if (!flag2 || num2 < num) { num = num2; pos = position; flag2 = true; if (!flag) { break; } } } return flag2; } public void RecoverSpawnedZDOs() { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_0071: Unknown result type (might be due to invalid IL or missing references) if (ZDOMan.instance == null || (Object)(object)ZoneSystem.instance == (Object)null || spawnedZDOs.Count > 0) { return; } Dictionary zDODictionary = GetZDODictionary(); if (zDODictionary != null) { foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value != null && value.GetPosition().x > 25000f && value.GetInt("AvalorMazePiece", 0) == 1) { spawnedZDOs.Add(value.m_uid); } } } if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)("Avalor Labyrinth: Recovered " + spawnedZDOs.Count + " ZDOs from memory.")); } if (StartLocation == Vector3.zero) { StartLocation = ComputeStartLocation(); } } public static Vector3 ComputeStartLocation() { //IL_0056: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) int num = 40; int num2 = 40; if (MistsofAvalorPlugin.ComplexityConfig.Value == MazeComplexity.Normal) { num = 20; num2 = 20; } else if (MistsofAvalorPlugin.ComplexityConfig.Value == MazeComplexity.Extreme) { num = 60; num2 = 60; } float num3 = 6f; float num4 = (0f - (float)num / 2f) * num3; float num5 = (0f - (float)num2 / 2f) * num3; return MazeCenter + new Vector3(num4, 0.5f, num5) + new Vector3(0f, 1f, 0f); } private void Awake() { Instance = this; } public unsafe IEnumerator GenerateMaze(Action onStartAreaReady = null) { Vector3 center = MazeCenter; IsGenerating = true; AvalorMazeGrid.Invalidate(); bool dbg = MistsofAvalorPlugin.DebugLogging.Value; float genStartTime = Time.realtimeSinceStartup; if (dbg) { Vector3 val = center; Logger.LogInfo((object)("[Avalor] Generating Labyrinth at " + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString())); } StartLocation = ComputeStartLocation(); onStartAreaReady?.Invoke(); List toWipe = new List(); int stableHashCode = StringExtensionMethods.GetStableHashCode("Player"); int stableHashCode2 = StringExtensionMethods.GetStableHashCode("Player_tombstone"); Dictionary zDODictionary = GetZDODictionary(); if (zDODictionary != null) { foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value == null) { continue; } Vector3 position = value.GetPosition(); if (!(position.x <= 25000f) && !(Vector3.Distance(position, center) > 2000f)) { int prefab = value.GetPrefab(); if (prefab != stableHashCode && prefab != stableHashCode2) { toWipe.Add(value); } } } } else { foreach (ZDOID spawnedZDO in spawnedZDOs) { if (!(spawnedZDO == ZDOID.None)) { ZDO zDO = ZDOMan.instance.GetZDO(spawnedZDO); if (zDO != null) { toWipe.Add(zDO); } } } } int destroyCount = 0; long session = ZDOMan.GetSessionID(); foreach (ZDO item2 in toWipe) { if (item2 == null) { continue; } ZNetView val2 = ZNetScene.instance.FindInstance(item2); if ((Object)(object)val2 != (Object)null) { val2.ClaimOwnership(); ZNetScene.instance.Destroy(((Component)val2).gameObject); } else { if (!item2.IsOwner()) { item2.SetOwner(session); } ZDOMan.instance.DestroyZDO(item2); } destroyCount++; if (destroyCount >= 50) { destroyCount = 0; yield return null; } } spawnedZDOs.Clear(); if (dbg) { Logger.LogInfo((object)$"[Avalor] Sky-region wipe removed {toWipe.Count} old ZDO(s) before rebuild."); } int width = 40; int depth = 40; int floors = 2; int num = 15; if (MistsofAvalorPlugin.ComplexityConfig.Value == MazeComplexity.Normal) { width = 20; depth = 20; floors = 1; num = 5; } else if (MistsofAvalorPlugin.ComplexityConfig.Value == MazeComplexity.Extreme) { width = 60; depth = 60; floors = 3; num = 30; } if (dbg) { Logger.LogInfo((object)($"[Avalor] Config: complexity={MistsofAvalorPlugin.ComplexityConfig.Value} " + $"size={width}x{depth}x{floors} arenas={num} difficulty={MistsofAvalorPlugin.DifficultyConfig.Value} " + $"clutter={MistsofAvalorPlugin.ClutterConfig.Value} lighting={MistsofAvalorPlugin.LightingConfig.Value} mist={MistsofAvalorPlugin.MistConfig.Value}")); } float cellSize = 6f; float floorHeight = 4f; AvalorMazeGenerator avalorMazeGenerator = this; Vector2 val3 = new Vector2((float)width * cellSize, (float)depth * cellSize); avalorMazeGenerator.mazeSpan = ((Vector2)(ref val3)).magnitude; float num2 = (0f - (float)width / 2f) * cellSize; float num3 = (0f - (float)depth / 2f) * cellSize; Vector3 val4 = center + new Vector3(num2, 0f, num3); StartLocation = val4 + new Vector3(0f, 1.5f, 0f); ZNetScene instance = ZNetScene.instance; GameObject val5 = ((instance != null) ? instance.GetPrefab("Avalor_MegaFloor") : null); if ((Object)(object)val5 != (Object)null) { InstantiatePiece(val5, val4, Quaternion.identity); } ZNetScene instance2 = ZNetScene.instance; GameObject val6 = ((instance2 != null) ? instance2.GetPrefab("Avalor_StartDais") : null); if ((Object)(object)val6 != (Object)null) { InstantiatePiece(val6, val4, Quaternion.identity); } if (dbg) { Logger.LogInfo((object)$"[Avalor] Entrance platform placed at {StartLocation}."); } MazeCell[,,] grid = new MazeCell[width, floors, depth]; for (int i = 0; i < width; i++) { for (int j = 0; j < floors; j++) { for (int k = 0; k < depth; k++) { grid[i, j, k] = new MazeCell(); } } } Random rnd = new Random(); Stack stack = new Stack(); Vector3Int val7 = default(Vector3Int); ((Vector3Int)(ref val7))..ctor(0, 0, 0); grid[((Vector3Int)(ref val7)).x, ((Vector3Int)(ref val7)).y, ((Vector3Int)(ref val7)).z].visited = true; stack.Push(val7); while (stack.Count > 0) { val7 = stack.Pop(); List unvisitedNeighbors = GetUnvisitedNeighbors(val7, grid, width, floors, depth, rnd); if (unvisitedNeighbors.Count > 0) { stack.Push(val7); Vector3Int val8 = unvisitedNeighbors[rnd.Next(unvisitedNeighbors.Count)]; RemoveWall(val7, val8, grid); grid[((Vector3Int)(ref val8)).x, ((Vector3Int)(ref val8)).y, ((Vector3Int)(ref val8)).z].visited = true; stack.Push(val8); } } for (int l = 1; l < width - 1; l++) { for (int m = 0; m < floors; m++) { for (int n = 1; n < depth - 1; n++) { int num4 = 0; if (grid[l, m, n].wallTop) { num4++; } if (grid[l, m, n].wallBottom) { num4++; } if (grid[l, m, n].wallLeft) { num4++; } if (grid[l, m, n].wallRight) { num4++; } if (num4 >= 3 && rnd.NextDouble() < 0.3499999940395355) { List list = new List(); if (grid[l, m, n].wallTop && n < depth - 1) { list.Add(new Vector3Int(l, m, n + 1)); } if (grid[l, m, n].wallBottom && n > 0) { list.Add(new Vector3Int(l, m, n - 1)); } if (grid[l, m, n].wallLeft && l > 0) { list.Add(new Vector3Int(l - 1, m, n)); } if (grid[l, m, n].wallRight && l < width - 1) { list.Add(new Vector3Int(l + 1, m, n)); } if (list.Count > 0) { Vector3Int chosen = list[rnd.Next(list.Count)]; RemoveWall(new Vector3Int(l, m, n), chosen, grid); } } } } } for (int num5 = 0; num5 < num; num5++) { int num6 = rnd.Next(1, width - 4); int num7 = rnd.Next(0, floors); int num8 = rnd.Next(1, depth - 4); int num9 = rnd.Next(2, 5); for (int num10 = num6; num10 < num6 + num9; num10++) { for (int num11 = num8; num11 < num8 + num9; num11++) { if (num10 < num6 + num9 - 1) { grid[num10, num7, num11].wallRight = false; grid[num10 + 1, num7, num11].wallLeft = false; } if (num10 > num6) { grid[num10, num7, num11].wallLeft = false; grid[num10 - 1, num7, num11].wallRight = false; } if (num11 < num8 + num9 - 1) { grid[num10, num7, num11].wallTop = false; grid[num10, num7, num11 + 1].wallBottom = false; } if (num11 > num8) { grid[num10, num7, num11].wallBottom = false; grid[num10, num7, num11 - 1].wallTop = false; } } } float num12 = ((float)num6 + (float)(num9 - 1) / 2f - (float)width / 2f) * cellSize; float num13 = ((float)num8 + (float)(num9 - 1) / 2f - (float)depth / 2f) * cellSize; Vector3 val9 = center + new Vector3(num12, (float)num7 * floorHeight, num13); ZNetScene instance3 = ZNetScene.instance; GameObject val10 = ((instance3 != null) ? instance3.GetPrefab("Avalor_Chest") : null); string[] array = new string[2] { "Spawner_DraugrPile", "BonePileSpawner" }; string text = array[rnd.Next(array.Length)]; ZNetScene instance4 = ZNetScene.instance; GameObject val11 = ((instance4 != null) ? instance4.GetPrefab(text) : null); if ((Object)(object)val10 != (Object)null) { int num14 = Mathf.Min(num9 - 1, 4); float num15 = (float)num9 * 1.5f; Vector3[] array2 = (Vector3[])(object)new Vector3[4] { new Vector3(num15, 0f, num15), new Vector3(0f - num15, 0f, num15), new Vector3(0f - num15, 0f, 0f - num15), new Vector3(num15, 0f, 0f - num15) }; for (int num16 = 0; num16 < num14; num16++) { Vector3 position2 = val9 + new Vector3(array2[num16].x, 0.02f, array2[num16].z); GameObject chestObj = InstantiatePiece(val10, position2, Quaternion.Euler(0f, (float)rnd.Next(0, 360), 0f)); int lootTier = ((num9 != 4 || !(rnd.NextDouble() < 0.5)) ? 1 : 2); PopulateChest(chestObj, MistsofAvalorPlugin.DifficultyConfig.Value, lootTier); } } if ((Object)(object)val11 != (Object)null && num9 >= 2 && rnd.NextDouble() < 0.55) { int num17 = 1; for (int num18 = 0; num18 < num17; num18++) { float num19 = (float)((rnd.NextDouble() > 0.5) ? 1 : (-1)) * ((float)num9 * 1f); float num20 = (float)((rnd.NextDouble() > 0.5) ? 1 : (-1)) * ((float)num9 * 1f); Vector3 position3 = val9 + new Vector3(num19, FloorSurfaceLift(num7), num20); InstantiatePiece(val11, position3, Quaternion.identity); } } } grid[0, 0, 0].wallRight = false; if (width > 1) { grid[1, 0, 0].wallLeft = false; } grid[0, 0, 0].wallTop = false; if (depth > 1) { grid[0, 0, 1].wallBottom = false; } Queue queue = new Queue(); queue.Enqueue(new Vector3Int(0, 0, 0)); Vector3Int val12 = default(Vector3Int); ((Vector3Int)(ref val12))..ctor(0, 0, 0); int num21 = 0; for (int num22 = 0; num22 < width; num22++) { for (int num23 = 0; num23 < floors; num23++) { for (int num24 = 0; num24 < depth; num24++) { grid[num22, num23, num24].visited = false; } } } grid[0, 0, 0].visited = true; while (queue.Count > 0) { Vector3Int val13 = queue.Dequeue(); int distance = grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].distance; if (distance > num21) { num21 = distance; val12 = val13; } if (!grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].wallTop && ((Vector3Int)(ref val13)).z < depth - 1 && !grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z + 1].visited) { grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z + 1].visited = true; grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z + 1].distance = distance + 1; queue.Enqueue(new Vector3Int(((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z + 1)); } if (!grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].wallBottom && ((Vector3Int)(ref val13)).z > 0 && !grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z - 1].visited) { grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z - 1].visited = true; grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z - 1].distance = distance + 1; queue.Enqueue(new Vector3Int(((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z - 1)); } if (!grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].wallRight && ((Vector3Int)(ref val13)).x < width - 1 && !grid[((Vector3Int)(ref val13)).x + 1, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].visited) { grid[((Vector3Int)(ref val13)).x + 1, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].visited = true; grid[((Vector3Int)(ref val13)).x + 1, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].distance = distance + 1; queue.Enqueue(new Vector3Int(((Vector3Int)(ref val13)).x + 1, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z)); } if (!grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].wallLeft && ((Vector3Int)(ref val13)).x > 0 && !grid[((Vector3Int)(ref val13)).x - 1, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].visited) { grid[((Vector3Int)(ref val13)).x - 1, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].visited = true; grid[((Vector3Int)(ref val13)).x - 1, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].distance = distance + 1; queue.Enqueue(new Vector3Int(((Vector3Int)(ref val13)).x - 1, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z)); } if (!grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].wallCeiling && ((Vector3Int)(ref val13)).y < floors - 1 && !grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y + 1, ((Vector3Int)(ref val13)).z].visited) { grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y + 1, ((Vector3Int)(ref val13)).z].visited = true; grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y + 1, ((Vector3Int)(ref val13)).z].distance = distance + 1; queue.Enqueue(new Vector3Int(((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y + 1, ((Vector3Int)(ref val13)).z)); } if (!grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y, ((Vector3Int)(ref val13)).z].wallFloor && ((Vector3Int)(ref val13)).y > 0 && !grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y - 1, ((Vector3Int)(ref val13)).z].visited) { grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y - 1, ((Vector3Int)(ref val13)).z].visited = true; grid[((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y - 1, ((Vector3Int)(ref val13)).z].distance = distance + 1; queue.Enqueue(new Vector3Int(((Vector3Int)(ref val13)).x, ((Vector3Int)(ref val13)).y - 1, ((Vector3Int)(ref val13)).z)); } } Vector3Int exitCell = val12; Vector3Int prizeCell = ChooseAdjacentOpenCell(grid, val12, width, depth); yield return PlaceExitAndPrize(center, exitCell, prizeCell, width, depth, cellSize, floorHeight); ZNetScene instance5 = ZNetScene.instance; GameObject chunkPrefab = ((instance5 != null) ? instance5.GetPrefab("Avalor_MazeChunk") : null); int chunkW = 4; int chunkD = 4; int num25 = Mathf.CeilToInt((float)width / (float)chunkW); int num26 = Mathf.CeilToInt((float)depth / (float)chunkD); List list2 = new List(); for (int num27 = 0; num27 < num25; num27++) { for (int num28 = 0; num28 < num26; num28++) { list2.Add(new Vector2Int(num27, num28)); } } list2.Sort((Vector2Int a, Vector2Int val17) => (((Vector2Int)(ref a)).x * ((Vector2Int)(ref a)).x + ((Vector2Int)(ref a)).y * ((Vector2Int)(ref a)).y).CompareTo(((Vector2Int)(ref val17)).x * ((Vector2Int)(ref val17)).x + ((Vector2Int)(ref val17)).y * ((Vector2Int)(ref val17)).y)); int chunkCount = 0; int vaultCount = 0; foreach (Vector2Int item3 in list2) { Vector2Int current3 = item3; int x = ((Vector2Int)(ref current3)).x; int y = ((Vector2Int)(ref current3)).y; byte[] array3 = new byte[chunkW * chunkD * floors]; int num29 = 0; for (int num30 = 0; num30 < floors; num30++) { for (int num31 = 0; num31 < chunkW; num31++) { for (int num32 = 0; num32 < chunkD; num32++) { int num33 = x * chunkW + num31; int num34 = y * chunkD + num32; byte b = 0; if (num33 < width && num34 < depth) { MazeCell mazeCell = grid[num33, num30, num34]; if (mazeCell.wallTop) { b |= 1; } if (mazeCell.wallBottom) { b |= 2; } if (mazeCell.wallLeft) { b |= 4; } if (mazeCell.wallRight) { b |= 8; } if (mazeCell.wallFloor) { b |= 0x10; } if (mazeCell.wallCeiling) { b |= 0x20; } if (!mazeCell.wallFloor && num30 > 0) { b |= 0x40; } } array3[num29++] = b; } } } if ((Object)(object)chunkPrefab != (Object)null) { float num35 = ((float)(x * chunkW) + (float)(chunkW - 1) / 2f - (float)width / 2f) * cellSize; float num36 = ((float)(y * chunkD) + (float)(chunkD - 1) / 2f - (float)depth / 2f) * cellSize; Vector3 position4 = center + new Vector3(num35, 0f, num36); GameObject val14 = InstantiatePiece(chunkPrefab, position4, Quaternion.identity); if ((Object)(object)val14 != (Object)null) { chunkCount++; ZNetView component = val14.GetComponent(); if ((Object)(object)component != (Object)null && component.GetZDO() != null) { component.GetZDO().Set("Avalor_ChunkData", array3); component.GetZDO().Set("Avalor_ChunkWidth", chunkW); component.GetZDO().Set("Avalor_ChunkDepth", chunkD); component.GetZDO().Set("Avalor_ChunkFloors", floors); } } } yield return null; } ZNetScene instance6 = ZNetScene.instance; object obj = ((instance6 != null) ? instance6.GetPrefab("Avalor_Mist") : null); if (obj == null) { ZNetScene instance7 = ZNetScene.instance; obj = ((instance7 != null) ? instance7.GetPrefab("vfx_swamp_mist") : null); } GameObject mistPrefab = (GameObject)obj; ZNetScene instance8 = ZNetScene.instance; object obj2 = ((instance8 != null) ? instance8.GetPrefab("Avalor_CryptTorch") : null); if (obj2 == null) { ZNetScene instance9 = ZNetScene.instance; obj2 = ((instance9 != null) ? instance9.GetPrefab("piece_walltorch") : null); } GameObject torchPrefab = (GameObject)obj2; ZNetScene instance10 = ZNetScene.instance; GameObject trapPrefab = ((instance10 != null) ? instance10.GetPrefab("Avalor_SpikeTrap") : null); ZNetScene instance11 = ZNetScene.instance; GameObject poisonTrapPrefab = ((instance11 != null) ? instance11.GetPrefab("Avalor_PoisonTrap") : null); ZNetScene instance12 = ZNetScene.instance; GameObject chainPrefab = ((instance12 != null) ? instance12.GetPrefab("Avalor_Clutter_Chain") : null); ZNetScene instance13 = ZNetScene.instance; GameObject vaultGatePrefab = ((instance13 != null) ? instance13.GetPrefab("Avalor_Gate") : null); ZNetScene instance14 = ZNetScene.instance; object obj3 = ((instance14 != null) ? instance14.GetPrefab("Avalor_VaultChest") : null); if (obj3 == null) { ZNetScene instance15 = ZNetScene.instance; obj3 = ((instance15 != null) ? instance15.GetPrefab("Avalor_Chest") : null); } GameObject vaultChestPrefab = (GameObject)obj3; ZNetScene instance16 = ZNetScene.instance; GameObject archwayPrefab = ((instance16 != null) ? instance16.GetPrefab("Avalor_Archway") : null); string[] array4 = new string[8] { "Avalor_Clutter_stone_pile", "Avalor_Clutter_BoneFragments", "Avalor_Clutter_Pickable_SunkenCryptRandom", "Avalor_Clutter_Pickable_ForestCryptRandom", "Avalor_Clutter_Pickable_ForestCryptRemains01", "Avalor_Clutter_Pickable_ForestCryptRemains02", "Avalor_Clutter_Pickable_ForestCryptRemains03", "Avalor_Clutter_Pickable_ForestCryptRemains04" }; string[] array5 = new string[6] { "Avalor_Clutter_dvergrprops_crate", "Avalor_Clutter_dvergrprops_barrel", "Avalor_Clutter_dvergrprops_crate_long", "Avalor_Clutter_crypt_skeleton_chest", "Avalor_Clutter_wood_stack", "Avalor_Clutter_bone_stack" }; string[] array6 = new string[7] { "Avalor_Clutter_piece_banner01", "Avalor_Clutter_piece_banner02", "Avalor_Clutter_piece_banner03", "Avalor_Clutter_piece_banner04", "Avalor_Clutter_piece_banner05", "Avalor_Clutter_dvergrprops_banner", "Avalor_Clutter_dvergrprops_hooknchain" }; string[] array7 = new string[5] { "Avalor_Clutter_ShieldWood", "Avalor_Clutter_ShieldBronzeBuckler", "Avalor_Clutter_ShieldIronBuckler", "Avalor_Clutter_ShieldSerpentscale", "Avalor_Clutter_ShieldCarapace" }; GameObject[] floorPropPrefabs = ResolvePrefabs(array4); GameObject[] wallBasePropPrefabs = ResolvePrefabs(array5); GameObject[] wallHangPrefabs = ResolvePrefabs(array6); GameObject[] wallShieldPrefabs = ResolvePrefabs(array7); if (dbg) { Logger.LogInfo((object)($"[Avalor] Clutter resolved: floorProps={floorPropPrefabs.Length}/{array4.Length} " + $"wallBase={wallBasePropPrefabs.Length}/{array5.Length} hang={wallHangPrefabs.Length}/{array6.Length} shields={wallShieldPrefabs.Length}/{array7.Length}")); if (floorPropPrefabs.Length < array4.Length || wallBasePropPrefabs.Length < array5.Length || wallHangPrefabs.Length < array6.Length || wallShieldPrefabs.Length < array7.Length) { Logger.LogWarning((object)"[Avalor] Some clutter prefabs failed to resolve - check the Avalor_Clutter_* clones in ClonePrefabs."); } } float offset = cellSize / 2f; float torchChance = 0.35f; int torchCount = 0; int mistCount = 0; int chainCount = 0; int clutterCount = 0; int maxClutter = 480; if (MistsofAvalorPlugin.ClutterConfig.Value == ClutterDensity.Extreme) { maxClutter = 850; } else if (MistsofAvalorPlugin.ClutterConfig.Value == ClutterDensity.None) { maxClutter = 0; } int instantiationCount = 0; for (int y2 = 0; y2 < floors; y2++) { for (int x2 = 0; x2 < width; x2++) { for (int z = 0; z < depth; z++) { MazeCell mazeCell2 = grid[x2, y2, z]; float num37 = ((float)x2 - (float)width / 2f) * cellSize; float num38 = ((float)z - (float)depth / 2f) * cellSize; Vector3 cellPos = center + new Vector3(num37, (float)y2 * floorHeight, num38); if ((Object)(object)mistPrefab != (Object)null && mistCount < 16 && rnd.NextDouble() < 0.014999999664723873) { mistCount++; InstantiatePiece(mistPrefab, cellPos, Quaternion.identity); } if (MistsofAvalorPlugin.ClutterConfig.Value != ClutterDensity.None && (Object)(object)chainPrefab != (Object)null && chainCount < 40 && rnd.NextDouble() < 0.05) { chainCount++; float num39 = (float)(rnd.NextDouble() * (double)(cellSize - 2f) - (double)(cellSize / 2f - 1f)); float num40 = (float)(rnd.NextDouble() * (double)(cellSize - 2f) - (double)(cellSize / 2f - 1f)); InstantiatePiece(chainPrefab, cellPos + new Vector3(num39, floorHeight - 0.1f, num40), Quaternion.Euler(0f, (float)rnd.Next(0, 360), 0f)); } float num41 = 0.02f; if (MistsofAvalorPlugin.DifficultyConfig.Value == DifficultyLevel.Normal) { num41 = 0.08f; } else if (MistsofAvalorPlugin.DifficultyConfig.Value == DifficultyLevel.Hardcore) { num41 = 0.15f; } if (y2 == 0 && Vector3.Distance(cellPos, StartLocation) > 30f && rnd.NextDouble() < (double)num41) { GameObject val15 = ((rnd.NextDouble() < 0.5) ? trapPrefab : poisonTrapPrefab); if ((Object)(object)val15 != (Object)null) { InstantiatePiece(val15, cellPos + new Vector3(0f, -2.5f, 0f), Quaternion.identity); } } int num42; double num43; switch (MistsofAvalorPlugin.ClutterConfig.Value) { case ClutterDensity.None: num42 = 0; num43 = 0.0; break; case ClutterDensity.High: num42 = 1; num43 = 0.75; break; case ClutterDensity.Higher: num42 = 2; num43 = 0.75; break; case ClutterDensity.Extreme: num42 = 3; num43 = 0.9; break; default: num42 = 1; num43 = 0.45; break; } for (int num44 = 0; num44 < num42; num44++) { if (rnd.NextDouble() < num43) { SpawnFloorProp((float)(rnd.NextDouble() * (double)(cellSize - 3f) - (double)(cellSize / 2f - 1.5f)), (float)(rnd.NextDouble() * (double)(cellSize - 3f) - (double)(cellSize / 2f - 1.5f))); } } int num45 = 0; if (mazeCell2.wallRight) { num45++; if (rnd.NextDouble() < (double)torchChance) { SpawnTorch(cellPos + new Vector3(offset - 0.8f, 0.1f, 0f), Quaternion.Euler(0f, -90f, 0f)); } DressWall(Vector3.left, Quaternion.LookRotation(Vector3.left, Vector3.up)); } if (mazeCell2.wallTop) { num45++; if (rnd.NextDouble() < (double)torchChance) { SpawnTorch(cellPos + new Vector3(0f, 0.1f, offset - 0.8f), Quaternion.Euler(0f, 180f, 0f)); } DressWall(Vector3.back, Quaternion.LookRotation(Vector3.back, Vector3.up)); } if (mazeCell2.wallBottom) { num45++; DressWall(Vector3.forward, Quaternion.LookRotation(Vector3.forward, Vector3.up)); } if (mazeCell2.wallLeft) { num45++; if (rnd.NextDouble() < (double)torchChance) { SpawnTorch(cellPos + new Vector3(0f - offset + 0.8f, 0.1f, 0f), Quaternion.Euler(0f, 90f, 0f)); } DressWall(Vector3.right, Quaternion.LookRotation(Vector3.right, Vector3.up)); } bool flag = !mazeCell2.wallFloor || !mazeCell2.wallCeiling; bool flag2 = Vector3.Distance(cellPos, StartLocation) < 30f; bool flag3 = x2 == ((Vector3Int)(ref exitCell)).x && y2 == ((Vector3Int)(ref exitCell)).y && z == ((Vector3Int)(ref exitCell)).z; bool flag4 = x2 == ((Vector3Int)(ref prizeCell)).x && y2 == ((Vector3Int)(ref prizeCell)).y && z == ((Vector3Int)(ref prizeCell)).z; if (num45 >= 3 && !flag && !flag2 && !flag3 && !flag4 && (Object)(object)vaultGatePrefab != (Object)null && (Object)(object)vaultChestPrefab != (Object)null && rnd.NextDouble() < 0.4000000059604645) { Vector3 val16 = cellPos; Quaternion rotation = Quaternion.identity; if (!mazeCell2.wallTop) { val16 += new Vector3(0f, 0f, offset); rotation = Quaternion.identity; } else if (!mazeCell2.wallBottom) { val16 += new Vector3(0f, 0f, 0f - offset); rotation = Quaternion.identity; } else if (!mazeCell2.wallRight) { val16 += new Vector3(offset, 0f, 0f); rotation = Quaternion.Euler(0f, 90f, 0f); } else if (!mazeCell2.wallLeft) { val16 += new Vector3(0f - offset, 0f, 0f); rotation = Quaternion.Euler(0f, 90f, 0f); } val16.y = cellPos.y; InstantiatePiece(vaultGatePrefab, val16, rotation); if ((Object)(object)archwayPrefab != (Object)null) { InstantiatePiece(archwayPrefab, val16, rotation); } GameObject chestObj2 = InstantiatePiece(vaultChestPrefab, cellPos + new Vector3(0f, 0.02f, 0f), Quaternion.Euler(0f, (float)rnd.Next(0, 360), 0f)); PopulateChest(chestObj2, MistsofAvalorPlugin.DifficultyConfig.Value, 3); vaultCount++; } instantiationCount++; if (instantiationCount >= 30) { instantiationCount = 0; yield return null; } void DressWall(Vector3 inward, Quaternion faceRot) { //IL_0002: 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_0019: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_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) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: 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_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) Vector3 val17 = default(Vector3); ((Vector3)(ref val17))..ctor(0f - inward.z, 0f, inward.x); Vector3 val18 = -inward; if (rnd.NextDouble() < 0.85) { GameObject[] array8 = ((wallBasePropPrefabs.Length != 0 && rnd.NextDouble() < 0.7) ? wallBasePropPrefabs : floorPropPrefabs); if (array8.Length != 0) { float num46 = (float)(rnd.NextDouble() * 3.4 - 1.7); Vector3 pos = cellPos + val18 * (offset - 0.4f) + val17 * num46 + new Vector3(0f, 0.02f, 0f); SpawnClutter(array8[rnd.Next(array8.Length)], pos, faceRot * Quaternion.Euler(0f, (float)rnd.Next(-20, 20), 0f)); } } if (rnd.NextDouble() < 0.5) { float num47 = (float)(rnd.NextDouble() * 3.0 - 1.5); if (wallShieldPrefabs.Length != 0 && (wallHangPrefabs.Length == 0 || rnd.NextDouble() < 0.5)) { Vector3 pos2 = cellPos + val18 * (offset - 0.22f) + val17 * num47 + new Vector3(0f, 1.55f, 0f); SpawnClutter(wallShieldPrefabs[rnd.Next(wallShieldPrefabs.Length)], pos2, Quaternion.FromToRotation(Vector3.up, inward)); } else if (wallHangPrefabs.Length != 0) { Vector3 pos3 = cellPos + val18 * (offset - 0.15f) + val17 * num47 + new Vector3(0f, 1.45f, 0f); SpawnClutter(wallHangPrefabs[rnd.Next(wallHangPrefabs.Length)], pos3, faceRot * Quaternion.Inverse(ClutterTurn)); } } } void SpawnFloorProp(float xOff, float zOff) { //IL_0029: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (floorPropPrefabs.Length != 0) { GameObject prefab2 = floorPropPrefabs[rnd.Next(floorPropPrefabs.Length)]; SpawnClutter(prefab2, cellPos + new Vector3(xOff, 0.02f, zOff), Quaternion.Euler(0f, (float)rnd.Next(0, 360), 0f)); } } } } } if (dbg) { Logger.LogInfo((object)($"[Avalor] Generation complete in {Time.realtimeSinceStartup - genStartTime:F1}s: " + $"chunks={chunkCount} torches={torchCount}/{200} vaults={vaultCount} tracked-ZDOs={spawnedZDOs.Count}")); } AvalorResetManager.Instance?.MarkGenerated(); IsGenerating = false; AvalorMazeGrid.Invalidate(); GameObject SpawnClutter(GameObject val17, Vector3 pos, Quaternion rot) { //IL_002f: 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_0031: 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) if ((Object)(object)val17 == (Object)null || clutterCount >= maxClutter) { return null; } clutterCount++; return InstantiatePiece(val17, pos, rot * ClutterTurn); } GameObject SpawnTorch(Vector3 pos, Quaternion rot) { //IL_0034: 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) if ((Object)(object)torchPrefab == (Object)null || torchCount >= 200) { return null; } torchCount++; return InstantiatePiece(torchPrefab, pos, rot); } } private static Vector3Int ChooseAdjacentOpenCell(MazeCell[,,] grid, Vector3Int cell, int width, int depth) { //IL_0047: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) MazeCell mazeCell = grid[((Vector3Int)(ref cell)).x, ((Vector3Int)(ref cell)).y, ((Vector3Int)(ref cell)).z]; if (!mazeCell.wallRight && ((Vector3Int)(ref cell)).x < width - 1) { return new Vector3Int(((Vector3Int)(ref cell)).x + 1, ((Vector3Int)(ref cell)).y, ((Vector3Int)(ref cell)).z); } if (!mazeCell.wallLeft && ((Vector3Int)(ref cell)).x > 0) { return new Vector3Int(((Vector3Int)(ref cell)).x - 1, ((Vector3Int)(ref cell)).y, ((Vector3Int)(ref cell)).z); } if (!mazeCell.wallTop && ((Vector3Int)(ref cell)).z < depth - 1) { return new Vector3Int(((Vector3Int)(ref cell)).x, ((Vector3Int)(ref cell)).y, ((Vector3Int)(ref cell)).z + 1); } if (!mazeCell.wallBottom && ((Vector3Int)(ref cell)).z > 0) { return new Vector3Int(((Vector3Int)(ref cell)).x, ((Vector3Int)(ref cell)).y, ((Vector3Int)(ref cell)).z - 1); } return cell; } private IEnumerator PlaceExitAndPrize(Vector3 center, Vector3Int exitCell, Vector3Int prizeCell, int width, int depth, float cellSize, float floorHeight) { //IL_000e: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) float num = ((float)((Vector3Int)(ref exitCell)).x - (float)width / 2f) * cellSize; float num2 = ((float)((Vector3Int)(ref exitCell)).z - (float)depth / 2f) * cellSize; float exitFloorY = (float)((Vector3Int)(ref exitCell)).y * floorHeight; Vector3 exitPos = center + new Vector3(num, exitFloorY + 0.5f, num2); ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab("Avalor_EndShrine") : null); if ((Object)(object)val != (Object)null) { InstantiatePiece(val, new Vector3(exitPos.x, exitFloorY, exitPos.z + 2.4f), Quaternion.identity); } ZNetScene instance2 = ZNetScene.instance; GameObject val2 = ((instance2 != null) ? instance2.GetPrefab("Avalor_ExitPortal") : null); if ((Object)(object)val2 == (Object)null) { ZNetScene instance3 = ZNetScene.instance; val2 = ((instance3 != null) ? instance3.GetPrefab("Avalor_OverworldPortal") : null); Logger.LogWarning((object)"[Avalor][FAIL] Avalor_ExitPortal is not registered - falling back to the 7m overworld monument at the maze exit. It will clip the ceiling, but the labyrinth stays completable. Check CreateExitPortal in AvalorAssetManager."); } if ((Object)(object)val2 != (Object)null) { if ((Object)(object)InstantiatePiece(val2, exitPos, Quaternion.identity) == (Object)null) { Logger.LogError((object)"[Avalor][FAIL] the exit portal failed to instantiate - THIS LABYRINTH HAS NO WAY OUT. Use avalor_reset to regenerate it."); } else { Logger.LogInfo((object)$"[Avalor] exit portal placed at cell {exitCell} -> {exitPos:F1}."); } ZNetScene instance4 = ZNetScene.instance; GameObject val3 = ((instance4 != null) ? instance4.GetPrefab("Avalor_RecallRune") : null); if ((Object)(object)val3 != (Object)null) { InstantiatePiece(val3, exitPos + new Vector3(0f, 0f, -2f), Quaternion.identity); } } else { Logger.LogError((object)"[Avalor][FAIL] neither Avalor_ExitPortal nor Avalor_OverworldPortal is registered - THIS LABYRINTH HAS NO WAY OUT. Prefab cloning failed; check the load log for 'CreateExitPortal failed'."); } yield return null; ZNetScene instance5 = ZNetScene.instance; GameObject val4 = ((instance5 != null) ? instance5.GetPrefab("Avalor_PrizeChest") : null); if ((Object)(object)val4 == (Object)null) { ZNetScene instance6 = ZNetScene.instance; val4 = ((instance6 != null) ? instance6.GetPrefab("piece_chest_blackmetal") : null); Logger.LogWarning((object)"[Avalor][FAIL] Avalor_PrizeChest is not registered - falling back to raw piece_chest_blackmetal, which WILL destroy itself on the maze floor. Check CreatePrizeChest in AvalorAssetManager."); } if ((Object)(object)val4 == (Object)null) { Logger.LogError((object)"[Avalor][FAIL] no prize chest prefab at all - the Avalorian Greatsword was NOT placed in this labyrinth."); yield break; } Vector3 val5 = default(Vector3); if (prizeCell != exitCell) { val5 = center + new Vector3(((float)((Vector3Int)(ref prizeCell)).x - (float)width / 2f) * cellSize, (float)((Vector3Int)(ref prizeCell)).y * floorHeight + 0.02f, ((float)((Vector3Int)(ref prizeCell)).z - (float)depth / 2f) * cellSize); } else { ((Vector3)(ref val5))..ctor(exitPos.x + 1.6f, exitFloorY + 0.02f, exitPos.z); Logger.LogWarning((object)"[Avalor][FAIL] exit cell reports no open side - prize chest placed in-cell as a fallback. It shares the portal's cell but is still reachable."); } GameObject val6 = InstantiatePiece(val4, val5, Quaternion.Euler(0f, 90f, 0f)); if ((Object)(object)val6 == (Object)null) { Logger.LogError((object)"[Avalor][FAIL] the greatsword prize chest failed to instantiate."); } else { Logger.LogInfo((object)$"[Avalor] greatsword prize chest placed at cell {prizeCell} -> {val5:F1}."); } PlaceGreatswordPrize(val6); } public IEnumerator RemoveCeiling() { int destroyCount = 0; foreach (ZDOID spawnedZDO in spawnedZDOs) { ZDO zDO = ZDOMan.instance.GetZDO(spawnedZDO); if (zDO != null && zDO.GetPosition().x > 25000f && zDO.GetPosition().y > 505f) { ZDOMan.instance.DestroyZDO(zDO); } destroyCount++; if (destroyCount >= 50) { destroyCount = 0; yield return null; } } } private List GetUnvisitedNeighbors(Vector3Int current, MazeCell[,,] grid, int width, int floors, int depth, Random rnd) { //IL_004c: 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) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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) List list = new List(); if (((Vector3Int)(ref current)).x > 0 && !grid[((Vector3Int)(ref current)).x - 1, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z].visited) { list.Add(new Vector3Int(((Vector3Int)(ref current)).x - 1, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z)); } if (((Vector3Int)(ref current)).x < width - 1 && !grid[((Vector3Int)(ref current)).x + 1, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z].visited) { list.Add(new Vector3Int(((Vector3Int)(ref current)).x + 1, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z)); } if (((Vector3Int)(ref current)).z > 0 && !grid[((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z - 1].visited) { list.Add(new Vector3Int(((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z - 1)); } if (((Vector3Int)(ref current)).z < depth - 1 && !grid[((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z + 1].visited) { list.Add(new Vector3Int(((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z + 1)); } if (rnd.NextDouble() < 0.15000000596046448) { if (((Vector3Int)(ref current)).y > 0 && !grid[((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y - 1, ((Vector3Int)(ref current)).z].visited) { list.Add(new Vector3Int(((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y - 1, ((Vector3Int)(ref current)).z)); } if (((Vector3Int)(ref current)).y < floors - 1 && !grid[((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y + 1, ((Vector3Int)(ref current)).z].visited) { list.Add(new Vector3Int(((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y + 1, ((Vector3Int)(ref current)).z)); } } return list; } private void RemoveWall(Vector3Int current, Vector3Int chosen, MazeCell[,,] grid) { if (((Vector3Int)(ref current)).x == ((Vector3Int)(ref chosen)).x && ((Vector3Int)(ref current)).z == ((Vector3Int)(ref chosen)).z) { if (((Vector3Int)(ref current)).y < ((Vector3Int)(ref chosen)).y) { grid[((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z].wallCeiling = false; grid[((Vector3Int)(ref chosen)).x, ((Vector3Int)(ref chosen)).y, ((Vector3Int)(ref chosen)).z].wallFloor = false; } else if (((Vector3Int)(ref current)).y > ((Vector3Int)(ref chosen)).y) { grid[((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z].wallFloor = false; grid[((Vector3Int)(ref chosen)).x, ((Vector3Int)(ref chosen)).y, ((Vector3Int)(ref chosen)).z].wallCeiling = false; } } else if (((Vector3Int)(ref current)).y == ((Vector3Int)(ref chosen)).y) { if (((Vector3Int)(ref current)).x == ((Vector3Int)(ref chosen)).x && ((Vector3Int)(ref current)).z < ((Vector3Int)(ref chosen)).z) { grid[((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z].wallTop = false; grid[((Vector3Int)(ref chosen)).x, ((Vector3Int)(ref chosen)).y, ((Vector3Int)(ref chosen)).z].wallBottom = false; } else if (((Vector3Int)(ref current)).x == ((Vector3Int)(ref chosen)).x && ((Vector3Int)(ref current)).z > ((Vector3Int)(ref chosen)).z) { grid[((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z].wallBottom = false; grid[((Vector3Int)(ref chosen)).x, ((Vector3Int)(ref chosen)).y, ((Vector3Int)(ref chosen)).z].wallTop = false; } else if (((Vector3Int)(ref current)).x < ((Vector3Int)(ref chosen)).x && ((Vector3Int)(ref current)).z == ((Vector3Int)(ref chosen)).z) { grid[((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z].wallRight = false; grid[((Vector3Int)(ref chosen)).x, ((Vector3Int)(ref chosen)).y, ((Vector3Int)(ref chosen)).z].wallLeft = false; } else if (((Vector3Int)(ref current)).x > ((Vector3Int)(ref chosen)).x && ((Vector3Int)(ref current)).z == ((Vector3Int)(ref chosen)).z) { grid[((Vector3Int)(ref current)).x, ((Vector3Int)(ref current)).y, ((Vector3Int)(ref current)).z].wallLeft = false; grid[((Vector3Int)(ref chosen)).x, ((Vector3Int)(ref chosen)).y, ((Vector3Int)(ref chosen)).z].wallRight = false; } } } private static float FloorSurfaceLift(int floorIndex) { return 0.1f; } private static GameObject[] ResolvePrefabs(string[] names) { List list = new List(); for (int i = 0; i < names.Length; i++) { ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(names[i]) : null); if ((Object)(object)val != (Object)null) { list.Add(val); } } return list.ToArray(); } private GameObject InstantiatePiece(GameObject prefab, Vector3 position, Quaternion rotation) { //IL_000c: 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_0048: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab == (Object)null) { return null; } GameObject obj = Object.Instantiate(prefab, position, rotation); ZNetView component = obj.GetComponent(); if ((Object)(object)component != (Object)null && component.GetZDO() != null) { component.GetZDO().Set("AvalorMazePiece", 1); spawnedZDOs.Add(component.GetZDO().m_uid); } return obj; } private void PlaceGreatswordPrize(GameObject chestObj) { if ((Object)(object)chestObj == (Object)null) { return; } Container component = chestObj.GetComponent(); if (!((Object)(object)component == (Object)null)) { component.m_defaultItems.m_drops.Clear(); if (!AvalorLootManager.AddGuaranteed(component, "Avalor_Greatsword")) { Logger.LogWarning((object)"[Avalor] Avalor_Greatsword not registered - prize chest left EMPTY."); } else if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"[Avalor] greatsword prize placed in the blackmetal chest at the escape portal."); } } } private void PopulateChest(GameObject chestObj, DifficultyLevel diff, int lootTier = 1) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)chestObj == (Object)null)) { Container component = chestObj.GetComponent(); if (!((Object)(object)component == (Object)null) && component.GetInventory() != null) { component.m_defaultItems.m_drops.Clear(); AvalorLootManager.PopulateChest(component, diff, lootTier, Depth01(chestObj.transform.position), null); } } } private float Depth01(Vector3 pos) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (mazeSpan <= 0f) { return 0.5f; } return Mathf.Clamp01(Vector3.Distance(pos, StartLocation) / mazeSpan); } } public static class AvalorMazeGrid { public const float CellSize = 6f; public const float FloorHeight = 4f; public const float SpawnLift = 0.3f; private const float CacheTTL = 60f; private static readonly Dictionary _cells = new Dictionary(); private static float _builtAt = -999f; private static bool _valid; private static int _chunkCount; public static int CachedCellCount { get { if (!_valid) { return 0; } return _cells.Count; } } public static void Invalidate() { _valid = false; _cells.Clear(); _chunkCount = 0; } private static void EnsureBuilt() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) if ((_valid && Time.realtimeSinceStartup - _builtAt < 60f) || ((Object)(object)AvalorMazeGenerator.Instance != (Object)null && AvalorMazeGenerator.Instance.IsGenerating)) { return; } Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { return; } _cells.Clear(); _chunkCount = 0; Vector3 mazeCenter = AvalorMazeGenerator.MazeCenter; int stableHashCode = StringExtensionMethods.GetStableHashCode("Avalor_MazeChunk"); Vector3Int key = default(Vector3Int); foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value == null || value.GetPrefab() != stableHashCode) { continue; } byte[] byteArray = value.GetByteArray("Avalor_ChunkData", (byte[])null); if (byteArray == null || byteArray.Length == 0) { continue; } int num = value.GetInt("Avalor_ChunkWidth", 5); int num2 = value.GetInt("Avalor_ChunkDepth", 5); int num3 = value.GetInt("Avalor_ChunkFloors", 3); if (num <= 0 || num2 <= 0 || num3 <= 0 || byteArray.Length < num * num2 * num3) { continue; } Vector3 position = value.GetPosition(); _chunkCount++; for (int i = 0; i < num3; i++) { for (int j = 0; j < num; j++) { for (int k = 0; k < num2; k++) { byte value2 = byteArray[(i * num + j) * num2 + k]; float num4 = position.x + ((float)j - (float)(num - 1) / 2f) * 6f; float num5 = position.z + ((float)k - (float)(num2 - 1) / 2f) * 6f; ((Vector3Int)(ref key))..ctor(Mathf.RoundToInt((num4 - mazeCenter.x) / 6f), i, Mathf.RoundToInt((num5 - mazeCenter.z) / 6f)); _cells[key] = value2; } } } } _builtAt = Time.realtimeSinceStartup; _valid = _cells.Count > 0; if (_valid) { Logger.LogInfo((object)$"[Avalor] maze grid decoded {_cells.Count} cell(s) from {_chunkCount} chunk ZDO(s)."); } } public static bool TryGetCell(Vector3 world, out byte bits, out Vector3 cellCenter) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) //IL_003c: 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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0082: 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_00ac: 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_00c6: Unknown result type (might be due to invalid IL or missing references) bits = 0; cellCenter = Vector3.zero; EnsureBuilt(); if (!_valid) { return false; } Vector3 mazeCenter = AvalorMazeGenerator.MazeCenter; Vector3Int key = default(Vector3Int); ((Vector3Int)(ref key))..ctor(Mathf.RoundToInt((world.x - mazeCenter.x) / 6f), Mathf.RoundToInt((world.y - mazeCenter.y) / 4f), Mathf.RoundToInt((world.z - mazeCenter.z) / 6f)); if (!_cells.TryGetValue(key, out bits)) { return false; } cellCenter = new Vector3(mazeCenter.x + (float)((Vector3Int)(ref key)).x * 6f, mazeCenter.y + (float)((Vector3Int)(ref key)).y * 4f, mazeCenter.z + (float)((Vector3Int)(ref key)).z * 6f); return true; } public static bool IsOpenFloor(byte bits, int y) { if (bits == 0) { return false; } if ((bits & 0xF) == 15) { return false; } if (y > 0 && (bits & 0x40) != 0) { return false; } return true; } public static bool TryFindOpenNeighbour(Vector3 world, out Vector3 neighbourCenter) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_009a: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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) neighbourCenter = Vector3.zero; if (!TryGetCell(world, out var bits, out var cellCenter)) { return false; } int y = Mathf.RoundToInt((cellCenter.y - AvalorMazeGenerator.MazeCenter.y) / 4f); byte[] array = new byte[4] { 8, 4, 1, 2 }; Vector3[] array2 = (Vector3[])(object)new Vector3[4] { new Vector3(6f, 0f, 0f), new Vector3(-6f, 0f, 0f), new Vector3(0f, 0f, 6f), new Vector3(0f, 0f, -6f) }; for (int i = 0; i < array.Length; i++) { if ((bits & array[i]) == 0 && TryGetCell(cellCenter + array2[i], out var bits2, out var cellCenter2) && IsOpenFloor(bits2, y)) { neighbourCenter = cellCenter2; return true; } } return false; } public static bool TryFindOpenSpawnNear(Vector3 playerPos, Quaternion playerRot, out Vector3 spawn, HashSet usedThisTick = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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) //IL_009f: 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_00f4: 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) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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) spawn = Vector3.zero; EnsureBuilt(); if (!_valid) { return false; } Vector3 val = playerRot * Vector3.forward; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Vector3.forward); Vector3 mazeCenter = AvalorMazeGenerator.MazeCenter; int num = Mathf.Clamp(Mathf.RoundToInt((playerPos.y - mazeCenter.y) / 4f), 0, 8); Vector3 val2 = default(Vector3); Vector3Int item = default(Vector3Int); for (int i = 0; i < 20; i++) { float num2; if (i < 13) { val2 = Quaternion.Euler(0f, Random.Range(-70f, 70f), 0f) * val; num2 = Random.Range(10f, 26f); } else { Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized; ((Vector3)(ref val2))..ctor(normalized.x, 0f, normalized.y); num2 = Random.Range(6f, 16f); } Vector3 world = playerPos + val2 * num2; world.y = mazeCenter.y + (float)num * 4f; if (!TryGetCell(world, out var bits, out var cellCenter) || !IsOpenFloor(bits, num)) { continue; } if (usedThisTick != null) { ((Vector3Int)(ref item))..ctor(Mathf.RoundToInt((cellCenter.x - mazeCenter.x) / 6f), num, Mathf.RoundToInt((cellCenter.z - mazeCenter.z) / 6f)); if (!usedThisTick.Add(item)) { continue; } } spawn = cellCenter + Vector3.up * 0.3f; return true; } return false; } } public class AvalorGate : MonoBehaviour, Interactable { public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } string text = "Avalor Crypt Key"; bool flag = false; foreach (ItemData allItem in user.GetInventory().GetAllItems()) { if (allItem.m_shared.m_name == text) { flag = true; break; } } if (flag) { user.GetInventory().RemoveItem(text, 1, -1, true); ((Character)user).Message((MessageType)2, "Crypt Gate unlocked.", 0, (Sprite)null); ZNetView component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { component.ClaimOwnership(); ZNetScene.instance.Destroy(((Component)component).gameObject); } return true; } ((Character)user).Message((MessageType)2, "Requires Avalor Crypt Key!", 0, (Sprite)null); return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverText() { return "Crypt Gate\n[Requires Avalor Crypt Key]"; } public string GetHoverName() { return "Crypt Gate"; } } public class AvalorPressurePlate : MonoBehaviour { public GameObject SpikePrefab; public bool IsPoison; private bool triggered; private const float PoisonSurvivalFloor = 6f; private void OnTriggerEnter(Collider other) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) if (triggered) { return; } Player component = ((Component)other).GetComponent(); if (!((Object)(object)component != (Object)null) || (Object)(object)component != (Object)(object)Player.m_localPlayer) { return; } triggered = true; float health = ((Character)component).GetHealth(); float num = 0.4f; if (MistsofAvalorPlugin.DifficultyConfig != null) { if (MistsofAvalorPlugin.DifficultyConfig.Value == DifficultyLevel.Normal) { num = 0.6f; } else if (MistsofAvalorPlugin.DifficultyConfig.Value == DifficultyLevel.Hardcore) { num = 0.85f; } } float num2 = health * num; HitData val = new HitData(); val.m_point = ((Component)component).transform.position; if (IsPoison) { num2 = Mathf.Max(0f, Mathf.Min(num2, health - 6f)); val.m_damage.m_poison = num2; ZNetScene instance = ZNetScene.instance; GameObject val2 = ((instance != null) ? instance.GetPrefab("vfx_Blob_hit") : null); if ((Object)(object)val2 != (Object)null) { Object.Instantiate(val2, ((Component)component).transform.position, Quaternion.identity); } } else { val.m_damage.m_damage = num2; } ((Character)component).Damage(val); if ((Object)(object)SpikePrefab != (Object)null) { ZNetView component2 = SpikePrefab.GetComponent(); if ((Object)(object)component2 != (Object)null && component2.IsValid()) { component2.InvokeRPC(ZNetView.Everybody, "TriggerSpikeAnim", Array.Empty()); } } ((MonoBehaviour)this).StartCoroutine(ResetCooldown()); } private IEnumerator ResetCooldown() { yield return (object)new WaitForSeconds(5f); triggered = false; } } public class AvalorSpikeAnim : MonoBehaviour { private ZNetView znv; private void Awake() { znv = ((Component)this).GetComponent(); if ((Object)(object)znv != (Object)null && znv.IsValid()) { znv.Register("TriggerSpikeAnim", (Action)RPC_TriggerSpikeAnim); } } private void RPC_TriggerSpikeAnim(long sender) { ((MonoBehaviour)this).StartCoroutine(AnimateSpikes()); } private IEnumerator AnimateSpikes() { Vector3 start = ((Component)this).transform.position; Vector3 end = start + new Vector3(0f, 2f, 0f); float t = 0f; while (t < 1f) { t += Time.deltaTime * 5f; ((Component)this).transform.position = Vector3.Lerp(start, end, t); yield return null; } yield return (object)new WaitForSeconds(2f); ((Component)this).transform.position = start; } } public class AvalorBossBar : MonoBehaviour { private GameObject _uiRoot; private RectTransform _barRt; private Image _fill; private Text _nameText; private Font _valheimFont; private Character _tracked; private Vector3 _lastKnownPos; private string _displayName; private string _token; private string _fallback; private Color _fillColour = AvalorCryptEnvZone.AvalorGreen; private const float ShowRange = 30f; private bool _priorityHeld; public static AvalorBossBar Instance { get; private set; } private void Awake() { Instance = this; } public void Track(Character c, string nameToken, string fallback, Color fillColour, bool priority = false) { //IL_0056: 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_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_00b3: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)c == (Object)null) && (priority || !((Object)(object)_tracked != (Object)null) || !((Object)(object)_tracked != (Object)(object)c) || _tracked.IsDead() || !_priorityHeld)) { _tracked = c; _token = nameToken; _fallback = fallback; _fillColour = fillColour; _priorityHeld = priority; _displayName = null; _lastKnownPos = ((Component)c).transform.position; if ((Object)(object)_uiRoot == (Object)null && (Object)(object)Hud.instance != (Object)null) { CreateUI(); } if ((Object)(object)_fill != (Object)null) { ((Graphic)_fill).color = _fillColour; } if (MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)($"[Avalor] boss bar tracking '{fallback}' (priority={priority}) - " + $"hud={(Object)(object)Hud.instance != (Object)null} ui={(Object)(object)_uiRoot != (Object)null}")); } } } private string ResolveName() { if (!string.IsNullOrEmpty(_displayName)) { return _displayName; } string result = (string.IsNullOrEmpty(_fallback) ? "Avalorian Revenant" : _fallback); if (string.IsNullOrEmpty(_token)) { return result; } string text = null; if (Localization.instance != null) { text = Localization.instance.Localize(_token); } if (string.IsNullOrEmpty(text) || text[0] == '$' || text[0] == '[') { return result; } _displayName = text; return _displayName; } private void CreateUI() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_008c: 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_00b6: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Hud.instance == (Object)null) && !((Object)(object)Hud.instance.m_rootObject == (Object)null)) { Text componentInChildren = Hud.instance.m_rootObject.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { _valheimFont = componentInChildren.font; } _uiRoot = new GameObject("AvalorBossUI"); _uiRoot.transform.SetParent(Hud.instance.m_rootObject.transform, false); RectTransform obj = _uiRoot.AddComponent(); obj.anchorMin = new Vector2(0.5f, 1f); obj.anchorMax = new Vector2(0.5f, 1f); obj.pivot = new Vector2(0.5f, 1f); obj.anchoredPosition = new Vector2(0f, -50f); BuildBar("AvalorRevenantBar", _uiRoot.transform, Vector2.zero, new Vector2(600f, 30f)); _uiRoot.SetActive(false); } } private void BuildBar(string barName, Transform parent, Vector2 anchoredPos, Vector2 size) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0030: 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_0064: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00aa: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0253: 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_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(barName); val.transform.SetParent(parent, false); _barRt = val.AddComponent(); _barRt.anchorMin = new Vector2(0.5f, 1f); _barRt.anchorMax = new Vector2(0.5f, 1f); _barRt.pivot = new Vector2(0.5f, 1f); _barRt.anchoredPosition = anchoredPos; _barRt.sizeDelta = size; GameObject val2 = new GameObject("Trim"); val2.transform.SetParent(val.transform, false); RectTransform obj = val2.AddComponent(); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.offsetMin = new Vector2(-2f, -2f); obj.offsetMax = new Vector2(2f, 2f); ((Graphic)val2.AddComponent()).color = new Color(0.72f, 0.62f, 0.24f, 1f); GameObject val3 = new GameObject("Bkg"); val3.transform.SetParent(val.transform, false); RectTransform obj2 = val3.AddComponent(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.sizeDelta = Vector2.zero; ((Graphic)val3.AddComponent()).color = new Color(0f, 0f, 0f, 0.9f); GameObject val4 = new GameObject("Fill"); val4.transform.SetParent(val.transform, false); RectTransform obj3 = val4.AddComponent(); obj3.anchorMin = Vector2.zero; obj3.anchorMax = Vector2.one; obj3.sizeDelta = Vector2.zero; obj3.pivot = new Vector2(0f, 0.5f); _fill = val4.AddComponent(); ((Graphic)_fill).color = AvalorCryptEnvZone.AvalorGreen; ((Graphic)_fill).raycastTarget = false; GameObject val5 = new GameObject("NameText"); val5.transform.SetParent(val.transform, false); RectTransform obj4 = val5.AddComponent(); obj4.anchorMin = new Vector2(0.5f, 0.5f); obj4.anchorMax = new Vector2(0.5f, 0.5f); obj4.pivot = new Vector2(0.5f, 0.5f); obj4.anchoredPosition = Vector2.zero; obj4.sizeDelta = new Vector2(560f, 30f); _nameText = val5.AddComponent(); _nameText.alignment = (TextAnchor)4; ((Graphic)_nameText).color = Color.white; _nameText.fontSize = 22; ((Graphic)_nameText).raycastTarget = false; _nameText.font = (((Object)(object)_valheimFont != (Object)null) ? _valheimFont : Resources.GetBuiltinResource("Arial.ttf")); Shadow obj5 = val5.AddComponent(); obj5.effectColor = Color.black; obj5.effectDistance = new Vector2(1f, -1f); } private void LateUpdate() { //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_0070: 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_00f1: 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_010a: 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) if ((Object)(object)Hud.instance == (Object)null) { return; } int num; if ((Object)(object)_tracked != (Object)null && !_tracked.IsDead()) { num = ((_tracked.GetHealth() > 0f) ? 1 : 0); if (num != 0) { _lastKnownPos = ((Component)_tracked).transform.position; } } else { num = 0; } if (num == 0 || (Object)(object)Player.m_localPlayer == (Object)null || Vector3.Distance(((Component)Player.m_localPlayer).transform.position, _lastKnownPos) > 30f) { if ((Object)(object)_uiRoot != (Object)null && _uiRoot.activeSelf) { _uiRoot.SetActive(false); } return; } if ((Object)(object)_uiRoot == (Object)null) { CreateUI(); } if (!((Object)(object)_uiRoot == (Object)null)) { if (!_uiRoot.activeSelf) { _uiRoot.SetActive(true); } if (((Graphic)_fill).color != _fillColour) { ((Graphic)_fill).color = _fillColour; } _nameText.text = ResolveName(); float maxHealth = _tracked.GetMaxHealth(); float num2 = Mathf.Clamp01((maxHealth > 0f) ? (_tracked.GetHealth() / maxHealth) : 0f); ((Component)_fill).transform.localScale = new Vector3(num2, 1f, 1f); } } } public class AvalorGraceCountdown : MonoBehaviour { private GameObject _uiRoot; private Text _line; private Text _sub; private CanvasGroup _group; private Font _valheimFont; private bool _wasInside; private float _remaining; private float _fade; private bool _finished; private const float GoodLuckHold = 1.6f; private const float GoodLuckFade = 1.4f; private void LateUpdate() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer != (Object)null) || !AvalorRegion.InSkyMaze(((Component)localPlayer).transform.position)) { if (_wasInside) { Reset(); } _wasInside = false; return; } if (!_wasInside) { _wasInside = true; _remaining = 20f; _fade = 0f; _finished = false; } if ((Object)(object)_uiRoot == (Object)null) { CreateUI(); } if ((Object)(object)_uiRoot == (Object)null) { return; } if (!_finished) { _remaining -= Time.deltaTime; if (_remaining <= 0f) { _finished = true; _remaining = 0f; } } else { _fade += Time.deltaTime; if (_fade >= 3f) { if (_uiRoot.activeSelf) { _uiRoot.SetActive(false); } return; } } if (!_uiRoot.activeSelf) { _uiRoot.SetActive(true); } if (!_finished) { int num = Mathf.CeilToInt(_remaining); _line.text = num.ToString(); _sub.text = "The dead are stirring"; float num2 = 1f - Mathf.Clamp01(_remaining / 20f); _line.fontSize = Mathf.RoundToInt(Mathf.Lerp(54f, 78f, num2)); ((Graphic)_line).color = Color.Lerp(AvalorCryptEnvZone.AvalorGreen, new Color(0.95f, 0.72f, 0.3f), num2); _group.alpha = 1f; } else { _line.text = "Good luck."; _line.fontSize = 62; ((Graphic)_line).color = AvalorCryptEnvZone.AvalorGreen; _sub.text = ""; _group.alpha = 1f - Mathf.Clamp01((_fade - 1.6f) / 1.4f); } } private void Reset() { _finished = false; _fade = 0f; _remaining = 20f; if ((Object)(object)_uiRoot != (Object)null && _uiRoot.activeSelf) { _uiRoot.SetActive(false); } } private void CreateUI() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Hud.instance == (Object)null) && !((Object)(object)Hud.instance.m_rootObject == (Object)null)) { Text componentInChildren = Hud.instance.m_rootObject.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { _valheimFont = componentInChildren.font; } Font font = (((Object)(object)_valheimFont != (Object)null) ? _valheimFont : Resources.GetBuiltinResource("Arial.ttf")); _uiRoot = new GameObject("AvalorGraceCountdown"); _uiRoot.transform.SetParent(Hud.instance.m_rootObject.transform, false); RectTransform obj = _uiRoot.AddComponent(); obj.anchorMin = new Vector2(0.5f, 0.5f); obj.anchorMax = new Vector2(0.5f, 0.5f); obj.pivot = new Vector2(0.5f, 0.5f); obj.anchoredPosition = new Vector2(0f, 150f); obj.sizeDelta = new Vector2(700f, 140f); _group = _uiRoot.AddComponent(); _group.interactable = false; _group.blocksRaycasts = false; _line = MakeLabel("Count", _uiRoot.transform, new Vector2(0f, 12f), new Vector2(700f, 96f), 64, font); _sub = MakeLabel("Sub", _uiRoot.transform, new Vector2(0f, -44f), new Vector2(700f, 30f), 20, font); ((Graphic)_sub).color = new Color(0.86f, 0.9f, 0.86f, 0.75f); _uiRoot.SetActive(false); } } private static Text MakeLabel(string name, Transform parent, Vector2 pos, Vector2 size, int fontSize, Font font) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0025: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00c4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent(); obj.anchorMin = new Vector2(0.5f, 0.5f); obj.anchorMax = new Vector2(0.5f, 0.5f); obj.pivot = new Vector2(0.5f, 0.5f); obj.anchoredPosition = pos; obj.sizeDelta = size; Text obj2 = val.AddComponent(); obj2.font = font; obj2.fontSize = fontSize; obj2.alignment = (TextAnchor)4; ((Graphic)obj2).color = AvalorCryptEnvZone.AvalorGreen; ((Graphic)obj2).raycastTarget = false; Outline obj3 = val.AddComponent(); ((Shadow)obj3).effectColor = new Color(0f, 0f, 0f, 0.95f); ((Shadow)obj3).effectDistance = new Vector2(2f, -2f); return obj2; } } public class AvalorHuntEnforcer : MonoBehaviour { private static readonly List _pending = new List(); private static readonly HashSet _done = new HashSet(); public static void Enqueue(GameObject mob) { if (!((Object)(object)mob == (Object)null) && !_done.Contains(((Object)mob).GetInstanceID())) { _pending.Add(mob); } } private void Update() { if (_pending.Count == 0) { return; } GameObject[] array = _pending.ToArray(); _pending.Clear(); int num = 0; GameObject[] array2 = array; foreach (GameObject val in array2) { if ((Object)(object)val == (Object)null) { continue; } int instanceID = ((Object)val).GetInstanceID(); if (!_done.Add(instanceID)) { continue; } ZNetView component = val.GetComponent(); if (!((Object)(object)component != (Object)null) || !component.IsValid() || component.GetZDO() == null || component.GetZDO().GetInt("AvalorWarden", 0) != 1) { try { AvalorMobDirector.MakeItHunt(val); num++; } catch (Exception ex) { Logger.LogWarning((object)("[Avalor][FAIL] could not make '" + ((Object)val).name + "' hunt: " + ex.Message)); } } } if (num > 0 && MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)($"[Avalor] {num} maze mob(s) not spawned by the director were given " + "Avalorian senses and alerted.")); } } public static void Forget() { _pending.Clear(); _done.Clear(); } } public static class AvalorianName { public const string Prefix = "Avalorian "; public static void Apply(Character c) { if ((Object)(object)c == (Object)null) { return; } string name = c.m_name; if (!string.IsNullOrEmpty(name) && !name.StartsWith("Avalorian ", StringComparison.Ordinal) && Localization.instance != null) { string text = Localization.instance.Localize(name); if (!string.IsNullOrEmpty(text) && text[0] != '$' && text[0] != '[' && !text.StartsWith("Avalorian ", StringComparison.Ordinal)) { c.m_name = "Avalorian " + text; } } } } public class AvalorMobDirector : MonoBehaviour { private float spawnTimer; private float firstPresentTime = -1f; private const float MAX_MOB_DISTANCE = 50f; private const float MIN_MOB_DISTANCE = 20f; private const float SUBBOSS_CHANCE = 0.15f; public const float SPAWN_GRACE = 20f; private List _activeMobIds = new List(); private bool _recoveredThisMaze; private static readonly HashSet _reportedMissingPrefabs = new HashSet(); private const float REVENANT_CHANCE = 0.02f; public const string RevenantNameToken = "$enemy_avalor_revenant"; public const string RevenantZDOKey = "AvalorRevenant"; public const string SoMStealthExemptKey = "SoMStealthExempt"; private static readonly string[] RevenantVariants = new string[3] { "Draugr_Elite", "Charred_Melee", "Skeleton_Poison" }; private static readonly string[] EndBossVariants = new string[3] { "Skeleton_Hildir_nochest", "Charred_Melee_Dyrnwyn", "Draugr_Elite" }; public const string WardenNameToken = "$enemy_avalor_warden"; public const string WardenFallbackName = "The Avalorian Warden"; public const string WardenZDOKey = "AvalorWarden"; private const string WardenKilledZDOKey = "AvalorWardenDown"; public static readonly Color WardenBarColour = new Color(0.85f, 0.72f, 0.2f); private const float BossTriggerRange = 34f; private ZDOID _endBossId = ZDOID.None; private bool _endBossKilled; private ZDOID _stateMazeExitId = ZDOID.None; private const float WardenSeat = 0.5f; private const float WardenStandOff = 2f; private static Vector3 _exitCache; private static bool _exitCacheValid; private static ZDOID _exitCacheId = ZDOID.None; private static float _exitMissTime = -999f; private const float ExitMissBackoff = 5f; private const float HuntSenseRange = 60f; private static bool _spawnDiagLogged; public static AvalorMobDirector Instance { get; private set; } private void Awake() { Instance = this; } private void Update() { AvalorNet.EnsureRegistered(); spawnTimer += Time.deltaTime; if (spawnTimer >= 5f) { spawnTimer = 0f; ManageMobs(); } } private void ManageMobs() { //IL_00c0: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } List mazePlayers = AvalorNet.GetMazePlayers(); if (mazePlayers.Count == 0) { firstPresentTime = -1f; ClearAllMobs(); return; } if (firstPresentTime < 0f) { firstPresentTime = Time.time; } if (!_recoveredThisMaze) { _recoveredThisMaze = true; if (_activeMobIds.Count == 0) { RecoverActiveMobs(); } } _activeMobIds.RemoveAll((ZDOID id) => id == ZDOID.None || ZDOMan.instance.GetZDO(id) == null); for (int num = _activeMobIds.Count - 1; num >= 0; num--) { ZDO zDO = ZDOMan.instance.GetZDO(_activeMobIds[num]); if (zDO != null) { Vector3 position = zDO.GetPosition(); bool flag = false; for (int num2 = 0; num2 < mazePlayers.Count; num2++) { if (Vector3.Distance(mazePlayers[num2].pos, position) < 50f) { flag = true; break; } } if (!flag) { DestroyMobZdo(zDO); _activeMobIds.RemoveAt(num); } } } if (Time.time - firstPresentTime < 20f) { return; } ManageEndBoss(mazePlayers); int num3 = ((MistsofAvalorPlugin.DifficultyConfig == null) ? DifficultyLevel.Normal : MistsofAvalorPlugin.DifficultyConfig.Value) switch { DifficultyLevel.Easy => 5, DifficultyLevel.Hardcore => 10, _ => 7, }; int num4 = mazePlayers.Count * num3; if (_activeMobIds.Count < num4) { HashSet usedCells = new HashSet(); foreach (AvalorNet.PlayerPresence item in mazePlayers) { int num5 = 0; for (int num6 = 0; num6 < _activeMobIds.Count; num6++) { ZDO zDO2 = ZDOMan.instance.GetZDO(_activeMobIds[num6]); if (zDO2 != null && Vector3.Distance(zDO2.GetPosition(), item.pos) < 50f) { num5++; } } int num7 = Mathf.Min(3, num3 - num5); for (int num8 = 0; num8 < num7; num8++) { SpawnMobNearPlayer(item, usedCells); } } } if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)($"[Avalor] Mobs: mode={AvalorNet.Role} active={_activeMobIds.Count} " + $"target={num4} players-in-maze={mazePlayers.Count} grid-cells={AvalorMazeGrid.CachedCellCount}")); } } private static void DestroyMobZdo(ZDO zdo) { if (zdo == null) { return; } ZNetView val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.FindInstance(zdo) : null); if ((Object)(object)val != (Object)null) { val.ClaimOwnership(); ZNetScene.instance.Destroy(((Component)val).gameObject); return; } if (!zdo.IsOwner()) { zdo.SetOwner(ZDOMan.GetSessionID()); } ZDOMan.instance.DestroyZDO(zdo); } private void ClearAllMobs() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) for (int num = _activeMobIds.Count - 1; num >= 0; num--) { ZDO val = ((ZDOMan.instance != null) ? ZDOMan.instance.GetZDO(_activeMobIds[num]) : null); if (val != null) { DestroyMobZdo(val); } } _activeMobIds.Clear(); } private void RecoverActiveMobs() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { return; } int num = 0; foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value != null && AvalorRegion.InSkyMaze(value.GetPosition()) && value.GetInt("SoMStealthExempt", 0) == 1 && value.GetInt("AvalorWarden", 0) != 1) { GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(value.GetPrefab()) : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val.GetComponent() == (Object)null)) { _activeMobIds.Add(value.m_uid); num++; } } } if (num > 0) { Logger.LogInfo((object)$"[Avalor] director recovered {num} live maze mob(s) after a restart."); } } private static void MarkAsAvalorMob(GameObject go, Character c) { ZNetView component = go.GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid() && component.GetZDO() != null) { component.GetZDO().Set("SoMStealthExempt", 1); } if ((Object)(object)c != (Object)null) { AvalorStealthCompat.Register(c); } } public void OnMazeWiped() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) _endBossId = ZDOID.None; _endBossKilled = false; _stateMazeExitId = ZDOID.None; _exitCacheValid = false; _exitCacheId = ZDOID.None; _exitMissTime = -999f; _activeMobIds.Clear(); _recoveredThisMaze = false; AvalorMazeGrid.Invalidate(); } private static void MarkWardenDown(ZDOID exitId) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ZDO val = ((ZDOMan.instance != null) ? ZDOMan.instance.GetZDO(exitId) : null); if (val != null) { if (!val.IsOwner()) { val.SetOwner(ZDOMan.GetSessionID()); } val.Set("AvalorWardenDown", 1); } } private static void ScanWardenState(ZDOID exitId, out ZDO exitZdo, out bool wardenExists, out ZDOID wardenId) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0071: Unknown result type (might be due to invalid IL or missing references) exitZdo = ((ZDOMan.instance != null) ? ZDOMan.instance.GetZDO(exitId) : null); wardenExists = false; wardenId = ZDOID.None; Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { return; } foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value != null && AvalorRegion.InSkyMaze(value.GetPosition()) && value.GetInt("AvalorWarden", 0) == 1) { wardenExists = true; wardenId = value.m_uid; break; } } } private void ManageEndBoss(List players) { //IL_000c: 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_005d: 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_0033: 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_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_007b: 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_00e6: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_027b: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) if (!TryFindExit(out var pos, out var exitId)) { return; } if (exitId != _stateMazeExitId) { if (!((ZDOID)(ref _stateMazeExitId)).IsNone()) { Logger.LogWarning((object)"[Avalor][FAIL] the labyrinth was replaced without this machine being told (no OnMazeWiped) - most likely a reset that ran on another machine. Re-arming the Warden for the new maze."); } _stateMazeExitId = exitId; _endBossId = ZDOID.None; _endBossKilled = false; } if (!((ZDOID)(ref _endBossId)).IsNone() && ZDOMan.instance.GetZDO(_endBossId) == null) { _endBossKilled = true; _endBossId = ZDOID.None; MarkWardenDown(exitId); if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"[Avalor] the Avalorian Warden has fallen - the way out is unguarded."); } } if (!((ZDOID)(ref _endBossId)).IsNone() || _endBossKilled) { return; } bool flag = false; for (int i = 0; i < players.Count; i++) { if (Vector3.Distance(players[i].pos, pos) < 34f) { flag = true; break; } } if (!flag) { return; } ScanWardenState(exitId, out var exitZdo, out var wardenExists, out var wardenId); if (wardenExists) { _endBossId = wardenId; return; } if (exitZdo != null && exitZdo.GetInt("AvalorWardenDown", 0) == 1) { _endBossKilled = true; return; } string text = EndBossVariants[Random.Range(0, EndBossVariants.Length)]; ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(text) : null); if ((Object)(object)val == (Object)null) { if (_reportedMissingPrefabs.Add(text)) { Logger.LogWarning((object)("[Avalor][FAIL] end-boss prefab '" + text + "' not found - no Warden will guard this maze while that variant keeps being rolled.")); } return; } GameObject val2 = Object.Instantiate(val, WardenPost(pos), Quaternion.identity); Character component = val2.GetComponent(); if ((Object)(object)component == (Object)null) { return; } ZNetView component2 = val2.GetComponent(); if ((Object)(object)component2 != (Object)null && component2.IsValid() && component2.GetZDO() != null) { component2.GetZDO().Set("AvalorWarden", 1); } MarkAsAvalorMob(val2, component); MutateIntoEndBoss(val2, component, (MistsofAvalorPlugin.DifficultyConfig == null) ? DifficultyLevel.Normal : MistsofAvalorPlugin.DifficultyConfig.Value); if ((Object)(object)component2 != (Object)null && component2.IsValid() && component2.GetZDO() != null) { _endBossId = component2.GetZDO().m_uid; long num = NearestPlayerUid(players, val2.transform.position); if (num != 0L) { component2.GetZDO().SetOwner(num); } } if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)("[Avalor] the Avalorian Warden rises at the exit as '" + text + "' " + $"({component.GetMaxHealth():F0} hp) at {val2.transform.position:F0}.")); } } private static Vector3 WardenPost(Vector3 exit) { //IL_0000: 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_0016: 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) //IL_0043: 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_002c: 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_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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_008c: 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_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_007b: Unknown result type (might be due to invalid IL or missing references) if (!AvalorMazeGrid.TryGetCell(exit, out var _, out var cellCenter)) { Logger.LogWarning((object)"[Avalor][FAIL] no maze grid at the exit, so the Warden could not be given a post - it is spawning on the portal's own tile. Expect it to be standing in the doorway. This means the exit chunk's ZDO carries no layout data."); return exit; } if (!AvalorMazeGrid.TryFindOpenNeighbour(exit, out var neighbourCenter)) { Logger.LogWarning((object)"[Avalor][FAIL] the exit cell reports no open side - the Warden is being placed on the portal's own tile. It will guard the way out, but it will be standing in the doorway."); return cellCenter + Vector3.up * 0.5f; } Vector3 val = cellCenter - neighbourCenter; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { neighbourCenter += ((Vector3)(ref val)).normalized * 2f; } return neighbourCenter + Vector3.up * 0.5f; } private static long NearestPlayerUid(List players, Vector3 pos) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) long result = 0L; float num = float.MaxValue; for (int i = 0; i < players.Count; i++) { float num2 = Vector3.Distance(players[i].pos, pos); if (num2 < num && players[i].ownerUid != 0L) { num = num2; result = players[i].ownerUid; } } return result; } private static void MutateIntoEndBoss(GameObject go, Character c, DifficultyLevel diff) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) c.SetLevel(3); c.SetMaxHealth(c.GetMaxHealth() * 1.2f); c.SetMaxHealth(c.GetMaxHealth() * diff switch { DifficultyLevel.Easy => 3f, DifficultyLevel.Hardcore => 7f, _ => 4.5f, }); c.SetHealth(c.GetMaxHealth()); c.m_name = "$enemy_avalor_warden"; AvalorBossBar.Instance?.Track(c, "$enemy_avalor_warden", "The Avalorian Warden", WardenBarColour, priority: true); ApplyWardenLocal(go, c); BaseAI component = go.GetComponent(); if ((Object)(object)component != (Object)null) { component.Alert(); } } internal static void ApplyWardenLocal(GameObject go, Character c) { if (!((Object)(object)c == (Object)null)) { c.m_staggerDamageFactor = 0f; BaseAI component = go.GetComponent(); MonsterAI val = (MonsterAI)(object)((component is MonsterAI) ? component : null); if ((Object)(object)val != (Object)null) { val.m_fleeIfNotAlerted = false; val.m_fleeIfHurtWhenTargetCantBeReached = false; } AddWardenDrops(go); } } private static void AddWardenDrops(GameObject mob) { CharacterDrop val = mob.GetComponent(); if ((Object)(object)val == (Object)null) { val = mob.AddComponent(); } if (val.m_drops == null) { val.m_drops = new List(); } ZNetScene instance = ZNetScene.instance; GameObject val2 = ((instance != null) ? instance.GetPrefab("Avalor_RecallRune") : null); if ((Object)(object)val2 != (Object)null) { foreach (Drop drop in val.m_drops) { if ((Object)(object)drop.m_prefab == (Object)(object)val2) { return; } } } AddDrop(val, "Avalor_RecallRune", 1, 1, 1f); AddDrop(val, "GemstoneRed", 1, 2, 0.5f); AddDrop(val, "GemstoneBlue", 1, 2, 0.5f); AddDrop(val, "GemstoneGreen", 1, 2, 0.5f); AddDrop(val, "SurtlingCore", 6, 14, 0.8f); AddDrop(val, "BlackMetal", 8, 20, 0.7f); AddDrop(val, "Flametal", 4, 10, 0.45f); AddDrop(val, "Coins", 200, 600, 0.9f); } private static void AddDrop(CharacterDrop cd, string prefabName, int min, int max, float chance) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(prefabName) : null); if (!((Object)(object)val == (Object)null)) { cd.m_drops.Add(new Drop { m_prefab = val, m_amountMin = min, m_amountMax = max, m_chance = chance, m_onePerPlayer = false, m_levelMultiplier = false, m_dontScale = true }); } } public static bool TryFindExit(out Vector3 pos) { ZDOID exitId; return TryFindExit(out pos, out exitId); } public static bool TryFindExit(out Vector3 pos, out ZDOID exitId) { //IL_0062: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_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_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) //IL_002c: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) if (_exitCacheValid) { ZDO val = ((ZDOMan.instance != null) ? ZDOMan.instance.GetZDO(_exitCacheId) : null); if (val != null) { Vector3 position = val.GetPosition(); if (AvalorRegion.InSkyMaze(position)) { _exitCache = position; pos = position; exitId = _exitCacheId; return true; } } _exitCacheValid = false; _exitCacheId = ZDOID.None; } pos = Vector3.zero; exitId = ZDOID.None; if (Time.time - _exitMissTime < 5f) { return false; } Dictionary zDODictionary = AvalorMazeGenerator.GetZDODictionary(); if (zDODictionary == null) { return false; } int stableHashCode = StringExtensionMethods.GetStableHashCode("Avalor_ExitPortal"); int stableHashCode2 = StringExtensionMethods.GetStableHashCode("Avalor_OverworldPortal"); foreach (KeyValuePair item in zDODictionary) { ZDO value = item.Value; if (value == null) { continue; } int prefab = value.GetPrefab(); if (prefab == stableHashCode || prefab == stableHashCode2) { Vector3 position2 = value.GetPosition(); if (AvalorRegion.InSkyMaze(position2)) { _exitCache = position2; _exitCacheValid = true; _exitCacheId = value.m_uid; pos = position2; exitId = value.m_uid; return true; } } } _exitMissTime = Time.time; return false; } public static void MakeItHunt(GameObject mob) { BaseAI component = mob.GetComponent(); if (!((Object)(object)component == (Object)null)) { component.SetHuntPlayer(true); component.m_viewRange = Mathf.Max(component.m_viewRange, 60f); component.m_hearRange = Mathf.Max(component.m_hearRange, 60f); MonsterAI val = (MonsterAI)(object)((component is MonsterAI) ? component : null); if ((Object)(object)val != (Object)null) { val.m_enableHuntPlayer = true; val.m_fleeIfNotAlerted = false; val.m_fleeIfHurtWhenTargetCantBeReached = false; val.m_alertRange = Mathf.Max(val.m_alertRange, 60f); } component.Alert(); } } private void SpawnMobNearPlayer(AvalorNet.PlayerPresence p, HashSet usedCells) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) if (!AvalorMazeGrid.TryFindOpenSpawnNear(p.pos, p.rot, out var spawn, usedCells)) { return; } List list = new List { "Draugr", "Draugr_Elite", "Skeleton", "Skeleton_Poison", "Wraith", "Ghost", "Draugr_Ranged" }; if (MistsofAvalorPlugin.DifficultyConfig.Value == DifficultyLevel.Hardcore) { list.AddRange(new string[4] { "Charred_Melee", "Charred_Archer", "Charred_Mage", "Charred_Twitcher" }); } bool flag = Random.value < 0.02f; string text = (flag ? RevenantVariants[Random.Range(0, RevenantVariants.Length)] : list[Random.Range(0, list.Count)]); GameObject prefab = ZNetScene.instance.GetPrefab(text); if ((Object)(object)prefab == (Object)null) { if (_reportedMissingPrefabs.Add(text)) { Logger.LogWarning((object)("[Avalor][FAIL] spawn-pool prefab '" + text + "' does not exist - every roll of it spawns NOTHING. Fix the variant list.")); } return; } GameObject val = Object.Instantiate(prefab, spawn, Quaternion.identity); if (flag || Random.value < 0.15f) { AvalorMobModifier.MutateIntoSubBoss(val, MistsofAvalorPlugin.DifficultyConfig.Value, flag ? 3 : 0); } Character component = val.GetComponent(); ZNetView component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null && component2.IsValid() && component2.GetZDO() != null) { _activeMobIds.Add(component2.GetZDO().m_uid); } MarkAsAvalorMob(val, component); if (flag) { ZNetView component3 = val.GetComponent(); if ((Object)(object)component3 != (Object)null && component3.IsValid() && component3.GetZDO() != null) { component3.GetZDO().Set("AvalorRevenant", 1); } if ((Object)(object)component != (Object)null) { component.m_name = "$enemy_avalor_revenant"; AvalorBossBar.Instance?.Track(component, "$enemy_avalor_revenant", "Avalorian Revenant", AvalorCryptEnvZone.AvalorGreen); } if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)$"[Avalor] Avalorian Revenant ('{text}') spawned at {spawn:F0}."); } } MakeItHunt(val); if ((Object)(object)component2 != (Object)null && component2.IsValid() && component2.GetZDO() != null && p.ownerUid != 0L) { component2.GetZDO().SetOwner(p.ownerUid); } if (!_spawnDiagLogged && (Object)(object)component2 != (Object)null && component2.GetZDO() != null) { _spawnDiagLogged = true; bool persistent = component2.GetZDO().Persistent; string text2 = $"[Avalor] first director spawn '{text}': persistent={persistent} " + $"owner={component2.GetZDO().GetOwner()} (this session={ZDOMan.GetSessionID()})"; if (persistent) { Logger.LogInfo((object)text2); } else { Logger.LogWarning((object)("[Avalor][FAIL] " + text2 + " - NON-PERSISTENT mob ZDOs are never ownership-assigned to clients; on a dedicated server this mob will neither simulate nor be culled. The prefab's ZNetView must be persistent.")); } } } } public static class AvalorMobModifier { public const string SubBossZDOKey = "AvalorSubBoss"; public static void MutateIntoSubBoss(GameObject mob, DifficultyLevel diff, int forceLevel = 0) { Character component = mob.GetComponent(); if (!((Object)(object)component == (Object)null)) { component.SetLevel((forceLevel > 0) ? forceLevel : ((diff == DifficultyLevel.Hardcore) ? 3 : 2)); component.SetMaxHealth(component.GetMaxHealth() * 1.2f); int num = Random.Range(0, 5); ZNetView component2 = mob.GetComponent(); if ((Object)(object)component2 != (Object)null && component2.IsValid() && component2.GetZDO() != null) { component2.GetZDO().Set("AvalorSubBoss", num + 1); } if (num == 0) { component.SetMaxHealth(component.GetMaxHealth() * 2.5f); } switch (diff) { case DifficultyLevel.Normal: component.SetMaxHealth(component.GetMaxHealth() * 1.5f); break; case DifficultyLevel.Hardcore: component.SetMaxHealth(component.GetMaxHealth() * 2.5f); break; } component.SetHealth(component.GetMaxHealth()); ApplyLocalMutations(mob, num, diff); } } public static void ApplyLocalMutations(GameObject mob, int variant, DifficultyLevel diff) { //IL_0061: 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_0098: 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_00b0: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown Character component = mob.GetComponent(); if (!((Object)(object)component == (Object)null)) { float num = 1f; string text = null; switch (variant) { case 0: num = 1.2f; component.m_staggerDamageFactor = 0f; text = "Goliath "; break; case 1: num = 1.1f; component.m_damageModifiers.m_poison = (DamageModifier)3; text = "Venomous "; break; case 2: num = 1.1f; component.m_damageModifiers.m_frost = (DamageModifier)3; text = "Glacial "; break; case 3: num = 1.05f; component.m_damageModifiers.m_blunt = (DamageModifier)1; component.m_damageModifiers.m_slash = (DamageModifier)1; component.m_damageModifiers.m_pierce = (DamageModifier)1; text = "Vampiric "; break; case 4: num = 1.1f; component.m_damageModifiers.m_lightning = (DamageModifier)3; component.m_runSpeed *= 1.3f; component.m_speed *= 1.3f; text = "Lightning "; break; } Transform transform = mob.transform; transform.localScale *= num; AvalorianName.Apply(component); if (text != null && !component.m_name.StartsWith(text, StringComparison.Ordinal)) { component.m_name = text + component.m_name; } component.m_faction = (Faction)3; component.m_group = "Avalor_Undead"; switch (diff) { case DifficultyLevel.Normal: component.m_speed *= 1.15f; component.m_walkSpeed *= 1.15f; component.m_runSpeed *= 1.15f; break; case DifficultyLevel.Hardcore: component.m_speed *= 1.35f; component.m_walkSpeed *= 1.35f; component.m_runSpeed *= 1.35f; break; } if ((Object)(object)mob.GetComponent() == (Object)null) { mob.AddComponent(); } CharacterDrop val = mob.GetComponent(); if ((Object)(object)val == (Object)null) { val = mob.gameObject.AddComponent(); } ZNetScene instance = ZNetScene.instance; GameObject val2 = ((instance != null) ? instance.GetPrefab("Avalor_Key") : null); if ((Object)(object)val2 != (Object)null) { Drop item = new Drop { m_prefab = val2, m_amountMin = 1, m_amountMax = 1, m_chance = 0.18f, m_levelMultiplier = false, m_dontScale = true }; val.m_drops.Add(item); } } } } public class AvalorMobBehavior : MonoBehaviour { private BaseAI ai; private Character character; private float originalRunSpeed; private float originalWalkSpeed; private float updateTimer; private void Start() { ai = ((Component)this).GetComponent(); character = ((Component)this).GetComponent(); if ((Object)(object)character != (Object)null) { originalRunSpeed = character.m_runSpeed; originalWalkSpeed = character.m_speed; } } private void Update() { updateTimer += Time.deltaTime; if (updateTimer < 1f) { return; } updateTimer = 0f; if ((Object)(object)ai != (Object)null && (Object)(object)character != (Object)null) { if (ai.IsAlerted()) { character.m_runSpeed = originalRunSpeed; } else { character.m_runSpeed = originalWalkSpeed; } } } } public class AvalorPathLeveler : MonoBehaviour { public float LevelRadius = 4f; public float SmoothRadius = 16f; private const int PassVersion = 4; public bool Done { get; private set; } private IEnumerator Start() { if ((Object)(object)ZNet.instance == (Object)null) { Done = true; yield break; } yield return AvalorTerrainOps.WaitForGround(((Component)this).transform.position, SmoothRadius); if (!AvalorTerrainOps.ClaimPass(((Component)this).gameObject, 4)) { Done = true; yield break; } AvalorTerrainOps.EmitOp(((Component)this).transform.position, level: false, 0f, SmoothRadius, LevelRadius + 1f); Done = true; } } public class AvalorPortal : MonoBehaviour { public unsafe static void SpawnPortal(Vector3 position) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab("portal_stone") : null); if ((Object)(object)val != (Object)null) { float y = position.y; if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(position, ref y)) { position.y = y; } GameObject obj = Object.Instantiate(val, position, Quaternion.identity); if (MistsofAvalorPlugin.DebugLogging.Value) { Vector3 val2 = position; Logger.LogInfo((object)("Spawned Avalor Portal at " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString())); } obj.AddComponent(); } } public static void TeleportToAvalor(Player player) { //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) if ((Object)(object)AvalorMazeGenerator.Instance != (Object)null) { ((MonoBehaviour)AvalorMazeGenerator.Instance).StartCoroutine(TeleportRoutine(player)); } else { ((Character)player).TeleportTo(AvalorMazeGenerator.MazeCenter, ((Component)player).transform.rotation, true); } } private static IEnumerator TeleportRoutine(Player player) { if ((Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer()) { ((Character)player).Message((MessageType)2, "Entering the Mists of Avalor...", 0, (Sprite)null); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC("wubarrk.mistsofavalor.EnsureMaze", Array.Empty()); } yield return (object)new WaitForSeconds(1.5f); Vector3 val = AvalorMazeGenerator.ComputeStartLocation(); AvalorSafePlatform.Drop(val, 8f, 30f); ((Character)player).TeleportTo(val, ((Component)player).transform.rotation, true); yield break; } if (!AvalorMazeGenerator.MazeExistsInWorld()) { ((Character)player).Message((MessageType)2, "The mists gather...\nThe labyrinth is being forged. Hold fast.", 0, (Sprite)null); ((MonoBehaviour)AvalorMazeGenerator.Instance).StartCoroutine(AvalorMazeGenerator.Instance.GenerateMaze()); } else { ((Character)player).Message((MessageType)2, "Entering the Mists of Avalor...", 0, (Sprite)null); AvalorMazeGenerator.Instance.RecoverSpawnedZDOs(); } yield return (object)new WaitUntil((Func)(() => !AvalorMazeGenerator.Instance.IsGenerating)); Vector3 val2 = ((AvalorMazeGenerator.StartLocation != Vector3.zero) ? AvalorMazeGenerator.StartLocation : AvalorMazeGenerator.ComputeStartLocation()); AvalorSafePlatform.Drop(val2, 8f, 12f); ((Character)player).TeleportTo(val2, ((Component)player).transform.rotation, true); } } public class AvalorPortalWalkTrigger : MonoBehaviour { private const float ChargeTime = 1.1f; private const float ReArmDelay = 6f; private static float s_suppressUntil; private float _charge; private bool _fired; public static void Suppress() { s_suppressUntil = Time.time + 6f; } private void OnTriggerExit(Collider other) { if (IsLocalPlayer(other)) { _charge = 0f; } } private void OnTriggerStay(Collider other) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (_fired || Time.time < s_suppressUntil || !IsLocalPlayer(other)) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } _charge += Time.deltaTime; AvalorPortalRuneVFX componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.Charge = Mathf.Clamp01(_charge / 1.1f); } if (_charge < 1.1f) { ((Character)localPlayer).Message((MessageType)2, "The mists reach for you...", 0, (Sprite)null); return; } _fired = true; Suppress(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.Discharge(); } AvalorPortalTrigger.Travel(localPlayer, ((Component)this).transform.position); _charge = 0f; ((MonoBehaviour)this).Invoke("ReArm", 6f); } private void ReArm() { _fired = false; } private static bool IsLocalPlayer(Collider other) { if ((Object)(object)other == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { return false; } Player componentInParent = ((Component)other).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { return (Object)(object)componentInParent == (Object)(object)Player.m_localPlayer; } return false; } } public class AvalorPortalGlow : MonoBehaviour { private Light _light; private float _base; private void Awake() { _light = ((Component)this).GetComponent(); if ((Object)(object)_light != (Object)null) { _base = _light.intensity; } } private void Update() { if (!((Object)(object)_light == (Object)null)) { float time = Time.time; float num = 0.82f + 0.18f * Mathf.Sin(time * 1.6f) + 0.08f * Mathf.Sin(time * 0.53f); _light.intensity = _base * num; } } } public class AvalorPortalTrigger : MonoBehaviour, Interactable, Hoverable { public static void Travel(Player player, Vector3 gatePos) { //IL_000a: 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_0080: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return; } if (AvalorRegion.InSkyMaze(gatePos)) { ((Character)player).Message((MessageType)2, "Returning to the Waking World...", 0, (Sprite)null); Vector3 val = default(Vector3); Vector3 val2 = default(Vector3); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetLocationIcon("StartTemple", ref val)) { val2 = val + new Vector3(0f, 1.5f, 0f); } else { ((Vector3)(ref val2))..ctor(0f, 50f, 0f); } AvalorPortalWalkTrigger.Suppress(); ((Character)player).TeleportTo(val2, ((Component)player).transform.rotation, false); } else { AvalorPortalWalkTrigger.Suppress(); AvalorPortal.TeleportToAvalor(player); } } public bool Interact(Humanoid user, bool hold, bool alt) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (hold || alt) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if ((Object)(object)val == (Object)null) { return false; } Travel(val, ((Component)this).transform.position); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverText() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (AvalorRegion.InSkyMaze(((Component)this).transform.position)) { return Localization.instance.Localize("Step through to return to the Waking World\n[$KEY_Use] Return now"); } return Localization.instance.Localize("Step through to enter the Mists of Avalor\n[$KEY_Use] Enter now"); } public string GetHoverName() { return "Decrepit Avalor Portal"; } } public class AvalorPortalSpawner : MonoBehaviour { private const float TorchSink = 0.06f; private const float TorchSpacing = 10f; private const int TorchSetsSkipped = 4; private const float WaterLevel = 30f; private const float DryMargin = 1.2f; private const float FlatSampleR = 6f; private const float FlatThreshold = 2.5f; private const float StoneMarginD = 12f; private const float PathLevelerReach = 16f; private const float PortalMinDist = 68f; private const float PortalMaxDist = 96f; private const float CorridorBlockPenalty = 200f; private const float CorridorSampleStep = 8f; private const float PathCorridorHalfWidth = 5.5f; private void Start() { ((MonoBehaviour)this).StartCoroutine(SpawnRoutine()); } private IEnumerator SpawnRoutine() { while ((Object)(object)ZNet.instance == (Object)null || (Object)(object)ZNetScene.instance == (Object)null) { yield return (object)new WaitForSeconds(1f); } yield return (object)new WaitForSeconds(2f); AvalorNet.EnsureRegistered(); Vector3 pos; ZDO zdo; bool portalExists = AvalorNet.TryFindOverworldPortalNearTemple(out pos, out zdo); if (!MistsofAvalorPlugin.SpawnPortalAtStart.Value) { if (!portalExists) { yield break; } if (AvalorNet.IsServerRole) { if (zdo != null) { if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"Avalor Labyrinth: Config set to false. Destroying existing Overworld Portal at spawn."); } if (!zdo.IsOwner()) { zdo.SetOwner(ZDOMan.GetSessionID()); } ZDOMan.instance.DestroyZDO(zdo); } } else { AvalorNet.RequestPortalSite(); } yield break; } GameObject portalPrefab = ZNetScene.instance.GetPrefab("Avalor_OverworldPortal"); if ((Object)(object)portalPrefab == (Object)null) { yield break; } Vector3 spawnPos = Vector3.zero; float waitT; switch (AvalorNet.Role) { default: yield break; case AvalorNet.NetRole.PlayerHost: AvalorNet.ServerMarkPortalSiting(); break; case AvalorNet.NetRole.Client: if (portalExists) { yield break; } AvalorNet.RequestPortalSite(); for (waitT = 0f; waitT < 10f; waitT += 0.5f) { if (AvalorNet.PortalGrantAnswered) { break; } yield return (object)new WaitForSeconds(0.5f); } if (!AvalorNet.PortalSiteGranted) { if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"[Avalor] portal siting not granted to this client (exists, claimed elsewhere, or no answer)."); } yield break; } Logger.LogInfo((object)"[Avalor] portal siting GRANTED to this client - building the temple site locally."); break; } if (portalExists) { yield break; } if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)$"Avalor Labyrinth: siting the Overworld Portal {68f:F0}-{96f:F0}m from StartTemple."); } if (!TryFindPortalPlacement(((Component)this).transform.position, out spawnPos, out var pathDir3)) { spawnPos = ((Component)this).transform.position - ((Component)this).transform.forward * 78f; GroundAt(spawnPos, out spawnPos); pathDir3 = FlatDir(((Component)this).transform.position, spawnPos); if (spawnPos.y < 30.5f) { spawnPos.y = 30.5f; } Logger.LogWarning((object)"[Avalor] Portal placement search failed; used raised fallback pad."); } float y = spawnPos.y; spawnPos.y = AvalorTerrainOps.MatchedGroundHeight(spawnPos, 6f, 52f); if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)($"[Avalor] Portal placed at {spawnPos:F0} (natural {y:F1} -> matched " + $"{spawnPos.y:F1}, water {30f}).")); } GameObject prefab = ZNetScene.instance.GetPrefab("Avalor_PortalDecor"); AvalorTerrainFlattener f = null; if ((Object)(object)prefab != (Object)null) { GameObject val = Object.Instantiate(prefab, spawnPos, Quaternion.identity); f = (((Object)(object)val != (Object)null) ? val.GetComponent() : null); } yield return WaitForFlattener(f, 40f); Quaternion val2 = Quaternion.LookRotation(-pathDir3); Object.Instantiate(portalPrefab, spawnPos, val2); if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"Avalor Labyrinth: Spawning spooky geometric decor around Overworld Portal."); } ClearAreaVegetation(spawnPos, 24f, ((Component)this).transform.position); Vector3 val3 = spawnPos - ((Component)this).transform.position; Vector3 dirToPortal = ((Vector3)(ref val3)).normalized; val3 = Vector3.Cross(dirToPortal, Vector3.up); Vector3 sidePerp = ((Vector3)(ref val3)).normalized; int spooky = 0; List list = new List(); GameObject val4 = ZNetScene.instance.GetPrefab("paved_road_v2") ?? ZNetScene.instance.GetPrefab("paved_road"); GameObject ghostTorch = ZNetScene.instance.GetPrefab("Avalor_CryptTorch") ?? ZNetScene.instance.GetPrefab("piece_groundtorch_blue"); GameObject prefab2 = ZNetScene.instance.GetPrefab("Avalor_PathLeveler"); waitT = Vector3.Distance(((Component)this).transform.position, spawnPos); GroundAt(((Component)this).transform.position, out var grounded); float y2 = grounded.y; float y3 = spawnPos.y; ComputeStoneGap(((Component)this).transform.position, out var _, out var _, out var ringRadius); float startD = Mathf.Max(8f, ringRadius + 3f); float num = ringRadius + 16f + 4f; float torchStartD = Mathf.Max(num, startD + 40f); Quaternion torchFacing = Quaternion.LookRotation(sidePerp); for (float num2 = startD; num2 < waitT - 3f; num2 += 2f) { float num3 = Mathf.Clamp01(num2 / waitT); float num4 = Mathf.Lerp(y2, y3, num3); float num5 = Mathf.Clamp01((num2 - startD) / Mathf.Max(1f, num - startD)); Vector3 val5 = ((Component)this).transform.position + dirToPortal * num2; GroundAt(val5, out var grounded2); val5.y = Mathf.Lerp(grounded2.y, num4, num5); if ((Object)(object)prefab2 != (Object)null && num2 >= num && (int)num2 % 4 == 0) { GameObject val6 = Object.Instantiate(prefab2, new Vector3(val5.x, num4, val5.z), Quaternion.identity); AvalorPathLeveler avalorPathLeveler = (((Object)(object)val6 != (Object)null) ? val6.GetComponent() : null); if ((Object)(object)avalorPathLeveler != (Object)null) { list.Add(avalorPathLeveler); } } if (num2 < waitT - 10f) { ClearObstacles(val5, 5.5f); } if ((Object)(object)val4 != (Object)null) { SpawnDecor(val4, val5, Quaternion.LookRotation(dirToPortal)); } } yield return WaitForLevelers(list, 40f); if ((Object)(object)ghostTorch != (Object)null) { for (float num6 = torchStartD; num6 < waitT - 3f; num6 += 10f) { Vector3 val7 = ((Component)this).transform.position + dirToPortal * num6; SpawnDecor(ghostTorch, TorchSeat(val7 + sidePerp * 2.6f), torchFacing, alwaysLit: true); spooky++; SpawnDecor(ghostTorch, TorchSeat(val7 - sidePerp * 2.6f), torchFacing, alwaysLit: true); spooky++; } } GameObject prefab3 = ZNetScene.instance.GetPrefab("SwampTree1"); if ((Object)(object)prefab3 != (Object)null) { for (int i = 0; i < 13; i++) { Vector3 grounded3 = Vector3.zero; bool flag = false; for (int j = 0; j < 8; j++) { if (flag) { break; } float num7 = ((float)i * 27.692308f + Random.Range(-14f, 14f) + (float)j * 9f) * ((float)Math.PI / 180f); float num8 = Random.Range(16f, 22f); Vector3 val8 = spawnPos + new Vector3(Mathf.Cos(num7) * num8, 0f, Mathf.Sin(num7) * num8); if (!InPathCorridor(val8, spawnPos, dirToPortal, sidePerp)) { grounded3 = val8; flag = true; } } if (flag) { GroundAt(grounded3, out grounded3); grounded3.y -= 2.2f; SpawnDecor(prefab3, grounded3, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f)); spooky++; } } } GameObject prefab4 = ZNetScene.instance.GetPrefab("stone_wall_2x2"); if ((Object)(object)prefab4 != (Object)null) { Vector2[] array = (Vector2[])(object)new Vector2[6] { new Vector2(9f, -5f), new Vector2(-9f, -5f), new Vector2(13f, 3f), new Vector2(-13f, 3f), new Vector2(10f, 13f), new Vector2(-10f, 13f) }; for (int k = 0; k < array.Length; k++) { Vector3 pos2 = SitePoint(spawnPos, dirToPortal, sidePerp, array[k].x, array[k].y); pos2.y -= 0.45f + (float)(k % 3) * 0.18f; float num9 = ((array[k].x > 0f) ? 1f : (-1f)) * (18f + (float)(k % 3) * 9f); SpawnDecor(prefab4, pos2, Quaternion.Euler(6f - (float)(k % 3) * 4f, num9, (k % 2 == 0) ? 5f : (-5f))); spooky++; } } GameObject prefab5 = ZNetScene.instance.GetPrefab("MountainGraveStone01"); if ((Object)(object)prefab5 != (Object)null) { for (int l = 0; l < 7; l++) { bool flag2 = l % 2 == 0; float lateral = (flag2 ? 12f : (-12f)); float along = 6f + (float)(l / 2) * 4f; Vector3 pos3 = SitePoint(spawnPos, dirToPortal, sidePerp, lateral, along); Quaternion val9 = Quaternion.LookRotation(flag2 ? (-sidePerp) : sidePerp); SpawnDecor(prefab5, pos3, val9 * Quaternion.Euler(7f - (float)(l % 3) * 5f, 0f, flag2 ? 4f : (-4f))); spooky++; } } string[] array2 = new string[4] { "BoneFragments", "BoneFragments", "BoneFragments", "BoneFragments" }; foreach (string text in array2) { GameObject prefab6 = ZNetScene.instance.GetPrefab(text); if (!((Object)(object)prefab6 == (Object)null)) { float num10 = Random.Range(0f, (float)Math.PI * 2f); float num11 = Random.Range(5f, 10f); Vector3 grounded4 = spawnPos + new Vector3(Mathf.Cos(num10) * num11, 0f, Mathf.Sin(num10) * num11); GroundAt(grounded4, out grounded4); SpawnDecor(prefab6, grounded4, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f)); spooky++; } } GameObject val10 = ZNetScene.instance.GetPrefab("Avalor_Mist") ?? ZNetScene.instance.GetPrefab("vfx_swamp_mist"); if ((Object)(object)val10 != (Object)null) { for (int n = 0; n < 5; n++) { float num12 = Random.Range(0f, (float)Math.PI * 2f); float num13 = Random.Range(0.5f, 3.5f); Vector3 pos4 = spawnPos + new Vector3(Mathf.Cos(num12) * num13, 0.1f, Mathf.Sin(num12) * num13); SpawnDecor(val10, pos4, Quaternion.identity); spooky++; } } if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)$"Avalor Labyrinth: portal area dressed with {spooky} spooky decor pieces."); } for (int pass = 0; pass < 4; pass++) { yield return (object)new WaitForSeconds(3f); ClearAreaVegetation(spawnPos, 24f, ((Component)this).transform.position); for (float num14 = startD; num14 < waitT - 10f; num14 += 4f) { GroundAt(((Component)this).transform.position + dirToPortal * num14, out var grounded5); ClearObstacles(grounded5, 5.5f); } } if (MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)"Avalor Labyrinth: portal clearing re-swept for streamed-in vegetation."); } if (AvalorNet.Role == AvalorNet.NetRole.Client) { AvalorNet.NotifyPortalSited(); } } private GameObject SpawnDecor(GameObject prefab, Vector3 pos, Quaternion rot, bool alwaysLit = false) { //IL_000c: 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) if ((Object)(object)prefab == (Object)null) { return null; } GameObject obj = Object.Instantiate(prefab, pos, rot); ZNetView component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_persistent = true; if (component.GetZDO() != null) { component.GetZDO().Set("AvalorDecor", 1); if (alwaysLit) { component.GetZDO().Set("AvalorAlwaysLit", 1); } } } return obj; } private void ClearAreaVegetation(Vector3 center, float radius, Vector3 stones) { //IL_0000: 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_0066: Unknown result type (might be due to invalid IL or missing references) Collider[] array = Physics.OverlapSphere(center, radius); for (int i = 0; i < array.Length; i++) { ZNetView componentInParent = ((Component)array[i]).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null) && componentInParent.IsValid() && componentInParent.GetZDO() != null && !IsProtected(componentInParent) && componentInParent.GetZDO().GetInt("AvalorDecor", 0) != 1) { string ln = Utils.GetPrefabName(((Component)componentInParent).gameObject).ToLower(); if (!(Vector3.Distance(((Component)componentInParent).transform.position, stones) < 12f) && IsClearableVegetation(ln)) { Destroy(componentInParent.GetZDO()); } } } } private static bool IsProtected(ZNetView view) { if ((Object)(object)((Component)view).GetComponentInChildren(true) != (Object)null) { return true; } if ((Object)(object)((Component)view).GetComponentInChildren(true) != (Object)null) { return true; } if ((Object)(object)((Component)view).GetComponentInChildren(true) != (Object)null) { return true; } string text = Utils.GetPrefabName(((Component)view).gameObject).ToLower(); if (!text.Contains("tombstone") && !text.Contains("bossstone") && !text.Contains("starttemple") && !text.Contains("runestone")) { return text.Contains("portal"); } return true; } private static bool IsClearableVegetation(string ln) { if (!ln.Contains("tree") && !ln.Contains("beech") && !ln.Contains("birch") && !ln.Contains("oak") && !ln.Contains("fir") && !ln.Contains("pine") && !ln.Contains("rock") && !ln.Contains("bush") && !ln.Contains("shrub") && !ln.Contains("stone") && !ln.Contains("log") && !ln.Contains("stump") && !ln.Contains("copper") && !ln.Contains("tin") && !ln.Contains("ore") && !ln.Contains("pickable") && !ln.Contains("mushroom") && !ln.Contains("beehive") && !ln.Contains("spawner") && !ln.Contains("stubbe") && !ln.Contains("vines") && !ln.Contains("cloudberry") && !ln.Contains("raspberry") && !ln.Contains("blueberry")) { return ln.Contains("bramble"); } return true; } private void ClearObstacles(Vector3 pos, float radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Collider[] array = Physics.OverlapSphere(pos, radius); for (int i = 0; i < array.Length; i++) { ZNetView componentInParent = ((Component)array[i]).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null) && componentInParent.IsValid() && componentInParent.GetZDO() != null && !IsProtected(componentInParent) && componentInParent.GetZDO().GetInt("AvalorDecor", 0) != 1) { string text = Utils.GetPrefabName(((Component)componentInParent).gameObject).ToLower(); if (text.Contains("tree") || text.Contains("beech") || text.Contains("birch") || text.Contains("oak") || text.Contains("fir") || text.Contains("pine") || text.Contains("rock") || text.Contains("bush") || text.Contains("shrub") || text.Contains("stone") || text.Contains("log") || text.Contains("stump") || text.Contains("stubbe")) { Destroy(componentInParent.GetZDO()); } } } } private static IEnumerator WaitForFlattener(AvalorTerrainFlattener f, float timeout) { if ((Object)(object)f == (Object)null) { yield return (object)new WaitForSeconds(1.5f); yield break; } float deadline = Time.realtimeSinceStartup + timeout; while (!f.Done) { if (Time.realtimeSinceStartup >= deadline) { Logger.LogWarning((object)("[Avalor][FAIL] the portal clearing's terrain pass did not finish within " + $"{timeout:F0}s. Seating decor anyway - it may sit high or low against " + "ground that is still settling.")); yield break; } yield return null; } yield return null; } private static IEnumerator WaitForLevelers(List levelers, float timeout) { if (levelers == null || levelers.Count == 0) { yield return (object)new WaitForSeconds(2.5f); yield break; } float deadline = Time.realtimeSinceStartup + timeout; while (true) { bool flag = true; for (int i = 0; i < levelers.Count; i++) { if ((Object)(object)levelers[i] != (Object)null && !levelers[i].Done) { flag = false; break; } } if (flag) { break; } if (Time.realtimeSinceStartup >= deadline) { Logger.LogWarning((object)($"[Avalor][FAIL] {levelers.Count} path leveller(s) did not all finish " + $"within {timeout:F0}s. Seating torches anyway - some may sit off the path grade.")); break; } yield return null; } yield return null; } private static void Destroy(ZDO zdo) { if (zdo != null && ZDOMan.instance != null) { if (!zdo.IsOwner()) { zdo.SetOwner(ZDOMan.GetSessionID()); } ZDOMan.instance.DestroyZDO(zdo); } } private Vector3 TorchSeat(Vector3 xz) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) GroundAt(xz, out var grounded); xz.y = grounded.y - 0.06f; return xz; } private void GroundAt(Vector3 xz, out Vector3 grounded) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) grounded = xz; float y = default(float); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(new Vector3(xz.x, 0f, xz.z), ref y)) { grounded.y = y; } else if (WorldGenerator.instance != null) { grounded.y = WorldGenerator.instance.GetHeight(xz.x, xz.z); } } private bool TryFindPortalPlacement(Vector3 center, out Vector3 portalPos, out Vector3 pathDir) { //IL_0001: 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) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: 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_00a4: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) ComputeStoneGap(center, out var gapCenter, out var gapHalf, out var _); float num = Mathf.Max(0f, gapHalf - (float)Math.PI / 15f); float[] array = new float[6] { 78f, 84f, 72f, 90f, 68f, 96f }; float[] array2 = new float[5] { 0f, 0.5f, -0.5f, 1f, -1f }; Vector3 val = Vector3.zero; float num2 = float.MaxValue; float[] array3 = array; for (int i = 0; i < array3.Length; i++) { float num3 = Mathf.Clamp(array3[i], 68f, 96f); float[] array4 = array2; foreach (float num4 in array4) { float num5 = gapCenter + num4 * num; Vector3 grounded = center + new Vector3(Mathf.Cos(num5), 0f, Mathf.Sin(num5)) * num3; GroundAt(grounded, out grounded); float num6 = ScoreSpot(grounded); if (num6 < num2) { num2 = num6; val = grounded; } if (num6 <= 0f) { portalPos = grounded; pathDir = FlatDir(center, grounded); return true; } } } if (num2 > 0f) { for (int k = 0; k < 360; k += 12) { float num7 = (float)k * ((float)Math.PI / 180f); if (BearingHitsStone(center, num7)) { continue; } array3 = array; for (int i = 0; i < array3.Length; i++) { float num8 = Mathf.Clamp(array3[i], 68f, 96f); Vector3 grounded2 = center + new Vector3(Mathf.Cos(num7), 0f, Mathf.Sin(num7)) * num8; GroundAt(grounded2, out grounded2); float num9 = ScoreSpot(grounded2); if (num9 < num2) { num2 = num9; val = grounded2; } } } } portalPos = val; pathDir = FlatDir(center, val); return val != Vector3.zero; } private float ScoreSpot(Vector3 pos) { //IL_0006: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) float num = 0f; if (pos.y < 31.2f) { num += 1000f + (31.2f - pos.y) * 50f; } float num2 = Flatness(pos); if (num2 > 2.5f) { num += 100f + (num2 - 2.5f) * 20f; } return num + (float)CorridorObstructions(pos) * 200f; } private int CorridorObstructions(Vector3 cand) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_000d: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_004f: 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_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_00b8: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; Vector3 val = cand - position; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 1f) { return 0; } val /= magnitude; HashSet hashSet = new HashSet(); int num = 0; for (float num2 = 20f; num2 < magnitude - 6f; num2 += 8f) { Collider[] array = Physics.OverlapSphere(position + val * num2, 5.5f); foreach (Collider val2 in array) { ZNetView val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponentInParent() : null); if (!((Object)(object)val3 == (Object)null) && val3.IsValid() && val3.GetZDO() != null && IsProtected(val3) && hashSet.Add(val3.GetZDO().m_uid)) { num++; } } } return num; } private float Flatness(Vector3 c) { //IL_0019: 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_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_003f: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_007d: Unknown result type (might be due to invalid IL or missing references) float num = float.MaxValue; float num2 = float.MinValue; for (int i = 0; i < 8; i++) { float num3 = (float)i * ((float)Math.PI / 4f); Vector3 grounded = c + new Vector3(Mathf.Cos(num3), 0f, Mathf.Sin(num3)) * 6f; GroundAt(grounded, out grounded); num = Mathf.Min(num, grounded.y); num2 = Mathf.Max(num2, grounded.y); } num = Mathf.Min(num, c.y); num2 = Mathf.Max(num2, c.y); return num2 - num; } private Vector3 SitePoint(Vector3 portal, Vector3 dirToPortal, Vector3 sidePerp, float lateral, float along) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Vector3 grounded = portal + sidePerp * lateral - dirToPortal * along; GroundAt(grounded, out grounded); return grounded; } private static bool InPathCorridor(Vector3 p, Vector3 portal, Vector3 dirToPortal, Vector3 sidePerp) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0024: 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) Vector3 val = p - portal; val.y = 0f; if (Vector3.Dot(val, dirToPortal) > 0f) { return false; } return Mathf.Abs(Vector3.Dot(val, sidePerp)) < 5.5f; } private Vector3 FlatDir(Vector3 from, Vector3 to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) Vector3 val = to - from; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude > 0.001f)) { return Vector3.forward; } return ((Vector3)(ref val)).normalized; } private void ComputeStoneGap(Vector3 center, out float gapCenter, out float gapHalf, out float ringRadius) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00fb: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_008a: Unknown result type (might be due to invalid IL or missing references) List list = new List(); ringRadius = 8f; Collider[] array = Physics.OverlapSphere(center, 13f); for (int i = 0; i < array.Length; i++) { ZNetView componentInParent = ((Component)array[i]).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null) && componentInParent.IsValid() && IsRingStone(Utils.GetPrefabName(((Component)componentInParent).gameObject))) { Vector3 val = ((Component)componentInParent).transform.position - center; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 4f)) { list.Add(Mathf.Atan2(val.z, val.x)); ringRadius = Mathf.Max(ringRadius, ((Vector3)(ref val)).magnitude); } } } if (list.Count < 2) { Vector3 val2 = -((Component)this).transform.forward; val2.y = 0f; val2 = ((((Vector3)(ref val2)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val2)).normalized : Vector3.forward); gapCenter = Mathf.Atan2(val2.z, val2.x); gapHalf = 0.43633232f; return; } list.Sort(); float num = -1f; float num2 = 0f; for (int j = 0; j < list.Count; j++) { float num3 = list[j]; float num4 = ((j + 1 < list.Count) ? list[j + 1] : (list[0] + (float)Math.PI * 2f)); float num5 = num4 - num3; if (num5 > num) { num = num5; num2 = (num3 + num4) * 0.5f; } } gapCenter = num2; gapHalf = num * 0.5f; } private bool BearingHitsStone(Vector3 center, float bearing) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) float num = bearing * 57.29578f; Collider[] array = Physics.OverlapSphere(center, 13f); for (int i = 0; i < array.Length; i++) { ZNetView componentInParent = ((Component)array[i]).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null || !componentInParent.IsValid() || !IsRingStone(Utils.GetPrefabName(((Component)componentInParent).gameObject))) { continue; } Vector3 val = ((Component)componentInParent).transform.position - center; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 4f)) { float num2 = Mathf.Atan2(val.z, val.x) * 57.29578f; if (Mathf.Abs(Mathf.DeltaAngle(num, num2)) < 12f) { return true; } } } return false; } private bool IsRingStone(string prefabName) { string text = prefabName.ToLower(); if (!text.Contains("runestone") && !text.Contains("rock_3") && !text.Contains("bossstone") && !text.Contains("stonepillar")) { return text.Contains("stone_pile"); } return true; } } public class AvalorTerrainFlattener : MonoBehaviour { private const int PassVersion = 3; public const float LevelRadius = 22f; public const float SmoothRadius = 52f; public const float TempleProtectRadius = 16f; public bool Done { get; private set; } private IEnumerator Start() { if ((Object)(object)ZNet.instance == (Object)null) { Done = true; yield break; } yield return AvalorTerrainOps.WaitForGround(((Component)this).transform.position, 52f); if (!AvalorTerrainOps.ClaimPass(((Component)this).gameObject, 3)) { Done = true; yield break; } Vector3 zero = Vector3.zero; float keepOutRadius = 0f; if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetLocationIcon("StartTemple", ref zero)) { keepOutRadius = 16f; } AvalorTerrainOps.Apply(((Component)this).gameObject, ((Component)this).transform.position, 22f, 52f, 30f, zero, keepOutRadius); Done = true; } } public static class AvalorTerrainOps { private const string TerrainPassKey = "AvalorTerrainPass"; private const float PadSpacing = 6f; private const float RingSpacing = 12f; private const float OpLevelRadius = 7f; private const float OpSmoothRadius = 11f; private const float WaterLevel = 30f; public static bool ClaimPass(GameObject host, int passVersion) { if ((Object)(object)host == (Object)null) { return false; } ZNetView component = host.GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return true; } ZDO zDO = component.GetZDO(); if (zDO == null) { return true; } if (zDO.GetInt("AvalorTerrainPass", 0) >= passVersion) { return false; } if (!zDO.IsOwner()) { zDO.SetOwner(ZDOMan.GetSessionID()); } zDO.Set("AvalorTerrainPass", passVersion); return true; } public static bool GroundReady(Vector3 centre, float radius) { //IL_0014: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZoneSystem.instance == (Object)null) { return false; } if (!ZoneSystem.instance.IsZoneLoaded(centre)) { return false; } for (float num = 0f; num < 360f; num += 45f) { if (!ZoneSystem.instance.IsZoneLoaded(centre + Quaternion.Euler(0f, num, 0f) * (Vector3.forward * radius))) { return false; } } return true; } public static IEnumerator WaitForGround(Vector3 centre, float radius, float timeout = 30f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) float deadline = Time.realtimeSinceStartup + timeout; while (!GroundReady(centre, radius)) { if (Time.realtimeSinceStartup >= deadline) { Logger.LogWarning((object)($"[Avalor][FAIL] terrain: waited {timeout:F0}s at {centre:F0} and the " + $"zones inside {radius:F0}m never all streamed in. Shaping anyway - the " + "pad may be cropped at a zone border, which still beats an unshaped site.")); break; } yield return (object)new WaitForSeconds(0.25f); } } public static void Apply(GameObject host, Vector3 centre, float levelRadius, float smoothRadius, float paintRadius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Apply(host, centre, levelRadius, smoothRadius, paintRadius, Vector3.zero, 0f); } public static void Apply(GameObject host, Vector3 centre, float levelRadius, float smoothRadius, float paintRadius, Vector3 keepOutCentre, float keepOutRadius) { //IL_002b: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0072: 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_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) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ZNet.instance == (Object)null)) { float fence = ((keepOutRadius > 0f) ? (keepOutRadius + 11f) : 0f); int num = 0; num += Emit(host, centre, 0f, levelRadius, 6f, level: true, paintRadius, keepOutCentre, fence); num += Emit(host, centre, levelRadius, smoothRadius, 12f, level: false, paintRadius, keepOutCentre, fence); if (MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value) { Vector2i zone = ZoneSystem.GetZone(centre); Logger.LogInfo((object)($"[Avalor] terrain: {num} op(s) spanning {ZonesCovered(centre, smoothRadius)} zone(s) " + $"at {centre:F0} (zone {zone.x},{zone.y}); level r={levelRadius} smooth r={smoothRadius}.")); } } } public static void EmitOp(Vector3 at, bool level, float levelRadius, float smoothRadius, float paintRadius) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0071: Expected O, but got Unknown GameObject val = new GameObject("AvalorTerrainOp"); val.SetActive(false); val.transform.position = at; val.AddComponent().m_settings = new Settings { m_level = level, m_levelRadius = (level ? levelRadius : 0f), m_smooth = true, m_smoothRadius = smoothRadius, m_square = false, m_paintCleared = (paintRadius > 0f), m_paintRadius = paintRadius }; val.SetActive(true); } private static int Emit(GameObject host, Vector3 centre, float innerRadius, float outerRadius, float spacing, bool level, float paintRadius, Vector3 keepOutCentre, float fence) { //IL_0056: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_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_007a: 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) int num = Mathf.CeilToInt(outerRadius / spacing); int num2 = 0; Vector3 val = default(Vector3); for (int i = -num; i <= num; i++) { for (int j = -num; j <= num; j++) { ((Vector3)(ref val))..ctor((float)i * spacing, 0f, (float)j * spacing); float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > outerRadius || (innerRadius > 0f && magnitude <= innerRadius - 7f)) { continue; } Vector3 val2 = centre + val; if (fence > 0f) { float num3 = val2.x - keepOutCentre.x; float num4 = val2.z - keepOutCentre.z; if (num3 * num3 + num4 * num4 < fence * fence) { continue; } } EmitOp(val2, level, 7f, 11f, (magnitude <= paintRadius) ? 8f : 0f); num2++; } } return num2; } public static float MatchedGroundHeight(Vector3 centre, float innerRadius, float outerRadius) { //IL_000d: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_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_008a: 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_0096: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZoneSystem.instance == (Object)null) { return centre.y; } double num = 0.0; double num2 = 0.0; float num7 = default(float); for (float num3 = innerRadius; num3 <= outerRadius + 0.01f; num3 += 4f) { int num4 = Mathf.Max(8, Mathf.RoundToInt(num3)); float num5 = Mathf.Max(0.25f, num3 / Mathf.Max(outerRadius, 1f)); for (int i = 0; i < num4; i++) { float num6 = 360f / (float)num4 * (float)i; Vector3 val = centre + Quaternion.Euler(0f, num6, 0f) * (Vector3.forward * num3); if (ZoneSystem.instance.GetGroundHeight(val, ref num7) && !(num7 <= 30f)) { num += (double)(num7 * num5); num2 += (double)num5; } } } if (num2 <= 0.0) { return centre.y; } return Mathf.Max((float)(num / num2), 31.2f); } private static int ZonesCovered(Vector3 centre, float radius) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) //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) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); Vector2i zone = ZoneSystem.GetZone(centre); hashSet.Add(((long)zone.x << 32) ^ (uint)zone.y); for (float num = 0f; num < 360f; num += 45f) { Vector2i zone2 = ZoneSystem.GetZone(centre + Quaternion.Euler(0f, num, 0f) * (Vector3.forward * radius)); hashSet.Add(((long)zone2.x << 32) ^ (uint)zone2.y); } return hashSet.Count; } } public class AvalorAssetManager { private const float TorchHeight = 1.9f; private const float TorchSkullAt = 0.9f; private const float CELL = 6f; private const float STOREY = 4f; private const float SLAB = 0.4f; private const float WALL_HALF = 0.4f; private const float SEAM = 0.4f; private const float WALL_OVERHANG = 0.90000004f; private const float WALL_BLEED = 0.3f; private const float PortalHeight = 7f; public static readonly Color AvalorGreen = new Color(0.3f, 1f, 0.55f); private const float PortalGap = 3.2f; private const float PortalToeIn = 6f; private static readonly Dictionary _detailSign = new Dictionary(); public static void Init() { PrefabManager.OnVanillaPrefabsAvailable += ClonePrefabs; ZoneManager.OnVanillaLocationsAvailable += RegisterLocations; } private static void ClonePrefabs() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Expected O, but got Unknown //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Expected O, but got Unknown //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Expected O, but got Unknown //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Expected O, but got Unknown //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: 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_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0684: Unknown result type (might be due to invalid IL or missing references) //IL_068e: Expected O, but got Unknown //IL_0c63: Unknown result type (might be due to invalid IL or missing references) //IL_0c6d: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0c9d: 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_0c80: Unknown result type (might be due to invalid IL or missing references) //IL_0c8a: Unknown result type (might be due to invalid IL or missing references) //IL_0716: Unknown result type (might be due to invalid IL or missing references) //IL_0720: Expected O, but got Unknown //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_080a: Unknown result type (might be due to invalid IL or missing references) //IL_0814: Expected O, but got Unknown //IL_0d82: Unknown result type (might be due to invalid IL or missing references) //IL_0d8c: Expected O, but got Unknown //IL_0796: Unknown result type (might be due to invalid IL or missing references) //IL_07ca: Unknown result type (might be due to invalid IL or missing references) //IL_07d4: Expected O, but got Unknown //IL_0886: Unknown result type (might be due to invalid IL or missing references) //IL_08a1: Unknown result type (might be due to invalid IL or missing references) //IL_08d0: Unknown result type (might be due to invalid IL or missing references) //IL_08da: Expected O, but got Unknown //IL_0980: Unknown result type (might be due to invalid IL or missing references) //IL_099b: Unknown result type (might be due to invalid IL or missing references) //IL_09c1: Unknown result type (might be due to invalid IL or missing references) //IL_09cb: Expected O, but got Unknown AvalorKitBundle.Load(); GameObject val = PrefabManager.Instance.CreateClonedPrefab("Avalor_Wall", "stone_wall_2x1"); if ((Object)(object)val != (Object)null) { InfuseCryptMaterial(val); } PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); GameObject val2 = PrefabManager.Instance.CreateClonedPrefab("Avalor_Floor", "stone_floor_2x2"); if ((Object)(object)val2 != (Object)null) { InfuseCryptMaterial(val2); } PrefabManager.Instance.AddPrefab(new CustomPrefab(val2, false)); GameObject val3 = PrefabManager.Instance.CreateClonedPrefab("Avalor_Stair", "wood_stair"); if ((Object)(object)val3 != (Object)null) { InfuseCryptMaterial(val3); } PrefabManager.Instance.AddPrefab(new CustomPrefab(val3, false)); GameObject val4 = PrefabManager.Instance.CreateEmptyPrefab("Avalor_MegaFloor", true); Object.DestroyImmediate((Object)(object)val4.GetComponent()); Object.DestroyImmediate((Object)(object)val4.GetComponent()); StripColliders(val4); val4.layer = 10; val4.GetComponent().m_persistent = true; BoxCollider obj = val4.AddComponent(); obj.size = new Vector3(30f, 0.5f, 30f); obj.center = new Vector3(0f, -0.25f, 0f); PrefabManager.Instance.AddPrefab(new CustomPrefab(val4, false)); GameObject val5 = PrefabManager.Instance.CreateEmptyPrefab("Avalor_CompositeWall", true); Object.DestroyImmediate((Object)(object)val5.GetComponent()); Object.DestroyImmediate((Object)(object)val5.GetComponent()); val5.layer = 10; val5.GetComponent().m_persistent = true; BoxCollider obj2 = val5.AddComponent(); obj2.size = new Vector3(6f, 4f, 0.5f); obj2.center = new Vector3(0f, 2f, 0f); if ((Object)(object)val != (Object)null) { List list = new List(); for (float num = -2f; num <= 2f; num += 2f) { for (float num2 = 0f; num2 <= 3f; num2 += 1f) { list.Add(Matrix4x4.TRS(new Vector3(num, num2, 0f), Quaternion.identity, Vector3.one)); } } CombineTileMeshes(val, val5, list); } DressCompositeWithAuthored(val5, "wallA", 'W'); PrefabManager.Instance.AddPrefab(new CustomPrefab(val5, false)); CreateWallVariant("Avalor_CompositeWallB", "wallB", val); CreateWallVariant("Avalor_CompositeWallC", "wallC", val); GameObject val6 = PrefabManager.Instance.CreateEmptyPrefab("Avalor_CompositeStair", true); Object.DestroyImmediate((Object)(object)val6.GetComponent()); Object.DestroyImmediate((Object)(object)val6.GetComponent()); val6.layer = 10; val6.GetComponent().m_persistent = true; if ((Object)(object)val3 != (Object)null && (Object)(object)val2 != (Object)null) { List list2 = new List(); list2.Add(Matrix4x4.TRS(new Vector3(0f, 0f, 0f), Quaternion.identity, Vector3.one)); list2.Add(Matrix4x4.TRS(new Vector3(0f, 2f, 2f), Quaternion.identity, Vector3.one)); list2.Add(Matrix4x4.TRS(new Vector3(2f, 0f, 0f), Quaternion.identity, Vector3.one)); list2.Add(Matrix4x4.TRS(new Vector3(2f, 2f, 2f), Quaternion.identity, Vector3.one)); CombineTileMeshes(val3, val6, list2); List list3 = new List(); for (float num3 = 0f; num3 <= 4f; num3 += 2f) { for (float num4 = 0f; num4 <= 4f; num4 += 2f) { if (!(num3 < 4f) || !(num4 < 4f)) { list3.Add(Matrix4x4.TRS(new Vector3(num3, 4f, num4), Quaternion.identity, Vector3.one)); } } } CombineTileMeshes(val2, val6, list3); } PrefabManager.Instance.AddPrefab(new CustomPrefab(val6, false)); GameObject val7 = PrefabManager.Instance.CreateEmptyPrefab("Avalor_MazeChunk", true); Object.DestroyImmediate((Object)(object)val7.GetComponent()); Object.DestroyImmediate((Object)(object)val7.GetComponent()); StripColliders(val7); val7.layer = 10; val7.GetComponent().m_persistent = true; val7.AddComponent(); PrefabManager.Instance.AddPrefab(new CustomPrefab(val7, false)); GameObject val8 = PrefabManager.Instance.CreateEmptyPrefab("Avalor_CompositeFloor", true); Object.DestroyImmediate((Object)(object)val8.GetComponent()); Object.DestroyImmediate((Object)(object)val8.GetComponent()); val8.layer = 10; val8.GetComponent().m_persistent = true; BoxCollider obj3 = val8.AddComponent(); obj3.size = new Vector3(6f, 0.5f, 6f); obj3.center = new Vector3(0f, 0.25f, 0f); if ((Object)(object)val2 != (Object)null) { List list4 = new List(); for (float num5 = -2f; num5 <= 2f; num5 += 2f) { for (float num6 = -2f; num6 <= 2f; num6 += 2f) { list4.Add(Matrix4x4.TRS(new Vector3(num5, 0f, num6), Quaternion.identity, Vector3.one)); } } CombineTileMeshes(val2, val8, list4); } DressCompositeWithAuthored(val8, "floorA", 'F'); PrefabManager.Instance.AddPrefab(new CustomPrefab(val8, false)); CreateFloorVariant("Avalor_CompositeFloorB", "floorB", val2); CreateFloorVariant("Avalor_CompositeFloorC", "floorC", val2); GameObject val9 = PrefabManager.Instance.CreateEmptyPrefab("Avalor_CompositeCeiling", true); Object.DestroyImmediate((Object)(object)val9.GetComponent()); Object.DestroyImmediate((Object)(object)val9.GetComponent()); StripColliders(val9); val9.layer = 10; val9.GetComponent().m_persistent = true; if ((Object)(object)val2 != (Object)null) { List list5 = new List(); for (float num7 = -2f; num7 <= 2f; num7 += 2f) { for (float num8 = -2f; num8 <= 2f; num8 += 2f) { list5.Add(Matrix4x4.TRS(new Vector3(num7, -0.5f, num8), Quaternion.identity, Vector3.one)); } } CombineTileMeshes(val2, val9, list5); } DressCompositeWithAuthored(val9, ((Object)(object)AvalorKitBundle.GetMesh("ceilingA") != (Object)null) ? "ceilingA" : "floorA", 'C'); PrefabManager.Instance.AddPrefab(new CustomPrefab(val9, false)); GameObject val10 = PrefabManager.Instance.CreateClonedPrefab("Avalor_Key", "CryptKey"); if ((Object)(object)val10 != (Object)null) { ItemDrop component = val10.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_itemData.m_shared.m_name = "Avalor Crypt Key"; component.m_itemData.m_shared.m_description = "Unlocks the vault gates in the Mists of Avalor."; component.m_itemData.m_shared.m_maxStackSize = 20; component.m_itemData.m_dropPrefab = val10; } ItemManager.Instance.AddItem(new CustomItem(val10, false)); } GameObject val11 = PrefabManager.Instance.CreateClonedPrefab("Avalor_Gate", "iron_grate"); if ((Object)(object)val11 != (Object)null) { Door component2 = val11.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } WearNTear component3 = val11.GetComponent(); if ((Object)(object)component3 != (Object)null) { Object.DestroyImmediate((Object)(object)component3); } val11.AddComponent(); val11.transform.localScale = new Vector3(3f, 2f, 1f); InfuseCryptMaterial(val11); ZNetView component4 = val11.GetComponent(); if ((Object)(object)component4 != (Object)null) { component4.m_persistent = true; } PrefabManager.Instance.AddPrefab(new CustomPrefab(val11, false)); } GameObject val12 = PrefabManager.Instance.CreateClonedPrefab("Avalor_Chest", "piece_chest_wood"); if ((Object)(object)val12 != (Object)null) { MakeIndestructibleContainer(val12); InfuseCryptMaterial(val12); } PrefabManager.Instance.AddPrefab(new CustomPrefab(val12, false)); GameObject val13 = PrefabManager.Instance.CreateClonedPrefab("Avalor_SpikeTrap", "piece_sharpstakes"); if ((Object)(object)val13 != (Object)null) { WearNTear component5 = val13.GetComponent(); if ((Object)(object)component5 != (Object)null) { Object.DestroyImmediate((Object)(object)component5); } BoxCollider val14 = val13.GetComponent(); if ((Object)(object)val14 == (Object)null) { val14 = val13.AddComponent(); } ((Collider)val14).isTrigger = true; val14.size = new Vector3(4f, 7f, 4f); val14.center = new Vector3(0f, 3.5f, 0f); val13.AddComponent().SpikePrefab = val13; val13.AddComponent(); InfuseCryptMaterial(val13); PrefabManager.Instance.AddPrefab(new CustomPrefab(val13, false)); } GameObject val15 = PrefabManager.Instance.CreateClonedPrefab("Avalor_PoisonTrap", "piece_chest_wood"); if ((Object)(object)val15 != (Object)null) { WearNTear component6 = val15.GetComponent(); if ((Object)(object)component6 != (Object)null) { Object.DestroyImmediate((Object)(object)component6); } Piece component7 = val15.GetComponent(); if ((Object)(object)component7 != (Object)null) { Object.DestroyImmediate((Object)(object)component7); } Container component8 = val15.GetComponent(); if ((Object)(object)component8 != (Object)null) { Object.DestroyImmediate((Object)(object)component8); } BoxCollider val16 = val15.GetComponent(); if ((Object)(object)val16 == (Object)null) { val16 = val15.AddComponent(); } ((Collider)val16).isTrigger = true; val16.size = new Vector3(4f, 7f, 4f); val16.center = new Vector3(0f, 3.5f, 0f); val15.AddComponent().IsPoison = true; InfuseCryptMaterial(val15); PrefabManager.Instance.AddPrefab(new CustomPrefab(val15, false)); } CreateOverworldPortal(); CreateExitPortal(); CreateEnvZone(); CreateRecallRune(); CreatePortalDecor(); CreatePathLeveler(); CreateCryptTorch(); CreateMistVolume(); CreateStairTile(); CreateArchway(); CreateVaultChest(); CreatePrizeChest(); CreateStartDais(); CreateEndShrine(); string[] array = new string[27] { "bone_stack", "stone_pile", "wood_stack", "BoneFragments", "Pickable_SunkenCryptRandom", "Pickable_ForestCryptRandom", "Pickable_ForestCryptRemains01", "Pickable_ForestCryptRemains02", "Pickable_ForestCryptRemains03", "Pickable_ForestCryptRemains04", "dvergrprops_crate", "dvergrprops_barrel", "dvergrprops_crate_long", "crypt_skeleton_chest", "Chain", "piece_banner01", "piece_banner02", "piece_banner03", "piece_banner04", "piece_banner05", "dvergrprops_banner", "dvergrprops_hooknchain", "ShieldWood", "ShieldBronzeBuckler", "ShieldIronBuckler", "ShieldSerpentscale", "ShieldCarapace" }; foreach (string text in array) { try { GameObject val17 = PrefabManager.Instance.CreateClonedPrefab("Avalor_Clutter_" + text, text); if ((Object)(object)val17 == (Object)null) { continue; } MakeStaticDecor(val17); if (text != null) { int length = text.Length; if (length <= 22) { switch (length) { case 20: if (text == "crypt_skeleton_chest") { val17.transform.localScale = Vector3.one * 0.7f; } break; case 22: if (text == "dvergrprops_crate_long") { val17.transform.localScale = Vector3.one * 0.8f; } break; } } else if (length != 26) { if (length == 29) { switch (text[28]) { case '1': break; case '2': goto IL_0c2c; case '3': goto IL_0c3c; case '4': goto IL_0c4c; default: goto IL_0cb1; } if (text == "Pickable_ForestCryptRemains01") { goto IL_0c96; } } } else { char c = text[9]; if (c != 'F') { if (c == 'S' && text == "Pickable_SunkenCryptRandom") { goto IL_0c96; } } else if (text == "Pickable_ForestCryptRandom") { goto IL_0c96; } } } goto IL_0cb1; IL_0c96: val17.transform.localScale = Vector3.one * 1.3f; goto IL_0cb1; IL_0cb1: List list6 = new List(); Transform[] componentsInChildren = val17.GetComponentsInChildren(true); foreach (Transform val18 in componentsInChildren) { if (!((Object)(object)val18 == (Object)null) && !((Object)(object)val18 == (Object)(object)val17.transform)) { string text2 = ((Object)val18).name.ToLower(); if (text2.Contains("particle") || text2.Contains("vfx") || text2.Contains("sparkle")) { list6.Add(((Component)val18).gameObject); } } } foreach (GameObject item in list6) { if ((Object)(object)item != (Object)null) { Object.DestroyImmediate((Object)(object)item); } } PrefabManager.Instance.AddPrefab(new CustomPrefab(val17, false)); goto end_IL_0b13; IL_0c3c: if (text == "Pickable_ForestCryptRemains03") { goto IL_0c96; } goto IL_0cb1; IL_0c2c: if (text == "Pickable_ForestCryptRemains02") { goto IL_0c96; } goto IL_0cb1; IL_0c4c: if (text == "Pickable_ForestCryptRemains04") { goto IL_0c96; } goto IL_0cb1; end_IL_0b13:; } catch (Exception ex) { Logger.LogWarning((object)("Avalor: failed to build clutter clone for '" + text + "': " + ex.Message)); } } AvalorWeapons.Register(); PrefabManager.OnVanillaPrefabsAvailable -= ClonePrefabs; } private static void CreateOverworldPortal() { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateClonedPrefab("Avalor_OverworldPortal", "portal_stone"); if (!((Object)(object)val == (Object)null)) { TeleportWorld component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } TeleportWorldTrigger[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } WearNTear component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } val.AddComponent(); float targetHeight = (DressPortalWithAuthored(val, 7f) ? 7f : 2.5f); AddPortalPresence(val, targetHeight); ZNetView component3 = val.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.m_persistent = true; } PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } } catch (Exception ex) { Logger.LogError((object)("Avalor: CreateOverworldPortal failed: " + ex)); } } private static void CreateExitPortal() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateClonedPrefab("Avalor_ExitPortal", "portal_stone"); if ((Object)(object)val == (Object)null) { return; } TeleportWorld component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } TeleportWorldTrigger[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } WearNTear component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } Transform[] componentsInChildren2 = val.GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)val.transform) && ((Object)val2).name.StartsWith("_target_found")) { ((Component)val2).gameObject.SetActive(true); } } StripColliders(val); val.AddComponent(); AddPortalPresence(val, 2.5f); ZNetView component3 = val.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.m_persistent = true; } PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } catch (Exception ex) { Logger.LogError((object)("Avalor: CreateExitPortal failed: " + ex)); } } private static void CreateEnvZone() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateEmptyPrefab("Avalor_EnvZone", true); if (!((Object)(object)val == (Object)null)) { Object.DestroyImmediate((Object)(object)val.GetComponent()); Object.DestroyImmediate((Object)(object)val.GetComponent()); StripColliders(val); ZNetView component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_persistent = true; } val.AddComponent(); PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } } catch (Exception ex) { Logger.LogError((object)("Avalor: CreateEnvZone failed: " + ex)); } } private static void CreateRecallRune() { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateClonedPrefab("Avalor_RecallRune", "Ruby"); if (!((Object)(object)val == (Object)null)) { ItemDrop component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_itemData.m_shared.m_name = "Avalor Recall Rune"; component.m_itemData.m_shared.m_description = "Channel to return to your last bed. Consumed on use."; component.m_itemData.m_shared.m_itemType = (ItemType)2; component.m_itemData.m_shared.m_maxStackSize = 10; component.m_itemData.m_dropPrefab = val; SE_AvalorRecall sE_AvalorRecall = ScriptableObject.CreateInstance(); ((Object)sE_AvalorRecall).name = "SE_AvalorRecall"; ((StatusEffect)sE_AvalorRecall).m_name = "Recalling"; ((StatusEffect)sE_AvalorRecall).m_ttl = 5f; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)sE_AvalorRecall, false)); component.m_itemData.m_shared.m_consumeStatusEffect = (StatusEffect)(object)sE_AvalorRecall; } ItemManager.Instance.AddItem(new CustomItem(val, false)); } } catch (Exception ex) { Logger.LogError((object)("Avalor: CreateRecallRune failed: " + ex)); } } private static void CreatePortalDecor() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateEmptyPrefab("Avalor_PortalDecor", true); if (!((Object)(object)val == (Object)null)) { Object.DestroyImmediate((Object)(object)val.GetComponent()); Object.DestroyImmediate((Object)(object)val.GetComponent()); StripColliders(val); ZNetView component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_persistent = true; } val.AddComponent(); val.AddComponent(); PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } } catch (Exception ex) { Logger.LogError((object)("Avalor: CreatePortalDecor failed: " + ex)); } } private static void CreatePathLeveler() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateEmptyPrefab("Avalor_PathLeveler", true); if (!((Object)(object)val == (Object)null)) { Object.DestroyImmediate((Object)(object)val.GetComponent()); Object.DestroyImmediate((Object)(object)val.GetComponent()); StripColliders(val); ZNetView component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_persistent = true; } val.AddComponent(); PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } } catch (Exception ex) { Logger.LogError((object)("Avalor: CreatePathLeveler failed: " + ex)); } } private static GameObject FitAuthoredVisual(GameObject parent, string module, Vector3 targetSize, Vector3 localCentre, float yaw) { //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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0069: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00c0: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)parent == (Object)null || !AvalorKitBundle.Available) { return null; } Mesh mesh = AvalorKitBundle.GetMesh(module); if ((Object)(object)mesh == (Object)null) { return null; } Material material = AvalorKitBundle.GetMaterial(module); if ((Object)(object)material == (Object)null) { return null; } Bounds bounds = mesh.bounds; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(targetSize.x / Mathf.Max(0.001f, ((Bounds)(ref bounds)).size.x), targetSize.y / Mathf.Max(0.001f, ((Bounds)(ref bounds)).size.y), targetSize.z / Mathf.Max(0.001f, ((Bounds)(ref bounds)).size.z)); Quaternion val2 = Quaternion.Euler(0f, yaw, 0f); GameObject val3 = new GameObject("Avalor_Authored_" + module); val3.transform.SetParent(parent.transform, false); val3.transform.localRotation = val2; val3.transform.localScale = val; val3.transform.localPosition = localCentre - val2 * Vector3.Scale(((Bounds)(ref bounds)).center, val); val3.AddComponent().sharedMesh = mesh; ((Renderer)val3.AddComponent()).sharedMaterial = material; if (MistsofAvalorPlugin.DebugLogging == null || MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)$"[Avalor] authored '{module}' -> {((Object)parent).name}: raw {((Bounds)(ref bounds)).size:F2} fit {targetSize:F2} yaw {yaw:F0}"); } return val3; } private static void StripColliders(GameObject prefab) { if (!((Object)(object)prefab == (Object)null)) { Collider[] componentsInChildren = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } EffectArea[] componentsInChildren2 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } } } private static GameObject CreateBarePrefab(string name) { GameObject val = PrefabManager.Instance.CreateEmptyPrefab(name, true); if ((Object)(object)val == (Object)null) { return null; } MeshRenderer component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } MeshFilter component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } StripColliders(val); val.layer = 10; ZNetView component3 = val.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.m_persistent = true; } return val; } private static void CreateStairTile() { //IL_002e: 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) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown try { GameObject val = CreateBarePrefab("Avalor_CompositeStairTile"); if (!((Object)(object)val == (Object)null)) { GameObject val2 = FitAuthoredVisual(val, "stairs", new Vector3(6f, 4f, 6f), new Vector3(0f, 2f, 0f), 0f); if ((Object)(object)val2 == (Object)null) { Object.DestroyImmediate((Object)(object)val); return; } val2.AddComponent().sharedMesh = val2.GetComponent().sharedMesh; PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } } catch (Exception ex) { Logger.LogError((object)("Avalor: CreateStairTile failed: " + ex)); } } private static void CreateArchway() { //IL_002b: 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) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown try { GameObject val = CreateBarePrefab("Avalor_Archway"); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)FitAuthoredVisual(val, "archway", new Vector3(6.4f, 4.3f, 0.55f), new Vector3(0f, 2.15f, 0f), 0f) == (Object)null) { Object.DestroyImmediate((Object)(object)val); } else { PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } } } catch (Exception ex) { Logger.LogError((object)("Avalor: CreateArchway failed: " + ex)); } } private static void CreateVaultChest() { //IL_007b: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown try { GameObject prefab = PrefabManager.Instance.GetPrefab("Avalor_Chest"); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning((object)"[Avalor] Avalor_Chest not yet registered - vault chests keep the plain look. (Ordering: CreateVaultChest must run after the Avalor_Chest block.)"); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("Avalor_VaultChest", prefab); if (!((Object)(object)val == (Object)null)) { MeshRenderer[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Renderer)componentsInChildren[i]).enabled = false; } FitAuthoredVisual(val, "vault", new Vector3(1.7f, 1.05f, 1.45f), new Vector3(0f, 0.52f, 0f), 0f); PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } } catch (Exception ex) { Logger.LogError((object)("Avalor: CreateVaultChest failed: " + ex)); } } private static void CreatePrizeChest() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateClonedPrefab("Avalor_PrizeChest", "piece_chest_blackmetal"); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)"[Avalor][FAIL] could not clone piece_chest_blackmetal - the greatsword prize chest will fall back to the raw vanilla piece, which DESTROYS ITSELF on the maze floor."); return; } MakeIndestructibleContainer(val); PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } catch (Exception ex) { Logger.LogError((object)("Avalor: CreatePrizeChest failed: " + ex)); } } private static void MakeIndestructibleContainer(GameObject chest) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)chest == (Object)null)) { WearNTear[] componentsInChildren = chest.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } Container[] componentsInChildren2 = chest.GetComponentsInChildren(true); foreach (Container obj in componentsInChildren2) { obj.m_privacy = (PrivacySetting)2; obj.m_checkGuardStone = false; } Piece[] componentsInChildren3 = chest.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } ZNetView component = chest.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_persistent = true; } } } private static void CreateStartDais() { //IL_002e: 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) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown try { GameObject val = CreateBarePrefab("Avalor_StartDais"); if (!((Object)(object)val == (Object)null)) { GameObject val2 = FitAuthoredVisual(val, "start", new Vector3(14f, 0.35f, 14f), new Vector3(0f, 0.175f, 0f), 0f); if ((Object)(object)val2 == (Object)null) { Object.DestroyImmediate((Object)(object)val); return; } val2.AddComponent().sharedMesh = val2.GetComponent().sharedMesh; PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } } catch (Exception ex) { Logger.LogError((object)("Avalor: CreateStartDais failed: " + ex)); } } private static void CreateEndShrine() { //IL_002b: 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) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown try { GameObject val = CreateBarePrefab("Avalor_EndShrine"); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)FitAuthoredVisual(val, "end", new Vector3(6.6f, 3.9f, 2.6f), new Vector3(0f, 1.95f, 0f), 0f) == (Object)null) { Object.DestroyImmediate((Object)(object)val); } else { PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } } } catch (Exception ex) { Logger.LogError((object)("Avalor: CreateEndShrine failed: " + ex)); } } private static bool DressTorchWithAuthored(GameObject torch) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_010b: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)torch == (Object)null || !AvalorKitBundle.Available) { return false; } Mesh mesh = AvalorKitBundle.GetMesh("torch"); if ((Object)(object)mesh == (Object)null) { return false; } Material material = AvalorKitBundle.GetMaterial("torch"); if ((Object)(object)material == (Object)null) { return false; } MeshRenderer[] componentsInChildren = torch.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Renderer)componentsInChildren[i]).enabled = false; } float num = 1.7099999f; foreach (Transform item in torch.transform) { Transform val = item; if ((Object)(object)((Component)val).GetComponentInChildren(true) != (Object)null || (Object)(object)((Component)val).GetComponentInChildren(true) != (Object)null) { val.localPosition = new Vector3(0f, num, 0f); } } Bounds bounds = mesh.bounds; int num2 = LongAxis(((Bounds)(ref bounds)).size); OtherAxes(num2, ((Bounds)(ref bounds)).size, out var _, out var wi); Quaternion val2 = Quaternion.Inverse(Quaternion.LookRotation(Axis(wi), Axis(num2))); Vector3 size = ((Bounds)(ref bounds)).size; float num3 = 1.9f / Mathf.Max(0.001f, ((Vector3)(ref size))[num2]); GameObject val3 = new GameObject("AvalorAuthoredTorch"); val3.transform.SetParent(torch.transform, false); val3.transform.localRotation = val2; val3.transform.localScale = Vector3.one * num3; val3.transform.localPosition = new Vector3(0f, 0.95f, 0f) - val2 * (((Bounds)(ref bounds)).center * num3); val3.AddComponent().sharedMesh = mesh; ((Renderer)val3.AddComponent()).sharedMaterial = material; if (MistsofAvalorPlugin.DebugLogging == null || MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)$"[Avalor] authored torch fitted (mesh {((Bounds)(ref bounds)).size:F2} -> {1.9f}m, flame at y={num:F2})."); } return true; } private static void CreateMistVolume() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateClonedPrefab("Avalor_Mist", "vfx_swamp_mist"); if (!((Object)(object)val == (Object)null)) { val.AddComponent().Kind = AvalorAtmoKind.Mist; ZNetView component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_persistent = true; } PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } } catch (Exception ex) { Logger.LogError((object)("Avalor: CreateMistVolume failed: " + ex)); } } private static void CreateCryptTorch() { //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateClonedPrefab("Avalor_CryptTorch", "piece_groundtorch_blue"); if ((Object)(object)val == (Object)null) { return; } WearNTear component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } Fireplace component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } ParticleSystem[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } ParticleSystemRenderer[] componentsInChildren2 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } LightFlicker[] componentsInChildren3 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } LightLod[] componentsInChildren4 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren4[i]); } Light[] componentsInChildren5 = val.GetComponentsInChildren(true); foreach (Light val2 in componentsInChildren5) { val2.shadows = (LightShadows)0; val2.color = AvalorCryptEnvZone.AvalorGreen; val2.range = 12f; val2.intensity = 1.6f; ((Behaviour)val2).enabled = true; if ((Object)(object)((Component)val2).gameObject != (Object)(object)val) { ((Component)val2).gameObject.SetActive(true); } } DressTorchWithAuthored(val); val.AddComponent().Kind = AvalorAtmoKind.Torch; ZNetView component3 = val.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.m_persistent = true; } PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } catch (Exception ex) { Logger.LogError((object)("Avalor: CreateCryptTorch failed: " + ex)); } } private static void CreatePuddle() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown try { GameObject val = PrefabManager.Instance.CreateClonedPrefab("Avalor_Puddle", "TarLiquid"); if ((Object)(object)val == (Object)null) { return; } Aoe[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Aoe val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)val2); } } val.transform.localScale = new Vector3(0.12f, 0.35f, 0.12f); ZNetView component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_persistent = true; } PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } catch (Exception ex) { Logger.LogError((object)("Avalor: CreatePuddle failed: " + ex)); } } private static void MakeStaticDecor(GameObject go) { if ((Object)(object)go == (Object)null) { return; } ZNetView component = go.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_persistent = true; } Component[] componentsInChildren = go.GetComponentsInChildren(true); foreach (Component val in componentsInChildren) { if (val is ItemDrop || val is Piece || val is Destructible || val is Pickable || val is Floating || val is CharacterDrop || val is HoverText || val is EggHatch || val is WearNTear || val is MineRock || val is MineRock5) { Object.DestroyImmediate((Object)(object)val); } } Rigidbody component2 = go.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.isKinematic = true; component2.useGravity = false; Object.DestroyImmediate((Object)(object)component2); } ParticleSystemRenderer[] componentsInChildren2 = go.GetComponentsInChildren(true); foreach (ParticleSystemRenderer val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)val2); } } ParticleSystem[] componentsInChildren3 = go.GetComponentsInChildren(true); foreach (ParticleSystem val3 in componentsInChildren3) { if ((Object)(object)val3 != (Object)null) { Object.DestroyImmediate((Object)(object)val3); } } Light[] componentsInChildren4 = go.GetComponentsInChildren(true); foreach (Light val4 in componentsInChildren4) { if ((Object)(object)val4 != (Object)null) { Object.DestroyImmediate((Object)(object)val4); } } Projector[] componentsInChildren5 = go.GetComponentsInChildren(true); foreach (Projector val5 in componentsInChildren5) { if ((Object)(object)val5 != (Object)null) { Object.DestroyImmediate((Object)(object)val5); } } } public static void CombineTileMeshes(GameObject sourcePrefab, GameObject compositeParent, List transforms, bool copyColliders = false) { GameObject meshObj; Mesh val = BuildCombined(sourcePrefab, compositeParent, transforms, out meshObj); if (!((Object)(object)val == (Object)null) && copyColliders) { meshObj.AddComponent().sharedMesh = val; } } public static IEnumerator CombineTileMeshesThreaded(GameObject sourcePrefab, GameObject compositeParent, List transforms, Action onComplete) { if (transforms.Count == 0) { onComplete?.Invoke(null, null); yield break; } MeshFilter val = FindLOD0(sourcePrefab); if ((Object)(object)val == (Object)null) { onComplete?.Invoke(null, null); yield break; } Mesh sharedMesh = val.sharedMesh; Material[] sourceMaterials = ((Renderer)((Component)val).GetComponent()).sharedMaterials; Vector3[] sVerts = sharedMesh.vertices; if (sVerts == null || sVerts.Length == 0) { onComplete?.Invoke(null, null); yield break; } Vector3[] sNormals = sharedMesh.normals; Vector4[] sTangents = sharedMesh.tangents; Vector2[] sUV = sharedMesh.uv; int[] sTris = sharedMesh.triangles; Matrix4x4 val2 = Matrix4x4.TRS(((Component)val).transform.localPosition, ((Component)val).transform.localRotation, ((Component)val).transform.localScale); int n = transforms.Count; Matrix4x4[] mats = (Matrix4x4[])(object)new Matrix4x4[n]; for (int i = 0; i < n; i++) { mats[i] = transforms[i] * val2; } int sv = sVerts.Length; int st = sTris.Length; bool hasNormals = sNormals != null && sNormals.Length == sv; bool hasTangents = sTangents != null && sTangents.Length == sv; bool hasUV = sUV != null && sUV.Length == sv; Vector3[] verts = (Vector3[])(object)new Vector3[sv * n]; Vector3[] normals = (Vector3[])(object)(hasNormals ? new Vector3[sv * n] : null); Vector4[] tangents = (Vector4[])(object)(hasTangents ? new Vector4[sv * n] : null); Vector2[] uvs = (Vector2[])(object)(hasUV ? new Vector2[sv * n] : null); int[] tris = new int[st * n]; bool done = false; ThreadPool.QueueUserWorkItem(delegate { //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_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) //IL_0064: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_008c: 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_0095: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) try { for (int j = 0; j < n; j++) { Matrix4x4 val5 = mats[j]; int num = j * sv; for (int k = 0; k < sv; k++) { verts[num + k] = ((Matrix4x4)(ref val5)).MultiplyPoint3x4(sVerts[k]); Vector3 val6; if (hasNormals) { Vector3[] array = normals; int num2 = num + k; val6 = ((Matrix4x4)(ref val5)).MultiplyVector(sNormals[k]); array[num2] = ((Vector3)(ref val6)).normalized; } if (hasTangents) { Vector4 val7 = sTangents[k]; val6 = ((Matrix4x4)(ref val5)).MultiplyVector(new Vector3(val7.x, val7.y, val7.z)); Vector3 normalized = ((Vector3)(ref val6)).normalized; tangents[num + k] = new Vector4(normalized.x, normalized.y, normalized.z, val7.w); } if (hasUV) { uvs[num + k] = sUV[k]; } } int num3 = j * st; for (int l = 0; l < st; l++) { tris[num3 + l] = sTris[l] + num; } } } catch { } done = true; }); while (!done) { yield return null; } Mesh val3 = new Mesh(); val3.indexFormat = (IndexFormat)1; val3.SetVertices(verts); if (normals != null) { val3.SetNormals(normals); } if (tangents != null) { val3.SetTangents(tangents); } if (uvs != null) { val3.SetUVs(0, uvs); } val3.SetTriangles(tris, 0); if (normals == null) { val3.RecalculateNormals(); } if (tangents == null) { val3.RecalculateTangents(); } val3.RecalculateBounds(); GameObject val4 = new GameObject(((Object)sourcePrefab).name + "_Combined") { layer = sourcePrefab.layer }; val4.transform.SetParent(compositeParent.transform, false); val4.AddComponent().sharedMesh = val3; ((Renderer)val4.AddComponent()).sharedMaterials = sourceMaterials; MeshCollider arg = val4.AddComponent(); onComplete?.Invoke(val3, arg); } private static MeshFilter FindLOD0(GameObject sourcePrefab) { MeshFilter result = null; int num = -1; MeshFilter[] componentsInChildren = sourcePrefab.GetComponentsInChildren(true); foreach (MeshFilter val in componentsInChildren) { string text = ((Object)((Component)val).gameObject).name.ToLower(); if (!text.Contains("shadow") && !text.Contains("proxy") && (Object)(object)val.sharedMesh != (Object)null && val.sharedMesh.vertexCount > num) { MeshRenderer component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null && ((Renderer)component).sharedMaterials.Length != 0) { result = val; num = val.sharedMesh.vertexCount; } } } return result; } private static Mesh BuildCombined(GameObject sourcePrefab, GameObject compositeParent, List transforms, out GameObject meshObj) { //IL_0038: 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_004e: Unknown result type (might be due to invalid IL or missing references) //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_006c: 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_0075: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown meshObj = null; if (transforms.Count == 0) { return null; } MeshFilter val = FindLOD0(sourcePrefab); if ((Object)(object)val == (Object)null) { return null; } Mesh sharedMesh = val.sharedMesh; Material[] sharedMaterials = ((Renderer)((Component)val).GetComponent()).sharedMaterials; Matrix4x4 val2 = Matrix4x4.TRS(((Component)val).transform.localPosition, ((Component)val).transform.localRotation, ((Component)val).transform.localScale); List list = new List(); foreach (Matrix4x4 transform in transforms) { CombineInstance item = default(CombineInstance); ((CombineInstance)(ref item)).mesh = sharedMesh; ((CombineInstance)(ref item)).transform = transform * val2; list.Add(item); } Mesh val3 = new Mesh(); val3.indexFormat = (IndexFormat)1; val3.CombineMeshes(list.ToArray(), true, true); meshObj = new GameObject(((Object)sourcePrefab).name + "_Combined"); meshObj.layer = sourcePrefab.layer; meshObj.transform.SetParent(compositeParent.transform, false); meshObj.AddComponent().sharedMesh = val3; ((Renderer)meshObj.AddComponent()).sharedMaterials = sharedMaterials; return val3; } private static void InfuseCryptMaterial(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return; } Material val = null; GameObject prefab2 = PrefabManager.Instance.GetPrefab("blackmarble_2x2x1"); if ((Object)(object)prefab2 != (Object)null) { MeshRenderer componentInChildren = prefab2.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { val = ((Renderer)componentInChildren).sharedMaterial; } } if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("Avalor: InfuseCryptMaterial could not find a donor material for " + ((Object)prefab).name + " - it will keep its original vanilla appearance.")); return; } MeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (MeshRenderer val2 in componentsInChildren) { Material[] sharedMaterials = ((Renderer)val2).sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { sharedMaterials[j] = val; } ((Renderer)val2).sharedMaterials = sharedMaterials; } } private static float Sz(float v) { return Mathf.Max(0.001f, v); } private static void DressCompositeWithAuthored(GameObject composite, string moduleName, char kind) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_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_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: 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_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: 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_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: 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_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Expected O, but got Unknown //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_0410: 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) if ((Object)(object)composite == (Object)null || !AvalorKitBundle.Available) { return; } Mesh mesh = AvalorKitBundle.GetMesh(moduleName); if ((Object)(object)mesh == (Object)null) { return; } Material material = AvalorKitBundle.GetMaterial(moduleName); if ((Object)(object)material == (Object)null) { return; } List list = new List(); foreach (Transform item in composite.transform) { Transform val = item; list.Add(((Component)val).gameObject); } foreach (GameObject item2 in list) { Object.DestroyImmediate((Object)(object)item2); } Bounds bounds = mesh.bounds; int num = ThinAxis(((Bounds)(ref bounds)).size); OtherAxes(num, ((Bounds)(ref bounds)).size, out var ui, out var wi); Vector3 val2 = Axis(num) * (float)DetailSign(mesh, num); Vector3 val3 = Axis(ui); Vector3 val4; Vector3 right; float num2; float num3; float num4; Vector3 val5 = default(Vector3); switch (kind) { case 'W': val4 = Vector3.forward; right = Vector3.right; num2 = 6.9f; num3 = 4.3f; num4 = 0.4f; ((Vector3)(ref val5))..ctor(0f, 2f, 0.2f); break; case 'C': val4 = Vector3.down; right = Vector3.right; num2 = 6.4f; num3 = 6.4f; num4 = 0.4f; ((Vector3)(ref val5))..ctor(0f, -0.56f, 0f); break; default: val4 = Vector3.up; right = Vector3.right; num2 = 6.4f; num3 = 6.4f; num4 = 0.4f; ((Vector3)(ref val5))..ctor(0f, -0.2f, 0f); break; } Quaternion val6 = Quaternion.LookRotation(val4, right) * Quaternion.Inverse(Quaternion.LookRotation(val2, val3)); Vector3 one = Vector3.one; int num5 = ui; float num6 = num2; Vector3 size = ((Bounds)(ref bounds)).size; ((Vector3)(ref one))[num5] = num6 / Sz(((Vector3)(ref size))[ui]); int num7 = wi; float num8 = num3; size = ((Bounds)(ref bounds)).size; ((Vector3)(ref one))[num7] = num8 / Sz(((Vector3)(ref size))[wi]); float num9 = num4; size = ((Bounds)(ref bounds)).size; ((Vector3)(ref one))[num] = num9 / Sz(((Vector3)(ref size))[num]); Vector3 val7 = val5 - val6 * Vector3.Scale(one, ((Bounds)(ref bounds)).center); Mesh val8 = mesh; _ = Matrix4x4.identity; if (kind == 'W') { Matrix4x4 val9 = Matrix4x4.TRS(val7, val6, one); Matrix4x4 transform = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 180f, 0f), Vector3.one) * val9; val8 = new Mesh { name = moduleName + "_twosided", indexFormat = (IndexFormat)1 }; Mesh obj = val8; CombineInstance[] array = new CombineInstance[2]; CombineInstance val10 = default(CombineInstance); ((CombineInstance)(ref val10)).mesh = mesh; ((CombineInstance)(ref val10)).transform = val9; array[0] = val10; val10 = default(CombineInstance); ((CombineInstance)(ref val10)).mesh = mesh; ((CombineInstance)(ref val10)).transform = transform; array[1] = val10; obj.CombineMeshes((CombineInstance[])(object)array, true, true); val8.RecalculateBounds(); } else { Matrix4x4.TRS(val7, val6, one); } GameObject val11 = new GameObject(moduleName + "_LOD0"); val11.transform.SetParent(composite.transform, false); if (kind != 'W') { val11.transform.localScale = one; val11.transform.localRotation = val6; val11.transform.localPosition = val7; } val11.AddComponent().sharedMesh = val8; ((Renderer)val11.AddComponent()).sharedMaterial = material; val11.layer = composite.layer; if (MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value) { Vector3 val12; if (kind != 'W') { val12 = Vector3.Scale(one, ((Bounds)(ref bounds)).size); } else { Bounds bounds2 = val8.bounds; val12 = ((Bounds)(ref bounds2)).size; } Vector3 val13 = val12; Logger.LogInfo((object)($"[Avalor] authored '{moduleName}' -> {((Object)composite).name} [{kind}]: raw {((Bounds)(ref bounds)).size:F2} " + string.Format("thinAxis={0} detail={1}{2} fit {3:F2}", "XYZ"[num], (DetailSign(mesh, num) > 0) ? "+" : "-", "XYZ"[num], val13))); } } private static bool DressPortalWithAuthored(GameObject portal, float targetHeight) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0095: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: 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_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: 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_023e: 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_026d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)portal == (Object)null || !AvalorKitBundle.Available) { return false; } string text = (((Object)(object)AvalorKitBundle.GetMesh("portalpillar") != (Object)null) ? "portalpillar" : "portalArch"); Mesh mesh = AvalorKitBundle.GetMesh(text); if ((Object)(object)mesh == (Object)null) { return false; } Material material = AvalorKitBundle.GetMaterial(text); if ((Object)(object)material == (Object)null) { return false; } MeshRenderer[] componentsInChildren = portal.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Renderer)componentsInChildren[i]).enabled = false; } Bounds bounds = mesh.bounds; int num = LongAxis(((Bounds)(ref bounds)).size); OtherAxes(num, ((Bounds)(ref bounds)).size, out var ui, out var wi); Quaternion val = Quaternion.LookRotation(Axis(wi), Axis(num)); Quaternion val2 = Quaternion.LookRotation(Vector3.forward, Vector3.up) * Quaternion.Inverse(val); Vector3 size = ((Bounds)(ref bounds)).size; float num2 = targetHeight / Sz(((Vector3)(ref size))[num]); size = ((Bounds)(ref bounds)).size; float num3 = ((Vector3)(ref size))[ui] * num2 * 0.5f; float num4 = 1.6f + num3; for (int j = 0; j < 2; j++) { float num5 = ((j == 0) ? (-1f) : 1f); GameObject val3 = new GameObject((j == 0) ? "AvalorPillar_L" : "AvalorPillar_R"); val3.transform.SetParent(portal.transform, false); val3.transform.localScale = new Vector3(num2, num2, num2); Quaternion val4 = Quaternion.Euler(0f, (0f - num5) * 6f, 0f) * val2; val3.transform.localRotation = val4; Vector3 val5 = val4 * Vector3.Scale(Vector3.one * num2, ((Bounds)(ref bounds)).center); val3.transform.localPosition = new Vector3(num5 * num4 - val5.x, targetHeight * 0.5f - val5.y, 0f - val5.z); val3.AddComponent().sharedMesh = mesh; ((Renderer)val3.AddComponent()).sharedMaterial = material; val3.layer = portal.layer; BoxCollider obj = portal.AddComponent(); size = ((Bounds)(ref bounds)).size; float num6 = ((Vector3)(ref size))[ui] * num2 * 0.85f; size = ((Bounds)(ref bounds)).size; obj.size = new Vector3(num6, targetHeight, ((Vector3)(ref size))[wi] * num2 * 0.7f); obj.center = new Vector3(num5 * num4, targetHeight * 0.5f, 0f); } if (MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value) { string text2 = $"[Avalor] authored '{text}' -> twin-pillar gateway: raw {((Bounds)(ref bounds)).size:F2} "; object[] obj2 = new object[4] { "XYZ"[num], "XYZ"[ui], num2, null }; size = ((Bounds)(ref bounds)).size; obj2[3] = ((Vector3)(ref size))[ui] * num2; Logger.LogInfo((object)(text2 + string.Format("(up={0} face={1}) scale {2:F2}, pillar {3:F2}w x ", obj2) + $"{targetHeight:F2}h, gap {3.2f:F2}, span {2f * num4:F2}m")); } return true; } private static void AddPortalPresence(GameObject portal, float targetHeight) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_007c: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("AvalorPortalGlow"); val.transform.SetParent(portal.transform, false); val.transform.localPosition = new Vector3(0f, targetHeight * 0.5f, 0f); Light obj = val.AddComponent(); obj.type = (LightType)2; obj.color = AvalorGreen; obj.range = 20f; obj.intensity = 1.35f; obj.shadows = (LightShadows)0; val.AddComponent(); GameObject val2 = new GameObject("AvalorPortalApproach"); val2.transform.SetParent(portal.transform, false); val2.transform.localPosition = new Vector3(0f, targetHeight * 0.35f, 0f); val2.layer = portal.layer; BoxCollider obj2 = val2.AddComponent(); ((Collider)obj2).isTrigger = true; obj2.size = new Vector3(2.8799999f, targetHeight * 0.7f, 3f); val2.AddComponent(); AvalorPortalRuneVFX avalorPortalRuneVFX = portal.AddComponent(); avalorPortalRuneVFX.Colour = AvalorGreen; avalorPortalRuneVFX.GateWidth = 3.2f; avalorPortalRuneVFX.GateHeight = targetHeight; TintPortalVfx(portal, targetHeight); } private static void TintPortalVfx(GameObject portal, float targetHeight) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00ce: 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) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0133: Unknown result type (might be due to invalid IL or missing references) Light[] componentsInChildren = portal.GetComponentsInChildren(true); foreach (Light val in componentsInChildren) { if (!(((Object)((Component)val).gameObject).name == "AvalorPortalGlow")) { val.color = AvalorGreen; } } ParticleSystem[] componentsInChildren2 = portal.GetComponentsInChildren(true); foreach (ParticleSystem obj in componentsInChildren2) { ((Component)obj).transform.localScale = Vector3.one * 2.2f; ((Component)obj).transform.localPosition = new Vector3(0f, targetHeight * 0.35f, 0f); MainModule main = obj.main; ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0; ((MainModule)(ref main)).startColor = new MinMaxGradient(AvalorGreen); ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime; if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled) { Gradient val2 = new Gradient(); val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val2); } } } private static void CreateWallVariant(string prefabName, string moduleName, GameObject wallPrefab) { //IL_0062: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrefabManager.Instance.CreateEmptyPrefab(prefabName, true); if ((Object)(object)val == (Object)null) { return; } Object.DestroyImmediate((Object)(object)val.GetComponent()); Object.DestroyImmediate((Object)(object)val.GetComponent()); val.layer = 10; ZNetView component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_persistent = true; } BoxCollider obj = val.AddComponent(); obj.size = new Vector3(6f, 4f, 0.5f); obj.center = new Vector3(0f, 2f, 0f); if ((Object)(object)wallPrefab != (Object)null) { List list = new List(); for (float num = -2f; num <= 2f; num += 2f) { for (float num2 = 0f; num2 <= 3f; num2 += 1f) { list.Add(Matrix4x4.TRS(new Vector3(num, num2, 0f), Quaternion.identity, Vector3.one)); } } CombineTileMeshes(wallPrefab, val, list); } DressCompositeWithAuthored(val, moduleName, 'W'); PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } private static void CreateFloorVariant(string prefabName, string moduleName, GameObject floorPrefab) { //IL_0062: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrefabManager.Instance.CreateEmptyPrefab(prefabName, true); if ((Object)(object)val == (Object)null) { return; } Object.DestroyImmediate((Object)(object)val.GetComponent()); Object.DestroyImmediate((Object)(object)val.GetComponent()); val.layer = 10; ZNetView component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_persistent = true; } BoxCollider obj = val.AddComponent(); obj.size = new Vector3(6f, 0.5f, 6f); obj.center = new Vector3(0f, 0.25f, 0f); if ((Object)(object)floorPrefab != (Object)null) { List list = new List(); for (float num = -2f; num <= 2f; num += 2f) { for (float num2 = -2f; num2 <= 2f; num2 += 2f) { list.Add(Matrix4x4.TRS(new Vector3(num, 0f, num2), Quaternion.identity, Vector3.one)); } } CombineTileMeshes(floorPrefab, val, list); } DressCompositeWithAuthored(val, moduleName, 'F'); PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); } private static Vector3 Axis(int i) { //IL_0013: 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_0007: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(i switch { 1 => Vector3.up, 0 => Vector3.right, _ => Vector3.forward, }); } private static int ThinAxis(Vector3 s) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!(s.x <= s.y) || !(s.x <= s.z)) { if (!(s.y <= s.z)) { return 2; } return 1; } return 0; } private static int LongAxis(Vector3 s) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!(s.x >= s.y) || !(s.x >= s.z)) { if (!(s.y >= s.z)) { return 2; } return 1; } return 0; } private static void OtherAxes(int ni, Vector3 s, out int ui, out int wi) { int num = (ni + 1) % 3; int num2 = (ni + 2) % 3; if (((Vector3)(ref s))[num] >= ((Vector3)(ref s))[num2]) { ui = num; wi = num2; } else { ui = num2; wi = num; } } private static int DetailSign(Mesh mesh, int axis) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) int key = ((Object)mesh).GetInstanceID() * 4 + axis; if (_detailSign.TryGetValue(key, out var value)) { return value; } int num = 1; try { Vector3[] vertices = mesh.vertices; int[] triangles = mesh.triangles; Vector3 val = Axis(axis); double num2 = 0.0; double num3 = 0.0; for (int i = 0; i + 2 < triangles.Length; i += 3) { Vector3 val2 = Vector3.Cross(vertices[triangles[i + 1]] - vertices[triangles[i]], vertices[triangles[i + 2]] - vertices[triangles[i]]); float num4 = ((Vector3)(ref val2)).magnitude * 0.5f; if (!(num4 <= 0f)) { float num5 = Vector3.Dot(((Vector3)(ref val2)).normalized, val); if (num5 > 0.4f) { num2 += (double)num4; } else if (num5 < -0.4f) { num3 += (double)num4; } } } if (num3 > num2) { num = -1; } } catch (Exception ex) { Logger.LogWarning((object)("[Avalor] could not measure detail face of '" + ((Object)mesh).name + "' - assuming +axis. " + ex.Message)); } _detailSign[key] = num; return num; } private static void RegisterLocations() { if ((Object)(object)PrefabManager.Instance.GetPrefab("Avalor_OverworldPortal") != (Object)null) { GameObject prefab = PrefabManager.Instance.GetPrefab("StartTemple"); if ((Object)(object)prefab != (Object)null) { prefab.AddComponent(); } } ZoneManager.OnVanillaLocationsAvailable -= RegisterLocations; } } public class SE_AvalorRecall : StatusEffect { public override void Stop() { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) ((StatusEffect)this).Stop(); if ((Object)(object)base.m_character != (Object)null && base.m_character.IsPlayer()) { Character character = base.m_character; Player val = (Player)(object)((character is Player) ? character : null); Vector3 customSpawnPoint = Game.instance.GetPlayerProfile().GetCustomSpawnPoint(); if (customSpawnPoint == Vector3.zero) { ((Vector3)(ref customSpawnPoint))..ctor(0f, 50f, 0f); } ((Character)val).TeleportTo(customSpawnPoint, ((Component)val).transform.rotation, true); ((Character)val).Message((MessageType)2, "Returned safely!", 0, (Sprite)null); } } } public static class AvalorKitBundle { private const string BundleName = "avalor_kit"; private static bool _tried; private static AssetBundle _bundle; private static Material _donor; private static readonly Dictionary _meshCache = new Dictionary(); private static readonly Dictionary _matCache = new Dictionary(); public static bool Available => (Object)(object)_bundle != (Object)null; public static bool Load() { if (_tried) { return (Object)(object)_bundle != (Object)null; } _tried = true; try { _bundle = AssetUtils.LoadAssetBundleFromResources("avalor_kit", Assembly.GetExecutingAssembly()); if ((Object)(object)_bundle == (Object)null) { Logger.LogWarning((object)"[Avalor] Kit bundle 'avalor_kit' not found as an embedded resource - using vanilla fallback geometry."); return false; } if (MistsofAvalorPlugin.DebugLogging != null && MistsofAvalorPlugin.DebugLogging.Value) { Logger.LogInfo((object)("[Avalor] Kit bundle loaded. Assets: " + string.Join(", ", _bundle.GetAllAssetNames()))); } else { Logger.LogInfo((object)("[Avalor] Kit bundle loaded (" + _bundle.GetAllAssetNames().Length + " assets).")); } return true; } catch (Exception ex) { Logger.LogError((object)("[Avalor] Failed to load kit bundle - using vanilla fallback geometry. " + ex)); _bundle = null; return false; } } public static Mesh GetMesh(string moduleName) { if ((Object)(object)_bundle == (Object)null) { return null; } if (_meshCache.TryGetValue(moduleName, out var value)) { return value; } Mesh val = null; try { val = _bundle.LoadAsset(moduleName); } catch { } if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("[Avalor] kit mesh '" + moduleName + "' not in bundle.")); } _meshCache[moduleName] = val; return val; } public static Material GetMaterial(string moduleName) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if (_matCache.TryGetValue(moduleName, out var value)) { return value; } Material donor = GetDonor(); Material val = ((!((Object)(object)donor != (Object)null)) ? ((Material)null) : new Material(donor)); if ((Object)(object)val == (Object)null) { _matCache[moduleName] = null; return null; } ((Object)val).name = "Avalor_Mat_" + moduleName; Texture2D val2 = null; if ((Object)(object)_bundle != (Object)null) { try { val2 = _bundle.LoadAsset(moduleName + "_albedo"); } catch { } } if ((Object)(object)val2 != (Object)null) { val.mainTexture = (Texture)(object)val2; if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)val2); } if (val.HasProperty("_Color")) { val.SetColor("_Color", Color.white); } if (val.HasProperty("_MainColor")) { val.SetColor("_MainColor", Color.white); } } else { Logger.LogWarning((object)("[Avalor] kit albedo '" + moduleName + "_albedo' missing - module keeps plain dark stone.")); } _matCache[moduleName] = val; return val; } private static Material GetDonor() { if ((Object)(object)_donor != (Object)null) { return _donor; } string[] array = new string[3] { "stone_wall_2x1", "stone_wall_4x2", "blackmarble_2x2x1" }; foreach (string text in array) { GameObject prefab = PrefabManager.Instance.GetPrefab(text); if (!((Object)(object)prefab == (Object)null)) { MeshRenderer componentInChildren = prefab.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)((Renderer)componentInChildren).sharedMaterial != (Object)null) { _donor = ((Renderer)componentInChildren).sharedMaterial; break; } } } if ((Object)(object)_donor == (Object)null) { Logger.LogWarning((object)"[Avalor] no donor stone material found for kit materials."); } return _donor; } }