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 HoneySeal v2.0.2
BepInEx/plugins/BeeswaxCoating.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("BeeswaxCoating")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.0.2.0")] [assembly: AssemblyInformationalVersion("2.0.2+6afed075006b8bd8f5ba491151619501cdc6e2b5")] [assembly: AssemblyProduct("BeeswaxCoating")] [assembly: AssemblyTitle("BeeswaxCoating")] [assembly: AssemblyVersion("2.0.2.0")] namespace BeeswaxCoating; internal static class CoatingItem { public const string PrefabName = "BeeswaxCoating"; public const string WaxPrefabName = "Beeswax"; } [BepInPlugin("benjamin.beeswaxcoating", "HoneySeal", "2.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class BeeswaxCoatingPlugin : BaseUnityPlugin { public const string PluginGuid = "benjamin.beeswaxcoating"; public const string PluginName = "HoneySeal"; public const string PluginVersion = "2.0.2"; internal static ManualLogSource Logger; internal static ConfigEntry<bool> ShowHoverBadge; internal static ConfigEntry<int> BrushUses; internal static ConfigEntry<bool> CoatedSheen; internal static ConfigEntry<float> SheenIntensity; private Harmony _harmony; private bool _itemRegistered; private void Awake() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; ShowHoverBadge = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowHoverBadge", true, "Append a \"Honey sealed\" line to hover text."); BrushUses = ((BaseUnityPlugin)this).Config.Bind<int>("General", "BrushUses", 20, new ConfigDescription("Charges per crafted Honey Seal brush (shown as the durability bar). Applies to newly crafted brushes.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>())); CoatedSheen = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "CoatedSheen", true, "Give coated wood a subtle warm sheen so protected pieces can be recognized without hovering."); SheenIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "SheenIntensity", 0.15f, new ConfigDescription("Strength of the coated-wood sheen.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 0.5f), Array.Empty<object>())); PrefabManager.OnVanillaPrefabsAvailable += AddCoatingItem; _harmony = new Harmony("benjamin.beeswaxcoating"); _harmony.PatchAll(typeof(BeeswaxCoatingPlugin).Assembly); Logger.LogInfo((object)"HoneySeal 2.0.2 loaded"); } private void AddCoatingItem() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) PrefabManager.OnVanillaPrefabsAvailable -= AddCoatingItem; if (_itemRegistered) { return; } try { RegisterItem("Beeswax", "Beeswax", "A lump of amber beeswax. A legacy item - no longer used for crafting.", null, new Color(0.83f, 0.58f, 0.16f), new Color(0.55f, 0.36f, 0.08f)); ItemConfig val = new ItemConfig(); val.CraftingStation = "piece_workbench"; val.MinStationLevel = 1; val.Amount = 1; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Honey", 1, 0, true), new RequirementConfig("Resin", 2, 0, true) }; RegisterItem("BeeswaxCoating", "Honey Seal", "A soft lump of treated wax on a handle. Hold it and left-click exposed wood to brush on the coating.", val, new Color(0.94f, 0.87f, 0.64f), new Color(0.72f, 0.62f, 0.34f), isTool: true); _itemRegistered = true; } catch (Exception arg) { Logger.LogError((object)$"Failed to register items: {arg}"); } } private static void RegisterItem(string prefabName, string displayName, string description, ItemConfig recipeConfig, Color waxColor, Color cellColor, bool isTool = false) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Invalid comparison between Unknown and I4 //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) ItemConfig val = (ItemConfig)(((object)recipeConfig) ?? ((object)new ItemConfig())); val.Name = displayName; val.Description = description; CustomItem val2 = new CustomItem(prefabName, true, val); GameObject itemPrefab = val2.ItemPrefab; SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_itemType = (ItemType)((!isTool) ? 1 : 3); shared.m_maxStackSize = (isTool ? 1 : 50); shared.m_weight = 0.1f; if (isTool) { shared.m_useDurability = true; shared.m_maxDurability = BrushUses.Value; val2.ItemDrop.m_itemData.m_durability = BrushUses.Value; shared.m_equipDuration = 0f; shared.m_skillType = (SkillType)0; shared.m_blockPower = 0f; shared.m_timedBlockBonus = 0f; shared.m_attackForce = 0f; shared.m_backstabBonus = 0f; shared.m_perfectBlockAdrenaline = 0f; shared.m_blockAdrenaline = 0f; shared.m_maxBlockCharges = 0; shared.m_armor = 0f; } else { shared.m_useDurability = false; } shared.m_icons = (Sprite[])(object)new Sprite[1] { WaxAssets.CreateWaxIcon(waxColor, cellColor) }; if ((int)SystemInfo.graphicsDeviceType != 4) { int seed = ((prefabName == "BeeswaxCoating") ? 42 : 7); WaxAssets.AttachVisuals(itemPrefab, waxColor, cellColor, seed); } itemPrefab.layer = LayerMask.NameToLayer("item"); if ((Object)(object)itemPrefab.GetComponent<Rigidbody>() == (Object)null) { Rigidbody obj = itemPrefab.AddComponent<Rigidbody>(); obj.mass = 1f; obj.angularDrag = 0.6f; } BoxCollider component = itemPrefab.GetComponent<BoxCollider>(); if ((Object)(object)component != (Object)null) { component.size = new Vector3(0.45f, 0.3f, 0.45f); component.center = new Vector3(0f, 0.15f, 0f); } ItemManager.Instance.AddItem(val2); if (prefabName == "BeeswaxCoating") { WaxInteraction.CoatingSharedName = shared.m_name; } Logger.LogInfo((object)("Registered " + prefabName + " (token: " + shared.m_name + ", custom assets)")); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= AddCoatingItem; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal static class WaxAssets { public static void AttachVisuals(GameObject prefab, Color wax, Color cell, int seed) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Mesh sharedMesh = CreateWaxMesh(seed); Material val = CreateWaxMaterial(CreateWaxTexture(wax, cell, seed + 1)); MeshFilter component = prefab.GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null) { component.sharedMesh = sharedMesh; } MeshRenderer component2 = prefab.GetComponent<MeshRenderer>(); if ((Object)(object)component2 != (Object)null && (Object)(object)val != (Object)null) { ((Renderer)component2).sharedMaterial = val; } } public static Mesh CreateWaxMesh(int seed) { //IL_003b: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown Random rng = new Random(seed); List<Vector3> list = new List<Vector3>(150); List<Vector2> list2 = new List<Vector2>(150); List<int> list3 = new List<int>(300); AddHexPrism(list, list2, list3, rng, new Vector3(0f, 0f, 0f), 0.23f, 0.13f, 0.1f, 0.1f); AddHexPrism(list, list2, list3, rng, new Vector3(0.14f, 0.1f, 0.05f), 0.12f, 0.19f, 0.6f, 0.16f); AddHexPrism(list, list2, list3, rng, new Vector3(-0.13f, 0.09f, -0.06f), 0.09f, 0.15f, -0.4f, 0.18f); Mesh val = new Mesh { name = "BeeswaxCoating_WaxChunk" }; val.SetVertices(list); val.SetUVs(0, list2); val.SetTriangles(list3, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static void AddHexPrism(List<Vector3> verts, List<Vector2> uvs, List<int> tris, Random rng, Vector3 center, float radius, float height, float angleOffset, float jitter) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) int count = verts.Count; for (int i = 0; i < 2; i++) { float num = ((i == 0) ? 0f : height); for (int j = 0; j < 6; j++) { float num2 = angleOffset + (float)j * ((float)Math.PI / 3f); float num3 = radius * (1f + (float)(rng.NextDouble() * 2.0 - 1.0) * jitter); float num4 = Mathf.Cos(num2) * num3; float num5 = Mathf.Sin(num2) * num3; verts.Add(center + new Vector3(num4, num, num5)); uvs.Add(new Vector2(num4 / (radius * 4f) + 0.5f, num5 / (radius * 4f) + 0.5f)); } } int num6 = count + 6; for (int k = 1; k <= 4; k++) { tris.Add(count); tris.Add(count + k + 1); tris.Add(count + k); } for (int l = 1; l <= 4; l++) { tris.Add(num6); tris.Add(num6 + l); tris.Add(num6 + l + 1); } for (int m = 0; m < 6; m++) { int item = count + (m + 1) % 6; int item2 = num6 + (m + 1) % 6; tris.Add(count + m); tris.Add(item); tris.Add(item2); tris.Add(count + m); tris.Add(item2); tris.Add(num6 + m); } } public static Texture2D CreateWaxTexture(Color wax, Color cell, int seed) { //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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) Random random = new Random(seed); Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false) { name = "BeeswaxCoating_WaxTexture", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)0 }; Color[] array = (Color[])(object)new Color[16384]; float num = Mathf.Sqrt(3f) * 17f; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num2 = j; float num3 = i; float num4 = 25.5f; int num5 = Mathf.RoundToInt(num3 / num4); float num6 = Mathf.Round((num2 - ((num5 % 2 == 0) ? 0f : (num * 0.5f))) / num) * num + ((num5 % 2 == 0) ? 0f : (num * 0.5f)); float num7 = (float)num5 * num4; float num8 = Mathf.Abs(num2 - num6) / num; float num9 = Mathf.Abs(num3 - num7) / 17f + Mathf.Max(num8 - 0.5f, 0f); Color val2 = wax; if (num9 > 0.86f) { val2 = Color.Lerp(cell, wax, 0.25f); } else if (num9 > 0.78f) { val2 = Color.Lerp(wax, cell, 0.6f); } else { float num10 = Hash(num6 * 13.37f + num7 * 7.77f); val2 *= 0.92f + num10 * 0.14f; if (random.NextDouble() < 0.02) { val2 *= 0.85f; } } array[i * 128 + j] = val2; } } val.SetPixels(array); val.Apply(false, true); return val; } public static Sprite CreateWaxIcon(Color wax, Color cell) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_001e: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_012c: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { name = "BeeswaxCoating_WaxIcon", filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float x = ((float)j - 31.5f) / 24f; float y = (30.5f - (float)i) / 24f; float num = HexDist(x, y, 0.05f); float x2 = ((float)j - 45f) / 13f; float y2 = (44f - (float)i) / 13f; float num2 = HexDist(x2, y2, 0.35f); if (num < 1f || num2 < 1f) { bool num3 = num2 < num; float num4 = (num3 ? num2 : num); float num5 = (num3 ? 1.12f : 1f); num5 *= 0.85f + 0.3f * ((float)i / 64f); Color val2 = Color.Lerp(wax, cell, Mathf.Clamp01((num4 - 0.55f) * 2.2f)) * num5; if (!num3 && (((float)(j % 12) < 1.4f) ^ ((float)(i % 14) < 1.4f))) { val2 = Color.Lerp(val2, cell, 0.35f); } if (num4 > 0.93f) { val2 = cell * 0.55f; } array[i * 64 + j] = ClampColor(val2); } else { array[i * 64 + j] = Color.clear; } } } val.SetPixels(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f); } private static float HexDist(float x, float y, float rot) { float num = 0f; for (int i = 0; i < 6; i++) { float num2 = rot + (float)i * ((float)Math.PI / 3f); float num3 = x * Mathf.Cos(num2) + y * Mathf.Sin(num2); if (num3 > num) { num = num3; } } return num; } private static float Hash(float v) { double num = Math.Sin((double)v * 12.9898) * 43758.5453; return (float)(num - Math.Floor(num)); } private static Color ClampColor(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) return new Color(Mathf.Clamp01(c.r), Mathf.Clamp01(c.g), Mathf.Clamp01(c.b), Mathf.Clamp01(c.a)); } public static Material CreateWaxMaterial(Texture2D texture) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) string[] array = new string[4] { "Custom/Standard", "Sprites/Diffuse", "Sprites/Default", "Unlit/Texture" }; foreach (string text in array) { Shader val = Shader.Find(text); if ((Object)(object)val != (Object)null) { BeeswaxCoatingPlugin.Logger.LogInfo((object)("Wax material shader: " + text)); Material val2 = new Material(val) { mainTexture = (Texture)(object)texture }; if (val2.HasProperty("_Color")) { val2.SetColor("_Color", Color.white); } return val2; } } BeeswaxCoatingPlugin.Logger.LogWarning((object)"No shader found for wax material; item will render without one"); return null; } } internal enum WaxOutcome { NoTarget, NotBuildingPiece, DoesNotWeather, AlreadyWaxed, NotEnoughCoatings, Applied } internal static class WaxDecision { public static WaxOutcome Evaluate(bool hasHoveredPiece, bool hasWearNTear, bool suffersWeatherWear, bool alreadyWaxed, int coatingsOwned, int coatingsRequired) { if (!hasHoveredPiece) { return WaxOutcome.NoTarget; } if (!hasWearNTear) { return WaxOutcome.NotBuildingPiece; } if (!suffersWeatherWear) { return WaxOutcome.DoesNotWeather; } if (alreadyWaxed) { return WaxOutcome.AlreadyWaxed; } if (coatingsOwned < coatingsRequired) { return WaxOutcome.NotEnoughCoatings; } return WaxOutcome.Applied; } } internal static class WaxInteraction { internal static string CoatingSharedName; private static int _lastMessagePiece; private static WaxOutcome _lastMessageOutcome; private static float _lastMessageTime; private static readonly MethodInfo InventoryChangedMethod = typeof(Inventory).GetMethod("Changed", BindingFlags.Instance | BindingFlags.NonPublic); public static void TryApply() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)ZNetScene.instance == (Object)null || Menu.IsVisible() || InventoryGui.IsVisible() || Console.IsVisible() || TextInput.IsVisible() || Minimap.InTextInput() || Hud.IsPieceSelectionVisible()) { return; } ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon(); if (currentWeapon == null || string.IsNullOrEmpty(CoatingSharedName) || currentWeapon.m_shared.m_name != CoatingSharedName) { return; } GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject(); Piece val = (((Object)(object)hoverObject == (Object)null) ? null : hoverObject.GetComponentInParent<Piece>()); WearNTear val2 = (((Object)(object)val == (Object)null) ? null : ((Component)val).GetComponent<WearNTear>()); WaxOutcome waxOutcome = WaxDecision.Evaluate((Object)(object)val != (Object)null, (Object)(object)val2 != (Object)null, (Object)(object)val2 != (Object)null && IsWood(val2), (Object)(object)val2 != (Object)null && WaxState.IsWaxed(val2), 1, 1); switch (waxOutcome) { case WaxOutcome.NotBuildingPiece: Show(localPlayer, val, waxOutcome, "Only building pieces can be waxed"); break; case WaxOutcome.DoesNotWeather: Show(localPlayer, val, waxOutcome, PieceName(val) + " does not weather in the rain"); break; case WaxOutcome.AlreadyWaxed: Show(localPlayer, val, waxOutcome, PieceName(val) + " is already sealed"); break; case WaxOutcome.Applied: { Inventory inventory = ((Humanoid)localPlayer).GetInventory(); WaxState.SetWaxed(val2, value: true); WaxSheen.Apply(val2); currentWeapon.m_durability -= 1f; if (currentWeapon.m_durability <= 0f) { ((Humanoid)localPlayer).UnequipItem(currentWeapon, true); inventory.RemoveOneItem(currentWeapon); ((Character)localPlayer).Message((MessageType)1, "Honey seal applied - brush worn out", 0, (Sprite)null, false); } else { MarkInventoryChanged(inventory); ((Character)localPlayer).Message((MessageType)1, "Honey seal applied (" + Mathf.CeilToInt(currentWeapon.m_durability) + " uses left)", 0, (Sprite)null, false); } break; } case WaxOutcome.NotEnoughCoatings: break; } } private static void Show(Player player, Piece piece, WaxOutcome outcome, string text) { int num = (((Object)(object)piece != (Object)null) ? ((Object)piece).GetInstanceID() : 0); if (num != _lastMessagePiece || outcome != _lastMessageOutcome || !(Time.time - _lastMessageTime < 1f)) { _lastMessagePiece = num; _lastMessageOutcome = outcome; _lastMessageTime = Time.time; ((Character)player).Message((MessageType)1, text, 0, (Sprite)null, false); } } private static void MarkInventoryChanged(Inventory inventory) { try { InventoryChangedMethod?.Invoke(inventory, new object[2] { false, false }); } catch (Exception ex) { BeeswaxCoatingPlugin.Logger.LogDebug((object)("Inventory.Changed invoke failed: " + ex.Message)); } } private static bool IsWood(WearNTear wnt) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 MaterialType materialType = wnt.m_materialType; if ((int)materialType != 0 && (int)materialType != 3) { return (int)materialType == 8; } return true; } private static string PieceName(Piece piece) { return Localization.instance.Localize(piece.m_name); } } internal static class WaxState { private const string WaxedKey = "waxed"; public static bool IsWaxed(WearNTear wnt) { ZNetView validNetView = GetValidNetView((Component)(object)wnt); if ((Object)(object)validNetView != (Object)null) { return validNetView.GetZDO().GetBool("waxed", false); } return false; } public static void SetWaxed(WearNTear wnt, bool value) { ZNetView validNetView = GetValidNetView((Component)(object)wnt); if (!((Object)(object)validNetView == (Object)null)) { validNetView.ClaimOwnership(); validNetView.GetZDO().Set("waxed", value); } } private static ZNetView GetValidNetView(Component c) { if ((Object)(object)c == (Object)null) { return null; } ZNetView component = c.GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return null; } return component; } } internal static class WaxSheen { private static readonly Color Tint = new Color(1f, 0.72f, 0.25f, 1f); public static void Apply(WearNTear wnt) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (BeeswaxCoatingPlugin.CoatedSheen.Value && !((Object)(object)MaterialMan.instance == (Object)null) && !((Object)(object)wnt == (Object)null)) { float value = BeeswaxCoatingPlugin.SheenIntensity.Value; MaterialMan.instance.SetValue<Color>(((Component)wnt).gameObject, ShaderProps._EmissionColor, Tint * value, false); } } } [HarmonyPatch] internal static class WearPatches { [HarmonyPostfix] [HarmonyPatch(typeof(WearNTear), "HaveRoof")] private static void HaveRoof_Postfix(WearNTear __instance, ref bool __result) { if (!__result && WaxState.IsWaxed(__instance)) { __result = true; } } [HarmonyPostfix] [HarmonyPatch(typeof(WearNTear), "UpdateWear")] private static void UpdateWear_ApplySheen(WearNTear __instance) { if (WaxState.IsWaxed(__instance)) { WaxSheen.Apply(__instance); } } [HarmonyPostfix] [HarmonyPatch(typeof(HoverText), "GetHoverText")] private static void HoverText_GetHoverText_Postfix(HoverText __instance, ref string __result) { if (BeeswaxCoatingPlugin.ShowHoverBadge.Value) { WearNTear componentInParent = ((Component)__instance).GetComponentInParent<WearNTear>(); if ((Object)(object)componentInParent != (Object)null && WaxState.IsWaxed(componentInParent)) { __result += "\n<color=#F2B632>Honey sealed</color>"; } } } [HarmonyPrefix] [HarmonyPatch(typeof(Humanoid), "StartAttack")] private static bool StartAttack_UseCoating(Humanoid __instance, bool secondaryAttack) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || secondaryAttack) { return true; } if (!IsHeldCoating(__instance.GetCurrentWeapon())) { return true; } WaxInteraction.TryApply(); return false; } private static bool IsHeldCoating(ItemData held) { if (held == null || string.IsNullOrEmpty(WaxInteraction.CoatingSharedName)) { return false; } if ((Object)(object)held.m_dropPrefab != (Object)null && ((Object)held.m_dropPrefab).name == "BeeswaxCoating") { return true; } return held.m_shared.m_name == WaxInteraction.CoatingSharedName; } }