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 Fylgja v1.0.2
Fylgja.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Fylgja; public enum Arrival { Drop, Pause, Never } internal class Tracked { public PinData Pin; public int Slot; public Color Color; public SkyBeacon Beacon; public Arrival Mode; public bool Arrived; } [BepInPlugin("com.awuushy.valheim.fylgja", "Fylgja", "1.0.2")] public class FylgjaPlugin : BaseUnityPlugin { public const string Guid = "com.awuushy.valheim.fylgja"; public const string Name = "Fylgja"; public const string Version = "1.0.2"; private const string DefaultPalette = "E2B25C,8DB8CC,98B872,D2705A,A592CC"; internal static ConfigEntry<KeyCode> ToggleKey; internal static ConfigEntry<bool> ShowMessages; internal static ConfigEntry<Arrival> CtrlClickMode; internal static ConfigEntry<Arrival> ShiftClickMode; internal static ConfigEntry<float> ArrivalRadius; internal static ConfigEntry<int> MaxTrackedPins; internal static ConfigEntry<string> Palette; internal static ConfigEntry<float> MaxElevation; internal static ConfigEntry<float> MinElevation; internal static ConfigEntry<float> StarPixelSize; internal static ConfigEntry<float> ThreadPixelWidth; internal static ConfigEntry<float> OccludedVisibility; internal static ConfigEntry<float> IgnitionFlare; internal static ConfigEntry<float> IgnitionSeconds; internal static ConfigEntry<bool> SpiritEnabled; internal static ConfigEntry<float> SpiritScale; internal static ConfigEntry<float> SpiritDistance; internal static readonly List<Tracked> Tracks = new List<Tracked>(); private static readonly List<Tracked> Dying = new List<Tracked>(); private static Tracked _focus; private static Color[] _colors; private static Color _spiritColor = Color.white; internal static bool Enabled = true; internal static ManualLogSource Log; private static readonly MethodInfo ScreenToWorldPoint = AccessTools.Method(typeof(Minimap), "ScreenToWorldPoint", (Type[])null, (Type[])null); private static readonly MethodInfo GetClosestPin = AccessTools.Method(typeof(Minimap), "GetClosestPin", (Type[])null, (Type[])null); private static readonly FieldInfo LargeZoom = AccessTools.Field(typeof(Minimap), "m_largeZoom"); private static readonly FieldInfo PinsField = AccessTools.Field(typeof(Minimap), "m_pins"); private static readonly FieldInfo CameraField = AccessTools.Field(typeof(GameCamera), "m_camera"); private Spirit _spirit; private static Player _owner; private static float _restoreUntil; private static bool _restored; private static List<PinData> Pins() { return (List<PinData>)PinsField.GetValue(Minimap.instance); } private static Camera CameraOf(GameCamera gc) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown return (Camera)CameraField.GetValue(gc); } internal static Tracked Find(PinData pin) { for (int i = 0; i < Tracks.Count; i++) { if (Tracks[i].Pin == pin) { return Tracks[i]; } } return null; } private void Awake() { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_0287: 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_02b2: Expected O, but got Unknown //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("1 - General", "ToggleKey", (KeyCode)288, "Show or hide all guidance (tracked pins are kept)."); ShowMessages = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "ShowMessages", true, "Show on-screen messages when tracking starts, stops or a target is reached."); CtrlClickMode = ((BaseUnityPlugin)this).Config.Bind<Arrival>("1 - General", "CtrlClickMode", Arrival.Drop, "What happens when you reach a pin tracked with Ctrl+click on the map. Drop: tracking ends. Pause: the beacon goes out but the pin stays marked on the map, and lights up again when you walk away from it. Never: nothing happens, the beacon keeps burning."); ShiftClickMode = ((BaseUnityPlugin)this).Config.Bind<Arrival>("1 - General", "ShiftClickMode", Arrival.Pause, "Same as CtrlClickMode, for pins tracked with Shift+click on the map."); ArrivalRadius = ((BaseUnityPlugin)this).Config.Bind<float>("1 - General", "ArrivalRadius", 20f, "Horizontal distance in metres at which a target counts as reached."); MaxTrackedPins = ((BaseUnityPlugin)this).Config.Bind<int>("1 - General", "MaxTrackedPins", 5, new ConfigDescription("How many pins can be tracked at once. When the limit is reached, selecting another one drops the oldest. The wisp always follows the nearest.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), new object[0])); Palette = ((BaseUnityPlugin)this).Config.Bind<string>("1 - General", "Palette", "E2B25C,8DB8CC,98B872,D2705A,A592CC", "Colours (hex, comma separated) given to tracked pins in turn."); MaxElevation = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Sky star", "MaxElevation", 26f, "Degrees above the horizon at which the star hangs when the pin is far away."); MinElevation = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Sky star", "MinElevation", 7f, "Degrees above the horizon at which the star hangs when the pin is close."); StarPixelSize = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Sky star", "StarPixelSize", 56f, "Diameter of the star on screen, in pixels."); ThreadPixelWidth = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Sky star", "ThreadPixelWidth", 12f, "Width of the light thread on screen, in pixels."); OccludedVisibility = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Sky star", "OccludedVisibility", 0.45f, "How visible the star and its rune stay behind walls, hills and trees (0 = hidden, 1 = fully see-through). The pillar itself is always hidden by solid objects."); IgnitionFlare = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Sky star", "IgnitionFlare", 2.6f, "Star size multiplier at the moment a pin is selected."); IgnitionSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Sky star", "IgnitionSeconds", 1.4f, "How long the ignition flare lasts, in seconds."); SpiritEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Spirit", "Enabled", true, "Show the guiding flame that floats in front of you and sheds embers towards the nearest tracked pin."); SpiritScale = ((BaseUnityPlugin)this).Config.Bind<float>("3 - Spirit", "Scale", 1f, "Size multiplier of the flame."); SpiritDistance = ((BaseUnityPlugin)this).Config.Bind<float>("3 - Spirit", "Distance", 3.2f, "How far ahead of the character the flame floats, in metres."); _colors = ParsePalette(Palette.Value); new Harmony("com.awuushy.valheim.fylgja").PatchAll(); _spirit = new Spirit(); Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(RenderBeacons)); } private static Color[] ParsePalette(string text) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) List<Color> list = new List<Color>(); string[] array = (text ?? "").Split(','); Color item = default(Color); for (int i = 0; i < array.Length; i++) { if (ColorUtility.TryParseHtmlString("#" + array[i].Trim().TrimStart('#'), ref item)) { list.Add(item); } } if (list.Count == 0) { return ParsePalette("E2B25C,8DB8CC,98B872,D2705A,A592CC"); } return list.ToArray(); } private void OnDestroy() { //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.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(RenderBeacons)); for (int i = 0; i < Tracks.Count; i++) { Tracks[i].Beacon.Destroy(); } for (int j = 0; j < Dying.Count; j++) { Dying[j].Beacon.Destroy(); } Tracks.Clear(); Dying.Clear(); if (_spirit != null) { _spirit.Destroy(); } } private void RenderBeacons(Camera cam) { //IL_0059: 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_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_012a: Unknown result type (might be due to invalid IL or missing references) if (_spirit == null || (Object)(object)GameCamera.instance == (Object)null || (Object)(object)cam != (Object)(object)CameraOf(GameCamera.instance)) { return; } for (int i = 0; i < Tracks.Count; i++) { Tracked tracked = Tracks[i]; tracked.Beacon.Render(cam, (Enabled && !tracked.Arrived) ? tracked.Pin : null, tracked.Color, tracked == _focus); } for (int num = Dying.Count - 1; num >= 0; num--) { Dying[num].Beacon.Render(cam, null, Dying[num].Color, focus: false); if (Dying[num].Beacon.Finished) { Dying[num].Beacon.Destroy(); Dying.RemoveAt(num); } } if (_focus != null) { _spiritColor = _focus.Color; } _spirit.Render(cam, (Enabled && _focus != null) ? _focus.Pin : null, _spiritColor); } private void Update() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer != (Object)(object)_owner) { SwitchPlayer(Player.m_localPlayer); } if (!((Object)(object)Player.m_localPlayer == (Object)null)) { if (!_restored) { Restore(); } if (Input.GetKeyDown(ToggleKey.Value) && !IsTyping()) { Enabled = !Enabled; Say(Enabled ? Tr("Фюльгья проснулась", "Fylgja awakens") : Tr("Фюльгья уснула", "Fylgja sleeps")); } HandleMapSelection(); ValidateTargets(); UpdateFocus(); } } private static bool IsTyping() { if ((Object)(object)Minimap.instance != (Object)null) { return Minimap.InTextInput(); } return false; } private void HandleMapSelection() { //IL_0073: 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_00bb: 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: Expected O, but got Unknown //IL_01ca: 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) Minimap instance = Minimap.instance; if ((Object)(object)instance == (Object)null || !Minimap.IsOpen() || Minimap.InTextInput() || !Input.GetMouseButtonDown(0)) { return; } bool flag = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); bool flag2 = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); if (!flag && !flag2) { return; } Vector3 val = (Vector3)ScreenToWorldPoint.Invoke(instance, new object[1] { Input.mousePosition }); float num = instance.m_removeRadius * ((float)LargeZoom.GetValue(instance) * 2f); PinData val2 = (PinData)GetClosestPin.Invoke(instance, new object[3] { val, num, true }); if (val2 == null) { return; } Tracked tracked = Find(val2); if (tracked != null) { Drop(tracked); Save(); Say(Tr("Путь забыт", "Path forgotten")); return; } while (Tracks.Count >= MaxTrackedPins.Value) { Drop(Tracks[0]); Say(Tr("Предел меток: самая старая забыта", "Pin limit reached: the oldest was dropped")); } Enabled = true; bool flag3 = Tracks.Count == 0; Tracked tracked2 = new Tracked(); tracked2.Pin = val2; tracked2.Mode = (flag ? CtrlClickMode.Value : ShiftClickMode.Value); bool flag4 = tracked2.Mode == Arrival.Drop; tracked2.Slot = FreeSlot(); tracked2.Color = _colors[tracked2.Slot % _colors.Length]; tracked2.Beacon = new SkyBeacon(tracked2.Slot); tracked2.Beacon.Ignite(); Tracks.Add(tracked2); if (flag3) { _spirit.Ignite(); } Save(); string text = (string.IsNullOrEmpty(val2.m_name) ? Tr("метка", "pin") : val2.m_name); Say(Tr("Фюльгья ведёт к: ", "Fylgja leads to: ") + text + (flag4 ? Tr(" (один раз)", " (one trip)") : "")); } private static string SaveKey() { string text = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetWorldName() : ""); return "Fylgja.tracks." + text; } private static void Save() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected I4, but got Unknown Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || localPlayer.m_customData == null) { return; } StringBuilder stringBuilder = new StringBuilder(); CultureInfo invariantCulture = CultureInfo.InvariantCulture; for (int i = 0; i < Tracks.Count; i++) { Tracked tracked = Tracks[i]; if (stringBuilder.Length > 0) { stringBuilder.Append(';'); } stringBuilder.Append(tracked.Pin.m_pos.x.ToString("R", invariantCulture)).Append(',').Append(tracked.Pin.m_pos.z.ToString("R", invariantCulture)) .Append(',') .Append((int)tracked.Pin.m_type) .Append(',') .Append(tracked.Slot) .Append(',') .Append((int)tracked.Mode); } localPlayer.m_customData[SaveKey()] = stringBuilder.ToString(); } private static void Restore() { //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Invalid comparison between Unknown and I4 //IL_0210: 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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || localPlayer.m_customData == null) { _restored = true; return; } if (!localPlayer.m_customData.TryGetValue(SaveKey(), out var value) || string.IsNullOrEmpty(value)) { _restored = true; return; } List<PinData> list = (((Object)(object)Minimap.instance != (Object)null) ? Pins() : null); if (list == null || list.Count == 0) { if (Time.time > _restoreUntil) { _restored = true; } return; } _restored = true; CultureInfo invariantCulture = CultureInfo.InvariantCulture; string[] array = value.Split(';'); for (int i = 0; i < array.Length; i++) { if (Tracks.Count >= MaxTrackedPins.Value) { break; } string[] array2 = array[i].Split(','); if (array2.Length < 5 || !float.TryParse(array2[0], NumberStyles.Float, invariantCulture, out var result) || !float.TryParse(array2[1], NumberStyles.Float, invariantCulture, out var result2) || !int.TryParse(array2[2], out var result3) || !int.TryParse(array2[3], out var result4) || !int.TryParse(array2[4], out var result5)) { continue; } PinData val = null; for (int j = 0; j < list.Count; j++) { if ((int)list[j].m_type == result3 && Find(list[j]) == null) { float num = list[j].m_pos.x - result; float num2 = list[j].m_pos.z - result2; if (num * num + num2 * num2 < 0.25f) { val = list[j]; break; } } } if (val == null) { continue; } Tracked tracked = new Tracked(); tracked.Pin = val; tracked.Mode = (Arrival)result5; bool flag = false; for (int k = 0; k < Tracks.Count; k++) { if (Tracks[k].Slot == result4) { flag = true; } } tracked.Slot = (flag ? FreeSlot() : result4); tracked.Color = _colors[tracked.Slot % _colors.Length]; tracked.Beacon = new SkyBeacon(tracked.Slot); Tracks.Add(tracked); } Save(); } private static void SwitchPlayer(Player player) { for (int i = 0; i < Tracks.Count; i++) { Tracks[i].Beacon.Destroy(); } for (int j = 0; j < Dying.Count; j++) { Dying[j].Beacon.Destroy(); } Tracks.Clear(); Dying.Clear(); _focus = null; _owner = player; _restored = false; _restoreUntil = Time.time + 20f; } private static int FreeSlot() { int num = 0; while (true) { bool flag = false; for (int i = 0; i < Tracks.Count; i++) { if (Tracks[i].Slot == num) { flag = true; break; } } if (!flag) { break; } num++; } return num; } private static void Drop(Tracked t) { Tracks.Remove(t); t.Beacon.Retire(); Dying.Add(t); if (_focus == t) { _focus = null; } } private void ValidateTargets() { //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) if (Tracks.Count == 0) { return; } bool flag = (Object)(object)Minimap.instance == (Object)null; List<PinData> list = (flag ? null : Pins()); Vector3 position = ((Component)Player.m_localPlayer).transform.position; float num = ArrivalRadius.Value * ArrivalRadius.Value; for (int num2 = Tracks.Count - 1; num2 >= 0; num2--) { Tracked tracked = Tracks[num2]; if (flag || !list.Contains(tracked.Pin)) { Drop(tracked); } else if (tracked.Mode == Arrival.Never) { tracked.Arrived = false; } else { float num3 = tracked.Pin.m_pos.x - position.x; float num4 = tracked.Pin.m_pos.z - position.z; float num5 = num3 * num3 + num4 * num4; if (!tracked.Arrived && num5 < num) { if (tracked.Mode == Arrival.Drop) { Say(Tr("Вы на месте", "You have arrived")); Drop(tracked); Save(); } else { tracked.Arrived = true; } } else if (tracked.Arrived && num5 > num * 9f) { tracked.Arrived = false; } } } } private void UpdateFocus() { //IL_001d: 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) if (Tracks.Count == 0) { _focus = null; return; } Vector3 position = ((Component)Player.m_localPlayer).transform.position; Tracked tracked = null; float num = float.MaxValue; float num2 = float.MaxValue; for (int i = 0; i < Tracks.Count; i++) { if (!Tracks[i].Arrived) { float num3 = Tracks[i].Pin.m_pos.x - position.x; float num4 = Tracks[i].Pin.m_pos.z - position.z; float num5 = num3 * num3 + num4 * num4; if (num5 < num) { num = num5; tracked = Tracks[i]; } if (Tracks[i] == _focus) { num2 = num5; } } } if (_focus == null || tracked == _focus) { _focus = tracked; } else if (num < num2 * 0.7f) { _focus = tracked; } } internal static void Say(string text) { if (ShowMessages.Value && !((Object)(object)Player.m_localPlayer == (Object)null)) { ((Character)Player.m_localPlayer).Message((MessageType)1, text, 0, (Sprite)null, false); } } internal static string Tr(string ru, string en) { if (Localization.instance == null || !(Localization.instance.GetSelectedLanguage() == "Russian")) { return en; } return ru; } } [HarmonyPatch(typeof(Minimap), "UpdatePins")] internal static class MapMarker { private class Mark { public GameObject Root; public Image Ring; public Image Rune; } private static readonly Dictionary<PinData, Mark> Marks = new Dictionary<PinData, Mark>(); private static readonly List<PinData> Stale = new List<PinData>(); private static Sprite _ringSprite; private static void Postfix() { //IL_0194: 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_01bd: 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_0201: Unknown result type (might be due to invalid IL or missing references) List<Tracked> tracks = FylgjaPlugin.Tracks; Stale.Clear(); foreach (KeyValuePair<PinData, Mark> mark2 in Marks) { if (FylgjaPlugin.Find(mark2.Key) == null || (Object)(object)mark2.Value.Root == (Object)null || (Object)(object)mark2.Key.m_uiElement == (Object)null || (Object)(object)mark2.Value.Root.transform.parent != (Object)(object)mark2.Key.m_uiElement) { Stale.Add(mark2.Key); } } for (int i = 0; i < Stale.Count; i++) { Mark mark = Marks[Stale[i]]; if ((Object)(object)mark.Root != (Object)null) { Object.Destroy((Object)(object)mark.Root); } Marks.Remove(Stale[i]); } float num = 1f + 0.07f * Mathf.Sin(Time.unscaledTime * 3.2f); for (int j = 0; j < tracks.Count; j++) { PinData pin = tracks[j].Pin; if (!((Object)(object)pin.m_uiElement == (Object)null)) { if (!Marks.TryGetValue(pin, out var value)) { value = Build(pin.m_uiElement, tracks[j].Slot); Marks[pin] = value; } Color color = tracks[j].Color; if (tracks[j].Arrived) { color.a = 0.45f; } ((Graphic)value.Ring).color = color; ((Graphic)value.Rune).color = color; float num2 = (tracks[j].Arrived ? 1f : num); ((Transform)((Graphic)value.Ring).rectTransform).localScale = new Vector3(num2, num2, 1f); } } } private static Mark Build(RectTransform parent, int slot) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0045: 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_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_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_00cb: 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_0122: 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_014c: 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_0176: Unknown result type (might be due to invalid IL or missing references) Mark mark = new Mark(); mark.Root = new GameObject("Fylgja_Mark", new Type[1] { typeof(RectTransform) }); RectTransform val = (RectTransform)mark.Root.transform; ((Transform)val).SetParent((Transform)(object)parent, false); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = Vector2.zero; val.offsetMax = Vector2.zero; ((Transform)val).SetAsLastSibling(); mark.Ring = NewImage("Ring", val, RingSprite()); ((Graphic)mark.Ring).rectTransform.anchorMin = Vector2.zero; ((Graphic)mark.Ring).rectTransform.anchorMax = Vector2.one; ((Graphic)mark.Ring).rectTransform.offsetMin = new Vector2(-9f, -9f); ((Graphic)mark.Ring).rectTransform.offsetMax = new Vector2(9f, 9f); mark.Rune = NewImage("Rune", val, RuneTextures.GetSprite(slot)); RectTransform rectTransform = ((Graphic)mark.Rune).rectTransform; rectTransform.anchorMin = new Vector2(1f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0f, 0f); rectTransform.sizeDelta = new Vector2(18f, 18f); rectTransform.anchoredPosition = new Vector2(6f, 6f); return mark; } private static Image NewImage(string name, RectTransform parent, Sprite sprite) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent((Transform)(object)parent, false); Image val2 = val.AddComponent<Image>(); val2.sprite = sprite; ((Graphic)val2).raycastTarget = false; return val2; } private static Sprite RingSprite() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_011a: 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_00dd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ringSprite != (Object)null) { return _ringSprite; } Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)1; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = ((float)j + 0.5f) / 64f * 2f - 1f; float num2 = ((float)i + 0.5f) / 64f * 2f - 1f; float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = Mathf.Clamp01(1f - Mathf.Abs(num3 - 0.82f) / 0.1f); float num5 = Mathf.Clamp01(1f - Mathf.Abs(num3 - 0.82f) / 0.28f) * 0.35f; val.SetPixel(j, i, new Color(1f, 1f, 1f, Mathf.Clamp01(num4 + num5))); } } val.Apply(); _ringSprite = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); return _ringSprite; } } [HarmonyPatch(typeof(Minimap), "OnMapLeftClick")] internal static class BlockLeftClick { private static bool Prefix() { return !ModifierHeld(); } internal static bool ModifierHeld() { if (!Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)305) && !Input.GetKey((KeyCode)304)) { return Input.GetKey((KeyCode)303); } return true; } } [HarmonyPatch(typeof(Minimap), "OnMapDblClick")] internal static class BlockDoubleClick { private static bool Prefix() { return !BlockLeftClick.ModifierHeld(); } } internal static class RuneTextures { private static readonly float[][] Runes = new float[12][] { new float[12] { 0.35f, 0.05f, 0.35f, 0.95f, 0.35f, 0.65f, 0.75f, 0.92f, 0.35f, 0.38f, 0.75f, 0.65f }, new float[8] { 0.22f, 0.9f, 0.78f, 0.1f, 0.22f, 0.1f, 0.78f, 0.9f }, new float[12] { 0.5f, 0.05f, 0.5f, 0.95f, 0.5f, 0.95f, 0.2f, 0.64f, 0.5f, 0.95f, 0.8f, 0.64f }, new float[24] { 0.5f, 0.95f, 0.82f, 0.62f, 0.82f, 0.62f, 0.5f, 0.3f, 0.5f, 0.3f, 0.18f, 0.62f, 0.18f, 0.62f, 0.5f, 0.95f, 0.5f, 0.3f, 0.25f, 0.05f, 0.5f, 0.3f, 0.75f, 0.05f }, new float[12] { 0.3f, 0.05f, 0.3f, 0.95f, 0.7f, 0.05f, 0.7f, 0.95f, 0.3f, 0.38f, 0.7f, 0.62f }, new float[12] { 0.68f, 0.95f, 0.32f, 0.62f, 0.32f, 0.62f, 0.68f, 0.38f, 0.68f, 0.38f, 0.32f, 0.05f }, new float[8] { 0.72f, 0.82f, 0.3f, 0.5f, 0.3f, 0.5f, 0.72f, 0.18f }, new float[12] { 0.3f, 0.05f, 0.3f, 0.95f, 0.3f, 0.95f, 0.7f, 0.72f, 0.7f, 0.72f, 0.7f, 0.05f }, new float[12] { 0.3f, 0.05f, 0.3f, 0.95f, 0.3f, 0.95f, 0.7f, 0.75f, 0.7f, 0.75f, 0.3f, 0.55f }, new float[12] { 0.3f, 0.05f, 0.3f, 0.95f, 0.3f, 0.95f, 0.7f, 0.75f, 0.3f, 0.68f, 0.7f, 0.48f }, new float[12] { 0.3f, 0.05f, 0.3f, 0.95f, 0.3f, 0.75f, 0.7f, 0.55f, 0.7f, 0.55f, 0.3f, 0.35f }, new float[16] { 0.3f, 0.05f, 0.3f, 0.95f, 0.3f, 0.95f, 0.7f, 0.75f, 0.7f, 0.75f, 0.3f, 0.5f, 0.3f, 0.5f, 0.72f, 0.05f } }; private static readonly Texture2D[] Textures = (Texture2D[])(object)new Texture2D[Runes.Length]; private static readonly Sprite[] Sprites = (Sprite[])(object)new Sprite[Runes.Length]; public static int Count => Runes.Length; public static Texture2D Get(int slot) { int num = slot % Runes.Length; if ((Object)(object)Textures[num] == (Object)null) { Textures[num] = Draw(Runes[num]); } return Textures[num]; } public static Sprite GetSprite(int slot) { //IL_003f: 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) int num = slot % Runes.Length; if ((Object)(object)Sprites[num] == (Object)null) { Texture2D val = Get(num); Sprites[num] = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } return Sprites[num]; } private static Texture2D Draw(float[] strokes) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, true); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)2; for (int i = 0; i < 64; i++) { float num = ((float)i + 0.5f) / 64f; for (int j = 0; j < 64; j++) { float num2 = ((float)j + 0.5f) / 64f; float num3 = 10f; for (int k = 0; k < strokes.Length; k += 4) { num3 = Mathf.Min(num3, DistanceToSegment(num2, num, strokes[k], strokes[k + 1], strokes[k + 2], strokes[k + 3])); } float num4 = Mathf.Clamp01(1f - (num3 - 0.045f) / 0.03f); float num5 = Mathf.Exp((0f - num3) * num3 * 220f) * 0.45f; float num6 = Mathf.Clamp01((0.5f - Mathf.Max(Mathf.Abs(num2 - 0.5f), Mathf.Abs(num - 0.5f))) * 14f); val.SetPixel(j, i, new Color(1f, 1f, 1f, Mathf.Clamp01(num4 + num5) * num6)); } } val.Apply(); return val; } private static float DistanceToSegment(float px, float py, float ax, float ay, float bx, float by) { float num = bx - ax; float num2 = by - ay; float num3 = Mathf.Clamp01(((px - ax) * num + (py - ay) * num2) / (num * num + num2 * num2)); float num4 = ax + num * num3 - px; float num5 = ay + num2 * num3 - py; return Mathf.Sqrt(num4 * num4 + num5 * num5); } } internal class SkyBeacon { private const float RenderRadius = 150f; private const float FadeSpeed = 2.2f; private const float FarDistance = 600f; private const float NearDistance = 60f; private const float MinHeight = 40f; private const float RealThreadWidth = 0.7f; private const float RealStarSize = 4f; private const float GroundLoadedRange = 90f; private const float DayStarScale = 1.3f; private GameObject _root; private Transform _thread; private Transform _star; private Transform _starGhost; private Material _threadMat; private Material _starMat; private Material _starGhostMat; private readonly int _slot; private Transform _icon; private Transform _iconGhost; private Material _iconMat; private Material _iconGhostMat; private Transform _starBoost; private Transform _iconBoost; private Material _starBoostMat; private Material _iconBoostMat; private static float _daylight = 1f; private static float _daylightRef; private float _baseY; private float _baseVel; private bool _baseKnown; private float _fade; private float _emphasis = 1f; private bool _retired; private float _ignitionStart = -100f; private Vector3 _lastTarget; private bool _hasLast; private static Mesh _quad; public bool Finished { get { if (_retired) { return _fade <= 0.001f; } return false; } } public SkyBeacon(int slot) { _slot = slot; } public void Retire() { _retired = true; } public void Ignite() { _ignitionStart = Time.time; _fade = 0f; } public void Destroy() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; } public void Render(Camera cam, PinData target, Color color, bool focus) { //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) //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) //IL_010e: 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_014a: 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_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_016f: 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_0178: 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_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0313: 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_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: 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_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_0582: 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_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: 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_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) _emphasis = Mathf.MoveTowards(_emphasis, focus ? 1f : 0.55f, Time.unscaledDeltaTime * 2f); if (target != null) { _lastTarget = target.m_pos; _hasLast = true; } float num = ((target != null) ? 1f : 0f); _fade = Mathf.MoveTowards(_fade, num, Time.unscaledDeltaTime * 2.2f); if (_fade <= 0.001f || !_hasLast) { if ((Object)(object)_root != (Object)null && _root.activeSelf) { _root.SetActive(false); } } else { if ((Object)(object)_root == (Object)null && !Build()) { return; } if (!_root.activeSelf) { _root.SetActive(true); } Vector3 position = ((Component)cam).transform.position; Vector2 val = new Vector2(_lastTarget.x - position.x, _lastTarget.z - position.z); float magnitude = ((Vector2)(ref val)).magnitude; if (!(magnitude < 0.1f)) { Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(_lastTarget.x, GroundY(magnitude), _lastTarget.z); Vector3 val3 = val2 - position; float magnitude2 = ((Vector3)(ref val3)).magnitude; Vector3 val4 = new Vector3(val3.x, 0f, val3.z); Vector3 normalized = ((Vector3)(ref val4)).normalized; float num2 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(60f, 600f, magnitude)); float num3 = Mathf.Lerp(FylgjaPlugin.MinElevation.Value, FylgjaPlugin.MaxElevation.Value, num2) * ((float)Math.PI / 180f); float num4 = Mathf.Max(40f, magnitude * Mathf.Tan(num3)); float num5 = Mathf.Min(150f, cam.farClipPlane * 0.6f); float num6 = ((magnitude2 > num5) ? (num5 / magnitude2) : 1f); float num7 = 2f * magnitude2 * Mathf.Tan(cam.fieldOfView * 0.5f * ((float)Math.PI / 180f)) / (float)Screen.height; float num8 = Mathf.Clamp01((Time.time - _ignitionStart) / Mathf.Max(0.01f, FylgjaPlugin.IgnitionSeconds.Value)); float num9 = 1f + (FylgjaPlugin.IgnitionFlare.Value - 1f) * (1f - num8) * (1f - num8); float num10 = 0.5f + 0.5f * Mathf.Cos(EnvDayFraction() * (float)Math.PI * 2f); float num11 = 0.92f + 0.08f * Mathf.Sin(Time.time * 1.7f); float num12 = Mathf.Lerp(0.85f, 1f, num10) * num11 * _fade * _emphasis; float num13 = Daylight(); float num14 = Mathf.Lerp(0.7f, 1f, Mathf.InverseLerp(0.55f, 1f, _emphasis)); Vector3 val5 = position + val3 * num6; float num15 = num4 * num6; Vector3 val6 = val5 + Vector3.up * num15; float num16 = Mathf.Max(FylgjaPlugin.StarPixelSize.Value * num7, 4f) * num6 * num14 * Mathf.Lerp(1f, 1.3f, num13); float num17 = num16 * num9; Place(_starBoost, _starBoost, val6, ((Component)cam).transform.rotation, new Vector3(num17, num17, 1f)); Place(_star, _starGhost, val6, ((Component)cam).transform.rotation, new Vector3(num17, num17, 1f)); Color val7 = color; if ((Object)(object)_icon != (Object)null) { float num18 = num16 * 0.75f; Place(_icon, _iconGhost, val6 + ((Component)cam).transform.right * (num16 * 1.05f), ((Component)cam).transform.rotation, new Vector3(num18, num18, 1f)); Place(_iconBoost, _iconBoost, val6 + ((Component)cam).transform.right * (num16 * 1.05f), ((Component)cam).transform.rotation, new Vector3(num18, num18, 1f)); _iconBoostMat.color = new Color(val7.r, val7.g, val7.b, num12 * num13); _iconMat.color = new Color(val7.r, val7.g, val7.b, num12); _iconGhostMat.color = new Color(val7.r, val7.g, val7.b, num12 * Mathf.Clamp01(FylgjaPlugin.OccludedVisibility.Value)); } float num19 = Mathf.Max(FylgjaPlugin.ThreadPixelWidth.Value * num7, 0.7f) * num6 * num14 * Mathf.Lerp(1f, 1.3f, num13); _thread.position = val5 + Vector3.up * (num15 * 0.5f); _thread.rotation = Quaternion.LookRotation(normalized, Vector3.up); _thread.localScale = new Vector3(num19, num15, 1f); _threadMat.color = new Color(val7.r, val7.g, val7.b, Mathf.Min(1f, num12 * Mathf.Lerp(0.85f, 1.1f, num13))); _starMat.color = new Color(val7.r, val7.g, val7.b, num12); _starBoostMat.color = new Color(val7.r, val7.g, val7.b, num12 * num13); float num20 = Mathf.Clamp01(FylgjaPlugin.OccludedVisibility.Value); _starGhostMat.color = new Color(val7.r, val7.g, val7.b, num12 * num20); } } } private static float Daylight() { EnvMan instance = EnvMan.instance; Light val = (((Object)(object)instance != (Object)null) ? instance.m_dirLight : null); if ((Object)(object)val == (Object)null) { return _daylight; } if (_daylightRef <= 0f && instance.m_environments != null) { for (int i = 0; i < instance.m_environments.Count; i++) { _daylightRef = Mathf.Max(_daylightRef, instance.m_environments[i].m_lightIntensityDay); } } if (_daylightRef <= 0f) { return _daylight; } float num = Mathf.Clamp01((val.intensity / _daylightRef - 0.35f) / 0.5f); _daylight = Mathf.MoveTowards(_daylight, num, Time.unscaledDeltaTime * 0.5f); return _daylight; } private float GroundY(float flatDist) { //IL_001f: 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) float num = (((Object)(object)Player.m_localPlayer != (Object)null) ? ((Component)Player.m_localPlayer).transform.position.y : _baseY); float num2 = default(float); if (flatDist < 90f && (Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(_lastTarget, ref num2)) { num = num2; } if (!_baseKnown) { _baseY = num; _baseKnown = true; } _baseY = Mathf.SmoothDamp(_baseY, num, ref _baseVel, 0.4f); return _baseY; } private static void Place(Transform solid, Transform ghost, Vector3 pos, Quaternion rot, Vector3 scale) { //IL_0001: 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_000f: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) solid.position = pos; solid.rotation = rot; solid.localScale = scale; ghost.position = pos; ghost.rotation = rot; ghost.localScale = scale; } private static float EnvDayFraction() { if (!((Object)(object)EnvMan.instance != (Object)null)) { return 0.5f; } return EnvMan.instance.GetDayFraction(); } private bool Build() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown Shader val = Shader.Find("UI/Default"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Sprites/Default"); } if ((Object)(object)val == (Object)null) { FylgjaPlugin.Log.LogWarning((object)"No usable unlit shader found, sky beacon disabled."); return false; } _root = new GameObject("Fylgja_SkyBeacon"); Object.DontDestroyOnLoad((Object)(object)_root); Texture2D tex = MakeThreadTexture(); Texture2D tex2 = MakeStarTexture(); _starGhostMat = MakeMaterial(val, tex2, (CompareFunction)8, 3999); _starBoostMat = MakeMaterial(val, tex2, (CompareFunction)4, 4001); _starBoost = MakeQuad("StarBoost", _starBoostMat); _threadMat = MakeMaterial(val, tex, (CompareFunction)4, 4000); _starMat = MakeMaterial(val, tex2, (CompareFunction)4, 4000); _starGhost = MakeQuad("StarGhost", _starGhostMat); _thread = MakeQuad("Thread", _threadMat); _star = MakeQuad("Star", _starMat); Texture2D tex3 = RuneTextures.Get(_slot); _iconBoostMat = MakeMaterial(val, tex3, (CompareFunction)4, 4001); _iconBoost = MakeQuad("RuneBoost", _iconBoostMat); _iconGhostMat = MakeMaterial(val, tex3, (CompareFunction)8, 3999); _iconMat = MakeMaterial(val, tex3, (CompareFunction)4, 4000); _iconGhost = MakeQuad("RuneGhost", _iconGhostMat); _icon = MakeQuad("Rune", _iconMat); return true; } private Material MakeMaterial(Shader shader, Texture2D tex, CompareFunction zTest, int queue) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected I4, but got Unknown Material val = new Material(shader); val.mainTexture = (Texture)(object)tex; val.SetInt("unity_GUIZTestMode", (int)zTest); val.renderQueue = queue; return val; } private Transform MakeQuad(string name, Material mat) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(_root.transform, false); val.AddComponent<MeshFilter>().sharedMesh = UnitQuad(); MeshRenderer val2 = val.AddComponent<MeshRenderer>(); ((Renderer)val2).sharedMaterial = mat; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; return val.transform; } internal static Mesh UnitQuad() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //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_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_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_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_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_00e7: 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_0107: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_0167: 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_0178: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_quad != (Object)null) { return _quad; } _quad = new Mesh(); _quad.vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-0.5f, -0.5f, 0f), new Vector3(0.5f, -0.5f, 0f), new Vector3(0.5f, 0.5f, 0f), new Vector3(-0.5f, 0.5f, 0f) }; _quad.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; _quad.colors = (Color[])(object)new Color[4] { Color.white, Color.white, Color.white, Color.white }; _quad.triangles = new int[6] { 0, 2, 1, 0, 3, 2 }; _quad.bounds = new Bounds(Vector3.zero, new Vector3(1000f, 1000f, 1000f)); return _quad; } private static Texture2D MakeThreadTexture() { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) Texture2D val = NewTexture(32, 256); for (int i = 0; i < 256; i++) { float num = (float)i / 255f; float num2 = Mathf.SmoothStep(0f, 1f, num / 0.35f) * (0.35f + 0.65f * num); for (int j = 0; j < 32; j++) { float num3 = (float)j / 31f * 2f - 1f; float num4 = Mathf.Exp((0f - num3) * num3 * 12f); float num5 = Mathf.Exp((0f - num3) * num3 * 3.5f) * 0.3f; float num6 = Mathf.Clamp01((num4 + num5) * num2); float num7 = num4 * 0.6f; val.SetPixel(j, i, new Color(1f, 1f - 0.15f * (1f - num7), 1f - 0.4f * (1f - num7), num6)); } } val.Apply(); return val; } private static Texture2D MakeStarTexture() { //IL_0135: Unknown result type (might be due to invalid IL or missing references) Texture2D val = NewTexture(128, 128); for (int i = 0; i < 128; i++) { float num = (float)i / 127f * 2f - 1f; for (int j = 0; j < 128; j++) { float num2 = (float)j / 127f * 2f - 1f; float num3 = num2 * num2 + num * num; float num4 = Mathf.Exp((0f - num3) * 70f); float num5 = Mathf.Exp((0f - Mathf.Sqrt(num3)) * 5f) * 0.45f; float num6 = Mathf.Abs(num2); float num7 = Mathf.Abs(num); float num8 = (Mathf.Exp((0f - num6) * 3.5f) * Mathf.Exp((0f - num7) * 38f) + Mathf.Exp((0f - num7) * 3.5f) * Mathf.Exp((0f - num6) * 38f)) * 0.9f; float num9 = Mathf.Clamp01(1f - num3); float num10 = Mathf.Clamp01((num4 + num5 + num8) * num9); float num11 = Mathf.Clamp01(num4 * 1.2f); val.SetPixel(j, i, new Color(1f, 1f - 0.15f * (1f - num11), 1f - 0.4f * (1f - num11), num10)); } } val.Apply(); return val; } private static Texture2D NewTexture(int w, int h) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown Texture2D val = new Texture2D(w, h, (TextureFormat)4, true); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)2; ((Texture)val).anisoLevel = 4; return val; } } internal class Spirit { private const float BaseSize = 0.3f; private const float FadeSpeed = 1.6f; private const float EmberSpeed = 1.5f; private const float EmberRate = 22f; private GameObject _root; private Transform _head; private Material _headMat; private Light _light; private ParticleSystem _embers; private Material _emberMat; private Vector3 _pos; private Vector3 _vel; private Vector3 _dir = Vector3.forward; private Color _color = Color.white; private bool _snap = true; private float _fade; private float _ignitionStart = -100f; private Vector3 _lastTarget; private bool _hasLast; private static int _mask = -1; private static int Mask { get { if (_mask == -1) { _mask = LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" }); } return _mask; } } public void Ignite() { _ignitionStart = Time.time; _snap = true; } public void Destroy() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; } public void Render(Camera cam, PinData target, Color color) { //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) //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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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_011b: 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_0185: 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_018a: 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_018e: 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_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: 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) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0245: 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_0259: 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_0284: 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_0292: 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_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_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: 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_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: 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) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: 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_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0335: 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_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0352: 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_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_0390: 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_056a: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_05b8: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: 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_03d0: 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) bool flag = target != null && FylgjaPlugin.SpiritEnabled.Value && !Minimap.IsOpen(); if (target != null) { _lastTarget = target.m_pos; _hasLast = true; } float deltaTime = Time.deltaTime; _fade = Mathf.MoveTowards(_fade, flag ? 1f : 0f, deltaTime * 1.6f); if (_fade <= 0.001f || !_hasLast) { if ((Object)(object)_root != (Object)null && _root.activeSelf) { _root.SetActive(false); } _snap = true; } else if (!((Object)(object)_root == (Object)null) || Build()) { if (!_root.activeSelf) { _root.SetActive(true); } Transform transform = ((Component)cam).transform; Vector3 forward = transform.forward; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(forward.x, 0f, forward.z); if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { ((Vector3)(ref val))..ctor(transform.up.x, 0f, transform.up.z); } ((Vector3)(ref val)).Normalize(); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(_lastTarget.x - transform.position.x, 0f, _lastTarget.z - transform.position.z); float magnitude = ((Vector3)(ref val2)).magnitude; Vector3 val3 = ((magnitude > 0.01f) ? (val2 / magnitude) : val); float num = Vector3.SignedAngle(val, val3, Vector3.up); float num2 = 2f * Mathf.Atan(Mathf.Tan(cam.fieldOfView * 0.5f * ((float)Math.PI / 180f)) * cam.aspect) * 57.29578f; float num3 = num2 * 0.5f * 0.72f; float num4 = Mathf.Clamp(num, 0f - num3, num3); Vector3 val4 = Quaternion.AngleAxis(num4, Vector3.up) * val; float num5 = Mathf.Asin(Mathf.Clamp(forward.y, -1f, 1f)); num5 = Mathf.Clamp(num5, -(float)Math.PI / 12f, (float)Math.PI / 12f); float num6 = (((Object)(object)Player.m_localPlayer != (Object)null) ? Vector3.Distance(transform.position, ((Component)Player.m_localPlayer).transform.position + Vector3.up * 1.5f) : 0f); float num7 = num6 + FylgjaPlugin.SpiritDistance.Value; Vector3 val5 = transform.position + (val4 * Mathf.Cos(num5) + Vector3.up * Mathf.Sin(num5)) * num7 - Vector3.up * 0.2f; float time = Time.time; val5 += val3 * (0.2f + 0.15f * Mathf.Sin(time * 1.6f)); val5 += Vector3.up * (Mathf.Sin(time * 1.9f) * 0.07f); Vector3 val6 = val5 - transform.position; RaycastHit val7 = default(RaycastHit); if (Physics.Linecast(transform.position, val5, ref val7, Mask)) { val5 = transform.position + ((Vector3)(ref val6)).normalized * Mathf.Max(0.8f, ((RaycastHit)(ref val7)).distance - 0.25f); } if (_snap) { _pos = (((Object)(object)Player.m_localPlayer != (Object)null) ? (((Component)Player.m_localPlayer).transform.position + Vector3.up * 1.4f) : val5); _vel = Vector3.zero; _dir = val3; _color = color; _snap = false; } _pos = Vector3.SmoothDamp(_pos, val5, ref _vel, 0.25f, 40f, deltaTime); _dir = Vector3.Slerp(_dir, val3, 1f - Mathf.Exp((0f - deltaTime) * 5f)); _color = Color.Lerp(_color, color, 1f - Mathf.Exp((0f - deltaTime) * 4f)); float num8 = Mathf.Clamp01((time - _ignitionStart) / 1.1f); float num9 = 1f + 1.2f * (1f - num8) * (1f - num8); float num10 = 0.5f + 0.5f * Mathf.Cos((((Object)(object)EnvMan.instance != (Object)null) ? EnvMan.instance.GetDayFraction() : 0.5f) * (float)Math.PI * 2f); float num11 = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(8f, 50f, Mathf.Abs(num))); float num12 = _fade * Mathf.Lerp(0.8f, 1f, num10) * Mathf.Lerp(0.7f, 1f, num11); float num13 = 0.9f + 0.07f * Mathf.Sin(time * 11f) + 0.05f * Mathf.Sin(time * 17.3f + 1.3f); float num14 = 0.3f * FylgjaPlugin.SpiritScale.Value * num13 * num9; Color val8 = Color.Lerp(_color, Color.white, 0.5f); _head.position = _pos; _head.rotation = transform.rotation; _head.localScale = new Vector3(num14 * 2f, num14 * 2f, 1f); _headMat.color = new Color(val8.r, val8.g, val8.b, num12); UpdateEmbers(_pos, _dir, _color, num12); ((Component)_light).transform.position = _pos; _light.color = _color; _light.intensity = 0.55f * num12 * num9; } } private void UpdateEmbers(Vector3 pos, Vector3 dir, Color color, float alpha) { //IL_000b: 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_001c: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0089: 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_0099: Unknown result type (might be due to invalid IL or missing references) ((Component)_embers).transform.position = pos; MainModule main = _embers.main; ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(color.r, color.g, color.b, alpha)); VelocityOverLifetimeModule velocityOverLifetime = _embers.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(dir.x * 1.5f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(dir.z * 1.5f); EmissionModule emission = _embers.emission; ((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(22f * alpha); } private bool Build() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown Shader val = Shader.Find("UI/Default"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Sprites/Default"); } if ((Object)(object)val == (Object)null) { FylgjaPlugin.Log.LogWarning((object)"No usable unlit shader found, spirit disabled."); return false; } _root = new GameObject("Fylgja_Spirit"); Object.DontDestroyOnLoad((Object)(object)_root); Texture2D tex = MakeOrbTexture(); _headMat = NewMaterial(val, tex, 4002); _emberMat = NewMaterial(val, tex, 4001); GameObject val2 = new GameObject("Flame"); val2.transform.SetParent(_root.transform, false); val2.AddComponent<MeshFilter>().sharedMesh = SkyBeacon.UnitQuad(); MeshRenderer val3 = val2.AddComponent<MeshRenderer>(); ((Renderer)val3).sharedMaterial = _headMat; ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val3).receiveShadows = false; _head = val2.transform; BuildEmbers(); GameObject val4 = new GameObject("Light"); val4.transform.SetParent(_root.transform, false); _light = val4.AddComponent<Light>(); _light.type = (LightType)2; _light.range = 6f; _light.shadows = (LightShadows)0; return true; } private void BuildEmbers() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0092: 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_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_00c9: 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_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_0117: 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_0139: 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_014e: 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_017c: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_01b4: 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_01c3: 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_01da: 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_0200: 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) //IL_021c: 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_0238: 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_0262: 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_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Expected O, but got Unknown //IL_02ba: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Embers"); val.transform.SetParent(_root.transform, false); _embers = val.AddComponent<ParticleSystem>(); _embers.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = _embers.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.7f, 2.6f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.05f, 0.11f); ((MainModule)(ref main)).maxParticles = 80; ((MainModule)(ref main)).gravityModifier = new MinMaxCurve(-0.015f); EmissionModule emission = _embers.emission; ((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(22f); ShapeModule shape = _embers.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.1f; VelocityOverLifetimeModule velocityOverLifetime = _embers.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(0f); NoiseModule noise = _embers.noise; ((NoiseModule)(ref noise)).enabled = true; ((NoiseModule)(ref noise)).strength = new MinMaxCurve(0.35f); ((NoiseModule)(ref noise)).frequency = 0.7f; ((NoiseModule)(ref noise)).scrollSpeed = new MinMaxCurve(0.4f); ColorOverLifetimeModule colorOverLifetime = _embers.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; 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[3] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(1f, 0.18f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val2); SizeOverLifetimeModule sizeOverLifetime = _embers.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 0.9f), new Keyframe(1f, 0.15f) })); ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>(); ((Renderer)component).sharedMaterial = _emberMat; component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; _embers.Play(); } private static Material NewMaterial(Shader shader, Texture2D tex, int queue) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Material val = new Material(shader); val.mainTexture = (Texture)(object)tex; val.SetInt("unity_GUIZTestMode", 4); val.renderQueue = queue; return val; } private static Texture2D MakeOrbTexture() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, true); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)2; for (int i = 0; i < 64; i++) { float num = ((float)i + 0.5f) / 64f * 2f - 1f; for (int j = 0; j < 64; j++) { float num2 = ((float)j + 0.5f) / 64f * 2f - 1f; float num3 = num2 * num2 + num * num; float num4 = Mathf.Exp((0f - num3) * 38f); float num5 = Mathf.Exp((0f - Mathf.Sqrt(num3)) * 4.2f) * 0.55f; float num6 = Mathf.Clamp01(1f - num3); val.SetPixel(j, i, new Color(1f, 1f, 1f, Mathf.Clamp01((num4 + num5) * num6))); } } val.Apply(); return val; } }