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 Firefly v1.0.11
Firefly.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using ConditionalConfigSync; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Firefly")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Firefly")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("89ae6db4-e324-4aa5-b7f3-41efbd49d8b8")] [assembly: AssemblyFileVersion("1.0.11")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.11.0")] [module: UnverifiableCode] namespace Firefly; [BepInPlugin("shudnal.Firefly", "Firefly", "1.0.11")] [BepInDependency("_shudnal.ConditionalConfigSync", "1.0.5")] public class Firefly : BaseUnityPlugin { [HarmonyPatch(typeof(ZNetView), "Awake")] public static class ZNetView_Awake_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ZSyncTransform), "Awake")] public static class ZSyncTransform_Awake_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ZSyncTransform), "OnEnable")] public static class ZSyncTransform_OnEnable_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ItemDrop), "Awake")] public static class ItemDrop_Awake_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ItemDrop), "Start")] public static class ItemDrop_Start_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } public const string pluginID = "shudnal.Firefly"; public const string pluginName = "Firefly"; public const string pluginVersion = "1.0.11"; private readonly Harmony harmony = new Harmony("shudnal.Firefly"); internal static readonly ConfigSync configSync = new ConfigSync("shudnal.Firefly") { DisplayName = "Firefly", CurrentVersion = "1.0.11", MinimumRequiredVersion = "1.0.11" }; internal static Firefly instance; private static ConfigEntry<bool> configLocked; private static ConfigEntry<bool> loggingEnabled; public static ConfigEntry<int> itemStackSize; public static ConfigEntry<string> itemCraftingStation; public static ConfigEntry<int> itemMinStationLevel; public static ConfigEntry<int> statusEffectDuration; public static ConfigEntry<string> itemRecipe; public static ConfigEntry<float> itemWeight; public static ConfigEntry<Color> lightColor; public static ConfigEntry<float> lightIntensityOutdoors; public static ConfigEntry<float> lightRangeOutdoors; public static ConfigEntry<float> lightShadowsOutdoors; public static ConfigEntry<float> lightIntensityIndoors; public static ConfigEntry<float> lightRangeIndoors; public static ConfigEntry<float> lightShadowsIndoors; public static ConfigEntry<bool> showLightSource; public static ConfigEntry<bool> showLightFlare; private const string c_rootObjectName = "_shudnalRoot"; private const string c_rootPrefabsName = "Prefabs"; private static GameObject rootObject; private static GameObject rootPrefabs; public static GameObject fireflyPrefab; public static Sprite itemIcon; public static GameObject ballPrefab; public static bool prefabInit = false; private void Awake() { harmony.PatchAll(); instance = this; ConfigInit(); ((ConditionalConfigSync)configSync).AddLockingConfigEntry<bool>(configLocked); Game.isModded = true; LoadIcons(); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); instance = null; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } public static void LogInfo(object data) { if (loggingEnabled.Value) { ((BaseUnityPlugin)instance).Logger.LogInfo(data); } } public void ConfigInit() { //IL_01b4: Unknown result type (might be due to invalid IL or missing references) configLocked = config("General", "Lock Configuration", defaultValue: true, "Configuration is locked and can be changed by server admins only"); loggingEnabled = config("General", "Logging enabled", defaultValue: false, "Enable logging. [Not Synced with Server]", synchronizedSetting: false); itemStackSize = config("Item", "Stack size", 20, "How many items in stack"); itemCraftingStation = config("Item", "Crafting station", "$piece_workbench", "Station to craft item. Leave empty to craft with hands"); itemMinStationLevel = config("Item", "Crafting station level", 3, "Minimum level of station required to craft"); statusEffectDuration = config("Item", "Duration", 300, "Duration of status effect"); itemRecipe = config("Item", "Recipe", "Dandelion:1,GreydwarfEye:1,Resin:2", "Item recipe"); itemWeight = config("Item", "Weight", 0.5f, "Item weight"); itemCraftingStation.SettingChanged += delegate { FireflyItem.SetFireFlyRecipe(); }; itemMinStationLevel.SettingChanged += delegate { FireflyItem.SetFireFlyRecipe(); }; itemWeight.SettingChanged += delegate { FireflyItem.PatchLanternItemOnConfigChange(); }; itemStackSize.SettingChanged += delegate { FireflyItem.PatchLanternItemOnConfigChange(); }; lightColor = config<Color>("Light", "Color", new Color(1f, 0.62f, 0.48f), "Color of firefly light"); lightIntensityOutdoors = config("Light - Outdoors", "Intensity", 1f, "Intensity of light"); lightRangeOutdoors = config("Light - Outdoors", "Range", 30f, "Range of light"); lightShadowsOutdoors = config("Light - Outdoors", "Shadows strength", 0.8f, "Strength of shadows"); lightIntensityIndoors = config("Light - Indoors", "Intensity", 0.8f, "Intensity of light"); lightRangeIndoors = config("Light - Indoors", "Range", 20f, "Range of light"); lightShadowsIndoors = config("Light - Indoors", "Shadows strength", 0.9f, "Strength of shadows"); showLightSource = config("Misc", "Show point of light source", defaultValue: false, "Show floating point of light. Restart to see changes."); showLightFlare = config("Misc", "Show flare around light source", defaultValue: false, "Show flare surrounding point of light. Restart to see changes."); } private ConfigEntry<T> config<T>(string group, string name, T defaultValue, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, defaultValue, description); ((ConditionalConfigSync)configSync).AddConfigEntry<T>(val, (ConfigSyncMode)1, synchronizedSetting); return val; } private ConfigEntry<T> config<T>(string group, string name, T defaultValue, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } private void LoadIcons() { LoadIcon("firefly.png", ref itemIcon); } private void LoadIcon(string filename, ref Sprite icon) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Texture2D tex = new Texture2D(2, 2); if (LoadTexture(filename, ref tex)) { icon = Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), Vector2.zero); } } private bool LoadTexture(string filename, ref Texture2D tex) { string text = Path.Combine(Paths.PluginPath, filename); if (File.Exists(text)) { LogInfo("Loaded image: " + text); return ImageConversion.LoadImage(tex, File.ReadAllBytes(text)); } Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename)); Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(name); byte[] array = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(array, 0, array.Length); return ImageConversion.LoadImage(tex, array, true); } private static void InitRootObject() { //IL_0023: 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_008c: Expected O, but got Unknown if ((Object)(object)rootObject == (Object)null) { rootObject = (GameObject)(((object)GameObject.Find("_shudnalRoot")) ?? ((object)new GameObject("_shudnalRoot"))); } Object.DontDestroyOnLoad((Object)(object)rootObject); if ((Object)(object)rootPrefabs == (Object)null) { Transform obj = rootObject.transform.Find("Prefabs"); rootPrefabs = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)rootPrefabs == (Object)null) { rootPrefabs = new GameObject("Prefabs"); rootPrefabs.transform.SetParent(rootObject.transform, false); rootPrefabs.SetActive(false); } } } public static GameObject InitPrefabClone(GameObject prefabToClone, string prefabName) { InitRootObject(); if ((Object)(object)rootPrefabs.transform.Find(prefabName) != (Object)null) { return ((Component)rootPrefabs.transform.Find(prefabName)).gameObject; } prefabInit = true; GameObject val = Object.Instantiate<GameObject>(prefabToClone, rootPrefabs.transform, false); prefabInit = false; ((Object)val).name = prefabName; return val; } } internal class FireflyItem { [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDB_Awake_AddPrefab { private static void Postfix(ObjectDB __instance) { if (__instance.m_items.Count != 0 && !((Object)(object)__instance.GetItemPrefab("Wood") == (Object)null)) { RegisterFireflyPrefab(); } } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class ObjectDB_CopyOtherDB_AddPrefab { private static void Postfix(ObjectDB __instance) { if (__instance.m_items.Count != 0 && !((Object)(object)__instance.GetItemPrefab("Wood") == (Object)null)) { RegisterFireflyPrefab(); } } } [HarmonyPatch(typeof(FejdStartup), "OnDestroy")] public static class FejdStartup_OnDestroy_AddPrefab { private static void Prefix() { ClearPrefabReferences(); } } [HarmonyPatch(typeof(FejdStartup), "SetupGui")] public static class FejdStartup_SetupGui_AddLocalizedWords { private static void Postfix() { Localization_SetupLanguage_AddLocalizedWords.AddTranslations(Localization.instance, PlatformPrefs.GetString("language", "English")); } } [HarmonyPatch(typeof(Localization), "SetupLanguage")] public static class Localization_SetupLanguage_AddLocalizedWords { private static void Postfix(Localization __instance, string language) { AddTranslations(__instance, language); } public static void AddTranslations(Localization localization, string language) { localization.AddWord("item_firefly", GetItemName(language)); localization.AddWord("item_firefly_description", GetItemDescription(language)); localization.AddWord("se_firefly_description", GetStatusEffectTooltip(language)); } private static string GetItemName(string language) { if (1 == 0) { } string result = language switch { "Russian" => "Светлячок", "Chinese" => "萤火虫", "Chinese_Trad" => "螢火蟲", "French" => "Luciole", "German" => "Glühwürmchen", "Polish" => "Świetlik", "Korean" => "반딧불이", "Spanish" => "Luciérnaga", "Turkish" => "Ateşböceği", "Dutch" => "Glimworm", "Portuguese_Brazilian" => "Vaga-lume", "Japanese" => "ホタル", "Ukrainian" => "Світлячок", _ => "Firefly", }; if (1 == 0) { } return result; } private static string GetItemDescription(string language) { if (1 == 0) { } string result = language switch { "Russian" => "Светлячок, который проведет вас через самые темные ночи", "Chinese" => "一只被束缚的萤火虫,引导你度过最黑暗的夜晚", "Chinese_Trad" => "一隻被束縛的螢火蟲,引導你度過最黑暗的夜晚", "French" => "Une luciole liée pour vous guider à travers les nuits les plus sombres", "German" => "Ein gebundenes Glühwürmchen, das Sie durch die dunkelste Nacht führt", "Polish" => "Związany świetlik, który poprowadzi Cię przez najciemniejsze noce", "Korean" => "가장 어두운 밤을 안내할 묶인 반딧불이", "Spanish" => "Una luciérnaga atada que te guiará a través de las noches más oscuras.", "Turkish" => "En karanlık gecelerde size rehberlik edecek bağlı bir ateş böceği", "Dutch" => "Een gebonden vuurvliegje om je door de donkerste nachten te leiden", "Portuguese_Brazilian" => "Um vaga-lume preso para guiá-lo nas noites mais escuras", "Japanese" => "縛られたホタルがあなたを最も暗い夜へと導きます", "Ukrainian" => "Прив’язаний світлячок проведе вас у найтемніші ночі", _ => "A bound firefly to guide you through the darkest of nights", }; if (1 == 0) { } return result; } private static string GetStatusEffectTooltip(string language) { if (1 == 0) { } string result = language switch { "Russian" => "Выпустите светлячка, который будет сопровождать вас некоторое время", "Chinese" => "释放一只会陪伴你一段时间的萤火虫", "Chinese_Trad" => "釋放一隻會陪伴你一段時間的螢火蟲", "French" => "Libérez une luciole qui vous accompagnera pendant quelques temps", "German" => "Lassen Sie ein Glühwürmchen los, das Sie einige Zeit begleiten wird", "Polish" => "Wypuść świetlika, a będzie Ci towarzyszył przez jakiś czas", "Korean" => "한동안 동행할 반딧불을 풀어주세요", "Spanish" => "Suelta una luciérnaga que te acompañará durante un tiempo", "Turkish" => "Bir süre size eşlik edecek bir ateş böceğini serbest bırakın", "Dutch" => "Laat een vuurvlieg los die je een tijdje zal vergezellen", "Portuguese_Brazilian" => "Solte um vaga-lume que irá te acompanhar por algum tempo", "Japanese" => "しばらくあなたに同行するホタルを放ちます", "Ukrainian" => "Випустіть світлячка, який буде супроводжувати вас деякий час", _ => "Release a firefly that will accompany you for some time", }; if (1 == 0) { } return result; } } public const string itemName = "Firefly"; public static int itemHash = StringExtensionMethods.GetStableHashCode("Firefly"); public const string itemDropName = "$item_firefly"; public const string itemDropDescription = "$item_firefly_description"; public const string statusEffectDescription = "$se_firefly_description"; private static void CreateFireflyPrefab() { //IL_0056: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Wisp"); if (!((Object)(object)itemPrefab == (Object)null)) { Firefly.fireflyPrefab = Firefly.InitPrefabClone(itemPrefab, "Firefly"); Transform val = Firefly.fireflyPrefab.transform.Find("demister_ball"); ((Object)val).name = "firefly_ball"; val.localScale *= 0.75f; MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>(); ((Renderer)component).sharedMaterial = new Material(((Renderer)component).sharedMaterial) { name = "firefly_ball" }; ((Renderer)component).sharedMaterial.SetColor("_EmissionColor", Firefly.lightColor.Value); MainModule main = ((Component)Firefly.fireflyPrefab.transform.Find("flare")).GetComponent<ParticleSystem>().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.5f, 0f, 0.4f)); ParticleSystemRenderer component2 = ((Component)Firefly.fireflyPrefab.transform.Find("sparcs_front")).GetComponent<ParticleSystemRenderer>(); ((Renderer)component2).sharedMaterial = new Material(((Renderer)component2).sharedMaterial); ((Object)((Renderer)component2).sharedMaterial).name = "firefly_sparcs"; ((Renderer)component2).sharedMaterial.SetColor("_EmissionColor", Firefly.lightColor.Value); ((Component)Firefly.fireflyPrefab.transform.Find("Point light")).GetComponent<Light>().color = Firefly.lightColor.Value; Firefly.LogInfo("Created prefab " + ((Object)Firefly.fireflyPrefab).name); } } internal static void PatchFireFlyItemData(ItemData itemData) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (itemData != null) { itemData.m_dropPrefab = Firefly.fireflyPrefab; itemData.m_shared.m_icons[0] = Firefly.itemIcon; itemData.m_shared.m_name = "$item_firefly"; itemData.m_shared.m_description = "$item_firefly_description"; itemData.m_shared.m_itemType = (ItemType)2; itemData.m_shared.m_consumeStatusEffect = ObjectDB.instance.GetStatusEffect(SE_Firefly.statusEffectHash); itemData.m_shared.m_maxStackSize = Firefly.itemStackSize.Value; itemData.m_shared.m_maxQuality = 1; itemData.m_shared.m_weight = Firefly.itemWeight.Value; } } private static void RegisterFireflyPrefab() { ClearPrefabReferences(); if (!Object.op_Implicit((Object)(object)Firefly.fireflyPrefab)) { CreateFireflyPrefab(); } if (!Object.op_Implicit((Object)(object)Firefly.fireflyPrefab)) { return; } ItemData val = Firefly.fireflyPrefab.GetComponent<ItemDrop>()?.m_itemData; PatchFireFlyItemData(val); if (Object.op_Implicit((Object)(object)ObjectDB.instance) && !ObjectDB.instance.m_itemByHash.ContainsKey(itemHash)) { ObjectDB.instance.m_items.Add(Firefly.fireflyPrefab); ObjectDB.instance.m_itemByHash.Add(itemHash, Firefly.fireflyPrefab); if (val != null) { ObjectDB.instance.m_itemByData[val.m_shared] = Firefly.fireflyPrefab; } } if (Object.op_Implicit((Object)(object)ZNetScene.instance) && !ZNetScene.instance.m_namedPrefabs.ContainsKey(itemHash)) { ZNetScene.instance.m_prefabs.Add(Firefly.fireflyPrefab); ZNetScene.instance.m_namedPrefabs.Add(itemHash, Firefly.fireflyPrefab); } SetFireFlyRecipe(); } internal static void SetFireFlyRecipe() { //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)ObjectDB.instance)) { return; } if (ObjectDB.instance.m_recipes.RemoveAll((Recipe x) => ((Object)x).name == "Firefly") > 0) { Firefly.LogInfo("Replaced recipe Firefly"); } CraftingStation val = (string.IsNullOrWhiteSpace(Firefly.itemCraftingStation.Value) ? null : ((IEnumerable<Recipe>)ObjectDB.instance.m_recipes).FirstOrDefault((Func<Recipe, bool>)((Recipe rec) => rec.m_craftingStation?.m_name == Firefly.itemCraftingStation.Value))?.m_craftingStation); ItemDrop component = Firefly.fireflyPrefab.GetComponent<ItemDrop>(); Recipe val2 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val2).name = "Firefly"; val2.m_amount = 1; val2.m_minStationLevel = Firefly.itemMinStationLevel.Value; val2.m_item = component; val2.m_enabled = true; if ((Object)(object)val != (Object)null) { val2.m_craftingStation = val; } List<Requirement> list = new List<Requirement>(); string[] array = Firefly.itemRecipe.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { string[] array2 = text.Split(new char[1] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (array2.Length != 2) { continue; } int num2 = int.Parse(array2[1]); if (num2 > 0) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(array2[0].Trim()); if (!((Object)(object)itemPrefab == (Object)null)) { list.Add(new Requirement { m_amount = num2, m_resItem = itemPrefab.GetComponent<ItemDrop>() }); } } } val2.m_resources = list.ToArray(); ObjectDB.instance.m_recipes.Add(val2); } private static void ClearPrefabReferences() { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && ObjectDB.instance.m_itemByHash.ContainsKey(itemHash)) { ObjectDB.instance.m_items.Remove(ObjectDB.instance.m_itemByHash[itemHash]); ObjectDB.instance.m_itemByHash.Remove(itemHash); } if (Object.op_Implicit((Object)(object)ZNetScene.instance) && ZNetScene.instance.m_namedPrefabs.ContainsKey(itemHash)) { ZNetScene.instance.m_prefabs.Remove(ZNetScene.instance.m_namedPrefabs[itemHash]); ZNetScene.instance.m_namedPrefabs.Remove(itemHash); } } internal static void PatchInventory(Inventory inventory) { if (inventory == null) { return; } List<ItemData> list = new List<ItemData>(); inventory.GetAllItems("$item_firefly", list); foreach (ItemData item in list) { PatchFireFlyItemData(item); } } internal static void PatchLanternItemOnConfigChange() { GameObject fireflyPrefab = Firefly.fireflyPrefab; PatchFireFlyItemData((fireflyPrefab == null) ? null : fireflyPrefab.GetComponent<ItemDrop>()?.m_itemData); Player localPlayer = Player.m_localPlayer; PatchInventory((localPlayer != null) ? ((Humanoid)localPlayer).GetInventory() : null); } } public class SE_Firefly : StatusEffect { [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDB_Awake_AddStatusEffects { [HarmonyPriority(500)] private static void Postfix(ObjectDB __instance) { AddCustomStatusEffect(__instance); } } public const string statusEffectName = "Firefly"; public static int statusEffectHash = StringExtensionMethods.GetStableHashCode("Firefly"); public const string ballPrefabName = "firefly_ball"; public static int ballPrefaHash = StringExtensionMethods.GetStableHashCode("firefly_ball"); public LightFlicker m_lightFlicker; public LightLod m_lightLod; public Light m_light; public bool m_indoors; [Header("SE_Firefly")] public GameObject m_ballPrefab; public Vector3 m_offset = new Vector3(0.1f, 3.5f, 0.1f); public Vector3 m_offsetInterior = new Vector3(0.5f, 2.1f, 0f); public float m_maxDistance = 7f; public float m_ballAcceleration = 6f; public float m_ballMaxSpeed = 60f; public float m_ballFriction = 0.02f; public float m_noiseDistance = 1.35f; public float m_noiseDistanceInterior = 0.2f; public float m_noiseDistanceYScale = 0.35f; public float m_noiseSpeed = 0.4f; public float m_characterVelocityFactor = 3f; public float m_rotationSpeed = 8f; public int m_coverRayMask; public GameObject m_ballInstance; public Vector3 m_ballVel = new Vector3(0f, 0f, 0f); public override void Setup(Character character) { ((StatusEffect)this).Setup(character); if (m_coverRayMask == 0) { m_coverRayMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" }); } } private void SetLightIntensity(float intensity) { m_light.intensity = intensity; m_lightFlicker.m_baseIntensity = intensity; } public static void AddCustomStatusEffect(ObjectDB odb) { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) if (odb.m_StatusEffects.Count <= 0) { return; } StatusEffect? obj = odb.m_StatusEffects.Find((StatusEffect se) => ((Object)se).name == "Demister"); SE_Demister val = (SE_Demister)(object)((obj is SE_Demister) ? obj : null); if (!((Object)(object)val != (Object)null) || odb.m_StatusEffects.Any((StatusEffect se) => ((Object)se).name == "Firefly")) { return; } SE_Firefly sE_Firefly = ScriptableObject.CreateInstance<SE_Firefly>(); ((Object)sE_Firefly).name = "Firefly"; ((StatusEffect)sE_Firefly).m_nameHash = statusEffectHash; ((StatusEffect)sE_Firefly).m_icon = Firefly.itemIcon; ((StatusEffect)sE_Firefly).m_name = "$item_firefly"; ((StatusEffect)sE_Firefly).m_tooltip = "$se_firefly_description"; ((StatusEffect)sE_Firefly).m_ttl = Firefly.statusEffectDuration.Value; ((StatusEffect)sE_Firefly).m_startMessageType = (MessageType)1; if ((Object)(object)Firefly.ballPrefab == (Object)null) { CloneBallPrefab(val.m_ballPrefab); } if ((Object)(object)Firefly.ballPrefab != (Object)null) { sE_Firefly.m_ballPrefab = Firefly.ballPrefab; if (Object.op_Implicit((Object)(object)ZNetScene.instance) && !ZNetScene.instance.m_namedPrefabs.ContainsKey(ballPrefaHash)) { ZNetScene.instance.m_prefabs.Add(Firefly.ballPrefab); ZNetScene.instance.m_namedPrefabs.Add(ballPrefaHash, Firefly.ballPrefab); } } odb.m_StatusEffects.Add((StatusEffect)(object)sE_Firefly); } public static void CloneBallPrefab(GameObject demisterBall) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00e2: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Expected O, but got Unknown //IL_0255: 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_029c: 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_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Expected O, but got Unknown //IL_02e1: 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_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_032e: 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) if ((Object)(object)demisterBall == (Object)null) { return; } Firefly.ballPrefab = Firefly.InitPrefabClone(demisterBall, "firefly_ball"); Object.DestroyImmediate((Object)(object)((Component)Firefly.ballPrefab.transform.Find("effects/Particle System Force Field")).gameObject); Object.DestroyImmediate((Object)(object)Firefly.ballPrefab.GetComponent("Jewelcrafting.GemEffects.Wisplight/SetForceField")); GameObject gameObject = ((Component)Firefly.ballPrefab.transform.Find("demister_ball")).gameObject; if (Firefly.showLightSource.Value) { ((Object)gameObject).name = "firefly_ball"; gameObject.transform.localScale = Vector3.one * 0.03f; MeshRenderer component = gameObject.GetComponent<MeshRenderer>(); ((Renderer)component).sharedMaterial = new Material(((Renderer)component).sharedMaterial) { name = "firefly_ball" }; ((Renderer)component).sharedMaterial.SetColor("_EmissionColor", Firefly.lightColor.Value); } else { Object.DestroyImmediate((Object)(object)gameObject); } AudioSource component2 = ((Component)Firefly.ballPrefab.transform.Find("effects/SFX Start")).GetComponent<AudioSource>(); component2.volume = 0.2f; component2.pitch = 0.8f; AudioSource component3 = ((Component)Firefly.ballPrefab.transform.Find("effects/SFX")).GetComponent<AudioSource>(); component3.volume = 0.6f; component3.pitch = 0.75f; Light component4 = ((Component)Firefly.ballPrefab.transform.Find("effects/Point light")).GetComponent<Light>(); component4.intensity = Firefly.lightIntensityOutdoors.Value; component4.color = Firefly.lightColor.Value; component4.range = Firefly.lightRangeOutdoors.Value; component4.shadowStrength = Firefly.lightShadowsOutdoors.Value; component4.shadows = (LightShadows)((component4.shadowStrength > 0f) ? 2 : 0); Transform val = Firefly.ballPrefab.transform.Find("effects/flame"); for (int num = val.childCount - 1; num >= 0; num--) { Transform child = val.GetChild(num); if (((Object)child).name == "sparcs_front") { ParticleSystemRenderer component5 = ((Component)child).GetComponent<ParticleSystemRenderer>(); ((Renderer)component5).sharedMaterial = new Material(((Renderer)component5).sharedMaterial) { name = "firefly_sparcs" }; ((Renderer)component5).sharedMaterial.SetColor("_EmissionColor", Firefly.lightColor.Value); } else if (Firefly.showLightFlare.Value && ((Object)child).name == "flare") { child.localScale = Vector3.one * 0.5f; ParticleSystemRenderer component6 = ((Component)child).GetComponent<ParticleSystemRenderer>(); ((Renderer)component6).sharedMaterial = new Material(((Renderer)component6).sharedMaterial) { name = "firefly_flare" }; ((Renderer)component6).sharedMaterial.SetColor("_Color", Firefly.lightColor.Value); MainModule main = ((Component)child).GetComponent<ParticleSystem>().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(Firefly.lightColor.Value.r, Firefly.lightColor.Value.g, Firefly.lightColor.Value.b, 0.04f)); } else { Object.DestroyImmediate((Object)(object)((Component)val.GetChild(num)).gameObject); } } } public bool IsUnderRoof() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); return Physics.Raycast(base.m_character.GetCenterPoint(), Vector3.up, ref val, 4f, m_coverRayMask); } public override void UpdateStatusEffect(float dt) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: 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_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) ((StatusEffect)this).UpdateStatusEffect(dt); if (!Object.op_Implicit((Object)(object)m_ballInstance)) { Vector3 val = base.m_character.GetCenterPoint() + ((Component)base.m_character).transform.forward * 0.5f; m_ballInstance = Object.Instantiate<GameObject>(m_ballPrefab, val, Quaternion.identity); return; } _ = base.m_character; bool flag = IsUnderRoof(); Vector3 position = ((Component)base.m_character).transform.position; Vector3 val2 = m_ballInstance.transform.position; Vector3 val3 = (flag ? m_offsetInterior : m_offset); float num = (flag ? m_noiseDistanceInterior : m_noiseDistance); Vector3 val4 = position + ((Component)base.m_character).transform.TransformVector(val3); float num2 = Time.time * m_noiseSpeed; val4 += new Vector3(Mathf.Sin(num2 * 4f), Mathf.Sin(num2 * 2f) * m_noiseDistanceYScale, Mathf.Cos(num2 * 5f)) * num; float num3 = Vector3.Distance(val4, val2); Vector3 val5; if (num3 > m_maxDistance * 2f) { val2 = val4; } else if (num3 > m_maxDistance) { val5 = val2 - val4; Vector3 normalized = ((Vector3)(ref val5)).normalized; val2 = val4 + normalized * m_maxDistance; } val5 = val4 - val2; Vector3 normalized2 = ((Vector3)(ref val5)).normalized; m_ballVel += normalized2 * m_ballAcceleration * dt; if (((Vector3)(ref m_ballVel)).magnitude > m_ballMaxSpeed) { m_ballVel = ((Vector3)(ref m_ballVel)).normalized * m_ballMaxSpeed; } if (!flag) { Vector3 velocity = base.m_character.GetVelocity(); m_ballVel += velocity * m_characterVelocityFactor * dt; } m_ballVel -= m_ballVel * m_ballFriction; Vector3 position2 = val2 + m_ballVel * dt; m_ballInstance.transform.position = position2; Quaternion rotation = m_ballInstance.transform.rotation; rotation *= Quaternion.Euler(m_rotationSpeed, 0f, m_rotationSpeed * 0.5321f); m_ballInstance.transform.rotation = rotation; if (!Object.op_Implicit((Object)(object)m_light) || !Object.op_Implicit((Object)(object)m_lightFlicker) || !Object.op_Implicit((Object)(object)m_lightLod)) { m_lightFlicker = m_ballInstance.GetComponentInChildren<LightFlicker>(); m_light = m_ballInstance.GetComponentInChildren<Light>(); m_lightLod = m_ballInstance.GetComponentInChildren<LightLod>(); } if (base.m_ttl != 0f && base.m_ttl - ((StatusEffect)this).GetDuration() <= base.m_ttl * 0.1f) { SetLightIntensity(0.4f + 0.6f * (base.m_ttl - ((StatusEffect)this).GetDuration()) / (base.m_ttl * 0.1f)); } else if (base.m_character.InInterior() && !m_indoors) { m_indoors = true; SetLightIntensity(Firefly.lightIntensityIndoors.Value); m_light.range = Firefly.lightRangeIndoors.Value; m_light.shadowStrength = Firefly.lightShadowsIndoors.Value; m_lightLod.m_lightDistance = 40f; m_lightLod.m_baseRange = m_light.range; m_lightLod.m_baseShadowStrength = m_light.shadowStrength; m_light.shadows = (LightShadows)((m_light.shadowStrength > 0f) ? 2 : 0); } else if (!base.m_character.InInterior() && m_indoors) { m_indoors = true; SetLightIntensity(Firefly.lightIntensityOutdoors.Value); m_light.range = Firefly.lightRangeOutdoors.Value; m_light.shadowStrength = Firefly.lightShadowsOutdoors.Value; m_lightLod.m_lightDistance = 40f; m_lightLod.m_baseRange = m_light.range; m_lightLod.m_baseShadowStrength = m_light.shadowStrength; m_light.shadows = (LightShadows)((m_light.shadowStrength > 0f) ? 2 : 0); } } public void RemoveEffects() { if ((Object)(object)m_ballInstance != (Object)null) { ZNetView component = m_ballInstance.GetComponent<ZNetView>(); if (component.IsValid()) { component.ClaimOwnership(); component.Destroy(); } } } public override void OnApplicationQuit() { ((StatusEffect)this).OnApplicationQuit(); m_ballInstance = null; } public override void Stop() { ((StatusEffect)this).Stop(); RemoveEffects(); } public override void OnDestroy() { ((StatusEffect)this).OnDestroy(); RemoveEffects(); } }