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 DyeYourGear v1.40.0
BepInEx/plugins/DyeYourGear/DyeYourGear.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyFileVersion("0.1.23.0")] [assembly: AssemblyVersion("0.1.23.0")] namespace DyeYourGear; [BepInPlugin("valheim.dyeyourgear", "Dye Your Gear", "0.1.23")] public sealed class DyeYourGearPlugin : BaseUnityPlugin { public const string PluginId = "valheim.dyeyourgear"; public const string PluginName = "Dye Your Gear"; public const string PluginVersion = "0.1.23"; internal const string BottlePrefab = "DyeBottle"; internal const string ColorKey = "DyeYourGear.Color"; internal static DyeYourGearPlugin Instance; private Harmony harmony; private bool visible; private readonly List<ItemData> gear = new List<ItemData>(); private readonly List<string> gearLabels = new List<string>(); private readonly List<Sprite> gearIcons = new List<Sprite>(); private int selected; private int selectedFavourite; private bool favouritesMode; private float hue = 0.58f; private float saturation = 0.72f; private float value = 0.82f; private Texture2D wheel; private Vector2 scroll; private Rect window = new Rect(0f, 0f, 1450f, 820f); private bool cursorCaptured; private bool previousCursorVisible; private bool previousZCursorRequested; private CursorLockMode previousCursorLock; private readonly PlayerPreviewRenderer playerPreview = new PlayerPreviewRenderer(); private GUIStyle labelStyle; private GUIStyle itemNameStyle; private GUIStyle badgeStyle; private GUIStyle dyeBadgeStyle; private GUIStyle buttonStyle; private GUIStyle selectedButtonStyle; private GUIStyle instructionStyle; private GUIStyle tipHeaderStyle; private GUIStyle windowStyle; private GUIStyle swatchStyle; private bool controllerCursor; private Vector3 lastCursorPosition; private bool previewDirty; private int stickDirection; private float repeatAt; private float acceptAfter; internal bool IsOpen => visible; private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown Instance = this; harmony = new Harmony("valheim.dyeyourgear"); harmony.PatchAll(typeof(DyeYourGearPlugin).Assembly); CreateWheel(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Dye Your Gear 0.1.23 loaded (client-only; server mod not required)."); } internal void Warn(string message) { ((BaseUnityPlugin)this).Logger.LogWarning((object)message); } private void OnDestroy() { RestoreCursor(); if (harmony != null) { harmony.UnpatchSelf(); } if (Object.op_Implicit((Object)(object)wheel)) { Object.Destroy((Object)(object)wheel); } playerPreview.Dispose(); DyeVisuals.DisposeTextures(); Instance = null; } internal void Open(ItemData bottle) { //IL_013f: 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) Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return; } if (bottle != null && bottle.m_equipped) { ((Humanoid)localPlayer).UnequipItem(bottle, false); } gear.Clear(); gearLabels.Clear(); gearIcons.Clear(); foreach (ItemData allItem in ((Humanoid)localPlayer).GetInventory().GetAllItems()) { if (IsDyeable(allItem)) { gear.Add(allItem); gearLabels.Add(Localize(allItem.m_shared.m_name)); gearIcons.Add(allItem.GetIcon()); } } selected = ((gear.Count != 0) ? Mathf.Clamp(selected, 0, gear.Count - 1) : 0); favouritesMode = false; selectedFavourite = DyeFavourites.FirstEmpty(localPlayer); previewDirty = false; LoadItemColor(); stickDirection = 0; acceptAfter = Time.unscaledTime + 0.25f; playerPreview.Dispose(); visible = true; controllerCursor = !ZInput.IsMouseActive(); lastCursorPosition = Input.mousePosition; CaptureCursor(); if (Object.op_Implicit((Object)(object)InventoryGui.instance) && InventoryGui.IsVisible()) { InventoryGui.instance.Hide(); } CenterWindow(); } private void Close() { visible = false; favouritesMode = false; playerPreview.Dispose(); RestoreCursor(); } internal static void CloseForInterruption() { if ((Object)(object)Instance != (Object)null && Instance.visible) { Instance.Close(); } } private void CaptureCursor() { //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) if (!cursorCaptured) { previousCursorVisible = Cursor.visible; previousCursorLock = Cursor.lockState; previousZCursorRequested = ZCursor.IsRequested; cursorCaptured = true; } ZCursor.Show(); Cursor.lockState = (CursorLockMode)0; Cursor.visible = !controllerCursor; } internal void KeepCursorVisible() { if (visible) { ZCursor.Show(); ZCursor.LockState = (CursorLockMode)0; Cursor.lockState = (CursorLockMode)0; Cursor.visible = !controllerCursor; } } private void RestoreCursor() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (cursorCaptured) { if (previousZCursorRequested) { ZCursor.Show(); } else { ZCursor.Hide(); } ZCursor.LockState = previousCursorLock; Cursor.visible = previousCursorVisible; cursorCaptured = false; } } private void LateUpdate() { if (visible) { KeepCursorVisible(); } } private void Update() { //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) DyeBottle.Maintain(); if (!visible) { return; } if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { Close(); return; } UpdateCursorDevice(); if (Input.GetKeyDown((KeyCode)27) || ZInput.GetButtonDown("JoyMenu") || Menu.IsVisible()) { Close(); return; } if (ZInput.GetButtonDown("JoyButtonB")) { ZInput.ResetButtonStatus("JoyButtonB"); if (favouritesMode) { favouritesMode = false; } else if (previewDirty) { LoadItemColor(); } else { Close(); } return; } bool flag = Time.unscaledTime >= acceptAfter && ZInput.GetButtonDown("JoyButtonY"); if (Input.GetKeyDown((KeyCode)114) || (flag && !favouritesMode && ZInput.GetButton("JoyLBumper"))) { ResetArrowColours(); if (flag) { ZInput.ResetButtonStatus("JoyButtonY"); } flag = false; } if (flag) { ZInput.ResetButtonStatus("JoyButtonY"); if (favouritesMode) { SaveFavourite(); } else { favouritesMode = true; } } if (gear.Count == 0) { return; } float joyLeftStickX = ZInput.GetJoyLeftStickX(); float joyLeftStickY = ZInput.GetJoyLeftStickY(); int num = 0; if (Mathf.Max(Mathf.Abs(joyLeftStickX), Mathf.Abs(joyLeftStickY)) > 0.5f) { num = ((!(Mathf.Abs(joyLeftStickX) >= Mathf.Abs(joyLeftStickY))) ? ((joyLeftStickY < 0f) ? 3 : 4) : ((joyLeftStickX < 0f) ? 1 : 2)); } else if (Mathf.Max(Mathf.Abs(joyLeftStickX), Mathf.Abs(joyLeftStickY)) > 0.25f) { num = stickDirection; } int num2 = 0; if (Input.GetKeyDown((KeyCode)276) || Input.GetKeyDown((KeyCode)97) || ZInput.GetButtonDown("JoyDPadLeft")) { num2 = 1; } else if (Input.GetKeyDown((KeyCode)275) || Input.GetKeyDown((KeyCode)100) || ZInput.GetButtonDown("JoyDPadRight")) { num2 = 2; } else if (Input.GetKeyDown((KeyCode)273) || Input.GetKeyDown((KeyCode)119) || ZInput.GetButtonDown("JoyDPadUp")) { num2 = 3; } else if (Input.GetKeyDown((KeyCode)274) || Input.GetKeyDown((KeyCode)115) || ZInput.GetButtonDown("JoyDPadDown")) { num2 = 4; } if (num2 != 0) { Navigate(num2); } else if (num != 0 && (num != stickDirection || Time.unscaledTime >= repeatAt)) { Navigate(num); repeatAt = Time.unscaledTime + ((num != stickDirection) ? 0.4f : 0.18f); } stickDirection = num; float joyRightStickX = ZInput.GetJoyRightStickX(); float joyRightStickY = ZInput.GetJoyRightStickY(); if (Mathf.Abs(joyRightStickX) > 0.25f || Mathf.Abs(joyRightStickY) > 0.25f) { Vector2 val = new Vector2(Mathf.Cos(hue * MathF.PI * 2f), 0f - Mathf.Sin(hue * MathF.PI * 2f)) * saturation; val += new Vector2(joyRightStickX, joyRightStickY) * Mathf.Min(Time.unscaledDeltaTime, 0.05f) * 0.9f; if (((Vector2)(ref val)).sqrMagnitude > 1f) { ((Vector2)(ref val)).Normalize(); } saturation = ((Vector2)(ref val)).magnitude; if (saturation > 0.001f) { hue = Mathf.Repeat(Mathf.Atan2(0f - val.y, val.x) / (MathF.PI * 2f), 1f); } previewDirty = true; } if (ZInput.GetButtonDown("JoyLBumper") || Input.GetKeyDown((KeyCode)45) || Input.GetKeyDown((KeyCode)269)) { value = Mathf.Clamp(value - 0.08f, 0.15f, 1f); previewDirty = true; } if (ZInput.GetButtonDown("JoyRBumper") || Input.GetKeyDown((KeyCode)61) || Input.GetKeyDown((KeyCode)270)) { value = Mathf.Clamp(value + 0.08f, 0.15f, 1f); previewDirty = true; } float num3 = ZInput.GetJoyRTrigger() - ZInput.GetJoyLTrigger(); if (Mathf.Abs(num3) > 0.08f) { playerPreview.Rotate(num3 * Mathf.Min(Time.unscaledDeltaTime, 0.05f) * 105f); } if (Time.unscaledTime >= acceptAfter && (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271) || ZInput.GetButtonDown("JoyButtonA") || ZInput.GetButtonDown("JoyPlace"))) { if (favouritesMode) { PreviewFavourite(); } else { Apply(); } ZInput.ResetButtonStatus("JoyButtonA"); ZInput.ResetButtonStatus("JoyPlace"); } if (Input.GetKeyDown((KeyCode)127) || ZInput.GetButtonDown("JoyButtonX")) { if (favouritesMode) { RemoveFavourite(); } else { RemoveDye(); } ZInput.ResetButtonStatus("JoyButtonX"); } ConsumeMenuDirections(); } private void UpdateCursorDevice() { //IL_00e4: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) bool flag = Mathf.Abs(ZInput.GetJoyLeftStickX()) > 0.3f || Mathf.Abs(ZInput.GetJoyLeftStickY()) > 0.3f || Mathf.Abs(ZInput.GetJoyRightStickX()) > 0.3f || Mathf.Abs(ZInput.GetJoyRightStickY()) > 0.3f || ZInput.GetJoyLTrigger() > 0.08f || ZInput.GetJoyRTrigger() > 0.08f; string[] array = new string[11] { "JoyButtonA", "JoyPlace", "JoyButtonB", "JoyButtonX", "JoyButtonY", "JoyLBumper", "JoyRBumper", "JoyDPadLeft", "JoyDPadRight", "JoyDPadUp", "JoyDPadDown" }; foreach (string text in array) { flag |= ZInput.GetButtonDown(text); } Vector3 mousePosition = Input.mousePosition; Vector3 val = mousePosition - lastCursorPosition; bool flag2 = ((Vector3)(ref val)).sqrMagnitude > 4f || Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1); KeyCode[] array2 = new KeyCode[17]; RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); KeyCode[] array3 = (KeyCode[])(object)array2; foreach (KeyCode val2 in array3) { flag2 |= Input.GetKeyDown(val2); } if (flag) { controllerCursor = true; } else if (flag2) { controllerCursor = false; } lastCursorPosition = mousePosition; } private void Navigate(int dir) { if (favouritesMode) { int num = ((dir != 1 && dir != 3) ? 1 : (-1)); selectedFavourite = (selectedFavourite + num + 6) % 6; } else { MoveGrid((dir == 1) ? (-1) : ((dir == 2) ? 1 : 0), (dir == 3) ? (-1) : ((dir == 4) ? 1 : 0)); } } private void OnGUI() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (visible) { GUI.depth = -1000; float num = UiScale(); Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f)); EnsureStyles(); CenterWindow(); window = GUI.Window(784321, window, new WindowFunction(DrawWindow), "Dye Your Gear", windowStyle); GUI.matrix = matrix; } } private void EnsureStyles() { //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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00e6: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_0201: 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_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Expected O, but got Unknown //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Expected O, but got Unknown if (labelStyle == null) { Color textColor = default(Color); ((Color)(ref textColor))..ctor(1f, 0.78f, 0.22f, 1f); Color textColor2 = default(Color); ((Color)(ref textColor2))..ctor(1f, 0.91f, 0.62f, 1f); labelStyle = new GUIStyle(GUI.skin.label) { fontSize = 30, fontStyle = (FontStyle)1 }; labelStyle.normal.textColor = textColor; itemNameStyle = new GUIStyle(GUI.skin.label) { fontSize = 22, fontStyle = (FontStyle)1, alignment = (TextAnchor)3, clipping = (TextClipping)1 }; itemNameStyle.normal.textColor = Color.white; badgeStyle = new GUIStyle(GUI.skin.label) { fontSize = 18, fontStyle = (FontStyle)1, alignment = (TextAnchor)5 }; badgeStyle.normal.textColor = textColor; dyeBadgeStyle = new GUIStyle(badgeStyle); dyeBadgeStyle.normal.textColor = new Color(0.35f, 1f, 0.48f, 1f); buttonStyle = new GUIStyle(GUI.skin.button) { fontSize = 22, fontStyle = (FontStyle)1 }; buttonStyle.normal.textColor = Color.white; buttonStyle.hover.textColor = textColor2; buttonStyle.active.textColor = textColor; selectedButtonStyle = new GUIStyle(buttonStyle); selectedButtonStyle.normal.textColor = textColor; selectedButtonStyle.hover.textColor = textColor; selectedButtonStyle.fontStyle = (FontStyle)1; instructionStyle = new GUIStyle(GUI.skin.label) { fontSize = 19, fontStyle = (FontStyle)1, wordWrap = true }; instructionStyle.normal.textColor = Color.white; tipHeaderStyle = new GUIStyle(GUI.skin.label) { fontSize = 22, fontStyle = (FontStyle)1 }; tipHeaderStyle.normal.textColor = textColor; windowStyle = new GUIStyle(GUI.skin.window) { fontSize = 32, fontStyle = (FontStyle)1 }; windowStyle.normal.textColor = textColor; swatchStyle = new GUIStyle(GUI.skin.box); } } private static float UiScale() { return Mathf.Min(Mathf.Clamp((float)Screen.height / 1080f, 0.5f, 2f), Mathf.Min(((float)Screen.width - 30f) / 1450f, ((float)Screen.height - 30f) / 820f)); } private void CenterWindow() { float num = UiScale(); ((Rect)(ref window)).x = ((float)Screen.width / num - ((Rect)(ref window)).width) * 0.5f; ((Rect)(ref window)).y = ((float)Screen.height / num - ((Rect)(ref window)).height) * 0.5f; } private void DrawWindow(int id) { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06bf: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_06c6: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_06f3: Unknown result type (might be due to invalid IL or missing references) //IL_070e: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Invalid comparison between Unknown and I4 //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Unknown result type (might be due to invalid IL or missing references) //IL_07ce: Unknown result type (might be due to invalid IL or missing references) //IL_0819: Unknown result type (might be due to invalid IL or missing references) //IL_085e: Unknown result type (might be due to invalid IL or missing references) //IL_08c7: Unknown result type (might be due to invalid IL or missing references) //IL_08ff: Unknown result type (might be due to invalid IL or missing references) //IL_092a: Unknown result type (might be due to invalid IL or missing references) //IL_0945: Unknown result type (might be due to invalid IL or missing references) if (gear.Count == 0) { GUI.Label(new Rect(30f, 80f, 1000f, 60f), "No dyeable gear in your inventory.", labelStyle); if (GUI.Button(new Rect(30f, 160f, 550f, 55f), controllerCursor ? "LB+Y · Reset all arrow colours" : "Reset all arrow colours (R)", buttonStyle)) { ResetArrowColours(); } if (GUI.Button(new Rect(30f, 230f, 260f, 55f), controllerCursor ? "B · Close" : "Close", buttonStyle)) { Close(); } return; } Color color; bool flag = DyeData.TryGet(gear[selected], out color); Color color2 = GUI.color; GUI.color = new Color(0.075f, 0.085f, 0.1f, 0.97f); GUI.DrawTexture(new Rect(8f, 36f, 1434f, 776f), (Texture)(object)Texture2D.whiteTexture); GUI.color = color2; GUI.Label(new Rect(30f, 42f, 470f, 40f), "Choose gear — preview colour", labelStyle); GUI.Box(new Rect(30f, 82f, 430f, 48f), "", swatchStyle); GUI.Label(new Rect(45f, 88f, 265f, 38f), gearLabels[selected], itemNameStyle); if (flag) { GUI.Label(new Rect(280f, 88f, 160f, 38f), "DYE APPLIED", dyeBadgeStyle); } else if (gear[selected].m_equipped) { GUI.Label(new Rect(340f, 88f, 100f, 38f), "Equipped", badgeStyle); } int num = (gear.Count + 4 - 1) / 4; Rect val = default(Rect); ((Rect)(ref val))..ctor(30f, 145f, 445f, 380f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(0f, 0f, 420f, Mathf.Max(370f, (float)num * 104f)); scroll = GUI.BeginScrollView(val, scroll, val2); Rect val3 = default(Rect); Rect val5 = default(Rect); for (int i = 0; i < gear.Count; i++) { int num2 = i % 4; int num3 = i / 4; ((Rect)(ref val3))..ctor((float)num2 * 104f, (float)num3 * 104f, 96f, 96f); Color backgroundColor = GUI.backgroundColor; if (i == selected) { GUI.backgroundColor = new Color(1f, 0.68f, 0.12f, 1f); } if (GUI.Button(val3, "", buttonStyle)) { selected = i; LoadItemColor(); } GUI.backgroundColor = backgroundColor; Sprite val4 = gearIcons[i]; if (Object.op_Implicit((Object)(object)val4) && Object.op_Implicit((Object)(object)val4.texture)) { Rect textureRect = val4.textureRect; ((Rect)(ref val5))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)val4.texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)val4.texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)val4.texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)val4.texture).height); GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref val3)).x + 10f, ((Rect)(ref val3)).y + 10f, 76f, 76f), (Texture)(object)val4.texture, val5, true); } if (gear[i].m_equipped) { GUI.Label(new Rect(((Rect)(ref val3)).x + 65f, ((Rect)(ref val3)).y + 3f, 26f, 30f), "E", selectedButtonStyle); } if (DyeData.TryGet(gear[i], out color)) { GUI.Label(new Rect(((Rect)(ref val3)).x + 4f, ((Rect)(ref val3)).y + 65f, 86f, 26f), "DYED", dyeBadgeStyle); } } GUI.EndScrollView(); if (GUI.Button(new Rect(30f, 540f, 445f, 35f), controllerCursor ? "LB+Y · Reset all arrow colours" : "Reset all arrow colours (R)", instructionStyle)) { ResetArrowColours(); } Rect val6 = default(Rect); ((Rect)(ref val6))..ctor(575f, 82f, 360f, 360f); GUI.DrawTexture(val6, (Texture)(object)wheel, (ScaleMode)0, true); Event current = Event.current; if (!playerPreview.IsDragging && ((int)current.type == 0 || (int)current.type == 3) && ((Rect)(ref val6)).Contains(current.mousePosition)) { Vector2 val7 = current.mousePosition - ((Rect)(ref val6)).center; float num4 = ((Rect)(ref val6)).width * 0.5f; saturation = Mathf.Clamp01(((Vector2)(ref val7)).magnitude / num4); hue = Mathf.Repeat(Mathf.Atan2(0f - val7.y, val7.x) / (MathF.PI * 2f), 1f); previewDirty = true; current.Use(); } Vector2 val8 = ((Rect)(ref val6)).center + new Vector2(Mathf.Cos(hue * MathF.PI * 2f), 0f - Mathf.Sin(hue * MathF.PI * 2f)) * saturation * ((Rect)(ref val6)).width * 0.5f; GUI.Box(new Rect(val8.x - 8f, val8.y - 8f, 16f, 16f), ""); GUI.Label(new Rect(500f, 458f, 165f, 40f), "Brightness", labelStyle); float num5 = GUI.HorizontalSlider(new Rect(665f, 470f, 270f, 26f), value, 0.15f, 1f); if (num5 != value) { value = num5; previewDirty = true; } Color val9 = Color.HSVToRGB(hue, saturation, value); Color color3 = GUI.color; GUI.color = Color.black; GUI.DrawTexture(new Rect(575f, 525f, 360f, 45f), (Texture)(object)Texture2D.whiteTexture); GUI.color = val9; GUI.DrawTexture(new Rect(579f, 529f, 352f, 37f), (Texture)(object)Texture2D.whiteTexture); GUI.color = color3; GUI.Label(new Rect(575f, 495f, 420f, 35f), previewDirty ? "Unsaved colour preview" : (flag ? "Dye applied ✓" : "Original appearance"), labelStyle); GUI.Label(new Rect(500f, 570f, 530f, 25f), (!previewDirty) ? (controllerCursor ? "Move the right stick to try a colour" : "Click the colour wheel to try a colour") : (controllerCursor ? "Preview only — press A to save" : "Preview only — click Apply dye or press Enter"), instructionStyle); if (GUI.Button(new Rect(500f, 603f, 165f, 55f), controllerCursor ? "A · Apply dye" : "Apply dye", buttonStyle)) { Apply(); } bool enabled = GUI.enabled; GUI.enabled = flag; if (GUI.Button(new Rect(675f, 603f, 190f, 55f), controllerCursor ? "X · Remove dye" : "Remove applied dye", buttonStyle)) { RemoveDye(); } GUI.enabled = enabled; if (GUI.Button(new Rect(875f, 603f, 165f, 55f), (controllerCursor ? "B · " : "") + (previewDirty ? "Cancel" : "Close"), buttonStyle)) { if (previewDirty) { LoadItemColor(); } else { Close(); } } GUI.Label(new Rect(30f, 580f, 445f, 30f), controllerCursor ? "Controller" : "Mouse and keyboard", tipHeaderStyle); GUI.Label(new Rect(30f, 612f, 445f, 180f), controllerCursor ? "Stick / D-pad: gear; right stick: colour.\nLB/RB: brightness; LT/RT: rotate.\nA: apply; X: remove dye; B: back/close.\nY: favourites. There: D-pad chooses,\nA tries, Y saves, X clears, B exits.\nLB+Y: reset arrows; Start: game menu." : "Click gear, wheel and slider; Apply saves.\nClick a favourite to preview it.\nSave colour adds/replaces the selected slot.\nRemove favourite clears that slot.\nDrag preview to rotate; R resets arrows.\nArrows / WASD: gear; Enter: apply dye.", instructionStyle); DrawFavourites(); DrawPreviews(val9); GUI.DragWindow(new Rect(0f, 0f, 1450f, 34f)); } private void DrawPreviews(Color chosen) { //IL_0014: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(1060f, 42f, 360f, 40f), "Live preview", labelStyle); GUI.Box(new Rect(1060f, 82f, 360f, 700f), "", swatchStyle); Rect rect = default(Rect); ((Rect)(ref rect))..ctor(1070f, 92f, 340f, 590f); playerPreview.Draw(rect, Player.m_localPlayer, gear[selected], chosen, previewDirty); GUI.Label(new Rect(1080f, 694f, 320f, 78f), controllerCursor ? "LT/RT rotates the preview. Right stick previews colour. A saves; B discards changes." : "Drag left / right to rotate. Click Apply dye to save. Armour uses the character; other items have a large individual preview.", instructionStyle); } private void DrawFavourites() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(500f, 670f, 540f, 30f), (!controllerCursor) ? "Favourite colours — click a swatch to try" : (favouritesMode ? "Favourites — A try · Y save · X clear · B back" : "Y · Favourite colours"), tipHeaderStyle); Rect val = default(Rect); for (int i = 0; i < 6; i++) { ((Rect)(ref val))..ctor((float)(500 + i * 87), 705f, 78f, 36f); Color colour; bool flag = DyeFavourites.TryGet(Player.m_localPlayer, i, out colour); Color backgroundColor = GUI.backgroundColor; if (i == selectedFavourite) { GUI.backgroundColor = new Color(1f, 0.72f, 0.16f, 1f); } if (GUI.Button(val, "", (i == selectedFavourite) ? selectedButtonStyle : buttonStyle)) { selectedFavourite = i; if (flag) { PreviewFavourite(); } } GUI.backgroundColor = backgroundColor; if (flag) { Color color = GUI.color; GUI.color = colour; GUI.DrawTexture(new Rect(((Rect)(ref val)).x + 5f, ((Rect)(ref val)).y + 5f, ((Rect)(ref val)).width - 10f, ((Rect)(ref val)).height - 10f), (Texture)(object)Texture2D.whiteTexture); GUI.color = color; } else { GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 3f, ((Rect)(ref val)).width, 30f), "+ " + (i + 1), instructionStyle); } } if (GUI.Button(new Rect(500f, 751f, 250f, 39f), controllerCursor ? "Y · Save / replace" : "Save colour in slot", buttonStyle)) { SaveFavourite(); } Color colour2; bool enabled = DyeFavourites.TryGet(Player.m_localPlayer, selectedFavourite, out colour2); bool enabled2 = GUI.enabled; GUI.enabled = enabled; if (GUI.Button(new Rect(760f, 751f, 262f, 39f), controllerCursor ? "X · Clear favourite" : "Remove favourite", buttonStyle)) { RemoveFavourite(); } GUI.enabled = enabled2; } private void PreviewFavourite() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (DyeFavourites.TryGet(Player.m_localPlayer, selectedFavourite, out var colour)) { Color.RGBToHSV(colour, ref hue, ref saturation, ref value); previewDirty = true; favouritesMode = false; } } private void SaveFavourite() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && gear.Count != 0) { DyeFavourites.Set(Player.m_localPlayer, selectedFavourite, Color.HSVToRGB(hue, saturation, value)); ((Character)Player.m_localPlayer).Message((MessageType)2, "Colour saved to favourite " + (selectedFavourite + 1) + ".", 0, (Sprite)null, false); } } private void RemoveFavourite() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { DyeFavourites.Remove(Player.m_localPlayer, selectedFavourite); ((Character)Player.m_localPlayer).Message((MessageType)2, "Favourite " + (selectedFavourite + 1) + " removed.", 0, (Sprite)null, false); } } private void Select(int delta) { selected = (selected + delta + gear.Count) % gear.Count; int num = selected / 4; int num2 = (gear.Count + 3) / 4; scroll.y = Mathf.Clamp((float)num * 104f - 155f, 0f, Mathf.Max(0f, (float)num2 * 104f - 370f)); LoadItemColor(); } private void MoveGrid(int x, int y) { int num = selected / 4; int num2 = selected % 4; int num3 = (gear.Count + 3) / 4; num = Mathf.Clamp(num + y, 0, num3 - 1); num2 = Mathf.Clamp(num2 + x, 0, 3); int num4 = Mathf.Min(num * 4 + num2, gear.Count - 1); if (num4 != selected) { selected = num4; scroll.y = Mathf.Clamp((float)num * 104f - 155f, 0f, Mathf.Max(0f, (float)num3 * 104f - 370f)); LoadItemColor(); } } private static void ConsumeMenuDirections() { ZInput.ResetButtonStatus("JoyDPadLeft"); ZInput.ResetButtonStatus("JoyDPadRight"); ZInput.ResetButtonStatus("JoyDPadUp"); ZInput.ResetButtonStatus("JoyDPadDown"); ZInput.ResetButtonStatus("JoyHotbarLeft"); ZInput.ResetButtonStatus("JoyHotbarRight"); ZInput.ResetButtonStatus("JoyHotbarUse"); } private void LoadItemColor() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (selected >= 0 && selected < gear.Count) { previewDirty = false; if (DyeData.TryGet(gear[selected], out var color)) { Color.RGBToHSV(color, ref hue, ref saturation, ref value); return; } hue = 0f; saturation = 0f; value = 1f; } } private void Apply() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (selected >= 0 && selected < gear.Count && previewDirty) { DyeData.Set(gear[selected], Color.HSVToRGB(hue, saturation, value)); if (IsArrow(gear[selected])) { ArrowColourPreferences.Set(Player.m_localPlayer, gear[selected], remove: false); } previewDirty = false; DyePersistence.Snapshot(Player.m_localPlayer); NotifyInventory(((Humanoid)Player.m_localPlayer).GetInventory()); DyeNetwork.Sync(Player.m_localPlayer); DyeVisuals.Refresh(Player.m_localPlayer); ((Character)Player.m_localPlayer).Message((MessageType)2, "Colour applied to " + LocalName(gear[selected]) + ".", 0, (Sprite)null, false); } } private void RemoveDye() { if (selected >= 0 && selected < gear.Count) { gear[selected].m_customData.Remove("DyeYourGear.Color"); if (IsArrow(gear[selected])) { ArrowColourPreferences.Set(Player.m_localPlayer, gear[selected], remove: true); } DyePersistence.Snapshot(Player.m_localPlayer); LoadItemColor(); NotifyInventory(((Humanoid)Player.m_localPlayer).GetInventory()); DyeNetwork.Sync(Player.m_localPlayer); DyeVisuals.Refresh(Player.m_localPlayer); ((Character)Player.m_localPlayer).Message((MessageType)2, "Dye removed from " + LocalName(gear[selected]) + ".", 0, (Sprite)null, false); } } private static string LocalName(ItemData item) { return Localize(item.m_shared.m_name); } private void ResetArrowColours() { ArrowColourPreferences.Reset(Player.m_localPlayer); DyePersistence.Snapshot(Player.m_localPlayer); NotifyInventory(((Humanoid)Player.m_localPlayer).GetInventory()); LoadItemColor(); ((Character)Player.m_localPlayer).Message((MessageType)2, "All arrow colours restored to default. Future pickups use their original colours.", 0, (Sprite)null, false); } private static string Localize(string key) { try { Type type = AccessTools.TypeByName("Localization"); PropertyInfo propertyInfo = ((type != null) ? type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) : null); object obj = ((propertyInfo != null) ? propertyInfo.GetValue(null, null) : null); MethodInfo methodInfo = ((type != null) ? type.GetMethod("Localize", new Type[1] { typeof(string) }) : null); return (obj != null && methodInfo != null) ? ((string)methodInfo.Invoke(obj, new object[1] { key })) : key; } catch { return key; } } private static void NotifyInventory(Inventory inventory) { MethodInfo methodInfo = AccessTools.Method(typeof(Inventory), "Changed", new Type[2] { typeof(bool), typeof(bool) }, (Type[])null); if (methodInfo != null) { methodInfo.Invoke(inventory, new object[2] { false, false }); } } internal static bool IsBottle(ItemData item) { if (item != null && item.m_customData.ContainsKey("DyeYourGear.Bottle")) { return true; } if (item == null) { return false; } if (item.m_shared != null && string.Equals(item.m_shared.m_name, "Dye Bottle", StringComparison.Ordinal)) { return true; } if (!Object.op_Implicit((Object)(object)item.m_dropPrefab)) { return false; } return string.Equals(((Object)item.m_dropPrefab).name.Replace("(Clone)", "").Trim(), "DyeBottle", StringComparison.Ordinal); } internal static bool IsDyeable(ItemData item) { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 if (item == null || IsBottle(item)) { return false; } ItemType itemType = item.m_shared.m_itemType; if ((int)itemType != 6 && (int)itemType != 7 && (int)itemType != 11 && (int)itemType != 17 && (int)itemType != 3 && (int)itemType != 4 && (int)itemType != 14 && (int)itemType != 22 && (int)itemType != 20 && (int)itemType != 15 && (int)itemType != 5 && (int)itemType != 18 && (int)itemType != 19 && ((int)itemType != 24 || !HasWearableModel(item))) { return IsArrow(item); } return true; } internal static bool IsArrow(ItemData item) { if (item == null || item.m_shared == null) { return false; } return AmmunitionKind.IsArrowOrBolt(item.m_shared.m_ammoType, Object.op_Implicit((Object)(object)item.m_dropPrefab) ? ((Object)item.m_dropPrefab).name : null, item.m_shared.m_name); } private static bool HasWearableModel(ItemData item) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)item.m_dropPrefab)) { return false; } foreach (Transform item2 in item.m_dropPrefab.transform) { Transform val = item2; if (((Object)val).name.StartsWith("attach_", StringComparison.Ordinal) && ((Component)val).GetComponentsInChildren<Renderer>(true).Length != 0) { return true; } } return false; } private void CreateWheel() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) wheel = new Texture2D(256, 256, (TextureFormat)4, false); ((Object)wheel).name = "DyeYourGear_ColorWheel"; ((Object)wheel).hideFlags = (HideFlags)61; Color32[] array = (Color32[])(object)new Color32[65536]; float num = 127.5f; for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { float num2 = ((float)j - num) / num; float num3 = ((float)i - num) / num; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); array[i * 256 + j] = (Color32)((num4 <= 1f) ? Color32.op_Implicit(Color.HSVToRGB(Mathf.Repeat(Mathf.Atan2(num3, num2) / (MathF.PI * 2f), 1f), num4, 1f)) : new Color32((byte)0, (byte)0, (byte)0, (byte)0)); } } wheel.SetPixels32(array); wheel.Apply(false, true); } } internal sealed class PlayerPreviewRenderer { private const int PreviewLayer = 31; private Camera camera; private RenderTexture target; private float nextRender; private float previewYaw; private float lastMouseX; private bool dragging; private bool rotationChanged; private int lastColour; private ItemData lastItem; private GameObject weaponVisual; private ItemData weaponItem; private ItemData wearableItem; private List<GameObject> wearablePreview; private RuntimeAnimatorController cachedController; private AnimationClip neutralIdleClip; private readonly List<Material> weaponMaterials = new List<Material>(); private readonly List<Color> weaponColours = new List<Color>(); private readonly List<Mesh> previewMeshes = new List<Mesh>(); private static readonly FieldInfo LeftHand = AccessTools.Field(typeof(VisEquipment), "m_leftHand"); private static readonly FieldInfo RightHand = AccessTools.Field(typeof(VisEquipment), "m_rightHand"); private static readonly FieldInfo HelmetMount = AccessTools.Field(typeof(VisEquipment), "m_helmet"); internal bool IsDragging => dragging; internal void Rotate(float degrees) { if (!(Mathf.Abs(degrees) < 0.001f)) { previewYaw = Mathf.Repeat(previewYaw + degrees, 360f); rotationChanged = true; } } private bool IsHandItem(ItemData item) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 ItemType itemType = item.m_shared.m_itemType; if ((int)itemType != 6 && (int)itemType != 7 && (int)itemType != 11 && (int)itemType != 17 && (int)itemType != 18) { return (int)itemType != 24; } return false; } private void ClearWeapon() { if (Object.op_Implicit((Object)(object)weaponVisual)) { weaponVisual.SetActive(false); Object.Destroy((Object)(object)weaponVisual); } foreach (Material weaponMaterial in weaponMaterials) { if (Object.op_Implicit((Object)(object)weaponMaterial)) { AttachmentDyeMaterials.Forget(weaponMaterial); Object.Destroy((Object)(object)weaponMaterial); } } foreach (Mesh previewMesh in previewMeshes) { if (Object.op_Implicit((Object)(object)previewMesh)) { Object.Destroy((Object)(object)previewMesh); } } previewMeshes.Clear(); weaponMaterials.Clear(); weaponColours.Clear(); weaponVisual = null; weaponItem = null; } private void CopyWeaponMesh(Transform source, Transform parent, bool includeInactive = false) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0020: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(((Object)source).name); val.transform.SetParent(parent, false); val.transform.localPosition = source.localPosition; val.transform.localRotation = source.localRotation; val.transform.localScale = source.localScale; MeshFilter component = ((Component)source).GetComponent<MeshFilter>(); MeshRenderer component2 = ((Component)source).GetComponent<MeshRenderer>(); SkinnedMeshRenderer component3 = ((Component)source).GetComponent<SkinnedMeshRenderer>(); Mesh val2 = (Object.op_Implicit((Object)(object)component) ? component.sharedMesh : null); Renderer val3 = (Renderer)(object)component2; if (!Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)component3) && Object.op_Implicit((Object)(object)component3.sharedMesh)) { val2 = new Mesh(); component3.BakeMesh(val2); previewMeshes.Add(val2); val3 = (Renderer)(object)component3; } if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val3)) { val.AddComponent<MeshFilter>().sharedMesh = val2; Material[] sharedMaterials = val3.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { if (Object.op_Implicit((Object)(object)sharedMaterials[i])) { sharedMaterials[i] = new Material(sharedMaterials[i]); weaponMaterials.Add(sharedMaterials[i]); weaponColours.Add(sharedMaterials[i].HasProperty("_Color") ? sharedMaterials[i].color : Color.white); } } ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterials = sharedMaterials; } Light component4 = ((Component)source).GetComponent<Light>(); if (Object.op_Implicit((Object)(object)component4)) { Light obj = val.AddComponent<Light>(); obj.type = component4.type; obj.color = component4.color; obj.intensity = component4.intensity; obj.range = component4.range; obj.spotAngle = component4.spotAngle; obj.shadows = component4.shadows; obj.cullingMask = int.MinValue; } for (int j = 0; j < source.childCount; j++) { if (includeInactive || ((Component)source.GetChild(j)).gameObject.activeSelf) { CopyWeaponMesh(source.GetChild(j), val.transform, includeInactive); } } } private static void HideRenderers(object value, List<Renderer> hidden, HashSet<Renderer> seen) { GameObject val = (GameObject)((value is GameObject) ? value : null); if (Object.op_Implicit((Object)(object)val)) { Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val2) && val2.enabled && seen.Add(val2)) { val2.enabled = false; hidden.Add(val2); } } } else { if (!(value is IEnumerable enumerable)) { return; } foreach (object item in enumerable) { HideRenderers(item, hidden, seen); } } } private static List<Renderer> HideUnselectedEquipment(VisEquipment equipment, ItemData item) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_008f: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Invalid comparison between Unknown and I4 //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Invalid comparison between Unknown and I4 //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Invalid comparison between Unknown and I4 //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Invalid comparison between Unknown and I4 //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Invalid comparison between Unknown and I4 List<Renderer> list = new List<Renderer>(); HashSet<Renderer> seen = new HashSet<Renderer>(); ItemType itemType = item.m_shared.m_itemType; string[] array = new string[10] { "m_rightItemInstance", "m_leftItemInstance", "m_rightBackItemInstance", "m_leftBackItemInstance", "m_helmetItemInstance", "m_chestItemInstances", "m_legItemInstances", "m_shoulderItemInstances", "m_utilityItemInstances", "m_trinketItemInstances" }; foreach (string text in array) { if ((!(text == "m_helmetItemInstance") || ((int)itemType == 6 && !item.m_equipped)) && (!(text == "m_chestItemInstances") || (int)itemType != 7) && (!(text == "m_legItemInstances") || (int)itemType != 11) && (!(text == "m_shoulderItemInstances") || ((int)itemType == 17 && !item.m_equipped)) && (!(text == "m_utilityItemInstances") || (int)itemType != 18) && (!(text == "m_trinketItemInstances") || (int)itemType != 24)) { FieldInfo fieldInfo = AccessTools.Field(typeof(VisEquipment), text); if (fieldInfo != null) { HideRenderers(fieldInfo.GetValue(equipment), list, seen); } } } return list; } private void RenderSelected(Player player, ItemData item, int packed, bool dirty) { if (!UsesCharacterPreview(item)) { RenderStandaloneItem(player, item, packed); return; } VisEquipment component = ((Component)player).GetComponent<VisEquipment>(); if (!Object.op_Implicit((Object)(object)component)) { RenderPlayer(player); return; } List<Renderer> list = HideUnselectedEquipment(component, item); try { RenderSelectedItem(player, component, item, packed, dirty); } finally { foreach (Renderer item2 in list) { if (Object.op_Implicit((Object)(object)item2)) { item2.enabled = true; } } } } private static bool UsesCharacterPreview(ItemData item) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 ItemType itemType = item.m_shared.m_itemType; if ((int)itemType != 6 && (int)itemType != 7 && (int)itemType != 11) { return (int)itemType == 17; } return true; } private void RenderStandaloneItem(Player player, ItemData item, int packed) { //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)weaponVisual) || weaponItem != item) { ClearWeapon(); Transform val = null; if (Object.op_Implicit((Object)(object)item.m_dropPrefab)) { string[] array = new string[3] { "attach", "model", "" }; foreach (string text in array) { Transform val2 = ((text.Length == 0) ? item.m_dropPrefab.transform : item.m_dropPrefab.transform.Find(text)); if (Object.op_Implicit((Object)(object)val2) && (((Component)val2).GetComponentsInChildren<MeshFilter>(true).Length != 0 || ((Component)val2).GetComponentsInChildren<SkinnedMeshRenderer>(true).Length != 0)) { val = val2; break; } } } if (!Object.op_Implicit((Object)(object)val) && DyeYourGearPlugin.IsArrow(item) && item.m_shared.m_attack != null && Object.op_Implicit((Object)(object)item.m_shared.m_attack.m_attackProjectile)) { val = item.m_shared.m_attack.m_attackProjectile.transform; } if (Object.op_Implicit((Object)(object)val)) { weaponVisual = new GameObject("DYG_StandaloneItemPreview"); weaponVisual.SetActive(false); CopyWeaponMesh(val, weaponVisual.transform, includeInactive: true); FitAmmunition(weaponVisual.transform.GetChild(0)); previewYaw = 0f; weaponItem = item; } } Vector3 val3 = ((Component)player).transform.position + Vector3.up * 1000f; bool fog = RenderSettings.fog; List<Renderer> list = new List<Renderer>(); try { Renderer[] array2 = Object.FindObjectsOfType<Renderer>(); foreach (Renderer val4 in array2) { if (Object.op_Implicit((Object)(object)val4) && val4.enabled && ((Component)val4).gameObject.layer == 31) { list.Add(val4); val4.enabled = false; } } RenderSettings.fog = false; if (Object.op_Implicit((Object)(object)weaponVisual)) { weaponVisual.transform.position = val3; weaponVisual.transform.rotation = Quaternion.Euler(0f, previewYaw, 0f); DyeVisuals.ApplyObject(weaponVisual, packed, preview: true); Transform[] componentsInChildren = weaponVisual.GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.layer = 31; } weaponVisual.SetActive(true); Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(val3, Vector3.zero); bool flag = false; MeshRenderer[] componentsInChildren2 = weaponVisual.GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val5 in componentsInChildren2) { if (!flag) { bounds = ((Renderer)val5).bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(((Renderer)val5).bounds); } } Vector3 val6 = (flag ? ((Bounds)(ref bounds)).center : val3); camera.orthographicSize = Mathf.Max(0.05f, Mathf.Max(((Bounds)(ref bounds)).extents.y, ((Bounds)(ref bounds)).extents.x / camera.aspect) * 1.12f); ((Component)camera).transform.position = val6 + Vector3.forward * 4f; ((Component)camera).transform.LookAt(val6, Vector3.up); } else { ((Component)camera).transform.position = val3; } camera.Render(); } finally { if (Object.op_Implicit((Object)(object)weaponVisual)) { weaponVisual.SetActive(false); } RenderSettings.fog = fog; foreach (Renderer item2 in list) { if (Object.op_Implicit((Object)(object)item2)) { item2.enabled = true; } } } } private void RenderSelectedItem(Player player, VisEquipment equipment, ItemData item, int packed, bool dirty) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Invalid comparison between Unknown and I4 //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Invalid comparison between Unknown and I4 //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Invalid comparison between Unknown and I4 if (!item.m_equipped && ((int)item.m_shared.m_itemType == 18 || (int)item.m_shared.m_itemType == 24)) { RenderWearableAttachment(player, equipment, item, packed); } else if ((int)item.m_shared.m_itemType == 6 && !item.m_equipped) { object? value = HelmetMount.GetValue(equipment); Transform val = (Transform)((value is Transform) ? value : null); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)item.m_dropPrefab)) { RenderPlayer(player); } else { RenderPreviewAttachment(player, equipment, item, val, packed); } } else if (!IsHandItem(item)) { if (dirty) { DyeVisuals.RenderPreview(player, item, packed, delegate { RenderPlayer(player); }); } else { RenderPlayer(player); } } else if (!Object.op_Implicit((Object)(object)item.m_dropPrefab)) { RenderPlayer(player); } else { object? value2 = (((int)item.m_shared.m_itemType == 5 || (int)item.m_shared.m_itemType == 4 || (int)item.m_shared.m_itemType == 22) ? LeftHand : RightHand).GetValue(equipment); Transform val2 = (Transform)((value2 is Transform) ? value2 : null); if (!Object.op_Implicit((Object)(object)val2)) { RenderPlayer(player); } else { RenderPreviewAttachment(player, equipment, item, val2, packed); } } } private void RenderPreviewAttachment(Player player, VisEquipment equipment, ItemData item, Transform mount, int packed) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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) if (!Object.op_Implicit((Object)(object)weaponVisual) || weaponItem != item) { ClearWeapon(); Transform val = item.m_dropPrefab.transform.Find("attach"); if (DyeYourGearPlugin.IsArrow(item) && (!Object.op_Implicit((Object)(object)val) || ((Component)val).GetComponentsInChildren<MeshFilter>(true).Length == 0)) { GameObject val2 = ((item.m_shared.m_attack == null) ? null : item.m_shared.m_attack.m_attackProjectile); val = ((Object.op_Implicit((Object)(object)val2) && val2.GetComponentsInChildren<MeshFilter>(true).Length != 0) ? val2.transform : item.m_dropPrefab.transform); } if (!Object.op_Implicit((Object)(object)val)) { RenderPlayer(player); return; } weaponVisual = new GameObject("DYG_PreviewOnlyWeapon"); weaponVisual.SetActive(false); weaponVisual.transform.SetParent(mount, false); CopyWeaponMesh(val, weaponVisual.transform, DyeYourGearPlugin.IsArrow(item)); Transform child = weaponVisual.transform.GetChild(0); child.localPosition = Vector3.zero; child.localRotation = Quaternion.identity; Transform val3 = item.m_dropPrefab.transform.Find("equipoffset"); if (Object.op_Implicit((Object)(object)val3)) { child.localPosition = val3.localPosition; child.localRotation = val3.localRotation; } if (DyeYourGearPlugin.IsArrow(item)) { FitAmmunition(child); } weaponItem = item; } DyeVisuals.ApplyObject(weaponVisual, packed, preview: true); List<Renderer> list = new List<Renderer>(); try { string[] array = new string[4] { "m_rightItemInstance", "m_leftItemInstance", "m_rightBackItemInstance", "m_leftBackItemInstance" }; foreach (string text in array) { object? value = AccessTools.Field(typeof(VisEquipment), text).GetValue(equipment); GameObject val4 = (GameObject)((value is GameObject) ? value : null); if (!Object.op_Implicit((Object)(object)val4)) { continue; } Renderer[] componentsInChildren = val4.GetComponentsInChildren<Renderer>(); foreach (Renderer val5 in componentsInChildren) { if (val5.enabled) { list.Add(val5); val5.enabled = false; } } } weaponVisual.SetActive(true); RenderPlayer(player); } finally { weaponVisual.SetActive(false); foreach (Renderer item2 in list) { if (Object.op_Implicit((Object)(object)item2)) { item2.enabled = true; } } } } private static void FitAmmunition(Transform visual) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_011d: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_01a6: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) Bounds val = default(Bounds); bool flag = false; MeshFilter[] componentsInChildren = ((Component)visual).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val2 in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val2.sharedMesh)) { continue; } Bounds bounds = val2.sharedMesh.bounds; for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { for (int l = -1; l <= 1; l += 2) { Vector3 val3 = visual.InverseTransformPoint(((Component)val2).transform.TransformPoint(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)j, (float)k, (float)l)))); if (!flag) { ((Bounds)(ref val))..ctor(val3, Vector3.zero); flag = true; } else { ((Bounds)(ref val)).Encapsulate(val3); } } } } } if (flag) { Vector3 size = ((Bounds)(ref val)).size; float num = Mathf.Max(size.x, Mathf.Max(size.y, size.z)); if (!(num < 0.001f)) { Vector3 val4 = ((size.x >= size.y && size.x >= size.z) ? Vector3.right : ((size.y >= size.z) ? Vector3.up : Vector3.forward)); Vector3 val5 = ((val4 == Vector3.right) ? ((size.z <= size.y) ? Vector3.forward : Vector3.up) : ((!(val4 == Vector3.up)) ? ((size.x <= size.y) ? Vector3.right : Vector3.up) : ((size.z <= size.x) ? Vector3.forward : Vector3.right))); visual.localRotation = Quaternion.Inverse(Quaternion.LookRotation(val5, val4)); visual.localScale = Vector3.one * (0.95f / num); visual.localPosition = new Vector3(0f, 0.22f, 0f) - visual.localRotation * Vector3.Scale(((Bounds)(ref val)).center, visual.localScale); } } } private void RenderWearableAttachment(Player player, VisEquipment equipment, ItemData item, int packed) { MethodInfo methodInfo = AccessTools.Method(typeof(VisEquipment), "AttachArmor", (Type[])null, (Type[])null); try { if (wearableItem != item) { ClearWearable(); wearablePreview = methodInfo.Invoke(equipment, new object[3] { StringExtensionMethods.GetStableHashCode(((Object)item.m_dropPrefab).name), item.m_variant, 0 }) as List<GameObject>; wearableItem = item; } if (wearablePreview != null) { foreach (GameObject item2 in wearablePreview) { if (Object.op_Implicit((Object)(object)item2)) { item2.SetActive(true); DyeVisuals.ApplyObject(item2, packed, preview: true); } } } RenderPlayer(player); } finally { if (wearablePreview != null) { foreach (GameObject item3 in wearablePreview) { if (Object.op_Implicit((Object)(object)item3)) { item3.SetActive(false); } } } } } private void ClearWearable() { if (wearablePreview != null) { foreach (GameObject item in wearablePreview) { if (Object.op_Implicit((Object)(object)item)) { item.SetActive(false); Object.Destroy((Object)(object)item); } } } wearablePreview = null; wearableItem = null; } internal void Draw(Rect rect, Player player, ItemData item, Color colour, bool dirty) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00ee: Invalid comparison between Unknown and I4 //IL_0146: Unknown result type (might be due to invalid IL or missing references) Ensure(); Event current = Event.current; if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref rect)).Contains(current.mousePosition)) { dragging = true; lastMouseX = current.mousePosition.x; current.Use(); } else if ((int)current.type == 3 && dragging) { float num = current.mousePosition.x - lastMouseX; lastMouseX = current.mousePosition.x; Rotate(num * 0.65f); current.Use(); } else if ((int)current.type == 1 && dragging) { dragging = false; current.Use(); } int num2 = (dirty ? DyeData.Pack(colour) : DyeData.Pack(item)); bool flag = num2 != lastColour || item != lastItem || rotationChanged; if ((int)Event.current.type == 7 && Object.op_Implicit((Object)(object)player) && (flag || Time.unscaledTime >= nextRender)) { lastColour = num2; lastItem = item; rotationChanged = false; nextRender = Time.unscaledTime + 0.08f; RenderSelected(player, item, num2, dirty); } if (Object.op_Implicit((Object)(object)target)) { GUI.DrawTexture(rect, (Texture)(object)target, (ScaleMode)2, false); } } private void Ensure() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0085: 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_00ff: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)camera) || !Object.op_Implicit((Object)(object)target) || !target.IsCreated()) { Dispose(); GameObject val = new GameObject("DyeYourGear_PlayerPreview"); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); camera = val.AddComponent<Camera>(); ((Behaviour)camera).enabled = false; camera.clearFlags = (CameraClearFlags)2; camera.backgroundColor = new Color(0.32f, 0.34f, 0.36f, 1f); camera.orthographic = true; camera.aspect = 0.5762712f; camera.useOcclusionCulling = false; camera.nearClipPlane = 0.05f; camera.farClipPlane = 20f; camera.cullingMask = int.MinValue; target = new RenderTexture(680, 1180, 24, (RenderTextureFormat)0); ((Object)target).name = "DyeYourGear_PlayerPreview"; ((Object)target).hideFlags = (HideFlags)61; target.Create(); camera.targetTexture = target; } } private AnimationClip FindNeutralIdle(Animator animator) { RuntimeAnimatorController val = (Object.op_Implicit((Object)(object)animator) ? animator.runtimeAnimatorController : null); if ((Object)(object)val == (Object)(object)cachedController) { return neutralIdleClip; } cachedController = val; neutralIdleClip = null; if (!Object.op_Implicit((Object)(object)val)) { return null; } AnimationClip[] animationClips = val.animationClips; foreach (AnimationClip val2 in animationClips) { if (Object.op_Implicit((Object)(object)val2)) { string text = ((Object)val2).name.ToLowerInvariant(); if (text == "idle" || text == "player_idle") { neutralIdleClip = val2; break; } if ((Object)(object)neutralIdleClip == (Object)null && text.Contains("idle") && !text.Contains("alert") && !text.Contains("crouch") && !text.Contains("sneak") && !text.Contains("swim") && !text.Contains("sit") && !text.Contains("attack")) { neutralIdleClip = val2; } } } return neutralIdleClip; } private void RenderPlayer(Player player) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) Transform[] componentsInChildren = ((Component)player).GetComponentsInChildren<Transform>(true); Vector3[] array = (Vector3[])(object)new Vector3[componentsInChildren.Length]; Quaternion[] array2 = (Quaternion[])(object)new Quaternion[componentsInChildren.Length]; Vector3[] array3 = (Vector3[])(object)new Vector3[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { array[i] = componentsInChildren[i].localPosition; array2[i] = componentsInChildren[i].localRotation; array3[i] = componentsInChildren[i].localScale; } try { Animator componentInChildren = ((Component)player).GetComponentInChildren<Animator>(); AnimationClip val = FindNeutralIdle(componentInChildren); if (Object.op_Implicit((Object)(object)val)) { val.SampleAnimation(((Component)player).gameObject, 0f); } RenderPlayerPose(player); } finally { for (int j = 0; j < componentsInChildren.Length; j++) { if (Object.op_Implicit((Object)(object)componentsInChildren[j])) { componentsInChildren[j].localPosition = array[j]; componentsInChildren[j].localRotation = array2[j]; componentsInChildren[j].localScale = array3[j]; } } } } private void RenderPlayerPose(Player player) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = ((Component)player).GetComponentsInChildren<Renderer>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return; } Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(((Component)player).transform.position + Vector3.up, Vector3.one); bool flag = false; Dictionary<GameObject, int> dictionary = new Dictionary<GameObject, int>(); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (Object.op_Implicit((Object)(object)val) && val.enabled && ((Component)val).gameObject.activeInHierarchy && (val is SkinnedMeshRenderer || val is MeshRenderer)) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } if (!dictionary.ContainsKey(((Component)val).gameObject)) { dictionary.Add(((Component)val).gameObject, ((Component)val).gameObject.layer); } ((Component)val).gameObject.layer = 31; } } if (!flag) { return; } bool fog = RenderSettings.fog; List<Renderer> list = new List<Renderer>(); try { array = Object.FindObjectsOfType<Renderer>(); foreach (Renderer val2 in array) { if (Object.op_Implicit((Object)(object)val2) && val2.enabled && ((Component)val2).gameObject.layer == 31 && !dictionary.ContainsKey(((Component)val2).gameObject)) { list.Add(val2); val2.enabled = false; } } RenderSettings.fog = false; float num = Mathf.Max(1.8f, ((Bounds)(ref bounds)).size.y); Vector3 center = ((Bounds)(ref bounds)).center; Vector3 val3 = Quaternion.Euler(0f, previewYaw, 0f) * ((Component)player).transform.forward; camera.orthographicSize = num * 0.53f; Transform transform = ((Component)camera).transform; Vector3 extents = ((Bounds)(ref bounds)).extents; transform.position = center + val3 * (((Vector3)(ref extents)).magnitude + 4f); ((Component)camera).transform.LookAt(center, Vector3.up); camera.Render(); } finally { RenderSettings.fog = fog; foreach (Renderer item in list) { if (Object.op_Implicit((Object)(object)item)) { item.enabled = true; } } foreach (KeyValuePair<GameObject, int> item2 in dictionary) { if (Object.op_Implicit((Object)(object)item2.Key)) { item2.Key.layer = item2.Value; } } } } internal void Dispose() { ClearWearable(); ClearWeapon(); if (Object.op_Implicit((Object)(object)camera)) { Object.Destroy((Object)(object)((Component)camera).gameObject); } if (Object.op_Implicit((Object)(object)target)) { target.Release(); Object.Destroy((Object)(object)target); } camera = null; target = null; cachedController = null; neutralIdleClip = null; nextRender = 0f; lastItem = null; lastColour = -1; dragging = false; rotationChanged = true; } } internal static class DyeData { internal static void Set(ItemData item, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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) Color32 val = Color32.op_Implicit(color); item.m_customData["DyeYourGear.Color"] = val.r.ToString("X2") + val.g.ToString("X2") + val.b.ToString("X2"); } internal static bool TryGet(ItemData item, out Color color) { //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_0078: 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) color = Color.white; if (item == null || !item.m_customData.TryGetValue("DyeYourGear.Color", out var value) || value.Length != 6) { return false; } if (!int.TryParse(value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var result)) { return false; } color = new Color((float)((result >> 16) & 0xFF) / 255f, (float)((result >> 8) & 0xFF) / 255f, (float)(result & 0xFF) / 255f, 1f); return true; } internal static int Pack(ItemData item) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0022: 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) if (!TryGet(item, out var color)) { return 0; } Color32 val = Color32.op_Implicit(color); return 0x1000000 | (val.r << 16) | (val.g << 8) | val.b; } internal static int Pack(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_000c: 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_001f: Unknown result type (might be due to invalid IL or missing references) Color32 val = Color32.op_Implicit(color); return 0x1000000 | (val.r << 16) | (val.g << 8) | val.b; } internal static Color Unpack(int value) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) return new Color((float)((value >> 16) & 0xFF) / 255f, (float)((value >> 8) & 0xFF) / 255f, (float)(value & 0xFF) / 255f, 1f); } internal static Color Colorize(Color original, Color dye) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(((Color)(ref original)).grayscale); float num2 = 0.22f + 0.86f * Mathf.Pow(num, 0.85f); return new Color(Mathf.Clamp01(dye.r * num2), Mathf.Clamp01(dye.g * num2), Mathf.Clamp01(dye.b * num2), original.a); } } internal static class DyeNetwork { internal const string Chest = "DYG.Chest"; internal const string Legs = "DYG.Legs"; internal const string Helmet = "DYG.Helmet"; internal const string Shoulder = "DYG.Shoulder"; internal const string Right = "DYG.Right"; internal const string Left = "DYG.Left"; internal const string RightBack = "DYG.RightBack"; internal const string LeftBack = "DYG.LeftBack"; internal const string Utility = "DYG.Utility"; internal const string Trinket = "DYG.Trinket"; internal static readonly FieldInfo UtilityItem = AccessTools.Field(typeof(Humanoid), "m_utilityItem"); internal static readonly FieldInfo TrinketItem = AccessTools.Field(typeof(Humanoid), "m_trinketItem"); internal static readonly FieldInfo ChestItem = AccessTools.Field(typeof(Humanoid), "m_chestItem"); internal static readonly FieldInfo LegItem = AccessTools.Field(typeof(Humanoid), "m_legItem"); internal static readonly FieldInfo HelmetItem = AccessTools.Field(typeof(Humanoid), "m_helmetItem"); internal static readonly FieldInfo ShoulderItem = AccessTools.Field(typeof(Humanoid), "m_shoulderItem"); internal static readonly FieldInfo RightItem = AccessTools.Field(typeof(Humanoid), "m_rightItem"); internal static readonly FieldInfo LeftItem = AccessTools.Field(typeof(Humanoid), "m_leftItem"); internal static readonly FieldInfo HiddenRightItem = AccessTools.Field(typeof(Humanoid), "m_hiddenRightItem"); internal static readonly FieldInfo HiddenLeftItem = AccessTools.Field(typeof(Humanoid), "m_hiddenLeftItem"); internal static void Sync(Player player) { if (Object.op_Implicit((Object)(object)player)) { ZNetView component = ((Component)player).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component) && component.IsValid() && component.IsOwner()) { ZDO zDO = component.GetZDO(); ? val = zDO; object? value = UtilityItem.GetValue(player); ((ZDO)val).Set("DYG.Utility", DyeData.Pack((ItemData)((value is ItemData) ? value : null))); ? val2 = zDO; object? value2 = TrinketItem.GetValue(player); ((ZDO)val2).Set("DYG.Trinket", DyeData.Pack((ItemData)((value2 is ItemData) ? value2 : null))); ? val3 = zDO; object? value3 = ChestItem.GetValue(player); ((ZDO)val3).Set("DYG.Chest", DyeData.Pack((ItemData)((value3 is ItemData) ? value3 : null))); ? val4 = zDO; object? value4 = LegItem.GetValue(player); ((ZDO)val4).Set("DYG.Legs", DyeData.Pack((ItemData)((value4 is ItemData) ? value4 : null))); ? val5 = zDO; object? value5 = HelmetItem.GetValue(player); ((ZDO)val5).Set("DYG.Helmet", DyeData.Pack((ItemData)((value5 is ItemData) ? value5 : null))); ? val6 = zDO; object? value6 = ShoulderItem.GetValue(player); ((ZDO)val6).Set("DYG.Shoulder", DyeData.Pack((ItemData)((value6 is ItemData) ? value6 : null))); ? val7 = zDO; object? value7 = RightItem.GetValue(player); ((ZDO)val7).Set("DYG.Right", DyeData.Pack((ItemData)((value7 is ItemData) ? value7 : null))); ? val8 = zDO; object? value8 = LeftItem.GetValue(player); ((ZDO)val8).Set("DYG.Left", DyeData.Pack((ItemData)((value8 is ItemData) ? value8 : null))); ? val9 = zDO; object? value9 = HiddenRightItem.GetValue(player); ((ZDO)val9).Set("DYG.RightBack", DyeData.Pack((ItemData)((value9 is ItemData) ? value9 : null))); ? val10 = zDO; object? value10 = HiddenLeftItem.GetValue(player); ((ZDO)val10).Set("DYG.LeftBack", DyeData.Pack((ItemData)((value10 is ItemData) ? value10 : null))); } } } } internal static class DyePersistence { private const string BackupPrefix = "DyeYourGear.Item."; private static readonly FieldInfo PlayerCustomData = AccessTools.Field(typeof(Player), "m_customData"); private static Dictionary<string, string> Data(Player player) { if (!((Object)(object)player != (Object)null) || !(PlayerCustomData != null)) { return null; } return PlayerCustomData.GetValue(player) as Dictionary<string, string>; } private static string ItemKey(ItemData item) { string text = (Object.op_Implicit((Object)(object)item.m_dropPrefab) ? ((Object)item.m_dropPrefab).name.Replace("(Clone)", "").Trim() : item.m_shared.m_name); return "DyeYourGear.Item." + item.m_gridPos.x + ":" + item.m_gridPos.y + ":" + text; } internal static void Snapshot(Player player) { if (!Object.op_Implicit((Object)(object)player)) { return; } Dictionary<string, string> dictionary = Data(player); if (dictionary == null) { return; } List<string> list = new List<string>(); foreach (string key in dictionary.Keys) { if (key.StartsWith("DyeYourGear.Item.", StringComparison.Ordinal)) { list.Add(key); } } foreach (string item in list) { dictionary.Remove(item); } foreach (ItemData allItem in ((Humanoid)player).GetInventory().GetAllItems()) { if (allItem.m_customData.TryGetValue("DyeYourGear.Color", out var value) && value.Length == 6) { dictionary[ItemKey(allItem)] = value; } } } internal static void Restore(Player player) { if (!Object.op_Implicit((Object)(object)player)) { return; } Dictionary<string, string> dictionary = Data(player); if (dictionary == null) { return; } bool flag = false; foreach (ItemData allItem in ((Humanoid)player).GetInventory().GetAllItems()) { if (!allItem.m_customData.ContainsKey("DyeYourGear.Color") && dictionary.TryGetValue(ItemKey(allItem), out var value) && value.Length == 6) { allItem.m_customData["DyeYourGear.Color"] = value; flag = true; } } if (flag) { MethodInfo methodInfo = AccessTools.Method(typeof(Inventory), "Changed", new Type[2] { typeof(bool), typeof(bool) }, (Type[])null); if (methodInfo != null) { methodInfo.Invoke(((Humanoid)player).GetInventory(), new object[2] { false, false }); } } } } internal static class DyeBottle { internal const string MarkerKey = "DyeYourGear.Bottle"; internal static GameObject CarrierPrefab; private static GameObject prefab; private static GameObject prefabRoot; private static Recipe recipe; private static float nextMaintenance; private static bool warned; internal static void Maintain() { if (Time.unscaledTime < nextMaintenance) { return; } nextMaintenance = Time.unscaledTime + 0.5f; try { ObjectDB instance = ObjectDB.instance; if (!Object.op_Implicit((Object)(object)instance)) { return; } if (!Object.op_Implicit((Object)(object)prefab) || (Object)(object)instance.GetItemPrefab("DyeBottle") != (Object)(object)prefab || !Object.op_Implicit((Object)(object)recipe) || !instance.m_recipes.Contains(recipe)) { Register(instance); } if (!Object.op_Implicit((Object)(object)recipe) || !recipe.m_enabled) { ConfigureRecipe(instance); } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return; } foreach (ItemData allItem in ((Humanoid)localPlayer).GetInventory().GetAllItems()) { RestoreBottle(allItem); } if (Object.op_Implicit((Object)(object)recipe) && recipe.m_enabled && !localPlayer.IsRecipeKnown("Dye Bottle") && localPlayer.HaveRequirements(recipe, true, 1, 1)) { AccessTools.Method(typeof(Player), "AddKnownRecipe", new Type[1] { typeof(Recipe) }, (Type[])null).Invoke(localPlayer, new object[1] { recipe }); } } catch (Exception ex) { if (!warned && Object.op_Implicit((Object)(object)DyeYourGearPlugin.Instance)) { DyeYourGearPlugin.Instance.Warn("Dye Bottle registration will retry: " + ex); } warned = true; } } internal static void Register(ObjectDB db) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)db)) { return; } GameObject val = db.GetItemPrefab("MeadTasty") ?? db.GetItemPrefab("MeadHealthMinor") ?? db.GetItemPrefab("MeadBaseTasty"); if (!Object.op_Implicit((Object)(object)val)) { return; } CarrierPrefab = val; if (!Object.op_Implicit((Object)(object)prefab)) { prefabRoot = new GameObject("DyeBottle_PrefabRoot"); prefabRoot.SetActive(false); Object.DontDestroyOnLoad((Object)(object)prefabRoot); prefab = Object.Instantiate<GameObject>(val, prefabRoot.transform, false); ((Object)prefab).name = "DyeBottle"; prefab.SetActive(true); ItemDrop component = prefab.GetComponent<ItemDrop>(); SharedData shared = component.m_itemData.m_shared; SharedData val2 = new SharedData(); FieldInfo[] fields = typeof(SharedData).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { fieldInfo.SetValue(val2, fieldInfo.GetValue(shared)); } component.m_itemData.m_shared = val2; component.m_itemData.m_dropPrefab = prefab; component.m_itemData.m_customData = new Dictionary<string, string>(component.m_itemData.m_customData); component.m_itemData.m_customData["DyeYourGear.Bottle"] = "1"; val2.m_name = "Dye Bottle"; val2.m_description = "A reusable bottle for colouring armor, clothing and weapons. Use it from your inventory. Dyeing is free."; val2.m_itemType = (ItemType)19; val2.m_maxStackSize = 1; val2.m_weight = 0f; val2.m_questItem = false; val2.m_useDurability = false; val2.m_food = 0f; val2.m_foodStamina = 0f; val2.m_foodEitr = 0f; val2.m_foodBurnTime = 0f; val2.m_foodRegen = 0f; val2.m_isDrink = false; val2.m_consumeStatusEffect = null; val2.m_equipStatusEffect = null; val2.m_setStatusEffect = null; val2.m_attackStatusEffect = null; val2.m_attackStatusEffectChance = 0f; val2.m_appendToolTip = null; val2.m_projectileToolTip = false; Sprite val3 = LoadIcon(); if (Object.op_Implicit((Object)(object)val3)) { val2.m_icons = (Sprite[])