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 SosalGliders v1.0.1
BepInEx/patchers/SosalGliders/SosalGliders.RpcPreloader.dll
Decompiled 14 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Mono.Cecil; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public static class SosalGlidersRpcPreloader { public static IEnumerable<string> TargetDLLs { get { yield return "assembly_valheim.dll"; } } public static void Patch(AssemblyDefinition assembly) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (!Directory.Exists(Paths.PluginPath) || !Directory.EnumerateFiles(Paths.PluginPath, "ValheimGliders.dll", SearchOption.AllDirectories).Any()) { return; } TypeDefinition type = assembly.MainModule.GetType("ZRoutedRpc"); FieldDefinition val = ((type != null) ? ((IEnumerable<FieldDefinition>)type.Fields).FirstOrDefault((Func<FieldDefinition, bool>)((FieldDefinition f) => ((MemberReference)f).Name == "Everybody")) : null); if (val != null && val.IsLiteral) { if (((MemberReference)((FieldReference)val).FieldType).FullName != "System.Int64" || Convert.ToInt64(val.Constant) != 0L) { throw new InvalidOperationException("Unexpected ZRoutedRpc.Everybody definition; compatibility patch was not applied."); } val.IsLiteral = false; val.IsInitOnly = true; val.HasConstant = false; val.Attributes = (FieldAttributes)(val.Attributes & 0x7FFF); Logger.CreateLogSource("SosalGliders RPC").LogInfo((object)"Restored readable broadcast ID in memory (value 0). No game or dependency files were modified."); } } }
BepInEx/plugins/GliderRussianPatch/GliderRussianPatch.dll
Decompiled 14 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace GliderRussianPatch { [BepInPlugin("local.gliders.russian", "Gliders Russian and Two Recipes", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static readonly Type Items = AccessTools.TypeByName("IBelieveICanFly.Registration.Item"); internal static readonly Dictionary<string, string[]> Text = new Dictionary<string, string[]> { { "Glider_Pelt_Ygg", new string[2] { "Глайдер из оленьей шкуры", "Глайдер из кожаных обрывков, оленьей шкуры и древесины. Нажмите прыжок в воздухе, чтобы раскрыть его." } }, { "Glider_Troll_Ygg", new string[2] { "Глайдер из шкуры тролля", "Улучшенный глайдер из шкуры тролля и цельной древесины. Нажмите прыжок в воздухе, чтобы раскрыть его." } }, { "Glider_BackPack_Ygg", new string[2] { "Кристальный глайдер из волчьей шкуры", "Глайдер из кристаллов, волчьей шкуры и качественной древесины." } }, { "Glider_Gjall_BackPack_Ygg", new string[2] { "Воздушный шар гьялла", "Глайдер-шар из трофея гьялла, огоньков и древесины Иггдрасиля." } }, { "Glider_Gjall_Fader_BackPack_Ygg", new string[2] { "Усиленный глайдер гьялла", "Воздушный шар гьялла, усиленный силой Фейдера." } }, { "Glider_BackPack_DragonModer_Ygg", new string[2] { "Серебряные крылья Моудер", "Серебряные драконьи крылья, полученные от Моудер." } }, { "Glider_BackPack_BlackDragon_Ygg", new string[2] { "Крылья чёрного дракона", "Глайдер из особых крыльев чёрного дракона." } }, { "Glider_BackPack_RedDragon_Ygg", new string[2] { "Алые крылья", "Глайдер с алыми крыльями." } } }; private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("local.gliders.russian").PatchAll(); TranslateItems(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Russian glider text loaded; only deer and troll recipes remain visible."); } internal static bool Hidden(string id) { if (id != null && Text.ContainsKey(id) && id != "Glider_Pelt_Ygg") { return id != "Glider_Troll_Ygg"; } return false; } internal static void TranslateItems() { Type type = Items.Assembly.GetType("ItemManager.Item"); if (!(AccessTools.Field(type, "registeredItems").GetValue(null) is IEnumerable enumerable)) { return; } foreach (object item in enumerable) { object? value = AccessTools.Field(type, "Prefab").GetValue(item); GameObject val = (GameObject)((value is GameObject) ? value : null); if (Object.op_Implicit((Object)(object)val) && Text.TryGetValue(((Object)val).name, out var value2)) { for (int i = 0; i < 2; i++) { object obj = AccessTools.PropertyGetter(type, (i == 0) ? "Name" : "Description").Invoke(item, null); AccessTools.Method(obj.GetType(), "Russian", (Type[])null, (Type[])null).Invoke(obj, new object[1] { value2[i] }); } } } } internal static string Guide(string text) { if (Localization.instance == null || Localization.instance.GetSelectedLanguage() != "Russian") { return text; } if (text == "Valheim Gliders Guide") { return "Руководство по глайдерам"; } if (text == "Glider Controls") { return "Управление глайдером"; } if (text.Contains("<color=#FFB81F>") && text.Contains("STAMINA")) { return "<color=#FFB81F>ПОЛЁТ НА ГЛАЙДЕРЕ</color>\nНаденьте глайдер и прыгните с высоты. Для раскрытия нужно не менее 3 метров до земли.\n\n<color=#FFB81F>УПРАВЛЕНИЕ</color>\nПрыжок (по умолчанию пробел) — раскрыть или закрыть глайдер. Если переключение отключено в настройках мода, удерживайте кнопку прыжка.\nВперёд (W) — пикировать и набирать скорость.\nНазад (S) — замедлиться.\n\n<color=#FFB81F>ВЫНОСЛИВОСТЬ</color>\nПолёт расходует выносливость, если это включено в настройках мода. Следите за её запасом.\n\n<color=#FFB81F>ПРИЗЕМЛЕНИЕ</color>\nЗаранее выбирайте место посадки и оставляйте запас высоты для манёвра."; } return text; } } [HarmonyPatch] internal static class Registration { private static MethodBase TargetMethod() { return AccessTools.Method(Plugin.Items, "RegisterItems", (Type[])null, (Type[])null); } private static void Postfix() { Plugin.TranslateItems(); } } [HarmonyPatch(typeof(Player), "GetAvailableRecipes")] internal static class Recipes { private static void Prefix(HashSet<string> ___m_knownRecipes) { ObjectDB instance = ObjectDB.instance; if (!Object.op_Implicit((Object)(object)instance) || ___m_knownRecipes == null) { return; } foreach (Recipe recipe in instance.m_recipes) { if (Object.op_Implicit((Object)(object)recipe) && Object.op_Implicit((Object)(object)recipe.m_item)) { string name = ((Object)((Component)recipe.m_item).gameObject).name; if (!(name != "Glider_Pelt_Ygg") || !(name != "Glider_Troll_Ygg")) { recipe.m_enabled = true; ___m_knownRecipes.Add(recipe.m_item.m_itemData.m_shared.m_name); } } } } [HarmonyPriority(0)] private static void Postfix(ref List<Recipe> __0) { __0.RemoveAll((Recipe r) => Object.op_Implicit((Object)(object)r) && Object.op_Implicit((Object)(object)r.m_item) && Plugin.Hidden(((Object)((Component)r.m_item).gameObject).name)); } } [HarmonyPatch] internal static class Compendium { private static IEnumerable<MethodBase> TargetMethods() { Type t = AccessTools.TypeByName("ValheimGliders.Compendium.ValheimGlidersCompendium"); yield return AccessTools.Method(t, "EnsureGuide", (Type[])null, (Type[])null); yield return AccessTools.Method(t, "EnsureControls", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction i in instructions) { yield return i; if (i.opcode == OpCodes.Ldstr) { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "Guide", (Type[])null, (Type[])null)); } } } } }
BepInEx/plugins/ModerWingsTexture/ModerWingsTexture.dll
Decompiled 14 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Logging; using HarmonyLib; using IBelieveICanFly; using IBelieveICanFly.Patches; using IBelieveICanFly.Registration; using ItemManager; using Microsoft.CodeAnalysis; using MotherGliderAssets; using Newtonsoft.Json; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [BepInPlugin("local.gliders.modertexture", "Mother Glider", "4.0.2")] [BepInDependency("Yggdrah.ValheimGliders", "1.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class MotherGlider : BaseUnityPlugin { private const string ItemId = "Glider_BackPack_DragonModer_Ygg"; private const string FlightId = "DragonWings_Ygg1"; private static MotherGlider instance; private Harmony harmony; private string lastAttachmentState; private bool flightReported; private Material fittingMaterial; private Material packMaterial; private readonly List<Object> resources = new List<Object>(); private readonly List<GameObject> addedObjects = new List<GameObject>(); private readonly List<Action> restore = new List<Action>(); private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown instance = this; harmony = new Harmony("local.gliders.modertexture"); try { Item glider_BackPack_DragonModer_Ygg = Item.Glider_BackPack_DragonModer_Ygg; if (glider_BackPack_DragonModer_Ygg == null) { throw new InvalidOperationException("Original glider item missing."); } if (glider_BackPack_DragonModer_Ygg.Crafting.Stations.Count == 0) { glider_BackPack_DragonModer_Ygg.Crafting.Add((CraftingTable)5, 2); glider_BackPack_DragonModer_Ygg.RequiredItems.Add("TrophyDragonQueen", 1, 0); glider_BackPack_DragonModer_Ygg.RequiredItems.Add("BlackMetal", 1, 0); glider_BackPack_DragonModer_Ygg.RequiredItems.Add("FineWood", 30, 0); glider_BackPack_DragonModer_Ygg.RequiredItems.Add("AskHide", 5, 0); glider_BackPack_DragonModer_Ygg.CraftAmount = 1; } SetRussianText(); Type type = AccessTools.TypeByName("GliderRussianPatch.Plugin"); if (type != null) { MethodInfo methodInfo = AccessTools.Method(type, "Hidden", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(MotherGlider), "AllowRecipe", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo2 = AccessTools.Method(type, "TranslateItems", (Type[])null, (Type[])null); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(MotherGlider), "SetRussianText", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } harmony.Patch((MethodBase)AccessTools.Method(typeof(VisEquipment), "AttachArmor", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MotherGlider), "ReportAttachment", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(GliderVisual), "CreateVisualOnlyGliderMesh", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MotherGlider), "ReportFlightClone", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Mother Glider 4.0.2: wooden glider and small opaque leather pack; forge recipe registered."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Mother Glider initialization failed: " + ex)); } } private static void SetRussianText() { Item glider_BackPack_DragonModer_Ygg = Item.Glider_BackPack_DragonModer_Ygg; if (glider_BackPack_DragonModer_Ygg != null) { glider_BackPack_DragonModer_Ygg.Name.Russian("Глайдер матери"); glider_BackPack_DragonModer_Ygg.Description.Russian("Рукотворный глайдер с серо-белым полотном, деревянным каркасом и железными шарнирами. В сложенном виде — небольшой кожаный ранец с перекрёстными ремнями. Наденьте в слот аксессуара и нажмите прыжок в воздухе, чтобы раскрыть его."); } } private static void AllowRecipe(string id, ref bool __result) { if (id == "Glider_BackPack_DragonModer_Ygg") { __result = false; } } private static void ReportAttachment(int itemHash, List<GameObject> __result) { if (!Object.op_Implicit((Object)(object)instance) || itemHash != StringExtensionMethods.GetStableHashCode("Glider_BackPack_DragonModer_Ygg")) { return; } string text = "no attachment returned"; if (__result != null) { List<string> list = new List<string>(); foreach (GameObject item in __result) { if (Object.op_Implicit((Object)(object)item)) { MeshFilter componentInChildren = item.GetComponentInChildren<MeshFilter>(true); list.Add(((Object)item).name + ": " + ((Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)componentInChildren.sharedMesh)) ? ((Object)componentInChildren.sharedMesh).name : "legacy skin")); } } text = string.Join("; ", list); } if (!(instance.lastAttachmentState == text)) { instance.lastAttachmentState = text; ((BaseUnityPlugin)instance).Logger.LogInfo((object)("Actual equipped Moder attachment: " + text)); } } private static void ReportFlightClone(GameObject itemPrefab, GameObject __result) { if (Object.op_Implicit((Object)(object)instance) && !instance.flightReported && Object.op_Implicit((Object)(object)itemPrefab) && !(((Object)itemPrefab).name != "DragonWings_Ygg1") && Object.op_Implicit((Object)(object)__result)) { instance.flightReported = true; Transform val = __result.transform.Find("MotherGlider_RivetedFittings"); ((BaseUnityPlugin)instance).Logger.LogInfo((object)("Actual flight clone: mechanical fittings present=" + Object.op_Implicit((Object)(object)val))); } } private IEnumerator Start() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Waiting for vanilla item materials before creating glider visuals."); Material donor = null; while (!Object.op_Implicit((Object)(object)donor)) { donor = FindVanillaMaterial(); if (!Object.op_Implicit((Object)(object)donor)) { yield return (object)new WaitForSecondsRealtime(0.25f); } } ApplyVisuals(donor); } private static Material FindVanillaMaterial() { ObjectDB val = ObjectDB.instance; if (!Object.op_Implicit((Object)(object)val)) { return null; } string[] array = new string[3] { "CapeDeerHide", "CapeWolf", "HelmetLeather" }; foreach (string text in array) { GameObject itemPrefab = val.GetItemPrefab(text); if (!Object.op_Implicit((Object)(object)itemPrefab)) { continue; } Renderer[] componentsInChildren = itemPrefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if (!(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer)) { continue; } Material[] sharedMaterials = val2.sharedMaterials; foreach (Material val3 in sharedMaterials) { if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val3.shader) && val3.shader.isSupported && GeometryShaderPolicy.IsSupported(((Object)val3.shader).name) && val3.renderQueue < 3000 && val3.HasProperty("_MainTex")) { return val3; } } } } return null; } private Material OpaqueMaterial(Material donor, Texture2D albedo, string name) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) if (!GeometryShaderPolicy.IsSupported(((Object)donor.shader).name)) { throw new InvalidOperationException("Unsafe geometry shader: " + ((Object)donor.shader).name); } Material val = Own<Material>(new Material(donor) { name = name }); string[] texturePropertyNames = val.GetTexturePropertyNames(); foreach (string text in texturePropertyNames) { val.SetTexture(text, (Texture)null); } val.mainTexture = (Texture)(object)albedo; val.mainTextureScale = Vector2.one; val.mainTextureOffset = Vector2.zero; string[] array = new string[8] { "_NORMALMAP", "_METALLICGLOSSMAP", "_SPECGLOSSMAP", "_EMISSION", "_DETAIL_MULX2", "_ALPHATEST_ON", "_ALPHABLEND_ON", "_ALPHAPREMULTIPLY_ON" }; foreach (string text2 in array) { val.DisableKeyword(text2); } string[] array2 = new string[9] { "_Mode", "_Glossiness", "_Smoothness", "_GlossMapScale", "_Metallic", "_BumpScale", "_Cutoff", "_Wet", "_Wetness" }; foreach (string text3 in array2) { if (val.HasProperty(text3)) { val.SetFloat(text3, 0f); } } string[] array3 = new string[2] { "_Color", "_TintColor" }; foreach (string text4 in array3) { if (val.HasProperty(text4)) { val.SetColor(text4, Color.white); } } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", Color.black); } if (val.HasProperty("_SpecColor")) { val.SetColor("_SpecColor", new Color(0.04f, 0.04f, 0.04f, 1f)); } if (val.HasProperty("_SrcBlend")) { val.SetInt("_SrcBlend", 1); } if (val.HasProperty("_DstBlend")) { val.SetInt("_DstBlend", 0); } if (val.HasProperty("_ZWrite")) { val.SetInt("_ZWrite", 1); } if (val.HasProperty("_Alpha")) { val.SetFloat("_Alpha", 1f); } val.SetOverrideTag("RenderType", "Opaque"); val.renderQueue = 2000; return val; } private void ApplyVisuals(Material donor) { //IL_017d: 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_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) try { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ModelData modelData = ModelFile.Read(Path.Combine(directoryName, "mother-models-v4.json")); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Model file decoded: frame vertices=" + modelData.frame.vertices.Length / 3 + "; hardware groups=" + modelData.hardware.Length)); AssetBundle assetBundle = IBelieveICanFlyPlugin.GetAssetBundle("ibelieveicanfly"); GameObject val = (Object.op_Implicit((Object)(object)assetBundle) ? assetBundle.LoadAsset<GameObject>("DragonWings_Ygg1") : null); Transform val2 = (Object.op_Implicit((Object)(object)val) ? FindChild(val.transform, "Visual") : null); GameObject prefab = Item.Glider_BackPack_DragonModer_Ygg.Prefab; if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Original Moder prefabs unavailable."); } Mesh val3 = ReadMesh(modelData.frame, "MotherGlider_LeatherPack"); Transform[] bones; Mesh val4 = BuildFittings(modelData.hardware, val2, out bones); Texture2D albedo = LoadTexture(Path.Combine(directoryName, "mother-backpack-v3.png"), mipmaps: true); Texture2D albedo2 = LoadTexture(Path.Combine(directoryName, "mother-pack-v4.png"), mipmaps: true); Texture2D val5 = LoadTexture(Path.Combine(directoryName, "mother-sails-v4.png"), mipmaps: true); ((Texture)val5).wrapMode = (TextureWrapMode)0; Texture2D val6 = LoadTexture(Path.Combine(directoryName, "mother-icon-v4.png"), mipmaps: false); Sprite val7 = Own<Sprite>(Sprite.Create(val6, new Rect(0f, 0f, (float)((Texture)val6).width, (float)((Texture)val6).height), new Vector2(0.5f, 0.5f), 100f)); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Vanilla material ready: " + ((Object)donor).name + "; shader=" + ((Object)donor.shader).name)); fittingMaterial = OpaqueMaterial(donor, albedo, "MotherGlider_WoodAndIron"); packMaterial = OpaqueMaterial(donor, albedo2, "MotherGlider_SmallOpaquePack"); Material material = OpaqueMaterial(donor, val5, "MotherGlider_MatteSails"); ReplaceSails(val2, modelData.cloth, material); GameObject val8 = new GameObject("MotherGlider_RivetedFittings"); addedObjects.Add(val8); val8.transform.SetParent(val2, false); val8.layer = ((Component)val2).gameObject.layer; SkinnedMeshRenderer val9 = val8.AddComponent<SkinnedMeshRenderer>(); val9.sharedMesh = val4; ((Renderer)val9).sharedMaterial = fittingMaterial; val9.bones = bones; val9.rootBone = val2; ((Renderer)val9).localBounds = val4.bounds; val9.updateWhenOffscreen = true; ((Renderer)val9).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)val9).receiveShadows = true; ReplacePack(prefab, val3); GameObject val10 = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab("Glider_BackPack_DragonModer_Ygg") : null); if (Object.op_Implicit((Object)(object)val10) && (Object)(object)val10 != (Object)(object)prefab) { ReplacePack(val10, val3); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("ObjectDB Moder prefab: " + (Object.op_Implicit((Object)(object)val10) ? "found; attachment replaced" : "not registered yet; source prefab replaced"))); SharedData shared = prefab.GetComponent<ItemDrop>().m_itemData.m_shared; Sprite[] previousIcons = shared.m_icons; restore.Add(delegate { shared.m_icons = previousIcons; }); shared.m_icons = (Sprite[])(object)new Sprite[1] { val7 }; ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[10] { "Mother Glider 4.0.2 ready: claws/body removed; sails=", (modelData.cloth.vertices.Length / 3).ToString(), " vertices; fittings=", modelData.hardware.Length.ToString(), " bone groups; small pack height=", null, null, null, null, null }; Bounds bounds = val3.bounds; obj[5] = ((Bounds)(ref bounds)).size.y.ToString(); obj[6] = "; opaque queue="; obj[7] = packMaterial.renderQueue.ToString(); obj[8] = "; shader="; obj[9] = ((Object)donor.shader).name; logger.LogInfo((object)string.Concat(obj)); } catch (Exception ex) { RestoreVisuals(); ((BaseUnityPlugin)this).Logger.LogError((object)("Mother Glider visual loading failed; original prefabs restored. " + ex)); } } private void ReplaceSails(Transform visual, SkinData data, Material material) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Expected O, but got Unknown //IL_033e: Unknown result type (might be due to invalid IL or missing references) Transform val = visual.Find(data.rendererPath); SkinnedMeshRenderer val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<SkinnedMeshRenderer>() : null); if (!Object.op_Implicit((Object)(object)val2) || val2.bones.Length != data.bindPoses.Length / 16) { throw new InvalidDataException("Original sail rig does not match exported bind poses."); } Transform[] bones = val2.bones; foreach (Transform val3 in bones) { if (!Object.op_Implicit((Object)(object)val3)) { throw new InvalidDataException("Missing original sail bone."); } } Mesh val4 = ReadMesh(data, "MotherGlider_EngineeredSails"); Vector3[] array = (Vector3[])(object)new Vector3[val4.vertexCount]; BoneWeight[] array2 = (BoneWeight[])(object)new BoneWeight[val4.vertexCount]; for (int j = 0; j < val4.vertexCount; j++) { array[j] = new Vector3(data.normals[j * 3], data.normals[j * 3 + 1], data.normals[j * 3 + 2]); int num = j * 4; int num2 = j; BoneWeight val5 = default(BoneWeight); ((BoneWeight)(ref val5)).boneIndex0 = data.boneIndices[num]; ((BoneWeight)(ref val5)).boneIndex1 = data.boneIndices[num + 1]; ((BoneWeight)(ref val5)).boneIndex2 = data.boneIndices[num + 2]; ((BoneWeight)(ref val5)).boneIndex3 = data.boneIndices[num + 3]; ((BoneWeight)(ref val5)).weight0 = data.boneWeights[num]; ((BoneWeight)(ref val5)).weight1 = data.boneWeights[num + 1]; ((BoneWeight)(ref val5)).weight2 = data.boneWeights[num + 2]; ((BoneWeight)(ref val5)).weight3 = data.boneWeights[num + 3]; array2[num2] = val5; } Matrix4x4[] array3 = (Matrix4x4[])(object)new Matrix4x4[data.bindPoses.Length / 16]; for (int k = 0; k < array3.Length; k++) { for (int l = 0; l < 4; l++) { for (int m = 0; m < 4; m++) { ((Matrix4x4)(ref array3[k]))[l, m] = data.bindPoses[k * 16 + l * 4 + m]; } } } val4.normals = array; val4.boneWeights = array2; val4.bindposes = array3; val4.RecalculateTangents(); Renderer[] componentsInChildren = ((Component)visual).GetComponentsInChildren<Renderer>(true); foreach (Renderer val6 in componentsInChildren) { Renderer saved = val6; bool enabled = val6.enabled; restore.Add(delegate { if (Object.op_Implicit((Object)(object)saved)) { saved.enabled = enabled; } }); val6.enabled = false; } GameObject val7 = new GameObject("MotherGlider_EngineeredSails"); addedObjects.Add(val7); val7.transform.SetParent(val, false); val7.layer = ((Component)val).gameObject.layer; SkinnedMeshRenderer val8 = val7.AddComponent<SkinnedMeshRenderer>(); val8.sharedMesh = val4; ((Renderer)val8).sharedMaterial = material; val8.bones = val2.bones; val8.rootBone = val2.rootBone; val8.quality = (SkinQuality)4; ((Renderer)val8).localBounds = ((Renderer)val2).localBounds; val8.updateWhenOffscreen = true; ((Renderer)val8).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)val8).receiveShadows = true; } private Mesh BuildFittings(Hardware[] data, Transform visual, out Transform[] bones) { //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<int> list3 = new List<int>(); List<BoneWeight> list4 = new List<BoneWeight>(); Matrix4x4[] array = (Matrix4x4[])(object)new Matrix4x4[data.Length]; bones = (Transform[])(object)new Transform[data.Length]; for (int i = 0; i < data.Length; i++) { ModelFile.Validate(data[i].mesh); Transform val = visual.Find(data[i].bonePath); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidDataException("Wing bone missing: " + data[i].bonePath); } bones[i] = val; Matrix4x4 val2 = visual.worldToLocalMatrix * val.localToWorldMatrix; array[i] = val.worldToLocalMatrix * visual.localToWorldMatrix; int count = list.Count; MeshData mesh = data[i].mesh; for (int j = 0; j < mesh.vertices.Length / 3; j++) { list.Add(((Matrix4x4)(ref val2)).MultiplyPoint3x4(new Vector3(mesh.vertices[j * 3], mesh.vertices[j * 3 + 1], mesh.vertices[j * 3 + 2]))); list2.Add(new Vector2(mesh.uv[j * 2], mesh.uv[j * 2 + 1])); BoneWeight item = default(BoneWeight); ((BoneWeight)(ref item)).boneIndex0 = i; ((BoneWeight)(ref item)).weight0 = 1f; list4.Add(item); } bool flag = ((Matrix4x4)(ref val2)).determinant < 0f; for (int k = 0; k < mesh.triangles.Length; k += 3) { list3.Add(count + mesh.triangles[k + (flag ? 2 : 0)]); list3.Add(count + mesh.triangles[k + 1]); list3.Add(count + mesh.triangles[k + ((!flag) ? 2 : 0)]); } } Mesh val3 = Own<Mesh>(new Mesh { name = "MotherGlider_RivetedFittings" }); if (list.Count > 65535) { val3.indexFormat = (IndexFormat)1; } val3.SetVertices(list); val3.SetUVs(0, list2); val3.SetTriangles(list3, 0); val3.boneWeights = list4.ToArray(); val3.bindposes = array; FinishMesh(val3); return val3; } private void ReplacePack(GameObject item, Mesh mesh) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = item.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Renderer saved = val; bool enabled = val.enabled; restore.Add(delegate { if (Object.op_Implicit((Object)(object)saved)) { saved.enabled = enabled; } }); val.enabled = false; } foreach (Transform item2 in item.transform) { Transform val2 = item2; Transform saved2 = val2; string name = ((Object)val2).name; bool active = ((Component)val2).gameObject.activeSelf; restore.Add(delegate { if (Object.op_Implicit((Object)(object)saved2)) { ((Object)saved2).name = name; ((Component)saved2).gameObject.SetActive(active); } }); if (name.StartsWith("attach_", StringComparison.Ordinal)) { ((Object)val2).name = "MotherGlider_Legacy_" + name; } ((Component)val2).gameObject.SetActive(false); } GameObject val3 = RenderObject("attach_Spine2", mesh, item.transform); val3.SetActive(false); GameObject val4 = RenderObject("MotherGlider_GroundVisual", mesh, item.transform); val4.transform.localPosition = new Vector3(0f, 0.43f, 0.25f); } private GameObject RenderObject(string name, Mesh mesh, Transform parent) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown GameObject val = new GameObject(name); addedObjects.Add(val); val.transform.SetParent(parent, false); val.layer = ((Component)parent).gameObject.layer; val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); ((Renderer)val2).sharedMaterial = packMaterial; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)val2).receiveShadows = true; return val; } private T Own<T>(T value) where T : Object { resources.Add((Object)(object)value); return value; } private Texture2D LoadTexture(string path, bool mipmaps) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Texture2D val = Own<Texture2D>(new Texture2D(2, 2, (TextureFormat)4, mipmaps, false)); if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path), false)) { throw new InvalidDataException("Cannot load " + path); } ((Object)val).name = Path.GetFileNameWithoutExtension(path); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).anisoLevel = 4; val.Apply(mipmaps, true); return val; } private Mesh ReadMesh(MeshData data, string name) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown ModelFile.Validate(data); Vector3[] array = (Vector3[])(object)new Vector3[data.vertices.Length / 3]; Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length]; for (int i = 0; i < array.Length; i++) { array[i] = new Vector3(data.vertices[i * 3], data.vertices[i * 3 + 1], data.vertices[i * 3 + 2]); array2[i] = new Vector2(data.uv[i * 2], data.uv[i * 2 + 1]); } Mesh val = Own<Mesh>(new Mesh { name = name, vertices = array, uv = array2, triangles = data.triangles }); FinishMesh(val); return val; } private static void FinishMesh(Mesh mesh) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) Color[] array = (Color[])(object)new Color[mesh.vertexCount]; for (int i = 0; i < array.Length; i++) { array[i] = Color.white; } mesh.colors = array; mesh.RecalculateNormals(); mesh.RecalculateTangents(); mesh.RecalculateBounds(); } private static Transform FindChild(Transform parent, string name) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (((Object)parent).name == name) { return parent; } foreach (Transform item in parent) { Transform parent2 = item; Transform val = FindChild(parent2, name); if (Object.op_Implicit((Object)(object)val)) { return val; } } return null; } private void RestoreVisuals() { for (int num = restore.Count - 1; num >= 0; num--) { restore[num](); } restore.Clear(); foreach (GameObject addedObject in addedObjects) { if (Object.op_Implicit((Object)(object)addedObject)) { addedObject.SetActive(false); Object.Destroy((Object)(object)addedObject); } } addedObjects.Clear(); foreach (Object resource in resources) { if (Object.op_Implicit(resource)) { Object.Destroy(resource); } } resources.Clear(); } private void OnDestroy() { RestoreVisuals(); if (harmony != null) { harmony.UnpatchSelf(); } if ((Object)(object)instance == (Object)(object)this) { instance = null; } } } namespace MotherGliderAssets { public static class GeometryShaderPolicy { public static bool IsSupported(string name) { int result; switch (name) { default: result = ((name == "Standard (Specular setup)") ? 1 : 0); break; case "Custom/Creature": case "Custom/Piece": case "Standard": result = 1; break; } return (byte)result != 0; } } [Serializable] public sealed class ModelData { public MeshData frame; public Hardware[] hardware; public SkinData cloth; } [Serializable] public sealed class Hardware { public string bonePath; public MeshData mesh; } [Serializable] public class MeshData { public float[] vertices; public float[] uv; public int[] triangles; } [Serializable] public sealed class SkinData : MeshData { public string rendererPath; public float[] normals; public float[] boneWeights; public float[] bindPoses; public int[] boneIndices; } public static class ModelFile { public static ModelData Read(string path) { //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: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown JsonSerializerSettings val = new JsonSerializerSettings { MissingMemberHandling = (MissingMemberHandling)1, TypeNameHandling = (TypeNameHandling)0, MaxDepth = 16 }; ModelData modelData = JsonConvert.DeserializeObject<ModelData>(File.ReadAllText(path), val); if (modelData == null || modelData.hardware == null || modelData.hardware.Length == 0) { throw new InvalidDataException("Missing frame or hardware in " + Path.GetFileName(path)); } Validate(modelData.frame); ValidateSkin(modelData.cloth); Hardware[] hardware = modelData.hardware; foreach (Hardware hardware2 in hardware) { if (hardware2 == null || string.IsNullOrWhiteSpace(hardware2.bonePath)) { throw new InvalidDataException("Hardware bone path is missing."); } Validate(hardware2.mesh); } return modelData; } public static void ValidateSkin(SkinData data) { Validate(data); int num = data.vertices.Length / 3; if (string.IsNullOrWhiteSpace(data.rendererPath) || data.normals == null || data.normals.Length != num * 3 || data.boneIndices == null || data.boneIndices.Length != num * 4 || data.boneWeights == null || data.boneWeights.Length != num * 4 || data.bindPoses == null || data.bindPoses.Length == 0 || data.bindPoses.Length % 16 != 0) { throw new InvalidDataException("Invalid sail rig arrays."); } float[] normals = data.normals; foreach (float f in normals) { if (float.IsNaN(f) || float.IsInfinity(f)) { throw new InvalidDataException("Invalid sail normal."); } } float[] bindPoses = data.bindPoses; foreach (float f2 in bindPoses) { if (float.IsNaN(f2) || float.IsInfinity(f2)) { throw new InvalidDataException("Invalid bind pose."); } } for (int k = 0; k < num; k++) { float num2 = 0f; for (int l = 0; l < 4; l++) { int num3 = k * 4 + l; float num4 = data.boneWeights[num3]; if (float.IsNaN(num4) || float.IsInfinity(num4) || num4 < 0f || num4 > 1f || data.boneIndices[num3] < 0 || data.boneIndices[num3] >= data.bindPoses.Length / 16) { throw new InvalidDataException("Invalid sail bone weight."); } num2 += num4; } if (Math.Abs(num2 - 1f) > 0.001f) { throw new InvalidDataException("Sail weights do not sum to one."); } } } public static void Validate(MeshData data) { if (data == null || data.vertices == null || data.uv == null || data.triangles == null || data.vertices.Length == 0 || data.vertices.Length % 3 != 0 || data.triangles.Length == 0 || data.triangles.Length % 3 != 0 || data.uv.Length != data.vertices.Length / 3 * 2) { throw new InvalidDataException("Invalid mesh arrays."); } float[] vertices = data.vertices; foreach (float f in vertices) { if (float.IsNaN(f) || float.IsInfinity(f)) { throw new InvalidDataException("Non-finite vertex."); } } float[] uv = data.uv; foreach (float f2 in uv) { if (float.IsNaN(f2) || float.IsInfinity(f2)) { throw new InvalidDataException("Non-finite UV."); } } int[] triangles = data.triangles; foreach (int num in triangles) { if (num < 0 || num >= data.vertices.Length / 3) { throw new InvalidDataException("Invalid triangle index."); } } } } }
BepInEx/plugins/NightWanderer/NightWanderer.dll
Decompiled 14 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using IBelieveICanFly.Patches; using IBelieveICanFly.Registration; using ItemManager; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NightWandererMod { [BepInPlugin("local.gliders.nightwanderer", "Mist Glider", "1.0.4")] [BepInDependency("Yggdrah.ValheimGliders", "1.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private static Plugin self; private Harmony harmony; private GameObject root; private Texture2D hideTexture; private readonly Dictionary<Material, Material> materials = new Dictionary<Material, Material>(); private static readonly FieldInfo EquippedItem = AccessTools.Field(typeof(GliderSystem), "equippedGliderItem"); private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Expected O, but got Unknown //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Expected O, but got Unknown self = this; harmony = new Harmony("local.gliders.nightwanderer"); try { MethodInfo[] array = new MethodInfo[8] { Required(typeof(Config), "GetWingsConfigForItem"), Required(typeof(Config), "GetGliderStaminaDrainPerSecond"), Required(typeof(GliderVisual), "PositionGliderOnBack"), Required(typeof(GliderSystem), "UpdateGlidingZDO"), Required(typeof(GliderSystem), "PositionRemoteGliderOnBack"), Required(typeof(Config), "GetWingsForwardSpeed"), Required(typeof(Config), "GetWingsDescentSpeed"), Required(typeof(VisEquipment), "AttachArmor") }; if (EquippedItem == null) { throw new MissingFieldException("ValheimGliders equipped item field missing."); } GameObject val = Item.Glider_Troll_Ygg?.Prefab; if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("Original troll glider is unavailable."); } string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); hideTexture = new Texture2D(2, 2, (TextureFormat)4, true); if (!ImageConversion.LoadImage(hideTexture, File.ReadAllBytes(Path.Combine(directoryName, "mist-hide.png")))) { throw new InvalidDataException("Mist Glider hide texture failed to load."); } ((Object)hideTexture).name = "MistGlider_StitchedHide"; ((Texture)hideTexture).wrapMode = (TextureWrapMode)0; ((Texture)hideTexture).filterMode = (FilterMode)1; ((Texture)hideTexture).anisoLevel = 4; Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val2, File.ReadAllBytes(Path.Combine(directoryName, "night-icon.png")))) { throw new InvalidDataException("Mist Glider icon failed to load."); } Sprite val3 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f); root = new GameObject("NightWanderer_Prefabs"); root.SetActive(false); Object.DontDestroyOnLoad((Object)(object)root); GameObject val4 = Object.Instantiate<GameObject>(val, root.transform); ((Object)val4).name = "Glider_NightWanderer"; val4.SetActive(true); ItemDrop component = val4.GetComponent<ItemDrop>(); component.m_itemData = val.GetComponent<ItemDrop>().m_itemData.Clone(); component.m_itemData.m_shared = (SharedData)AccessTools.Method(typeof(object), "MemberwiseClone", (Type[])null, (Type[])null).Invoke(component.m_itemData.m_shared, null); component.m_itemData.m_shared.m_name = "$item_Glider_NightWanderer"; component.m_itemData.m_shared.m_description = "$item_Glider_NightWanderer_description"; component.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { val3 }; int num = ApplyFinish(val4); if (num == 0) { throw new InvalidOperationException("No troll backpack material slots found."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Stored backpack: charcoal finish applied to " + num + " material slots.")); Item val5 = new Item(val4, false) { Configurable = (Configurability)0, CraftAmount = 1 }; val5.Name.English("Mist Glider"); val5.Name.Russian("Глайдер туманов"); val5.Description.English("A charcoal-black glider and backpack. Standard glide: 10 m/s forward, 2.5 m/s descent. Approximately 20% more range from equal height than a troll glider at its default settings. Uses 10% less stamina. Equip and jump in mid-air to unfold."); val5.Description.Russian("Чёрный глайдер и рюкзак из тролльей шкуры. Обычное планирование: 10 м/с вперёд и 2,5 м/с вниз — примерно на 20% дальше с той же высоты, чем тролльий глайдер при стандартных настройках. Расход выносливости ниже на 10%. Наденьте и нажмите прыжок в воздухе, чтобы раскрыть его."); val5.Crafting.Add((CraftingTable)5, 2); val5.RequiredItems.Add("Glider_Troll_Ygg", 1, 0); val5.RequiredItems.Add("IronNails", 50, 0); val5.RequiredItems.Add("ElderBark", 8, 0); val5.RequiredItems.Add("Coal", 10, 0); val5.RequiredItems.Add("Chain", 1, 0); Patch(array[0], "RouteItem", prefix: false); Patch(array[1], "StaminaDrain", prefix: false); Patch(array[2], "LocalVisual", prefix: true); Patch(array[3], "SyncVariant", prefix: true); Patch(array[4], "RemoteVisual", prefix: true); Patch(array[5], "ForwardSpeed", prefix: false); Patch(array[6], "DescentSpeed", prefix: false); Patch(array[7], "StoredVisual", prefix: false); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Mist Glider 1.0.4 registered: stitched charcoal hide on wings and pack; 10 m/s forward, -2.5 m/s descent; Forge 2; stamina x0.90."); } catch (Exception ex) { harmony.UnpatchSelf(); ((BaseUnityPlugin)this).Logger.LogError((object)("Mist Glider initialization failed: " + ex)); } } private static MethodInfo Required(Type type, string method) { return AccessTools.Method(type, method, (Type[])null, (Type[])null) ?? throw new MissingMethodException(type.FullName, method); } private void Patch(MethodInfo original, string method, bool prefix) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(typeof(Plugin), method, (Type[])null); harmony.Patch((MethodBase)original, prefix ? val : null, prefix ? null : val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool IsNight(ItemData item) { return item != null && Rules.IsNight(Object.op_Implicit((Object)(object)item.m_dropPrefab) ? ((Object)item.m_dropPrefab).name : null, item.m_shared?.m_name); } private static bool LocalNight(Player player) { if (!Object.op_Implicit((Object)(object)player) || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return false; } (bool, int) equippedWingsConfig = GliderSystem.GetEquippedWingsConfig(player); return equippedWingsConfig.Item1 && equippedWingsConfig.Item2 == 6 && IsNight((ItemData)/*isinst with value type is only supported in some contexts*/); } private static void RouteItem(ItemData item, ref (bool, int) __result) { __result = Rules.Route(Object.op_Implicit((Object)(object)item?.m_dropPrefab) ? ((Object)item.m_dropPrefab).name : null, item?.m_shared?.m_name, Config.Wings6Enabled.Value, __result); } private static void StaminaDrain(ref float __result) { __result = Rules.Drain(__result, LocalNight(Player.m_localPlayer)); } private static void ForwardSpeed(int wingsIndex, ref float __result) { __result = Rules.Forward(__result, wingsIndex, wingsIndex == 6 && LocalNight(Player.m_localPlayer)); } private static void DescentSpeed(int wingsIndex, ref float __result) { __result = Rules.Descent(__result, wingsIndex, wingsIndex == 6 && LocalNight(Player.m_localPlayer)); } private static void StoredVisual(int itemHash, List<GameObject> __result) { if (itemHash != StringExtensionMethods.GetStableHashCode("Glider_NightWanderer") || __result == null) { return; } foreach (GameObject item in __result) { self.SafeFinish(item, "equipped backpack"); } } private static void LocalVisual(Player player, GameObject gliderMesh) { if (LocalNight(player)) { self.SafeFinish(gliderMesh, "local flight"); } } private static void SyncVariant(Player player, bool isGliding) { ZNetView val = (Object.op_Implicit((Object)(object)player) ? ((Component)player).GetComponent<ZNetView>() : null); if (Object.op_Implicit((Object)(object)player) && (Object)(object)player == (Object)(object)Player.m_localPlayer && Object.op_Implicit((Object)(object)val) && val.IsValid() && val.IsOwner()) { val.GetZDO().Set("NightWanderer_Active", isGliding && LocalNight(player)); } } private static void RemoteVisual(Player player, GameObject gliderMesh) { ZNetView val = (Object.op_Implicit((Object)(object)player) ? ((Component)player).GetComponent<ZNetView>() : null); if (Object.op_Implicit((Object)(object)val) && val.IsValid() && val.GetZDO().GetBool("NightWanderer_Active", false)) { self.SafeFinish(gliderMesh, "remote flight"); } } private void SafeFinish(GameObject obj, string context) { try { ApplyFinish(obj); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not apply black finish to " + context + ": " + ex)); } } private int ApplyFinish(GameObject obj) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)obj)) { return 0; } int num = 0; Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!(val is MeshRenderer) && !(val is SkinnedMeshRenderer)) { continue; } Material[] sharedMaterials = val.sharedMaterials; bool flag = false; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if (!Object.op_Implicit((Object)(object)val2) || !((Object)val2).name.StartsWith("Mat_Cart_FineWoodGlider_Ygg2", StringComparison.Ordinal)) { continue; } if (!materials.TryGetValue(val2, out var value)) { value = new Material(val2) { name = "NightWanderer_Charcoal" }; value.SetTexture("_MainTex", (Texture)(object)hideTexture); value.SetColor("_Color", Color.white); string[] array = new string[6] { "_DetailAlbedoMap", "_DetailNormalMap", "_EmissionMap", "_BumpMap", "_MetallicGlossMap", "_ParallaxMap" }; foreach (string text in array) { if (value.HasProperty(text)) { value.SetTexture(text, (Texture)null); } } string[] array2 = new string[7] { "_DETAIL_MULX2", "_EMISSION", "_ALPHABLEND_ON", "_ALPHAPREMULTIPLY_ON", "_NORMALMAP", "_METALLICGLOSSMAP", "_PARALLAXMAP" }; foreach (string text2 in array2) { value.DisableKeyword(text2); } string[] array3 = new string[3] { "_Glossiness", "_Smoothness", "_Metallic" }; foreach (string text3 in array3) { if (value.HasProperty(text3)) { value.SetFloat(text3, 0.05f); } } if (value.HasProperty("_EmissionColor")) { value.SetColor("_EmissionColor", Color.black); } if (value.HasProperty("_Mode")) { value.SetFloat("_Mode", 0f); } if (value.HasProperty("_SrcBlend")) { value.SetInt("_SrcBlend", 1); } if (value.HasProperty("_DstBlend")) { value.SetInt("_DstBlend", 0); } if (value.HasProperty("_ZWrite")) { value.SetInt("_ZWrite", 1); } value.SetOverrideTag("RenderType", "Opaque"); value.renderQueue = 2000; materials.Add(val2, value); } sharedMaterials[j] = value; flag = true; num++; } if (flag) { val.sharedMaterials = sharedMaterials; } } return num; } } public static class Rules { public const string ItemId = "Glider_NightWanderer"; public const string SourceId = "Glider_Troll_Ygg"; public const string NameKey = "$item_Glider_NightWanderer"; public const string NetworkKey = "NightWanderer_Active"; public const int WingsIndex = 6; public const float Charcoal = 0.085f; public const float StaminaFactor = 0.9f; public const float ForwardSpeed = 10f; public const float DescentSpeed = -2.5f; public static bool IsNight(string prefab, string name) { return string.Equals(prefab, "Glider_NightWanderer", StringComparison.Ordinal) || string.Equals(name, "$item_Glider_NightWanderer", StringComparison.Ordinal); } public static (bool, int) Route(string prefab, string name, bool sourceEnabled, (bool, int) original) { return IsNight(prefab, name) ? (sourceEnabled, sourceEnabled ? 6 : (-1)) : original; } public static float Drain(float original, bool equipped) { return (equipped && original > 0f) ? (original * 0.9f) : original; } public static float Forward(float original, int index, bool equipped) { return (equipped && index == 6) ? 10f : original; } public static float Descent(float original, int index, bool equipped) { return (equipped && index == 6) ? (-2.5f) : original; } } }
BepInEx/plugins/NoCrystalGliderCraft/NoCrystalGliderCraft.dll
Decompiled 14 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NoCrystalGliderCraft { [BepInPlugin("local.gliders.nocrystalcraft", "No Crystal Glider Craft", "1.0.0")] [BepInDependency("Yggdrah.ValheimGliders", "1.0.5")] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Player), "GetAvailableRecipes")] private static class RecipeList { [HarmonyPriority(0)] private static void Prefix() { DisableRecipe(); } [HarmonyPriority(0)] [HarmonyAfter(new string[] { "local.gliders.russian" })] private static void Postfix(ref List<Recipe> __0) { __0?.RemoveAll(IsTarget); } } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] private static class CraftGuard { [HarmonyPriority(800)] private static bool Prefix(Recipe ___m_craftRecipe) { return !IsTarget(___m_craftRecipe); } } public const string Guid = "local.gliders.nocrystalcraft"; public const string TargetPrefab = "Glider_BackPack_Ygg"; private Harmony harmony; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown harmony = new Harmony("local.gliders.nocrystalcraft"); try { harmony.PatchAll(typeof(Plugin).Assembly); DisableRecipe(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Crystal glider crafting disabled; existing items and other gliders are retained."); } catch { harmony.UnpatchSelf(); throw; } } private static bool Matches(string name) { return string.Equals(name, "Glider_BackPack_Ygg", StringComparison.Ordinal) || string.Equals(name, "Glider_BackPack_Ygg(Clone)", StringComparison.Ordinal); } internal static bool IsTarget(Recipe recipe) { if (!Object.op_Implicit((Object)(object)recipe) || !Object.op_Implicit((Object)(object)recipe.m_item)) { return false; } ItemData itemData = recipe.m_item.m_itemData; return Matches(((Object)((Component)recipe.m_item).gameObject).name) || (Object.op_Implicit((Object)(object)itemData?.m_dropPrefab) && Matches(((Object)itemData.m_dropPrefab).name)) || string.Equals(itemData?.m_shared?.m_name, "$item_Glider_BackPack_Ygg", StringComparison.Ordinal); } private static void DisableRecipe() { if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || ObjectDB.instance.m_recipes == null) { return; } foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if (IsTarget(recipe)) { recipe.m_enabled = false; } } } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } }
BepInEx/plugins/SosalGliders/SosalGliders.dll
Decompiled 14 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [BepInPlugin("local.sosal.gliders", "Sosal Gliders", "1.0.0")] [BepInDependency("Yggdrah.ValheimGliders", "1.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency("local.gliders.modertexture", "4.0.2")] [BepInDependency("local.gliders.nightwanderer", "1.0.4")] public sealed class SosalGliders : BaseUnityPlugin { public static bool CompatibilityReady; private void Awake() { FieldInfo field = typeof(ZRoutedRpc).GetField("Everybody", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); CompatibilityReady = field != null && !field.IsLiteral && Convert.ToInt64(field.GetValue(null)) == 0; if (!CompatibilityReady) { throw new InvalidOperationException("Sosal Gliders RPC preloader is missing. Install the BepInEx/patchers folder and restart."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Sosal Gliders: four-glider pack loaded; RPC compatibility verified."); } }