Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BifrostGate v1.0.1
plugins\Bifrost.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; 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: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Bifrost { [BepInPlugin("com.crasssam.bifrost", "Bifrost Gate", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class BifrostPlugin : BaseUnityPlugin { private sealed class Destination { internal string Name; internal Vector3 Position; internal float Yaw; internal string Id; } [HarmonyPatch(typeof(Player), "TryPlacePiece")] private static class UniquePlacementPatch { private static bool Prefix(Piece piece, ref bool __result) { if ((Object)(object)piece == (Object)null || !((Object)((Component)piece).gameObject).name.StartsWith("piece_bifrost_gate", StringComparison.Ordinal) || Instance?.gate == null) { return true; } MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, "Only one Bifrost Gate can exist in this world", 0, (Sprite)null, false, true); } __result = false; return false; } } [HarmonyPatch(typeof(TeleportWorld), "Interact")] private static class InteractPatch { private static bool Prefix(TeleportWorld __instance, bool hold, ref bool __result) { if (!IsGate(__instance)) { return true; } __result = false; if (hold || !AtGate(__instance)) { return false; } Instance.OpenDestinations(); __result = true; return false; } } [HarmonyPatch(typeof(TeleportWorld), "HaveTarget")] private static class HaveTargetPatch { private static bool Prefix(TeleportWorld __instance, ref bool __result) { if (AtGate(__instance)) { __result = Instance.selected != null; return false; } if (IsAvailable(__instance) && Instance.gate != null) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(TeleportWorld), "TargetFound")] private static class TargetFoundPatch { private static bool Prefix(TeleportWorld __instance, ref bool __result) { if (AtGate(__instance)) { __result = Instance.selected != null; return false; } if (IsAvailable(__instance) && Instance.gate != null) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(TeleportWorld), "Teleport")] private static class TravelPatch { private static bool Prefix(TeleportWorld __instance, Player player) { //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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00b2: 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_00b5: Unknown result type (might be due to invalid IL or missing references) if (!AtGate(__instance) && !IsAvailable(__instance)) { return true; } Destination destination = (AtGate(__instance) ? Instance.selected : Instance.gate); if (destination == null || (Object)(object)player == (Object)null) { return false; } if (!__instance.m_allowAllItems && !((Humanoid)player).IsTeleportable(__instance.m_allowAllItems)) { MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, "Cannot teleport with restricted items", 0, (Sprite)null, false, true); } return false; } Quaternion val = Quaternion.Euler(0f, destination.Yaw, 0f); Vector3 val2 = destination.Position + val * Vector3.forward * __instance.m_exitDistance + Vector3.up; ((Character)player).TeleportTo(val2, val, false); return false; } } [HarmonyPatch(typeof(TeleportWorld), "GetHoverText")] private static class HoverPatch { private static bool Prefix(TeleportWorld __instance, ref string __result) { if (IsGate(__instance)) { __result = (AtGate(__instance) ? ("Bifrost Gate [E] Destinations\nSelected: " + (Instance.selected?.Name ?? "None")) : "Only one Bifrost Gate can operate in this world"); return false; } if (IsAvailable(__instance) && Instance.gate != null) { __result = "Portal: " + __instance.GetText() + " [BIFROST]\nConnected to Bifrost Gate"; return false; } return true; } } private const string Prefab = "piece_bifrost_gate"; private const string SnapshotRpc = "Bifrost_Snapshot_v1"; private const string RequestRpc = "Bifrost_Request_v1"; private static readonly int Stone = StringExtensionMethods.GetStableHashCode("portal_stone"); private static readonly int Wood = StringExtensionMethods.GetStableHashCode("portal_wood"); private static readonly int Gate = StringExtensionMethods.GetStableHashCode("piece_bifrost_gate"); private static BifrostPlugin Instance; private Harmony harmony; private BifrostDestinationGrid destinationGrid; private readonly List<Destination> destinations = new List<Destination>(); private Destination gate; private Destination selected; private float nextScan; private string lastSnapshot; private bool registered; private void Awake() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown Instance = this; PrefabManager.OnVanillaPrefabsAvailable += Register; harmony = new Harmony("com.crasssam.bifrost"); harmony.PatchAll(); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= Register; destinationGrid?.Close(); Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } Instance = null; } private void Register() { //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_0021: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) PrefabManager.OnVanillaPrefabsAvailable -= Register; PieceConfig val = new PieceConfig { Name = "Bifrost Gate", Description = "The world's unique portal hub", PieceTable = "Hammer", Category = "Misc" }; CustomPiece val2 = new CustomPiece("piece_bifrost_gate", "portal_stone", val); GameObject prefab = PrefabManager.Instance.GetPrefab("portal_stone"); Piece val3 = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Piece>() : null); if ((Object)(object)val3 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Stone portal prefab was not found"); return; } val2.Piece.m_resources = ((IEnumerable<Requirement>)val3.m_resources).Select((Func<Requirement, Requirement>)((Requirement r) => new Requirement { m_resItem = r.m_resItem, m_amount = checked(r.m_amount * 2), m_recover = r.m_recover })).ToArray(); val2.Piece.m_name = "Bifrost Gate"; val2.Piece.m_description = "Connect to any named, unpaired portal"; val2.Piece.m_category = (PieceCategory)0; val2.Piece.m_craftingStation = val3.m_craftingStation; val2.Piece.m_icon = val3.m_icon; val2.Piece.m_canBeRemoved = true; ((Component)val2.Piece).gameObject.transform.localScale = Vector3.one * 1.4f; TeleportWorld component = ((Component)val2.Piece).GetComponent<TeleportWorld>(); if ((Object)(object)component != (Object)null) { component.m_allowAllItems = prefab.GetComponent<TeleportWorld>().m_allowAllItems; } ((Component)val2.Piece).gameObject.AddComponent<BifrostVisuals>(); PieceManager.Instance.AddPiece(val2); } private void Update() { if (destinationGrid != null && destinationGrid.IsOpen && Input.GetKeyDown((KeyCode)27)) { destinationGrid.Close(); } if (ZRoutedRpc.instance == null || (Object)(object)ZNet.instance == (Object)null) { destinationGrid?.Close(); registered = false; gate = null; selected = null; destinations.Clear(); return; } if (destinationGrid != null && destinationGrid.IsOpen && (gate == null || (Object)(object)Player.m_localPlayer == (Object)null)) { destinationGrid.Close(); } if (!registered) { ZRoutedRpc.instance.Register<string>("Bifrost_Snapshot_v1", (Action<long, string>)OnSnapshot); ZRoutedRpc.instance.Register<string>("Bifrost_Request_v1", (Action<long, string>)OnRequest); registered = true; } if (!(Time.time < nextScan)) { nextScan = Time.time + 3f; if (ZNet.instance.IsServer()) { ScanAndBroadcast(); return; } ZRoutedRpc.instance.InvokeRoutedRPC(ZNet.instance.GetServerPeer().m_uid, "Bifrost_Request_v1", new object[1] { "" }); } } private void OnRequest(long sender, string ignored) { if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer() && lastSnapshot != null) { ZRoutedRpc.instance.InvokeRoutedRPC(sender, "Bifrost_Snapshot_v1", new object[1] { lastSnapshot }); } } private static bool IsNone(ZDOID id) { //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 id == ZDOID.None; } private static IEnumerable<ZDO> AllZdos() { ZDOMan manager = ZDOMan.instance; if (manager == null) { yield break; } string[] array = new string[3] { "piece_bifrost_gate", "portal_stone", "portal_wood" }; foreach (string text in array) { List<ZDO> list = new List<ZDO>(); int num = 0; while (!manager.GetAllZDOsWithPrefabIterative(text, list, ref num)) { } foreach (ZDO item in list) { if (item != null) { yield return item; } } } } private static string Key(ZDO zdo) { return ((object)Unsafe.As<ZDOID, ZDOID>(ref zdo.m_uid)/*cast due to .constrained prefix*/).ToString(); } private void ScanAndBroadcast() { List<ZDO> source = (from z in AllZdos() where z.GetPrefab() == Gate || z.GetPrefab() == Stone || z.GetPrefab() == Wood select z).ToList(); List<ZDO> list = source.Where((ZDO z) => z.GetPrefab() == Gate).OrderBy<ZDO, string>(Key, StringComparer.Ordinal).ToList(); ZDO only = list.FirstOrDefault(); List<ZDO> endpoints = source.Where((ZDO z) => z != only && z.GetPrefab() != Gate && !string.IsNullOrWhiteSpace(z.GetString("tag", ""))).ToList(); List<ZDO> source2 = endpoints.Where((ZDO z) => IsNone(z.GetZDOID("target")) && endpoints.Count((ZDO p) => p.GetString("tag", "") == z.GetString("tag", "")) == 1).ToList(); string text = string.Join("\n", new string[1] { Serialize(only, "G") }.Concat(source2.Select((ZDO z) => Serialize(z, "P")))); if (text != lastSnapshot) { lastSnapshot = text; ZRoutedRpc.instance.InvokeRoutedRPC(0L, "Bifrost_Snapshot_v1", new object[1] { text }); OnSnapshot(0L, text); } if (list.Count > 1) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Multiple Bifrost Gates detected. Only the oldest ZDO is active; dismantle the duplicates."); } } private static string Serialize(ZDO z, string kind) { //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_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_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) if (z == null) { return kind; } Vector3 position = z.GetPosition(); string[] obj = new string[7] { kind, Convert.ToBase64String(Encoding.UTF8.GetBytes((kind == "G") ? "Bifrost Gate" : z.GetString("tag", ""))), Key(z), position.x.ToString("R", CultureInfo.InvariantCulture), position.y.ToString("R", CultureInfo.InvariantCulture), position.z.ToString("R", CultureInfo.InvariantCulture), null }; Quaternion rotation = z.GetRotation(); obj[6] = ((Quaternion)(ref rotation)).eulerAngles.y.ToString("R", CultureInfo.InvariantCulture); return string.Join("|", obj); } private static Destination Parse(string line) { //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) string[] array = line.Split(new char[1] { '|' }); if (array.Length != 7) { return null; } CultureInfo invariantCulture = CultureInfo.InvariantCulture; return new Destination { Name = Encoding.UTF8.GetString(Convert.FromBase64String(array[1])), Id = array[2], Position = new Vector3(float.Parse(array[3], invariantCulture), float.Parse(array[4], invariantCulture), float.Parse(array[5], invariantCulture)), Yaw = float.Parse(array[6], invariantCulture) }; } private void OnSnapshot(long sender, string payload) { if ((Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer() && sender != ZNet.instance.GetServerPeer().m_uid) { return; } try { string[] array = payload.Split(new char[1] { '\n' }, StringSplitOptions.None); gate = Parse(array[0]); destinations.Clear(); foreach (string item in array.Skip(1)) { Destination destination = Parse(item); if (destination != null) { destinations.Add(destination); } } destinations.Sort((Destination a, Destination b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase)); selected = ((selected == null) ? null : destinations.FirstOrDefault((Destination p) => p.Id == selected.Id)); destinationGrid?.Refresh(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Ignoring malformed portal snapshot: " + ex.Message)); } } private static bool IsGate(TeleportWorld portal) { if ((Object)(object)portal != (Object)null) { return ((Object)((Component)portal).gameObject).name.StartsWith("piece_bifrost_gate", StringComparison.Ordinal); } return false; } private static bool IsAvailable(TeleportWorld portal) { ZNetView component = ((Component)portal).GetComponent<ZNetView>(); ZDO zdo = ((component != null) ? component.GetZDO() : null); if (zdo != null && (Object)(object)Instance != (Object)null) { return Instance.destinations.Any((Destination p) => p.Id == Key(zdo)); } return false; } private static bool AtGate(TeleportWorld portal) { if (IsGate(portal) && Instance?.gate != null) { ZNetView component = ((Component)portal).GetComponent<ZNetView>(); ZDO val = ((component != null) ? component.GetZDO() : null); if (val != null) { return Key(val) == Instance.gate.Id; } } return false; } private void OpenDestinations() { if (destinationGrid == null) { destinationGrid = new BifrostDestinationGrid(() => destinations.Select((Destination p) => new BifrostDestinationGrid.Entry(p.Id, p.Name)).ToList(), delegate(string id) { Destination destination = destinations.FirstOrDefault((Destination p) => p.Id == id); if (destination != null) { selected = destination; MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, "Bifrost: " + destination.Name, 0, (Sprite)null, false, true); } } destinationGrid.Close(); }); } destinationGrid.Toggle(); } } internal sealed class BifrostDestinationGrid { internal sealed class Entry { internal readonly string Id; internal readonly string Name; internal Entry(string id, string name) { Id = id; Name = name; } } private const int Columns = 6; private const int Rows = 5; private const int PageSize = 30; private readonly Func<List<Entry>> getDestinations; private readonly Action<string> choose; private GameObject panel; private GameObject slotRoot; private InputField search; private GameObject pageLabel; private int page; internal bool IsOpen { get { if ((Object)(object)panel != (Object)null) { return panel.activeSelf; } return false; } } internal BifrostDestinationGrid(Func<List<Entry>> getDestinations, Action<string> choose) { this.getDestinations = getDestinations; this.choose = choose; } internal void Toggle() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00b9: 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_00d5: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_0199: Expected O, but got Unknown //IL_01c5: 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_0227: Unknown result type (might be due to invalid IL or missing references) if (IsOpen) { Close(); } else { if (GUIManager.Instance == null || (Object)(object)GUIManager.CustomGUIFront == (Object)null) { return; } panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, 780f, 590f, false); ((Object)panel).name = "BifrostDestinationGrid"; GUIManager.Instance.CreateText("BIFROST GATE", panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 255f), GUIManager.Instance.NorseBold, 30, GUIManager.Instance.ValheimOrange, true, Color.black, 440f, 48f, false); GameObject val = GUIManager.Instance.CreateInputField(panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 206f), (ContentType)0, "Search destinations...", 18, 550f, 34f); search = val.GetComponent<InputField>(); if ((Object)(object)search != (Object)null) { ((UnityEvent<string>)(object)search.onValueChanged).AddListener((UnityAction<string>)delegate { page = 0; Refresh(); }); } slotRoot = new GameObject("DestinationSlots", new Type[1] { typeof(RectTransform) }); slotRoot.transform.SetParent(panel.transform, false); AddButton("◀ Previous", new Vector2(-255f, -226f), 195f, 42f, delegate { page = Math.Max(0, page - 1); Refresh(); }); AddButton("Next ▶", new Vector2(255f, -226f), 195f, 42f, delegate { page++; Refresh(); }); AddButton("X", new Vector2(340f, 251f), 44f, 40f, Close); Refresh(); GUIManager.BlockInput(true); } } private GameObject AddButton(string label, Vector2 position, float width, float height, Action action) { //IL_0029: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown GameObject obj = GUIManager.Instance.CreateButton(label, panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), position, width, height); ((UnityEvent)obj.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { action(); }); return obj; } internal void Refresh() { //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_0259: 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_0277: 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_0293: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0169: 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_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Expected O, but got Unknown if (!IsOpen || (Object)(object)slotRoot == (Object)null) { return; } foreach (Transform item in slotRoot.transform) { ((Component)item).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)item).gameObject); } string query = (((Object)(object)search != (Object)null) ? search.text.Trim() : ""); List<Entry> list = (from p in getDestinations() where p.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0 select p).ToList(); int num = Math.Max(1, (list.Count + 30 - 1) / 30); page = Math.Min(page, num - 1); for (int num2 = 0; num2 < 30; num2++) { int num3 = page * 30 + num2; Entry entry = ((num3 < list.Count) ? list[num3] : null); int num4 = num2 % 6; int num5 = num2 / 6; string text = entry?.Name ?? ""; Button component = GUIManager.Instance.CreateButton(text, slotRoot.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-280f + (float)num4 * 112f, 140f - (float)num5 * 72f), 106f, 64f).GetComponent<Button>(); ((Selectable)component).interactable = entry != null; if (entry != null) { string id = entry.Id; ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { choose(id); }); } } if ((Object)(object)pageLabel != (Object)null) { pageLabel.SetActive(false); Object.Destroy((Object)(object)pageLabel); } pageLabel = GUIManager.Instance.CreateText($"{page + 1} / {num}", panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -226f), GUIManager.Instance.AveriaSerifBold, 18, GUIManager.Instance.ValheimOrange, false, Color.black, 140f, 38f, false); } internal void Close() { if (!((Object)(object)panel == (Object)null)) { GUIManager.BlockInput(false); Object.Destroy((Object)(object)panel); panel = null; slotRoot = null; search = null; pageLabel = null; } } } public sealed class BifrostVisuals : MonoBehaviour { private enum TextureTreatment { WarmPixels, WhiteMask } private static readonly Color Blue = new Color(0.12f, 0.54f, 1f, 1f); private static readonly Color RuneBlue = new Color(0.42f, 0.78f, 1f, 1f); private static readonly Dictionary<int, Texture2D> Recolored = new Dictionary<int, Texture2D>(); private Light[] lights; private readonly List<Material> runeMaterials = new List<Material>(); private readonly List<Renderer> runeRenderers = new List<Renderer>(); private readonly List<Material> vortexMaterials = new List<Material>(); private readonly List<ParticleSystem> colorParticles = new List<ParticleSystem>(); private readonly Dictionary<ParticleSystem, Particle[]> particleBuffers = new Dictionary<ParticleSystem, Particle[]>(); private float nextParticleCheck; private Shader additiveShader; private static readonly Dictionary<int, Texture2D> StoneRuneTextures = new Dictionary<int, Texture2D>(); private void Awake() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //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_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_0051: 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_00b7: 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_029d: 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_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) if ((int)SystemInfo.graphicsDeviceType == 4) { return; } GameObject val = new GameObject("BifrostBlueAura"); val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = new Vector3(0f, 1.8f, 0f); Light obj = val.AddComponent<Light>(); obj.type = (LightType)2; obj.color = Blue; obj.range = 7f; obj.intensity = 1.4f; obj.shadows = (LightShadows)0; lights = ((Component)this).GetComponentsInChildren<Light>(true); Light[] array = lights; for (int i = 0; i < array.Length; i++) { array[i].color = Blue; } TeleportWorld component = ((Component)this).GetComponent<TeleportWorld>(); if ((Object)(object)component != (Object)null) { component.m_colorTargetfound = Blue; } DisableSmoke(); foreach (Material item in ((Component)this).GetComponentsInChildren<Renderer>(true).SelectMany((Renderer r) => r.sharedMaterials)) { if ((Object)(object)item != (Object)null && (Object)(object)item.shader != (Object)null && ((Object)item.shader).name == "Legacy Shaders/Particles/Additive") { additiveShader = item.shader; break; } } Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { bool flag = val2 is ParticleSystemRenderer && val2.enabled; Material[] materials = val2.materials; foreach (Material val3 in materials) { if ((Object)(object)val3 == (Object)null) { continue; } bool flag2 = ((Object)val3).name.IndexOf("Portal_Metal_mat", StringComparison.OrdinalIgnoreCase) >= 0; if (flag) { vortexMaterials.Add(val3); ReplaceGradientShader(val3); RecolorTexture(val3, "_MainTex", (((Object)val3).name.IndexOf("PortalRunes", StringComparison.OrdinalIgnoreCase) >= 0) ? TextureTreatment.WhiteMask : TextureTreatment.WarmPixels); RecolorTexture(val3, "_BaseMap", TextureTreatment.WarmPixels); RecolorTexture(val3, "_EmissionMap", TextureTreatment.WarmPixels); RecolorTexture(val3, "_EmissiveColorMap", TextureTreatment.WarmPixels); NeutralVortexMaterial(val3); continue; } if (flag2) { RecolorStoneRunes(val3); runeMaterials.Add(val3); runeRenderers.Add(val2); ForceRuneEmission(val3); val3.EnableKeyword("_EMISSION"); continue; } RecolorTexture(val3, "_MainTex", TextureTreatment.WarmPixels); RecolorTexture(val3, "_EmissionMap", TextureTreatment.WarmPixels); if (val3.HasProperty("_EmissionColor")) { Color color = val3.GetColor("_EmissionColor"); if (color.r > color.b * 1.2f && color.r > 0.1f) { val3.SetColor("_EmissionColor", Blue * Mathf.Max(1f, ((Color)(ref color)).maxColorComponent)); } } } } TintParticles(); } private void LateUpdate() { //IL_0022: 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_0034: 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_00f3: Expected O, but got Unknown //IL_0103: 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_019e: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_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_01eb: 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_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: 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_01fd: 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_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020d: 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_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0226: 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 (lights == null) { return; } Light[] array = lights; foreach (Light val in array) { if ((Object)(object)val != (Object)null && val.color != Blue) { val.color = Blue; } } foreach (Material runeMaterial in runeMaterials) { if ((Object)(object)runeMaterial != (Object)null) { ForceRuneEmission(runeMaterial); } } foreach (Material vortexMaterial in vortexMaterials) { if ((Object)(object)vortexMaterial != (Object)null) { NeutralVortexMaterial(vortexMaterial); } } foreach (Renderer runeRenderer in runeRenderers) { if (!((Object)(object)runeRenderer == (Object)null)) { MaterialPropertyBlock val2 = new MaterialPropertyBlock(); runeRenderer.GetPropertyBlock(val2); val2.SetColor("_EmissionColor", RuneBlue * 2f); runeRenderer.SetPropertyBlock(val2); } } foreach (ParticleSystem colorParticle in colorParticles) { if ((Object)(object)colorParticle == (Object)null || !colorParticle.isPlaying) { continue; } MainModule main; if (particleBuffers.TryGetValue(colorParticle, out var value)) { int num = value.Length; main = colorParticle.main; if (num >= ((MainModule)(ref main)).maxParticles) { goto IL_01b9; } } Dictionary<ParticleSystem, Particle[]> dictionary = particleBuffers; main = colorParticle.main; value = (dictionary[colorParticle] = (Particle[])(object)new Particle[((MainModule)(ref main)).maxParticles]); goto IL_01b9; IL_01b9: int particles = colorParticle.GetParticles(value); bool flag = false; for (int j = 0; j < particles; j++) { Color32 startColor = ((Particle)(ref value[j])).startColor; Color val3 = ShiftHue(Color32.op_Implicit(startColor)); Color32 val4 = Color32.op_Implicit(val3); if (val4.r != startColor.r || val4.g != startColor.g || val4.b != startColor.b || val4.a != startColor.a) { ((Particle)(ref value[j])).startColor = Color32.op_Implicit(val3); flag = true; } } if (flag) { colorParticle.SetParticles(value, particles); } } if (Time.time >= nextParticleCheck) { nextParticleCheck = Time.time + 1f; DisableSmoke(); TintParticles(); } } private static Texture2D ReadTexture(Texture source) { //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_0055: 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_0067: 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_0073: 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_0080: Expected O, but got Unknown RenderTexture active = RenderTexture.active; RenderTexture val = null; try { val = RenderTexture.GetTemporary(source.width, source.height, 0, (RenderTextureFormat)0); Graphics.Blit(source, val); RenderTexture.active = val; Texture2D val2 = new Texture2D(source.width, source.height, (TextureFormat)4, false); val2.ReadPixels(new Rect(0f, 0f, (float)source.width, (float)source.height), 0, 0); val2.Apply(); ((Texture)val2).wrapMode = source.wrapMode; ((Texture)val2).filterMode = source.filterMode; return val2; } finally { RenderTexture.active = active; if ((Object)(object)val != (Object)null) { RenderTexture.ReleaseTemporary(val); } } } private static void RecolorStoneRunes(Material material) { //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_00bf: 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_00d3: 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_00e8: 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_0121: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_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) Texture texture = material.GetTexture("_EmissiveTex"); Texture texture2 = material.GetTexture("_MainTex"); if ((Object)(object)texture == (Object)null || (Object)(object)texture2 == (Object)null || texture.width != texture2.width || texture.height != texture2.height) { return; } int instanceID = ((Object)texture).GetInstanceID(); if (StoneRuneTextures.TryGetValue(instanceID, out var value)) { material.SetTexture("_EmissiveTex", (Texture)(object)value); material.SetTexture("_MainTex", (Texture)(object)StoneRuneTextures[~instanceID]); return; } Texture2D val = null; Texture2D val2 = null; try { val = ReadTexture(texture); val2 = ReadTexture(texture2); Color32[] pixels = val.GetPixels32(); Color32[] pixels2 = val2.GetPixels32(); int num = 0; for (int i = 0; i < pixels.Length; i++) { Color32 val3 = pixels[i]; if (val3.r >= 5 && val3.r > val3.g * 2 && val3.r > val3.b * 2) { byte b = (byte)((float)(int)val3.r * 0.72f); pixels[i] = new Color32((byte)((float)(int)b * 0.42f), (byte)((float)(int)b * 0.78f), b, val3.a); Color32 val4 = pixels2[i]; byte b2 = (byte)Mathf.Max((int)val4.r, Mathf.Max((int)val4.g, (int)val4.b)); pixels2[i] = new Color32((byte)((float)(int)b2 * 0.45f), (byte)((float)(int)b2 * 0.72f), (byte)((float)(int)b2 * 0.88f), val4.a); num++; } } if (num == 0) { Object.Destroy((Object)(object)val); Object.Destroy((Object)(object)val2); return; } val.SetPixels32(pixels); val2.SetPixels32(pixels2); val.Apply(false, true); val2.Apply(false, true); ((Object)val).name = "BifrostRuneEmission"; ((Object)val2).name = "BifrostRuneDiffuse"; StoneRuneTextures[instanceID] = val; StoneRuneTextures[~instanceID] = val2; material.SetTexture("_EmissiveTex", (Texture)(object)val); material.SetTexture("_MainTex", (Texture)(object)val2); Debug.Log((object)("Bifrost blue stone rune pixels: " + num)); } catch (Exception ex) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); } Debug.LogWarning((object)("Bifrost rune texture change failed: " + ex.Message)); } } private static void ForceRuneEmission(Material material) { //IL_0013: 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 (material.HasProperty("_EmissionColor")) { material.SetColor("_EmissionColor", RuneBlue * 2f); } } private static void NeutralVortexMaterial(Material material) { //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_002e: 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_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_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_0132: 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_0155: 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) //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_00c9: 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) if (material.HasProperty("_Color")) { Color color = material.GetColor("_Color"); material.SetColor("_Color", new Color(1f, 1f, 1f, color.a)); } if (material.HasProperty("_TintColor")) { Color color2 = material.GetColor("_TintColor"); bool flag = (Object)(object)material.shader != (Object)null && ((Object)material.shader).name == "Legacy Shaders/Particles/Additive" && (((Object)material).name.IndexOf("portal_flame", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)material).name.IndexOf("PortalRunes", StringComparison.OrdinalIgnoreCase) >= 0); material.SetColor("_TintColor", flag ? new Color(Blue.r, Blue.g, Blue.b, color2.a) : new Color(1f, 1f, 1f, color2.a)); } if (material.HasProperty("_BaseColor")) { Color color3 = material.GetColor("_BaseColor"); material.SetColor("_BaseColor", new Color(1f, 1f, 1f, color3.a)); } if (material.HasProperty("_EmissionColor")) { material.SetColor("_EmissionColor", Blue * 2f); } } private void TintParticles() { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0105: 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_0131: Invalid comparison between Unknown and I4 //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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Invalid comparison between Unknown and I4 //IL_0137: 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_0143: 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_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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Invalid comparison between Unknown and I4 //IL_0218: 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_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Invalid comparison between Unknown and I4 //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Invalid comparison between Unknown and I4 //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Invalid comparison between Unknown and I4 //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0293: 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_00da: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Invalid comparison between Unknown and I4 //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: 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_02c2: 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_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: 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) ParticleSystem[] componentsInChildren = ((Component)this).GetComponentsInChildren<ParticleSystem>(true); MinMaxGradient startColor2 = default(MinMaxGradient); foreach (ParticleSystem val in componentsInChildren) { ParticleSystemRenderer component = ((Component)val).GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component == (Object)null || !((Renderer)component).enabled) { continue; } if (!colorParticles.Contains(val)) { colorParticles.Add(val); } if (((Object)((Component)val).gameObject).name.Equals("Runes", StringComparison.OrdinalIgnoreCase)) { Material[] materials = ((Renderer)component).materials; foreach (Material val2 in materials) { if (!((Object)(object)val2 == (Object)null)) { ReplaceGradientShader(val2); RecolorTexture(val2, "_MainTex", TextureTreatment.WhiteMask); RecolorTexture(val2, "_BaseMap", TextureTreatment.WhiteMask); if (val2.HasProperty("_Color")) { val2.SetColor("_Color", Color.white); } if (val2.HasProperty("_TintColor")) { val2.SetColor("_TintColor", Color.white); } } } } MainModule main = val.main; MinMaxGradient startColor = ((MainModule)(ref main)).startColor; if ((int)((MinMaxGradient)(ref startColor)).mode == 0) { ((MainModule)(ref main)).startColor = new MinMaxGradient(ShiftHue(((MinMaxGradient)(ref startColor)).color)); } else if ((int)((MinMaxGradient)(ref startColor)).mode == 2) { ((MainModule)(ref main)).startColor = new MinMaxGradient(ShiftHue(((MinMaxGradient)(ref startColor)).colorMin), ShiftHue(((MinMaxGradient)(ref startColor)).colorMax)); } else if ((int)((MinMaxGradient)(ref startColor)).mode == 1 && ((MinMaxGradient)(ref startColor)).gradient != null) { ((MainModule)(ref main)).startColor = new MinMaxGradient(ShiftGradient(((MinMaxGradient)(ref startColor)).gradient)); } else if ((int)((MinMaxGradient)(ref startColor)).mode == 3 && ((MinMaxGradient)(ref startColor)).gradientMin != null && ((MinMaxGradient)(ref startColor)).gradientMax != null) { ((MainModule)(ref main)).startColor = new MinMaxGradient(ShiftGradient(((MinMaxGradient)(ref startColor)).gradientMin), ShiftGradient(((MinMaxGradient)(ref startColor)).gradientMax)); } else if ((int)((MinMaxGradient)(ref startColor)).mode == 4 && ((MinMaxGradient)(ref startColor)).gradient != null) { ((MinMaxGradient)(ref startColor2))..ctor(ShiftGradient(((MinMaxGradient)(ref startColor)).gradient)); ((MinMaxGradient)(ref startColor2)).mode = (ParticleSystemGradientMode)4; ((MainModule)(ref main)).startColor = startColor2; } ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime; if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled) { MinMaxGradient color = ((ColorOverLifetimeModule)(ref colorOverLifetime)).color; if ((int)((MinMaxGradient)(ref color)).mode == 1 && ((MinMaxGradient)(ref color)).gradient != null) { ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(ShiftGradient(((MinMaxGradient)(ref color)).gradient)); } else if ((int)((MinMaxGradient)(ref color)).mode == 3 && ((MinMaxGradient)(ref color)).gradientMin != null && ((MinMaxGradient)(ref color)).gradientMax != null) { ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(ShiftGradient(((MinMaxGradient)(ref color)).gradientMin), ShiftGradient(((MinMaxGradient)(ref color)).gradientMax)); } else if ((int)((MinMaxGradient)(ref color)).mode == 0) { ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(ShiftHue(((MinMaxGradient)(ref color)).color)); } else if ((int)((MinMaxGradient)(ref color)).mode == 2) { ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(ShiftHue(((MinMaxGradient)(ref color)).colorMin), ShiftHue(((MinMaxGradient)(ref color)).colorMax)); } } } } private static Gradient ShiftGradient(Gradient original) { //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_0023: 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_0045: Expected O, but got Unknown GradientColorKey[] colorKeys = original.colorKeys; for (int i = 0; i < colorKeys.Length; i++) { colorKeys[i].color = ShiftHue(colorKeys[i].color); } Gradient val = new Gradient(); val.SetKeys(colorKeys, original.alphaKeys); return val; } private static Color ShiftHue(Color original) { //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_0012: 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_003b: 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_0020: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(original, ref num, ref num2, ref num3); if (original.r <= original.b * 1.1f) { return original; } Color result = Color.HSVToRGB(0.59f, Mathf.Max(0.65f, num2), num3); result.a = original.a; return result; } private void DisableSmoke() { //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) ParticleSystem[] componentsInChildren = ((Component)this).GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val in componentsInChildren) { ParticleSystemRenderer component = ((Component)val).GetComponent<ParticleSystemRenderer>(); string text = ((Object)((Component)val).gameObject).name; if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).sharedMaterial != (Object)null) { text = text + " " + ((Object)((Renderer)component).sharedMaterial).name; } text = text.ToLowerInvariant(); if (text.Contains("smoke") || text.Contains("fog") || text.Contains("mist") || text.Contains("cloud")) { EmissionModule emission = val.emission; ((EmissionModule)(ref emission)).enabled = false; val.Stop(true, (ParticleSystemStopBehavior)0); if ((Object)(object)component != (Object)null) { ((Renderer)component).enabled = false; } } } } private void ReplaceGradientShader(Material material) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)material.shader == (Object)null || ((Object)material.shader).name.IndexOf("Gradient Mapped Particle", StringComparison.OrdinalIgnoreCase) < 0) { return; } Shader val = (((Object)(object)additiveShader != (Object)null) ? additiveShader : Shader.Find("Legacy Shaders/Particles/Additive")); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Bifrost: particle replacement shader unavailable for " + ((Object)material).name)); return; } Texture mainTexture = material.mainTexture; material.shader = val; if ((Object)(object)mainTexture != (Object)null) { material.mainTexture = mainTexture; } if (material.HasProperty("_TintColor")) { material.SetColor("_TintColor", Blue); } Debug.Log((object)("Bifrost replaced gradient shader: " + ((Object)material).name)); } private static void RecolorTexture(Material material, string property, TextureTreatment treatment) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00e1: 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_00f4: 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_0104: 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_0135: 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_014c: 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_0199: 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_0185: 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_01a5: Unknown result type (might be due to invalid IL or missing references) if (!material.HasProperty(property)) { return; } Texture texture = material.GetTexture(property); if ((Object)(object)texture == (Object)null || texture.width < 1 || texture.height < 1) { return; } int key = (int)(((Object)texture).GetInstanceID() * 4 + treatment); if (Recolored.TryGetValue(key, out var value)) { if ((Object)(object)value != (Object)null) { material.SetTexture(property, (Texture)(object)value); } return; } RenderTexture val = null; RenderTexture active = RenderTexture.active; Texture2D val2 = null; try { val = RenderTexture.GetTemporary(texture.width, texture.height, 0, (RenderTextureFormat)0); Graphics.Blit(texture, val); RenderTexture.active = val; val2 = new Texture2D(texture.width, texture.height, (TextureFormat)4, false); val2.ReadPixels(new Rect(0f, 0f, (float)texture.width, (float)texture.height), 0, 0); Color32[] pixels = val2.GetPixels32(); int num = 0; for (int i = 0; i < pixels.Length; i++) { Color32 val3 = pixels[i]; bool flag = val3.r >= 50 && (float)(int)val3.r >= (float)(int)val3.g * 0.9f && (float)(int)val3.r > (float)(int)val3.b * 1.14f; if (val3.a != 0 && ((treatment == TextureTreatment.WhiteMask) ? (val3.r >= 16) : flag)) { byte b = (byte)Mathf.Max((int)val3.r, Mathf.Max((int)val3.g, (int)val3.b)); pixels[i] = ((treatment == TextureTreatment.WhiteMask) ? new Color32(b, b, b, val3.a) : new Color32((byte)((float)(int)b * 0.12f), (byte)((float)(int)b * 0.57f), b, val3.a)); num++; } } if (num > 0) { val2.SetPixels32(pixels); val2.Apply(false, true); ((Object)val2).name = "BifrostBlue_" + ((Object)texture).name; Recolored[key] = val2; material.SetTexture(property, (Texture)(object)val2); } else { Recolored[key] = null; Object.Destroy((Object)(object)val2); } } catch (Exception ex) { if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); } Debug.LogWarning((object)("Bifrost: could not recolor portal texture " + ((Object)texture).name + ": " + ex.Message)); } finally { RenderTexture.active = active; if ((Object)(object)val != (Object)null) { RenderTexture.ReleaseTemporary(val); } } } } }