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 BifrostBrew v0.1.1
plugins\BifrostBrew.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("BifrostBrew")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BifrostBrew")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.1.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.0")] namespace BifrostBrew; [BepInPlugin("com.voxxsidus.bifrostbrew", "BifrostBrew", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class BifrostBrewPlugin : BaseUnityPlugin { public const string PluginGUID = "com.voxxsidus.bifrostbrew"; public const string PluginName = "BifrostBrew"; public const string PluginVersion = "0.1.1"; private static readonly Color BifrostColor = new Color(0.35f, 0.75f, 1f); private const string BifrostCategory = "bifrostbrew"; internal static ConfigEntry<float> ChannelSeconds; internal static ConfigEntry<float> CooldownMinutes; private const string BrewLiquidMaterial = "MajorStaminaPotion_mat"; private const string MeadBaseLiquidMaterial = "meadbase"; private static readonly Color BrewLightColor = new Color(0.75f, 0.7f, 1f); private static GameObject s_brewPrefab; private const string ServingTray = "Feaster"; internal static bool IsHeadless => (int)SystemInfo.graphicsDeviceType == 4; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) CreateConfig(); AddLocalizations(); new Harmony("com.voxxsidus.bifrostbrew").PatchAll(); PrefabManager.OnVanillaPrefabsAvailable += AddItems; ItemManager.OnItemsRegistered += AddBrewToServingTray; } private void AddItems() { try { CustomItem obj = AddMeadBase(); CustomItem val = AddBrew(); obj.ItemDrop.m_itemData.m_shared.m_consumeStatusEffect = val.ItemDrop.m_itemData.m_shared.m_consumeStatusEffect; AddFermenterConversion(); } finally { PrefabManager.OnVanillaPrefabsAvailable -= AddItems; } } private void CreateConfig() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; ChannelSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Bifrost Brew", "Channel seconds", 5f, new ConfigDescription("Seconds between drinking Bifrost Brew and being teleported. 0 teleports instantly.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), new object[1] { val })); CooldownMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("Bifrost Brew", "Cooldown minutes", 0f, new ConfigDescription("Minutes after a teleport before another Bifrost Brew can be drunk. 0 disables the cooldown. Status effects aren't saved, so logging out clears an active cooldown.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), new object[1] { val })); BifrostRecipe.Bind(((BaseUnityPlugin)this).Config, val); } private static bool IsIconLiquid(float h, float s) { if (h >= 1f / 12f && h <= 5f / 24f && s >= 0.15f) { if (!(h >= 13f / 120f)) { return s >= 0.46f; } return true; } return false; } private static Color BrewLiquidColor(float v) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return BifrostGradient(Mathf.InverseLerp(0.05f, 0.25f, v)); } private static Color BrewIconColor(float v) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return BifrostGradient(Mathf.InverseLerp(0.08f, 0.52f, v)); } private static Color BifrostGradient(float t) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!(t < 0.5f)) { return Color.Lerp(BifrostVfx.Blue, BifrostVfx.Violet, t * 2f - 1f); } return Color.Lerp(BifrostVfx.Cyan, BifrostVfx.Blue, t * 2f); } private CustomItem AddMeadBase() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //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) ItemConfig val = new ItemConfig { Name = "$item_meadbasebifrost", Description = "$item_meadbasebifrost_desc", CraftingStation = BifrostRecipe.GetStationName(), Amount = 1, Requirements = BifrostRecipe.GetRequirementConfigs() }; CustomItem val2 = new CustomItem("MeadBaseBifrost", "MeadBaseStaminaLingering", val); Recolor(val2.ItemPrefab, "meadbase", BifrostColor); RecolorIcon(val2, BifrostColor); ItemManager.Instance.AddItem(val2); BifrostRecipe.Attach(val2); return val2; } private CustomItem AddBrew() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0042: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown CustomItem val = new CustomItem("BifrostBrew", "MeadStaminaLingering"); SharedData shared = val.ItemDrop.m_itemData.m_shared; shared.m_name = "$item_bifrostbrew"; shared.m_description = "$item_bifrostbrew_desc"; Recolor(val.ItemPrefab, "MajorStaminaPotion_mat", BrewLightColor, BrewLiquidColor); RecolorIcon(val, BifrostColor, BrewIconColor); shared.m_consumeStatusEffect = CreateTeleportEffects(shared.m_icons[0], shared.m_consumeStatusEffect); Piece val2 = default(Piece); if (val.ItemPrefab.TryGetComponent<Piece>(ref val2)) { val2.m_name = shared.m_name; val2.m_description = shared.m_description; val2.m_icon = shared.m_icons[0]; val2.m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_resItem = val.ItemDrop, m_amount = 1, m_recover = true } }; } else { Logger.LogWarning((object)"MeadStaminaLingering has no Piece component; Bifrost Brew won't be placeable"); } ItemManager.Instance.AddItem(val); s_brewPrefab = val.ItemPrefab; return val; } private static void AddBrewToServingTray() { if ((Object)(object)s_brewPrefab == (Object)null || (Object)(object)ObjectDB.instance == (Object)null) { return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Feaster"); PieceTable val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces : null); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)"Feaster piece table not found; Bifrost Brew won't be placeable"); } else if (!val.m_pieces.Contains(s_brewPrefab)) { int num = val.m_pieces.FindIndex((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == "MeadStaminaLingering"); val.m_pieces.Insert((num >= 0) ? (num + 1) : val.m_pieces.Count, s_brewPrefab); } } private static StatusEffect CreateTeleportEffects(Sprite icon, StatusEffect vanillaEffect) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_00f7: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //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_0157: Expected O, but got Unknown StatusEffect val = ScriptableObject.CreateInstance<StatusEffect>(); ((Object)val).name = "SE_BifrostCooldown"; val.m_name = "$se_bifrostcooldown"; val.m_tooltip = "$se_bifrostcooldown_tooltip"; val.m_icon = icon; val.m_cooldownIcon = true; val.m_category = "bifrostbrew"; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(val, false)); SE_BifrostChannel.CooldownEffect = val; SE_BifrostChannel sE_BifrostChannel = ScriptableObject.CreateInstance<SE_BifrostChannel>(); ((Object)sE_BifrostChannel).name = "SE_BifrostChannel"; ((StatusEffect)sE_BifrostChannel).m_name = "$se_bifrostchannel"; ((StatusEffect)sE_BifrostChannel).m_tooltip = "$se_bifrostchannel_tooltip"; ((StatusEffect)sE_BifrostChannel).m_icon = icon; ((StatusEffect)sE_BifrostChannel).m_category = "bifrostbrew"; ((StatusEffect)sE_BifrostChannel).m_startMessageType = (MessageType)2; ((StatusEffect)sE_BifrostChannel).m_startMessage = "$se_bifrostchannel_start"; List<EffectData> list = new List<EffectData>(); if ((Object)(object)vanillaEffect != (Object)null) { list.AddRange(vanillaEffect.m_startEffects.m_effectPrefabs.Where((EffectData e) => (Object)(object)e.m_prefab != (Object)null && !((Object)e.m_prefab).name.StartsWith("vfx_"))); } GameObject val2 = BifrostVfx.CreateChannelEffect(); if ((Object)(object)val2 != (Object)null) { list.Add(new EffectData { m_prefab = val2, m_attach = true }); } ((StatusEffect)sE_BifrostChannel).m_startEffects = new EffectList { m_effectPrefabs = list.ToArray() }; GameObject val3 = BifrostVfx.CreateDepartEffect(); if ((Object)(object)val3 != (Object)null) { EffectList val4 = new EffectList(); val4.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = val3 } }; ((StatusEffect)sE_BifrostChannel).m_stopEffects = val4; } ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)sE_BifrostChannel, false)); return (StatusEffect)(object)sE_BifrostChannel; } private void AddFermenterConversion() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown CustomItemConversion val = new CustomItemConversion((ConversionConfig)new FermenterConversionConfig { FromItem = "MeadBaseBifrost", ToItem = "BifrostBrew", ProducedItems = BifrostRecipe.BrewsPerBase.Value }); ItemManager.Instance.AddItemConversion(val); } private static void Recolor(GameObject prefab, string liquidMaterial, Color color, Func<float, Color> colorAtV = null) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) Dictionary<Material, Material> dictionary = new Dictionary<Material, Material>(); Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; bool flag = false; for (int j = 0; j < sharedMaterials.Length; j++) { if ((Object)(object)sharedMaterials[j] == (Object)null || ((Object)sharedMaterials[j]).name != liquidMaterial) { continue; } if (!dictionary.TryGetValue(sharedMaterials[j], out var value)) { value = new Material(sharedMaterials[j]) { name = ((Object)sharedMaterials[j]).name + "_bifrost" }; if (!IsHeadless) { Texture texture = value.GetTexture("_MainTex"); Texture2D val2 = (Texture2D)(object)((texture is Texture2D) ? texture : null); if (val2 != null) { Texture2D val3 = CopyRegion((Texture)(object)val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), mipChain: true); ((Texture)val3).wrapMode = ((Texture)val2).wrapMode; ((Texture)val3).filterMode = ((Texture)val2).filterMode; ((Texture)val3).anisoLevel = ((Texture)val2).anisoLevel; ShiftHue(val3, colorAtV ?? ((Func<float, Color>)((float _) => color)), (float h, float sat) => sat >= 0.15f); value.SetTexture("_MainTex", (Texture)(object)val3); } } dictionary[sharedMaterials[j]] = value; } sharedMaterials[j] = value; flag = true; } if (flag) { val.sharedMaterials = sharedMaterials; } } Light[] componentsInChildren2 = prefab.GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].color = color; } } private static void RecolorIcon(CustomItem item, Color color, Func<float, Color> colorAtV = null) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e9: 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_00f9: 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_0126: Unknown result type (might be due to invalid IL or missing references) SharedData shared = item.ItemDrop.m_itemData.m_shared; if (IsHeadless || shared.m_icons == null || shared.m_icons.Length == 0) { return; } Sprite val = shared.m_icons[0]; if (!((Object)(object)val == (Object)null)) { Texture2D val2; try { val2 = CopyRegion((Texture)(object)val.texture, val.textureRect, mipChain: false); } catch (Exception ex) { Logger.LogWarning((object)(((Object)item.ItemPrefab).name + ": could not copy icon " + ((Object)val).name + ", keeping vanilla icon. " + ex.Message)); return; } ShiftHue(val2, colorAtV ?? ((Func<float, Color>)((float _) => color)), IsIconLiquid); float x = val.pivot.x; Rect rect = val.rect; float num = x / ((Rect)(ref rect)).width; float y = val.pivot.y; rect = val.rect; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(num, y / ((Rect)(ref rect)).height); Sprite val4 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), val3, val.pixelsPerUnit); ((Object)val4).name = ((Object)item.ItemPrefab).name; shared.m_icons = (Sprite[])(object)new Sprite[1] { val4 }; } } internal static Texture2D CopyRegion(Texture tex, Rect region, bool mipChain) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00c6: Expected O, but got Unknown int num = (int)((Rect)(ref region)).width; int num2 = (int)((Rect)(ref region)).height; RenderTexture temporary = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(((Rect)(ref region)).width / (float)tex.width, ((Rect)(ref region)).height / (float)tex.height); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(((Rect)(ref region)).x / (float)tex.width, ((Rect)(ref region)).y / (float)tex.height); Graphics.Blit(tex, temporary, val, val2); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val3 = new Texture2D(num, num2, (TextureFormat)4, mipChain) { name = ((Object)tex).name + "_bifrost" }; val3.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); return val3; } private static void ShiftHue(Texture2D tex, Func<float, Color> colorAtV, Func<float, float, bool> shouldShift) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) float[] array = new float[((Texture)tex).height]; float num = default(float); float num2 = default(float); for (int i = 0; i < array.Length; i++) { Color.RGBToHSV(colorAtV(((float)i + 0.5f) / (float)((Texture)tex).height), ref array[i], ref num, ref num2); } Color[] pixels = tex.GetPixels(); float arg = default(float); float num3 = default(float); float num4 = default(float); for (int j = 0; j < pixels.Length; j++) { Color.RGBToHSV(pixels[j], ref arg, ref num3, ref num4); if (shouldShift(arg, num3)) { Color val = Color.HSVToRGB(array[j / ((Texture)tex).width], num3, num4); val.a = pixels[j].a; pixels[j] = val; } } tex.SetPixels(pixels); tex.Apply(true, true); } private void AddLocalizations() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "item_bifrostbrew", "Bifrost Brew" }, { "item_bifrostbrew_desc", "A shimmering mead that carries you home across the rainbow bridge." }, { "item_meadbasebifrost", "Mead base: Bifrost" }, { "item_meadbasebifrost_desc", "Needs to ferment before it can be drunk." }, { "se_bifrostchannel", "Bifrost" }, { "se_bifrostchannel_tooltip", "Opens the Bifrost and carries you home to your bed." }, { "se_bifrostchannel_start", "The Bifrost shimmers around you..." }, { "se_bifrostcooldown", "Bifrost-weary" }, { "se_bifrostcooldown_tooltip", "The rainbow bridge needs time before it will carry you again." }, { "msg_bifrost_nohome", "The Bifrost cannot find your home" } }); } } internal static class BifrostRecipe { public const string MeadBaseName = "MeadBaseBifrost"; private const string DefaultIngredients = "Honey:10, GreydwarfEye:10, SurtlingCore:2"; private const string DefaultStation = "piece_MeadCauldron"; private const int DefaultBrewsPerBase = 6; public static ConfigEntry<string> Ingredients; public static ConfigEntry<string> Station; public static ConfigEntry<int> BrewsPerBase; private static Recipe s_recipe; public static void Bind(ConfigFile config, ConfigurationManagerAttributes adminOnly) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown Ingredients = config.Bind<string>("Recipe", "Mead base ingredients", "Honey:10, GreydwarfEye:10, SurtlingCore:2", new ConfigDescription("Ingredients for one Mead base: Bifrost, as ItemName:Amount pairs separated by commas. Use internal item names (e.g. Honey, GreydwarfEye, SurtlingCore, Thistle). Unknown names are skipped.", (AcceptableValueBase)null, new object[1] { adminOnly })); Station = config.Bind<string>("Recipe", "Mead base station", "piece_MeadCauldron", new ConfigDescription("Crafting station for the mead base, by prefab name: piece_MeadCauldron (Mead Ketill), piece_cauldron (Cauldron), piece_workbench (Workbench). Leave empty to craft it anywhere.", (AcceptableValueBase)null, new object[1] { adminOnly })); BrewsPerBase = config.Bind<int>("Recipe", "Brews per base", 6, new ConfigDescription("Bifrost Brews the fermenter produces from one mead base.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50), new object[1] { adminOnly })); Ingredients.SettingChanged += delegate { ApplyRecipe(); }; Station.SettingChanged += delegate { ApplyRecipe(); }; BrewsPerBase.SettingChanged += delegate { ApplyYield(); }; } public static RequirementConfig[] GetRequirementConfigs() { return ((IEnumerable<(ItemDrop, int)>)ResolveIngredients()).Select((Func<(ItemDrop, int), RequirementConfig>)(((ItemDrop item, int amount) i) => new RequirementConfig(((Object)i.item).name, i.amount, 0, true))).ToArray(); } public static string GetStationName() { if (TryFindStation(Station.Value, out var station)) { if (!((Object)(object)station != (Object)null)) { return null; } return ((Object)station).name; } Logger.LogWarning((object)("Unknown crafting station '" + Station.Value + "', using piece_MeadCauldron")); return "piece_MeadCauldron"; } public static void Attach(CustomItem meadBase) { CustomRecipe recipe = meadBase.Recipe; s_recipe = ((recipe != null) ? recipe.Recipe : null); } private static void ApplyRecipe() { if (!((Object)(object)s_recipe == (Object)null)) { s_recipe.m_resources = ((IEnumerable<(ItemDrop, int)>)ResolveIngredients()).Select((Func<(ItemDrop, int), Requirement>)(((ItemDrop item, int amount) i) => new Requirement { m_resItem = i.item, m_amount = i.amount, m_amountPerLevel = 0 })).ToArray(); if (TryFindStation(Station.Value, out var station)) { s_recipe.m_craftingStation = station; } else { Logger.LogWarning((object)("Unknown crafting station '" + Station.Value + "', keeping the current one")); } } } private static void ApplyYield() { Fermenter[] array = Resources.FindObjectsOfTypeAll<Fermenter>(); for (int i = 0; i < array.Length; i++) { foreach (ItemConversion item in array[i].m_conversion) { if ((Object)(object)item.m_from != (Object)null && ((Object)item.m_from).name == "MeadBaseBifrost") { item.m_producedItems = BrewsPerBase.Value; } } } } private static List<(ItemDrop item, int amount)> ResolveIngredients() { List<(ItemDrop, int)> list = Parse(Ingredients.Value, logProblems: true); if (list.Count > 0) { return list; } Logger.LogWarning((object)("No valid mead base ingredients in '" + Ingredients.Value + "', using the default recipe")); return Parse("Honey:10, GreydwarfEye:10, SurtlingCore:2", logProblems: false); } private static List<(ItemDrop item, int amount)> Parse(string text, bool logProblems) { List<(ItemDrop, int)> list = new List<(ItemDrop, int)>(); string[] array = (text ?? "").Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length == 0) { continue; } string[] array2 = text2.Split(new char[1] { ':' }); string text3 = array2[0].Trim(); int result = 1; if (array2.Length > 2 || (array2.Length == 2 && (!int.TryParse(array2[1].Trim(), out result) || result < 1))) { if (logProblems) { Logger.LogWarning((object)("Skipping mead base ingredient '" + text2 + "': expected ItemName:Amount")); } continue; } ItemDrop val = FindItem(text3); if ((Object)(object)val == (Object)null) { if (logProblems) { Logger.LogWarning((object)("Skipping mead base ingredient '" + text3 + "': no item with that name")); } } else { list.Add((val, result)); } } return list; } private static ItemDrop FindItem(string name) { GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(name) : null); if ((Object)(object)val == (Object)null) { val = PrefabManager.Instance.GetPrefab(name); } if (!((Object)(object)val != (Object)null)) { return null; } return val.GetComponent<ItemDrop>(); } private static bool TryFindStation(string name, out CraftingStation station) { station = null; if (string.IsNullOrWhiteSpace(name)) { return true; } GameObject prefab = PrefabManager.Instance.GetPrefab(CraftingStations.GetInternalName(name.Trim())); station = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<CraftingStation>() : null); return (Object)(object)station != (Object)null; } } public class SE_BifrostChannel : StatusEffect { internal static StatusEffect CooldownEffect; private bool m_fired; private bool m_teleported; public override void Setup(Character character) { base.m_ttl = BifrostBrewPlugin.ChannelSeconds.Value; ((StatusEffect)this).Setup(character); } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); if (!m_fired && !(base.m_time < base.m_ttl)) { m_fired = true; Character character = base.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && (Object)(object)val == (Object)(object)Player.m_localPlayer) { m_teleported = Teleport(val); } } } public override void Stop() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown if (!m_teleported) { base.m_stopEffects = new EffectList(); } ((StatusEffect)this).Stop(); } public override bool IsDone() { return m_fired; } private static bool Teleport(Player player) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (((Character)player).IsDead() || ((Character)player).IsTeleporting()) { return false; } if (!((Humanoid)player).IsTeleportable(false)) { ((Character)player).Message((MessageType)2, "$msg_noteleport", 0, (Sprite)null, false); return false; } if (!TryGetHome(out var destination)) { ((Character)player).Message((MessageType)2, "$msg_bifrost_nohome", 0, (Sprite)null, false); return false; } player.StopDoodadControl(); ((Character)player).AttachStop(); if (!((Character)player).TeleportTo(destination, ((Component)player).transform.rotation, true)) { return false; } StartCooldown(player); return true; } private static bool TryGetHome(out Vector3 destination) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); if (playerProfile.HaveCustomSpawnPoint()) { destination = playerProfile.GetCustomSpawnPoint(); return true; } if (ZoneSystem.instance.GetLocationIcon(Game.instance.m_StartLocation, ref destination)) { destination += Vector3.up * 2f; return true; } destination = playerProfile.GetHomePoint(); return destination != Vector3.zero; } private static void StartCooldown(Player player) { float value = BifrostBrewPlugin.CooldownMinutes.Value; if (!(value <= 0f) && !((Object)(object)CooldownEffect == (Object)null)) { StatusEffect val = ((Character)player).GetSEMan().AddStatusEffect(CooldownEffect, true, 0, 0f, (short)(-1)); if ((Object)(object)val != (Object)null) { val.m_ttl = value * 60f; } } } } [HarmonyPatch(typeof(Player), "CanConsumeItem")] internal static class BlockNonTeleportablePatch { private static void Postfix(Player __instance, ItemData item, ref bool __result) { if (__result && item.m_shared.m_consumeStatusEffect is SE_BifrostChannel && !((Humanoid)__instance).IsTeleportable(false)) { ((Character)__instance).Message((MessageType)2, "$msg_noteleport", 0, (Sprite)null, false); __result = false; } } } internal static class BifrostVfx { private const string NetworkedBase = "vfx_Potion_stamina_medium"; internal static readonly Color Cyan = new Color(0.45f, 0.85f, 1f); internal static readonly Color Blue = new Color(0.3f, 0.5f, 1f); internal static readonly Color Violet = new Color(0.7f, 0.45f, 1f); private static Material s_glow; private static Material s_ring; private static Material s_spark; private static Material s_rune; public static GameObject CreateChannelEffect() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0279: 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_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0369: 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_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) if (!LoadMaterials()) { return null; } GameObject val = CreateNetworkedRoot("vfx_BifrostChannel", 45f); Transform transform = new GameObject("portal").transform; transform.SetParent(val.transform, false); ParticleSystem ps = AddParticles(transform, "portal_glow", s_glow, (ParticleSystemRenderMode)2); Configure(ps, (min: 1.2f, max: 1.2f), (min: 3.2f, max: 3.4f), 4f); SetColor(ps, Blue, Cyan, 0.3f, 0.7f, 0.6f); Spin(ps, 15f); ParticleSystem ps2 = AddParticles(transform, "portal_ring", s_ring, (ParticleSystemRenderMode)2); Configure(ps2, (min: 1.6f, max: 1.6f), (min: 2.8f, max: 2.8f), 2.5f); SetColor(ps2, Cyan, Blue, 0.25f, 0.6f, 0.9f); Grow(ps2, 0.9f, 1.05f); Spin(ps2, 40f); ParticleSystem ps3 = AddParticles(transform, "portal_pulse", s_ring, (ParticleSystemRenderMode)2); Configure(ps3, (min: 1.2f, max: 1.2f), (min: 2.4f, max: 2.4f), 1.2f); SetColor(ps3, Cyan, Violet, 0.05f, 0.35f, 0.8f); Grow(ps3, 0.3f, 1.6f); ParticleSystem obj = AddParticles(transform, "portal_runes", s_rune, (ParticleSystemRenderMode)0); Configure(obj, (min: 2.6f, max: 2.6f), (min: 0.22f, max: 0.32f), 10f); Circle(obj, 1.25f, 0f); Orbit(obj, 0.9f, 0.25f, 0f); SetColor(obj, Cyan, Blue, 0.2f, 0.7f, 1f); TextureSheetAnimationModule textureSheetAnimation = obj.textureSheetAnimation; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled = true; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).mode = (ParticleSystemAnimationMode)0; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesX = 2; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesY = 2; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).animation = (ParticleSystemAnimationType)0; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).frameOverTime = new MinMaxCurve(0f, 0.999f); ((TextureSheetAnimationModule)(ref textureSheetAnimation)).cycleCount = 1; ParticleSystem ps4 = AddParticles(transform, "swirl", s_glow, (ParticleSystemRenderMode)0); Configure(ps4, (min: 2.2f, max: 2.8f), (min: 0.06f, max: 0.13f), 70f); Circle(ps4, 0.85f, 0.15f); Orbit(ps4, 3.2f, 0.9f, -0.15f); SetColor(ps4, Cyan, Blue, Violet, 0.1f, 0.65f); Trails(ps4, 0.7f, 0.35f); ParticleSystem ps5 = AddParticles(transform, "swirl_outer", s_glow, (ParticleSystemRenderMode)0); Configure(ps5, (min: 2.8f, max: 3.2f), (min: 0.1f, max: 0.2f), 30f); Circle(ps5, 1.4f, 0.2f); Orbit(ps5, -1.6f, 0.5f, 0f); SetColor(ps5, Violet, Blue, Cyan, 0.2f, 0.6f); ParticleSystem ps6 = AddParticles(val.transform, "sparkles", s_spark, (ParticleSystemRenderMode)0); Configure(ps6, (min: 0.6f, max: 1.1f), (min: 0.15f, max: 0.35f), 30f); Sphere(ps6, 1.1f); SetColor(ps6, Color.white, Cyan, 0.15f, 0.5f, 1f); Spin(ps6, 90f); AddLight(val.transform, "light", Cyan, 7f); val.AddComponent<BifrostChannelVfx>(); PrefabManager.Instance.AddPrefab(val); return val; } public static GameObject CreateDepartEffect() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) if (!LoadMaterials()) { return null; } GameObject val = CreateNetworkedRoot("vfx_BifrostDepart", 4f); ParticleSystem val2 = AddParticles(val.transform, "burst", s_glow, (ParticleSystemRenderMode)0, new Vector3(0f, 1f, 0f)); Configure(val2, (min: 0.8f, max: 1.6f), (min: 0.06f, max: 0.14f), 0f, loop: false); Burst(val2, (0f, 160)); Sphere(val2, 0.6f); MainModule main = val2.main; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).startSpeed = new MinMaxCurve(2f, 6f); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.3f); ((MainModule)(ref main)).startColor = new MinMaxGradient(Cyan, Violet); SetColor(val2, Color.white, Color.white, 0.02f, 0.5f, 1f); Trails(val2, 0.6f, 0.25f); ParticleSystem val3 = AddParticles(val.transform, "pillar", s_glow, (ParticleSystemRenderMode)3, new Vector3(0f, 4f, 0f)); Configure(val3, (min: 0.9f, max: 0.9f), (min: 1f, max: 1f), 0f, loop: false); Burst(val3, (0f, 3)); main = val3.main; ((MainModule)(ref main)).startSize3D = true; ((MainModule)(ref main)).startSizeX = MinMaxCurve.op_Implicit(1.4f); ((MainModule)(ref main)).startSizeY = MinMaxCurve.op_Implicit(9f); ((MainModule)(ref main)).startSizeZ = MinMaxCurve.op_Implicit(1f); SizeOverLifetimeModule sizeOverLifetime = val3.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).separateAxes = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).x = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 0.2f)); ((SizeOverLifetimeModule)(ref sizeOverLifetime)).y = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 1.2f)); ((SizeOverLifetimeModule)(ref sizeOverLifetime)).z = new MinMaxCurve(1f); SetColor(val3, Color.white, Cyan, 0.05f, 0.4f, 0.9f); ParticleSystem ps = AddParticles(val.transform, "shockwave", s_ring, (ParticleSystemRenderMode)2, new Vector3(0f, 0.1f, 0f)); Configure(ps, (min: 0.7f, max: 0.7f), (min: 1.5f, max: 1.5f), 0f, loop: false); Burst(ps, (0f, 1), (0.15f, 1)); Grow(ps, 0.4f, 4f); SetColor(ps, Color.white, Cyan, 0.02f, 0.3f, 1f); ParticleSystem ps2 = AddParticles(val.transform, "sparkles", s_spark, (ParticleSystemRenderMode)0, new Vector3(0f, 1f, 0f)); Configure(ps2, (min: 0.4f, max: 0.9f), (min: 0.2f, max: 0.45f), 0f, loop: false); Burst(ps2, (0f, 40)); Sphere(ps2, 1.5f); SetColor(ps2, Color.white, Cyan, 0.05f, 0.5f, 1f); ((Component)AddLight(val.transform, "light", Cyan, 10f)).transform.localPosition = new Vector3(0f, 1f, 0f); val.AddComponent<BifrostDepartVfx>(); PrefabManager.Instance.AddPrefab(val); return val; } private static GameObject CreateNetworkedRoot(string name, float lifetime) { GameObject val = PrefabManager.Instance.CreateClonedPrefab(name, "vfx_Potion_stamina_medium"); Transform[] array = Children(val.transform); for (int i = 0; i < array.Length; i++) { Object.DestroyImmediate((Object)(object)((Component)array[i]).gameObject); } if ((Object)(object)val.GetComponent<ZNetView>() == (Object)null) { val.AddComponent<ZNetView>(); } TimedDestruction val2 = val.GetComponent<TimedDestruction>(); if ((Object)(object)val2 == (Object)null) { val2 = val.AddComponent<TimedDestruction>(); } val2.m_timeout = lifetime; val2.m_triggerOnAwake = true; return val; } private static Transform[] Children(Transform parent) { Transform[] array = (Transform[])(object)new Transform[parent.childCount]; for (int i = 0; i < array.Length; i++) { array[i] = parent.GetChild(i); } return array; } private static bool LoadMaterials() { if ((Object)(object)s_glow != (Object)null) { return true; } Material prefab = Cache.GetPrefab<Material>("item_particle"); Material val = Cache.GetPrefab<Material>("light_glow") ?? prefab; Material source = Cache.GetPrefab<Material>("glow_pulse") ?? val; if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)"Bifrost effects disabled: vanilla particle materials not found"); return false; } s_glow = CopyMaterial(val, "bifrost_glow"); s_ring = CopyMaterial(source, "bifrost_ring"); s_spark = CopyMaterial(prefab ?? val, "bifrost_spark"); s_rune = CopyMaterial(val, "bifrost_rune"); Texture2D prefab2 = Cache.GetPrefab<Texture2D>("PortalRunes"); if ((Object)(object)prefab2 != (Object)null && !BifrostBrewPlugin.IsHeadless) { s_rune.mainTexture = (Texture)(object)RunesWithAlpha(prefab2); } return true; } private static Material CopyMaterial(Material source, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(source) { name = name }; if (val.HasProperty("_TintColor")) { val.SetColor("_TintColor", new Color(1f, 1f, 1f, 0.5f)); } return val; } private static Texture2D RunesWithAlpha(Texture2D runes) { //IL_0019: 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) Texture2D val = BifrostBrewPlugin.CopyRegion((Texture)(object)runes, new Rect(0f, 0f, (float)((Texture)runes).width, (float)((Texture)runes).height), mipChain: true); ((Texture)val).wrapMode = (TextureWrapMode)1; Color[] pixels = val.GetPixels(); for (int i = 0; i < pixels.Length; i++) { pixels[i] = new Color(1f, 1f, 1f, pixels[i].r); } val.SetPixels(pixels); val.Apply(true, true); return val; } private static ParticleSystem AddParticles(Transform parent, string name, Material material, ParticleSystemRenderMode renderMode, Vector3 localPosition = default(Vector3)) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0066: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = localPosition; ParticleSystem obj = val.AddComponent<ParticleSystem>(); MainModule main = obj.main; ((MainModule)(ref main)).playOnAwake = true; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0; ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0; ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.white); ((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f); ((MainModule)(ref main)).maxParticles = 500; ShapeModule shape = obj.shape; ((ShapeModule)(ref shape)).enabled = false; ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>(); ((Renderer)component).sharedMaterial = material; component.renderMode = renderMode; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; return obj; } private static void Configure(ParticleSystem ps, (float min, float max) lifetime, (float min, float max) size, float rate, bool loop = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) MainModule main = ps.main; ((MainModule)(ref main)).loop = loop; ((MainModule)(ref main)).duration = (loop ? 5f : 1f); ((MainModule)(ref main)).startLifetime = new MinMaxCurve(lifetime.min, lifetime.max); ((MainModule)(ref main)).startSize = new MinMaxCurve(size.min, size.max); EmissionModule emission = ps.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(rate); } private static void Burst(ParticleSystem ps, params (float time, short count)[] bursts) { //IL_0027: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Burst[] array = (Burst[])(object)new Burst[bursts.Length]; for (int i = 0; i < bursts.Length; i++) { array[i] = new Burst(bursts[i].time, bursts[i].count); } EmissionModule emission = ps.emission; ((EmissionModule)(ref emission)).SetBursts(array); } private static void Circle(ParticleSystem ps, float radius, float thickness) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) ShapeModule shape = ps.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10; ((ShapeModule)(ref shape)).radius = radius; ((ShapeModule)(ref shape)).radiusThickness = thickness; ((ShapeModule)(ref shape)).rotation = new Vector3(90f, 0f, 0f); } private static void Sphere(ParticleSystem ps, float radius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) ShapeModule shape = ps.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = radius; } private static void Orbit(ParticleSystem ps, float orbitY, float upward, float radial) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) VelocityOverLifetimeModule velocityOverLifetime = ps.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = MinMaxCurve.op_Implicit(0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = MinMaxCurve.op_Implicit(upward); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = MinMaxCurve.op_Implicit(0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalX = MinMaxCurve.op_Implicit(0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalY = MinMaxCurve.op_Implicit(orbitY); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalZ = MinMaxCurve.op_Implicit(0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).radial = MinMaxCurve.op_Implicit(radial); } private static void Spin(ParticleSystem ps, float degreesPerSecond) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) RotationOverLifetimeModule rotationOverLifetime = ps.rotationOverLifetime; ((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true; ((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = MinMaxCurve.op_Implicit(degreesPerSecond * ((float)Math.PI / 180f)); } private static void Grow(ParticleSystem ps, float from, float to) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) SizeOverLifetimeModule sizeOverLifetime = ps.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, from, 1f, to)); } private static void Trails(ParticleSystem ps, float ratio, float lifetime) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) TrailModule trails = ps.trails; ((TrailModule)(ref trails)).enabled = true; ((TrailModule)(ref trails)).ratio = ratio; ((TrailModule)(ref trails)).lifetime = MinMaxCurve.op_Implicit(lifetime); ((TrailModule)(ref trails)).dieWithParticles = true; ((TrailModule)(ref trails)).sizeAffectsWidth = true; ((TrailModule)(ref trails)).inheritParticleColor = true; ((TrailModule)(ref trails)).widthOverTrail = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 0f)); ((Component)ps).GetComponent<ParticleSystemRenderer>().trailMaterial = ((Renderer)((Component)ps).GetComponent<ParticleSystemRenderer>()).sharedMaterial; } private static void SetColor(ParticleSystem ps, Color a, Color b, float fadeIn, float fadeOut, float maxAlpha) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) SetGradient(ps, (GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(a, 0f), new GradientColorKey(b, 1f) }, fadeIn, fadeOut, maxAlpha); } private static void SetColor(ParticleSystem ps, Color a, Color b, Color c, float fadeIn, float fadeOut) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) SetGradient(ps, (GradientColorKey[])(object)new GradientColorKey[3] { new GradientColorKey(a, 0f), new GradientColorKey(b, 0.5f), new GradientColorKey(c, 1f) }, fadeIn, fadeOut, 1f); } private static void SetGradient(ParticleSystem ps, GradientColorKey[] colors, float fadeIn, float fadeOut, float maxAlpha) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) Gradient val = new Gradient(); val.SetKeys(colors, (GradientAlphaKey[])(object)new GradientAlphaKey[4] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(maxAlpha, fadeIn), new GradientAlphaKey(maxAlpha, fadeOut), new GradientAlphaKey(0f, 1f) }); ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val); } private static Light AddLight(Transform parent, string name, Color color, float range) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); Light obj = val.AddComponent<Light>(); obj.type = (LightType)2; obj.color = color; obj.range = range; obj.intensity = 0f; obj.shadows = (LightShadows)0; return obj; } } public class BifrostChannelVfx : MonoBehaviour { private const float OpenTime = 0.9f; private Transform m_portal; private Light m_light; private float m_time; private void Awake() { m_portal = ((Component)this).transform.Find("portal"); m_light = ((Component)this).GetComponentInChildren<Light>(); } private void Start() { PlaceOnGround(); Apply(0f); } private void Update() { m_time += Time.deltaTime; Apply(m_time); } private void Apply(float t) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(t / 0.9f)); if ((Object)(object)m_portal != (Object)null) { m_portal.localScale = Vector3.one * Mathf.Max(0.01f, num); } if ((Object)(object)m_light != (Object)null) { m_light.intensity = num * (2.2f + 0.5f * Mathf.Sin(t * 5f)); } } private void PlaceOnGround() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00d4: 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) if (!((Object)(object)m_portal == (Object)null)) { RaycastHit val = default(RaycastHit); float num = (((Object)(object)((Component)this).transform.parent != (Object)null) ? ((Component)this).transform.parent.position.y : ((!Physics.Raycast(((Component)this).transform.position, Vector3.down, ref val, 3f, LayerMask.GetMask(new string[5] { "Default", "static_solid", "terrain", "piece", "vehicle" }))) ? (((Component)this).transform.position.y - 0.9f) : ((RaycastHit)(ref val)).point.y)); m_portal.position = new Vector3(((Component)this).transform.position.x, num + 0.05f, ((Component)this).transform.position.z); } } } public class BifrostDepartVfx : MonoBehaviour { private const float FlashTime = 0.8f; private Light m_light; private float m_time; private void Awake() { m_light = ((Component)this).GetComponentInChildren<Light>(); } private void Update() { m_time += Time.deltaTime; if (!((Object)(object)m_light == (Object)null)) { float num = 1f - Mathf.Clamp01(m_time / 0.8f); m_light.intensity = 8f * num * num; } } }