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 TjalfesMarrow v0.11.0
TjalfesMarrow.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: AssemblyCompany("TjalfesMarrow")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TjalfesMarrow")] [assembly: AssemblyTitle("TjalfesMarrow")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 TjalfesMarrow { [BepInPlugin("TjalfesMarrow", "TjalfesMarrow", "0.11.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string ModGuid = "TjalfesMarrow"; public const string ModName = "TjalfesMarrow"; public const string ModVersion = "0.11.0"; internal const string ItemId = "TjalfesMarrow"; private const string BaseItem = "TrinketBloodGoldHealth"; internal const string MouldId = "TjalfesMarrowMould_TM"; internal const string CastId = "TjalfesMarrowCast_TM"; private static readonly string[] MouldBaseItems = new string[2] { "MoldSmallParts", "Flint" }; private static readonly string[] CastBaseItems = new string[2] { "SmallPartsGoldUncooked", "Flint" }; internal static ManualLogSource Log; internal static ConfigEntry<float> SpeedBonus; internal static ConfigEntry<float> ExploreBonus; internal static ConfigEntry<float> StaminaRegenBonus; internal static ConfigEntry<float> RunSaving; internal static ConfigEntry<float> JumpSaving; internal static ConfigEntry<bool> Craftable; internal static ConfigEntry<string> Station; internal static ConfigEntry<string> Ingredients; internal static ConfigEntry<int> StationLevel; internal static ConfigEntry<int> CastStationLevel; internal static ConfigEntry<bool> MouldNeeded; internal static ConfigEntry<string> CastStation; internal static ConfigEntry<string> FoundryPrefab; internal static ConfigEntry<float> FoundryTime; internal static ConfigEntry<float> LookGrey; internal static ConfigEntry<float> LookLight; private Harmony harmony; private CustomItem item; private SE_Stats effect; private Recipe recipe; private CustomItem mould; private CustomItem cast; private Recipe castRecipe; private ItemConversion conversion; private readonly Dictionary<Renderer, Material[]> originalMaterials = new Dictionary<Renderer, Material[]>(); private Sprite[] originalIcons; private readonly List<Object> madeForLook = new List<Object>(); private float lookGrey = -1f; private float lookLight = -1f; private static readonly HashSet<string> shown = new HashSet<string>(); private static readonly HashSet<string> told = new HashSet<string>(); private void Awake() { //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; SpeedBonus = Bind("1 - Effects", "Speed bonus (%)", 10f, "How much faster the one who wears the amulet walks, jogs and runs, in percent. Default 10. A change is used at once."); ExploreBonus = Bind("1 - Effects", "Discovery radius increase (%)", 50f, "How much bigger the area is that is uncovered on the map around the one who wears the amulet, in percent. Default 50."); StaminaRegenBonus = Bind("1 - Effects", "Stamina regeneration bonus (%)", 10f, "How much faster the stamina of the one who wears the amulet comes back, in percent. Default 10."); RunSaving = Bind("1 - Effects", "Run stamina saving (%)", 40f, "How much less stamina the one who wears the amulet uses for running, in percent. Default 40."); JumpSaving = Bind("1 - Effects", "Jump stamina use reduction (%)", 10f, "How much less stamina the one who wears the amulet uses for jumping, in percent. Default 10."); Craftable = Bind("2 - Crafting", "Craftable", def: true, "Whether the amulet can be crafted. Default true."); Station = Bind("2 - Crafting", "Crafting station", "Workbench", "Where the amulet is crafted when no mould is needed. A name such as Workbench, Forge, Cauldron, Stonecutter, ArtisanTable, BlackForge, MageTable, or the prefab name of any crafting station (for example piece_workbench). Empty or None: no station is needed. Default Workbench."); StationLevel = Bind("2 - Crafting", "Station level", 1, "The level that the crafting station needs to have. Default 1."); Ingredients = Bind("2 - Crafting", "Ingredients", "Pearl:3,LeatherScraps:3,BoneFragments:5", "What the amulet costs (with a mould: what the cast costs, together with the mould): ItemPrefab:amount, comma separated. An optional third number is the extra amount per upgrade level (ItemPrefab:amount:perLevel). Default Pearl:3,LeatherScraps:3,BoneFragments:5 (3 pearls, 3 leather scraps and 5 bones)."); MouldNeeded = Bind("2 - Crafting", "Mould needed", def: true, "The amulet is made in three steps: the mould (an item of its own, TjalfesMarrowMould_TM, which is used up) and the ingredients above make a cast (TjalfesMarrowCast_TM) at 'Cast station', and the cast is turned into the amulet in the Frost Foundry. The mould is not crafted and has no source of its own, so you have to give it to the players (spawn it, or put it in a loot list). With false, no mould, cast or foundry is needed: the amulet is crafted directly from the ingredients at 'Crafting station'. Default true."); CastStation = Bind("2 - Crafting", "Cast station", "BlackForge", "Where the cast is crafted (when a mould is needed). Same names as 'Crafting station'. Default BlackForge."); CastStationLevel = Bind("2 - Crafting", "Cast station level", 1, "The level that the station of the cast needs to have. Default 1."); FoundryTime = Bind("2 - Crafting", "Foundry time (seconds)", 60f, "How long the Frost Foundry needs to turn the cast into the amulet. Default 60."); FoundryPrefab = Bind("2 - Crafting", "Frost Foundry prefab", "piece_FrostFoundry", "The prefab name of the Frost Foundry, where the cast is turned into the amulet. Default piece_FrostFoundry."); LookGrey = Bind("3 - Look", "Grey amount (%)", 85f, "How much of the original gold colour is turned into grey, 0 to 100. 0 = the colours of the original trinket, 100 = completely grey. Default 85. A change is used at once."); LookLight = Bind("3 - Look", "Lightness (%)", 125f, "How light the amulet is, in percent. 100 = as the original, above 100 = lighter and whiter. Default 125. A change is used at once."); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { ApplyAll(); }; SynchronizationManager.OnConfigurationSynchronized += delegate { Log.LogInfo((object)($"The settings of the server were received: speed +{SpeedBonus.Value}%, discovery radius +{ExploreBonus.Value}%, stamina regeneration +{StaminaRegenBonus.Value}%, " + $"run -{RunSaving.Value}%, jump -{JumpSaving.Value}%, grey {LookGrey.Value}%, lightness {LookLight.Value}%, ingredients {Ingredients.Value}")); ApplyAll(); }; PrefabManager.OnVanillaPrefabsAvailable += AddAmulet; ItemManager.OnItemsRegistered += ApplyAll; PrefabManager.OnPrefabsRegistered += ApplyAll; PrefabManager.OnPrefabsRegistered += AddFoundryConversion; harmony = new Harmony("TjalfesMarrow"); InstallExplore(harmony); InstallSpeed(harmony); InstallStamina(harmony); InstallStaminaUse(harmony); Log.LogInfo((object)string.Format("{0} {1} (beta) loaded (speed +{2}%, discovery radius +{3}%, stamina regeneration +{4}%, run -{5}%, jump -{6}%)", "TjalfesMarrow", "0.11.0", SpeedBonus.Value, ExploreBonus.Value, StaminaRegenBonus.Value, RunSaving.Value, JumpSaving.Value)); } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); } } private ConfigEntry<T> Bind<T>(string section, string key, T def, string desc) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown return ((BaseUnityPlugin)this).Config.Bind<T>(section, key, def, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); } private void AddAmulet() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_0195: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: 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_022c: Expected O, but got Unknown //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= AddAmulet; try { effect = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)effect).name = "SE_TjalfesMarrow"; ((StatusEffect)effect).m_name = "Tjalfes Marrow"; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)effect, false)); ItemConfig val = new ItemConfig { Name = "Tjalfes Marrow", Description = "An amulet of old marrow and pearl. It makes the one who wears it swifter, and shows more of the world around them." }; item = new CustomItem("TjalfesMarrow", "TrinketBloodGoldHealth", val); SharedData shared = item.ItemDrop.m_itemData.m_shared; shared.m_equipStatusEffect = (StatusEffect)(object)effect; shared.m_setStatusEffect = null; shared.m_setName = ""; shared.m_setSize = 0; ClearAdrenaline(shared); RememberOriginals(); ItemManager.Instance.AddItem(item); recipe = ScriptableObject.CreateInstance<Recipe>(); ((Object)recipe).name = "Recipe_TjalfesMarrow"; recipe.m_item = item.ItemDrop; recipe.m_amount = 1; recipe.m_resources = (Requirement[])(object)new Requirement[0]; ItemManager.Instance.AddRecipe(new CustomRecipe(recipe, false, false)); string text = MouldBaseItems.FirstOrDefault((string n) => (Object)(object)PrefabManager.Instance.GetPrefab(n) != (Object)null); if (text != null) { mould = new CustomItem("TjalfesMarrowMould_TM", text, new ItemConfig { Name = "Mould: Tjalfes Marrow", Description = "A mould for the Tjalfes Marrow amulet. It is used up when the cast is made." }); ItemManager.Instance.AddItem(mould); } else { Log.LogWarning((object)("None of " + string.Join(", ", MouldBaseItems) + " exists: the mould could not be made")); } string text2 = CastBaseItems.FirstOrDefault((string n) => (Object)(object)PrefabManager.Instance.GetPrefab(n) != (Object)null); if (text2 != null) { cast = new CustomItem("TjalfesMarrowCast_TM", text2, new ItemConfig { Name = "Cast: Tjalfes Marrow", Description = "The Tjalfes Marrow has to be made from this cast in the Frost Foundry." }); ItemManager.Instance.AddItem(cast); castRecipe = ScriptableObject.CreateInstance<Recipe>(); ((Object)castRecipe).name = "Recipe_TjalfesMarrowCast_TM"; castRecipe.m_item = cast.ItemDrop; castRecipe.m_amount = 1; castRecipe.m_resources = (Requirement[])(object)new Requirement[0]; ItemManager.Instance.AddRecipe(new CustomRecipe(castRecipe, false, false)); } else { Log.LogWarning((object)("None of " + string.Join(", ", CastBaseItems) + " exists: the cast could not be made")); } Log.LogInfo((object)("Added the amulet TjalfesMarrow, " + ((mould != null) ? "TjalfesMarrowMould_TM" : "no mould") + " and " + ((cast != null) ? "TjalfesMarrowCast_TM" : "no cast"))); } catch (Exception ex) { Log.LogWarning((object)("Could not add the amulet: " + ex.Message)); } } private void RememberOriginals() { if (!Application.isBatchMode) { Renderer[] componentsInChildren = item.ItemPrefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { originalMaterials[val] = val.sharedMaterials; } originalIcons = item.ItemDrop.m_itemData.m_shared.m_icons; } } private void ApplyLook() { //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_031a: 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_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Expected O, but got Unknown //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) if (Application.isBatchMode || item == null || originalMaterials.Count == 0) { return; } float num = Mathf.Clamp01(LookGrey.Value / 100f); float num2 = Mathf.Max(0f, LookLight.Value / 100f); if (Mathf.Approximately(num, lookGrey) && Mathf.Approximately(num2, lookLight)) { return; } lookGrey = num; lookLight = num2; try { foreach (Object item in madeForLook) { if (item != (Object)null) { Object.Destroy(item); } } madeForLook.Clear(); Dictionary<Texture, Texture2D> dictionary = new Dictionary<Texture, Texture2D>(); foreach (KeyValuePair<Renderer, Material[]> originalMaterial in originalMaterials) { if ((Object)(object)originalMaterial.Key == (Object)null) { continue; } Material[] array = (Material[])(object)new Material[originalMaterial.Value.Length]; for (int i = 0; i < array.Length; i++) { if ((Object)(object)originalMaterial.Value[i] == (Object)null) { continue; } Material val = new Material(originalMaterial.Value[i]); madeForLook.Add((Object)(object)val); if (val.HasProperty("_MainTex") && (Object)(object)val.mainTexture != (Object)null) { Texture mainTexture = val.mainTexture; if (!dictionary.TryGetValue(mainTexture, out var value)) { value = ReadableCopy(mainTexture); if ((Object)(object)value != (Object)null) { Color[] pixels = value.GetPixels(); for (int j = 0; j < pixels.Length; j++) { pixels[j] = Tint(pixels[j], num, num2); } value.SetPixels(pixels); value.Apply(); madeForLook.Add((Object)(object)value); } dictionary[mainTexture] = value; } if ((Object)(object)value != (Object)null) { val.mainTexture = (Texture)(object)value; } } if (val.HasProperty("_Color")) { val.color = Tint(val.color, num, num2); } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", Tint(val.GetColor("_EmissionColor"), num, 1f)); } array[i] = val; } originalMaterial.Key.sharedMaterials = array; } SharedData shared = this.item.ItemDrop.m_itemData.m_shared; if (originalIcons != null) { Sprite[] array2 = (Sprite[])(object)new Sprite[originalIcons.Length]; for (int k = 0; k < array2.Length; k++) { Sprite val2 = (array2[k] = originalIcons[k]); if ((Object)(object)val2 == (Object)null || (Object)(object)val2.texture == (Object)null) { continue; } Texture2D val3 = ReadableCopy((Texture)(object)val2.texture); if (!((Object)(object)val3 == (Object)null)) { Rect textureRect = val2.textureRect; Color[] pixels2 = val3.GetPixels((int)((Rect)(ref textureRect)).x, (int)((Rect)(ref textureRect)).y, (int)((Rect)(ref textureRect)).width, (int)((Rect)(ref textureRect)).height); Object.Destroy((Object)(object)val3); for (int l = 0; l < pixels2.Length; l++) { pixels2[l] = Tint(pixels2[l], num, num2); } Texture2D val4 = new Texture2D((int)((Rect)(ref textureRect)).width, (int)((Rect)(ref textureRect)).height, (TextureFormat)4, false); val4.SetPixels(pixels2); val4.Apply(); Sprite val5 = Sprite.Create(val4, new Rect(0f, 0f, (float)((Texture)val4).width, (float)((Texture)val4).height), new Vector2(0.5f, 0.5f), val2.pixelsPerUnit); madeForLook.Add((Object)(object)val4); madeForLook.Add((Object)(object)val5); array2[k] = val5; } } shared.m_icons = array2; } Log.LogInfo((object)("Tjalfes Marrow: the model and the icon were made greyer and lighter (grey " + LookGrey.Value + "%, lightness " + LookLight.Value + "%)")); } catch (Exception ex) { Log.LogWarning((object)("Could not change the look of the amulet (it keeps the original colours): " + ex.Message)); } } private static Color Tint(Color color, float grey, float light) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) float num = color.r * 0.299f + color.g * 0.587f + color.b * 0.114f; Color val = Color.Lerp(color, new Color(num, num, num, color.a), grey); return new Color(Mathf.Clamp01(val.r * light), Mathf.Clamp01(val.g * light), Mathf.Clamp01(val.b * light), color.a); } private static Texture2D ReadableCopy(Texture source) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown if ((Object)(object)source == (Object)null || source.width <= 0 || source.height <= 0) { return null; } RenderTexture temporary = RenderTexture.GetTemporary(source.width, source.height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)0); RenderTexture active = RenderTexture.active; try { Graphics.Blit(source, temporary); RenderTexture.active = temporary; Texture2D val = new Texture2D(source.width, source.height, (TextureFormat)4, false); val.ReadPixels(new Rect(0f, 0f, (float)source.width, (float)source.height), 0, 0); val.Apply(); return val; } finally { RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); } } private static void ClearAdrenaline(SharedData shared) { shared.m_maxAdrenaline = 0f; shared.m_fullAdrenalineSE = null; shared.m_perfectBlockAdrenaline = 0f; Log.LogInfo((object)"The adrenaline of the amulet was cleared (meter, burst effect, perfect block)"); } private void ApplyAll() { if (item == null || (Object)(object)effect == (Object)null) { return; } try { ApplyLook(); ((StatusEffect)effect).m_tooltip = "Movement speed " + Signed(SpeedBonus.Value) + "%\nDiscovery radius " + Signed(ExploreBonus.Value) + "%\nStamina regeneration " + Signed(StaminaRegenBonus.Value) + "%\nRun stamina use " + Signed(0f - RunSaving.Value) + "%\nJump stamina use " + Signed(0f - JumpSaving.Value) + "%"; ApplyRecipe(); } catch (Exception ex) { Log.LogWarning((object)("Could not apply the settings of the amulet: " + ex.Message)); } } private static void ShowOnce(string effect, string detail) { if (shown.Add(effect)) { Log.LogInfo((object)("In effect: " + effect + " (" + detail + ")")); } } private static string Signed(float value) { return ((value >= 0f) ? "+" : "") + value.ToString("0.#"); } private void ApplyRecipe() { //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown if ((Object)(object)recipe == (Object)null || (Object)(object)ObjectDB.instance == (Object)null || (Object)(object)ZNetScene.instance == (Object)null) { return; } bool flag = MouldNeeded.Value && mould != null && cast != null && (Object)(object)castRecipe != (Object)null; List<Requirement> list = new List<Requirement>(); string[] array = (Ingredients.Value ?? "").Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Trim().Split(new char[1] { ':' }); GameObject val = FindItem(array2[0].Trim()); ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); if (!((Object)(object)val2 == (Object)null)) { int result; int amount = ((array2.Length <= 1 || !int.TryParse(array2[1], out result)) ? 1 : Mathf.Max(1, result)); int result2; int amountPerLevel = ((array2.Length > 2 && int.TryParse(array2[2], out result2)) ? Mathf.Max(0, result2) : 0); list.Add(new Requirement { m_resItem = val2, m_amount = amount, m_amountPerLevel = amountPerLevel, m_recover = true }); } } recipe.m_enabled = Craftable.Value && !flag; recipe.m_craftingStation = FindStation(Station.Value); recipe.m_minStationLevel = Mathf.Max(1, StationLevel.Value); recipe.m_resources = list.ToArray(); if ((Object)(object)castRecipe != (Object)null) { castRecipe.m_enabled = Craftable.Value && flag; castRecipe.m_craftingStation = FindStation(CastStation.Value); castRecipe.m_minStationLevel = Mathf.Max(1, CastStationLevel.Value); List<Requirement> list2 = new List<Requirement>(); if (mould != null) { list2.Add(new Requirement { m_resItem = mould.ItemDrop, m_amount = 1, m_amountPerLevel = 0, m_recover = false }); } list2.AddRange(list); castRecipe.m_resources = list2.ToArray(); } if (conversion != null) { conversion.m_cookTime = Mathf.Max(1f, FoundryTime.Value); } } private void AddFoundryConversion() { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown PrefabManager.OnPrefabsRegistered -= AddFoundryConversion; if (cast == null || item == null) { return; } string text = (FoundryPrefab.Value ?? "").Trim(); CookingStation val = null; foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null) && !(((Object)prefab).name != text)) { val = prefab.GetComponentInChildren<CookingStation>(true); break; } } if ((Object)(object)val == (Object)null) { Log.LogWarning((object)("The Frost Foundry '" + text + "' was not found as a cooking station: the cast cannot be turned into the amulet. Check 'Frost Foundry prefab'.")); return; } ItemConversion val2 = ((IEnumerable<ItemConversion>)val.m_conversion).FirstOrDefault((Func<ItemConversion, bool>)((ItemConversion c) => (Object)(object)c.m_from == (Object)(object)cast.ItemDrop)); if (val2 != null) { conversion = val2; return; } conversion = new ItemConversion { m_from = cast.ItemDrop, m_to = item.ItemDrop, m_cookTime = Mathf.Max(1f, FoundryTime.Value) }; val.m_conversion.Add(conversion); Log.LogInfo((object)("Frost Foundry (" + ((Object)val).name + "): TjalfesMarrowCast_TM -> TjalfesMarrow in " + FoundryTime.Value + "s")); } private static GameObject FindItem(string name) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(name); if ((Object)(object)itemPrefab != (Object)null) { return itemPrefab; } foreach (GameObject item in ObjectDB.instance.m_items) { if ((Object)(object)item != (Object)null && ((Object)item).name.Equals(name, StringComparison.OrdinalIgnoreCase)) { return item; } } if (name.Equals("Pearl", StringComparison.OrdinalIgnoreCase)) { itemPrefab = ObjectDB.instance.GetItemPrefab("AmberPearl"); if ((Object)(object)itemPrefab != (Object)null) { if (told.Add(name)) { Log.LogInfo((object)"Tjalfes Marrow: there is no item called 'Pearl' in this game, so 'AmberPearl' (the Amber Pearl) is used"); } return itemPrefab; } } if (told.Add(name)) { string[] array = (from i in ObjectDB.instance.m_items where (Object)(object)i != (Object)null && ((Object)i).name.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0 select ((Object)i).name).Take(12).ToArray(); Log.LogWarning((object)("Tjalfes Marrow: no item called '" + name + "' (ingredients). Similar names: " + ((array.Length == 0) ? "none" : string.Join(", ", array)))); } return null; } private static CraftingStation FindStation(string name) { name = (name ?? "").Trim(); if (name.Length == 0 || name.Equals("None", StringComparison.OrdinalIgnoreCase)) { return null; } string value; string text = (new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Workbench", "piece_workbench" }, { "Forge", "forge" }, { "Cauldron", "piece_cauldron" }, { "Stonecutter", "piece_stonecutter" }, { "ArtisanTable", "piece_artisanstation" }, { "Artisan", "piece_artisanstation" }, { "BlackForge", "blackforge" }, { "MageTable", "piece_magetable" } }.TryGetValue(name, out value) ? value : name); GameObject prefab = ZNetScene.instance.GetPrefab(text); CraftingStation val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<CraftingStation>() : null); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)("Tjalfes Marrow: no crafting station called '" + name + "' (" + text + "): the amulet needs no station")); } return val; } private static void InstallExplore(Harmony harmony) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0065: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(typeof(Minimap), "UpdateExplore", (Type[])null, (Type[])null); if (methodInfo == null) { Log.LogWarning((object)"Minimap.UpdateExplore not found: the amulet does not change the discovery radius"); return; } harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "BeforeExplore", (Type[])null), new HarmonyMethod(typeof(Plugin), "AfterExplore", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Discovery radius: set up"); } catch (Exception ex) { Log.LogWarning((object)("Could not set up the discovery radius: " + ex.Message)); } } private static void BeforeExplore(Minimap __instance, out float __state) { __state = __instance.m_exploreRadius; Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && Wearing(localPlayer)) { float exploreRadius = __state * (1f + Mathf.Max(-90f, ExploreBonus.Value) / 100f); ShowOnce("discovery radius", __state.ToString("0") + " m -> " + exploreRadius.ToString("0") + " m"); __instance.m_exploreRadius = exploreRadius; } } private static void AfterExplore(Minimap __instance, float __state) { __instance.m_exploreRadius = __state; } private static void InstallSpeed(Harmony harmony) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(typeof(Player), "GetEquipmentMovementModifier", (Type[])null, (Type[])null); if (methodInfo == null) { Log.LogWarning((object)"Player.GetEquipmentMovementModifier not found: the amulet does not change the movement speed"); return; } harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "Faster", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Movement speed: set up"); } catch (Exception ex) { Log.LogWarning((object)("Could not set up the movement speed: " + ex.Message)); } } private static void Faster(Player __instance, ref float __result) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && Wearing(__instance)) { __result += Mathf.Max(-90f, SpeedBonus.Value) / 100f; ShowOnce("movement speed", "equipment modifier now " + __result.ToString("0.00")); } } private static void InstallStamina(Harmony harmony) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(typeof(SEMan), "ModifyStaminaRegen", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "FasterStamina", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Stamina regeneration: set up"); } else { Log.LogWarning((object)"SEMan.ModifyStaminaRegen not found: the amulet does not change the stamina regeneration"); } } catch (Exception ex) { Log.LogWarning((object)("Could not set up the stamina regeneration: " + ex.Message)); } } private static void FasterStamina(SEMan __instance, ref float staminaMultiplier) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && __instance != null && !((Object)(object)__instance.m_character != (Object)(object)localPlayer) && Wearing(localPlayer)) { staminaMultiplier += Mathf.Max(-90f, StaminaRegenBonus.Value) / 100f; ShowOnce("stamina regeneration", "multiplier now " + staminaMultiplier.ToString("0.00")); } } private static void InstallStaminaUse(Harmony harmony) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(typeof(Player), "GetEquipmentRunStaminaModifier", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "LessRunStamina", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Run stamina use: set up"); } else { Log.LogWarning((object)"Player.GetEquipmentRunStaminaModifier not found: the amulet does not lower the stamina use of running"); } MethodInfo methodInfo2 = AccessTools.Method(typeof(Player), "GetEquipmentJumpStaminaModifier", (Type[])null, (Type[])null); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "LessJumpStamina", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Jump stamina use: set up"); } else { Log.LogWarning((object)"Player.GetEquipmentJumpStaminaModifier not found: the amulet does not lower the stamina use of jumping"); } } catch (Exception ex) { Log.LogWarning((object)("Could not set up the stamina use: " + ex.Message)); } } private static void LessRunStamina(Player __instance, ref float __result) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && Wearing(__instance)) { __result -= Mathf.Clamp(RunSaving.Value, -100f, 100f) / 100f; ShowOnce("run stamina use", "modifier now " + __result.ToString("0.00")); } } private static void LessJumpStamina(Player __instance, ref float __result) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && Wearing(__instance)) { __result -= Mathf.Clamp(JumpSaving.Value, -100f, 100f) / 100f; ShowOnce("jump stamina use", "modifier now " + __result.ToString("0.00")); } } private static bool Wearing(Player player) { ItemData val = (((Object)(object)player != (Object)null) ? ((Humanoid)player).m_trinketItem : null); bool flag = val != null && (Object)(object)val.m_dropPrefab != (Object)null && ((Object)val.m_dropPrefab).name == "TjalfesMarrow"; if ((Object)(object)player == (Object)(object)Player.m_localPlayer && shown.Add("trinket slot: " + ((val != null && (Object)(object)val.m_dropPrefab != (Object)null) ? ((Object)val.m_dropPrefab).name : "empty"))) { Log.LogInfo((object)("Trinket slot of the local player: " + ((val != null && (Object)(object)val.m_dropPrefab != (Object)null) ? ((Object)val.m_dropPrefab).name : "empty") + (flag ? " (the amulet)" : ""))); } return flag; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }