Please disclose if your mod was created primarily 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 KnarrTheTrader v0.5.2
plugins/Trader20.dll
Decompiled 2 years 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.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using Auga; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using JoshH.Extensions; using JoshH.UI; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using Trader20; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Experimental.Rendering; using UnityEngine.PostProcessing; using UnityEngine.UI; using UnityStandardAssets.ImageEffects; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: Guid("F9B815D6-6EF4-44DB-9A0F-436849B24670")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyProduct("Trader2.0")] [assembly: AssemblyCompany("")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("Trader2.0")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("0.5.2")] [assembly: AssemblyConfiguration("")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.5.2.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<e98b1d1a-1a8b-4fce-ab38-33f0ba39e46b>Embedded] internal sealed class <e98b1d1a-1a8b-4fce-ab38-33f0ba39e46b>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<e98b1d1a-1a8b-4fce-ab38-33f0ba39e46b>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <a546a844-44b5-4146-be53-ef59919185cc>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <a546a844-44b5-4146-be53-ef59919185cc>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <a546a844-44b5-4146-be53-ef59919185cc>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<e98b1d1a-1a8b-4fce-ab38-33f0ba39e46b>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContextAttribute : Attribute { public readonly byte Flag; public <6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContextAttribute(byte P_0) { Flag = P_0; } } } public class DragHandler : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { private Vector2 pointerOffset; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] private RectTransform canvasRectTransform; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] private RectTransform panelRectTransform; private bool clampedToLeft; private bool clampedToRight; private bool clampedToTop; private bool clampedToBottom; public void Start() { Canvas componentInParent = ((Component)this).GetComponentInParent<Canvas>(); if ((Object)(object)componentInParent != (Object)null) { ref RectTransform reference = ref canvasRectTransform; Transform transform = ((Component)componentInParent).transform; reference = (RectTransform)(object)((transform is RectTransform) ? transform : null); ref RectTransform reference2 = ref panelRectTransform; Transform transform2 = ((Component)this).transform; reference2 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null); } clampedToLeft = false; clampedToRight = false; clampedToTop = false; clampedToBottom = false; } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] public void OnBeginDrag(PointerEventData eventData) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) ((Transform)panelRectTransform).SetAsLastSibling(); RectTransformUtility.ScreenPointToLocalPointInRectangle(panelRectTransform, eventData.position, eventData.pressEventCamera, ref pointerOffset); } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] public void OnDrag(PointerEventData eventData) { //IL_0035: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01b4: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); if (!((Object)(object)panelRectTransform == (Object)null) && (!((Object)(object)OdinStore.instance != (Object)null) || ((Component)OdinStore.instance).gameObject.activeSelf) && RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectTransform, eventData.position, eventData.pressEventCamera, ref val)) { ((Transform)panelRectTransform).localPosition = Vector2.op_Implicit(val - pointerOffset); ClampToWindow(); Vector2 val2 = Vector2.op_Implicit(((Transform)panelRectTransform).localPosition); Rect rect; if (clampedToRight) { rect = canvasRectTransform.rect; float num = ((Rect)(ref rect)).width * 0.5f; rect = panelRectTransform.rect; val2.x = num - ((Rect)(ref rect)).width * (1f - panelRectTransform.pivot.x); } else if (clampedToLeft) { rect = canvasRectTransform.rect; float num2 = (0f - ((Rect)(ref rect)).width) * 0.5f; rect = panelRectTransform.rect; val2.x = num2 + ((Rect)(ref rect)).width * panelRectTransform.pivot.x; } if (clampedToTop) { rect = canvasRectTransform.rect; float num3 = ((Rect)(ref rect)).height * 0.5f; rect = panelRectTransform.rect; val2.y = num3 - ((Rect)(ref rect)).height * (1f - panelRectTransform.pivot.y); } else if (clampedToBottom) { rect = canvasRectTransform.rect; float num4 = (0f - ((Rect)(ref rect)).height) * 0.5f; rect = panelRectTransform.rect; val2.y = num4 + ((Rect)(ref rect)).height * panelRectTransform.pivot.y; } ((Transform)panelRectTransform).localPosition = Vector2.op_Implicit(val2); } } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] public void OnEndDrag(PointerEventData eventData) { } private void ClampToWindow() { Vector3[] array = (Vector3[])(object)new Vector3[4]; Vector3[] array2 = (Vector3[])(object)new Vector3[4]; canvasRectTransform.GetWorldCorners(array); panelRectTransform.GetWorldCorners(array2); if (array2[2].x > array[2].x) { if (!clampedToRight) { clampedToRight = true; } } else if (clampedToRight) { clampedToRight = false; } else if (array2[0].x < array[0].x) { if (!clampedToLeft) { clampedToLeft = true; } } else if (clampedToLeft) { clampedToLeft = false; } if (array2[2].y > array[2].y) { if (!clampedToTop) { clampedToTop = true; } } else if (clampedToTop) { clampedToTop = false; } else if (array2[0].y < array[0].y) { if (!clampedToBottom) { clampedToBottom = true; } } else if (clampedToBottom) { clampedToBottom = false; } } } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(2)] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] public class ElementScript : MonoBehaviour { public GameObject Icon; public Image Icon2; } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] public class LitPanelizer : MonoBehaviour { [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] public Image referenceimg; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] public Image repairBkg; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(new byte[] { 1, 2 })] public List<Image> _TabImages = new List<Image>(); public List<Image> _ButtonImages = new List<Image>(); private Material litpanel; private void Awake() { litpanel = ((Graphic)repairBkg).material; Transform[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<Transform>(); Transform[] array = componentsInChildren; foreach (Transform val in array) { if ((Object)(object)((Component)val).GetComponent<Image>() != (Object)null && ((Object)((Graphic)((Component)val).GetComponent<Image>()).material).name.StartsWith("REPLACE_")) { ((Graphic)((Component)val).GetComponent<Image>()).material = litpanel; } } foreach (Image tabImage in _TabImages) { tabImage.sprite = referenceimg.sprite; ((Graphic)tabImage).material = ((Graphic)referenceimg).material; } foreach (Image buttonImage in _ButtonImages) { ((Graphic)buttonImage).material = litpanel; } } private void OnEnable() { foreach (Image tabImage in _TabImages) { tabImage.sprite = referenceimg.sprite; ((Graphic)tabImage).material = ((Graphic)repairBkg).material; ((Graphic)tabImage).material.mainTexture = ((Graphic)referenceimg).mainTexture; } } } public class MaterialReplacer : MonoBehaviour { private void Awake() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>(); foreach (GameObject val in array) { if (((Object)val).name == "InteriorEnvirnomentZone") { Renderer component = ((Component)this).gameObject.GetComponent<Renderer>(); component = (Renderer)val.GetComponents<Renderer>().Clone(); } } } } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(2)] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] public class PlayerBaseMaker : MonoBehaviour { private EffectArea _playerBase; private GameObject _holder; private void OnEnable() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_playerBase != (Object)null)) { _holder = new GameObject(); _holder.SetActive(false); GameObject val = Object.Instantiate<GameObject>(_holder, ((Component)this).transform.position, Quaternion.identity); _playerBase = val.AddComponent<EffectArea>(); if (!((Object)(object)_playerBase == (Object)null)) { _playerBase.m_type = (Type)32; SphereCollider val2 = val.AddComponent<SphereCollider>(); val2.radius = 5f; ((Collider)val2).isTrigger = true; _playerBase.m_statusEffect = "SE_Cozy"; _holder.transform.SetParent(((Component)this).transform); } } } } [Serializable] internal enum ShaderType { Alpha, Blob, Bonemass, Clouds, Creature, Decal, Distortion, Flow, FlowOpaque, Grass, GuiScroll, HeightMap, Icon, InteriorSide, LitGui, LitParticles, MapShader, ParticleDetail, Piece, Player, Rug, ShadowBlob, SkyboxProcedural, SkyObject, StaticRock, Tar, TrilinearMap, BGBlur, Water, WaterBottom, WaterMask, Yggdrasil, YggdrasilRoot, ToonDeferredShading2017 } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] public class ShaderReplacerNew : MonoBehaviour { [Tooltip("Use this Field For Normal Renderers")] [SerializeField] internal Renderer[] _renderers; [SerializeField] internal ShaderType _shaderType = ShaderType.Creature; [SerializeField] internal bool DebugOutput; private void Awake() { if (IsHeadlessMode() || _renderers.Length == 0 || !((Component)this).gameObject.activeInHierarchy) { return; } Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if ((Object)(object)val == (Object)null) { continue; } Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 == (Object)null) { ((Component)val).gameObject.SetActive(false); } else { val2.shader = Shader.Find(ReturnEnumString(_shaderType)); } } } } internal string ReturnEnumString(ShaderType shaderchoice) { string result = ""; switch (shaderchoice) { case ShaderType.Alpha: result = "Custom/AlphaParticle"; break; case ShaderType.Blob: result = "Custom/Blob"; break; case ShaderType.Bonemass: result = "Custom/Bonemass"; break; case ShaderType.Clouds: result = "Custom/Clouds"; break; case ShaderType.Creature: result = "Custom/Creature"; break; case ShaderType.Decal: result = "Custom/Decal"; break; case ShaderType.Distortion: result = "Custom/Distortion"; break; case ShaderType.Flow: result = "Custom/Flow"; break; case ShaderType.FlowOpaque: result = "Custom/FlowOpaque"; break; case ShaderType.Grass: result = "Custom/Grass"; break; case ShaderType.GuiScroll: result = "Custom/GuiScroll"; break; case ShaderType.HeightMap: result = "Custom/HeightMap"; break; case ShaderType.Icon: result = "Custom/Icon"; break; case ShaderType.InteriorSide: result = "Custom/InteriorSide"; break; case ShaderType.LitGui: result = "Custom/LitGui"; break; case ShaderType.LitParticles: result = "Lux Lit Particles/ Bumped"; break; case ShaderType.MapShader: result = "Custom/mapshader"; break; case ShaderType.ParticleDetail: result = "Custom/ParticleDecal"; break; case ShaderType.Piece: result = "Custom/Piece"; break; default: throw new ArgumentOutOfRangeException("shaderchoice", shaderchoice, null); case ShaderType.Player: case ShaderType.Rug: case ShaderType.ShadowBlob: case ShaderType.SkyboxProcedural: case ShaderType.SkyObject: case ShaderType.StaticRock: case ShaderType.Tar: case ShaderType.TrilinearMap: case ShaderType.BGBlur: case ShaderType.Water: case ShaderType.WaterBottom: case ShaderType.WaterMask: case ShaderType.Yggdrasil: case ShaderType.YggdrasilRoot: case ShaderType.ToonDeferredShading2017: break; } return result; } public static bool IsHeadlessMode() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 return (int)SystemInfo.graphicsDeviceType == 4; } } [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] public class NewTrader : MonoBehaviour, Hoverable, Interactable { [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] private static NewTrader m_instance; public string m_name = "Knarr"; public float m_standRange = 15f; public float m_greetRange = 5f; public float m_byeRange = 5f; [Header("Dialog")] public float m_hideDialogDelay = 5f; public float m_randomTalkInterval = 30f; public List<string> m_randomTalk = new List<string>(); public List<string> m_randomGreets = new List<string>(); public List<string> m_randomGoodbye = new List<string>(); public List<string> m_randomStartTrade = new List<string>(); public List<string> m_randomBuy = new List<string>(); public List<string> m_randomSell = new List<string>(); public EffectList m_randomTalkFX = new EffectList(); public EffectList m_randomGreetFX = new EffectList(); public EffectList m_randomGoodbyeFX = new EffectList(); public EffectList m_randomStartTradeFX = new EffectList(); public EffectList m_randomSellFX = new EffectList(); [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] public SnapToGround _snapper; private bool m_didGreet; private bool m_didGoodbye; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] private Animator m_animator; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] private LookAt m_lookAt; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal OdinStore _store; [SerializeField] internal float rotateAtPlayerSpeed; private static readonly int Stand = Animator.StringToHash("Stand"); [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal ZNetView m_netview; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] public static NewTrader instance { [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(2)] get { return m_instance; } } [SerializeField] private float nextTime { get; set; } [SerializeField] private float modifier { get; set; } private void Start() { m_animator = ((Component)this).GetComponentInChildren<Animator>(); m_lookAt = ((Component)this).GetComponentInChildren<LookAt>(); ((MonoBehaviour)this).InvokeRepeating("RandomTalk", m_randomTalkInterval, m_randomTalkInterval); nextTime = 0f; SnapToGround.SnappAll(); _snapper = ((Component)this).GetComponent<SnapToGround>(); if (Object.op_Implicit((Object)(object)_snapper)) { _snapper.Snap(); } } private void Awake() { m_instance = this; } private void OnDestroy() { if ((Object)(object)m_instance == (Object)(object)this) { m_instance = null; } } private void Update() { modifier = Random.Range(-0.08f, 40f); } private void LateUpdate() { //IL_0006: 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_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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) Player closestPlayer = Player.GetClosestPlayer(((Component)this).transform.position, m_standRange); if (Object.op_Implicit((Object)(object)closestPlayer)) { m_animator.SetBool(Stand, true); m_lookAt.SetLoockAtTarget(((Character)closestPlayer).GetHeadPoint()); Vector3 position = ((Component)closestPlayer).transform.position; float num = Vector3.Distance(position, ((Component)instance).transform.position); if (!m_didGreet && num <= m_greetRange) { m_didGreet = true; m_didGoodbye = false; Say(m_randomGreets, "Greet"); if (global::Trader20.Trader20.KnarrPlaySound.Value) { GameObject prefab = m_randomGreetFX.m_effectPrefabs[Random.Range(0, m_randomGreetFX.m_effectPrefabs.Length)].m_prefab; prefab.GetComponent<AudioSource>().outputAudioMixerGroup = AudioMan.instance.m_ambientMixer; Object.Instantiate<GameObject>(prefab, ((Component)this).transform.position, Quaternion.identity); } } if (m_didGreet && !m_didGoodbye && num >= m_byeRange) { m_didGoodbye = true; m_didGreet = false; Say(m_randomGoodbye, "Greet"); if (global::Trader20.Trader20.KnarrPlaySound.Value) { GameObject prefab2 = m_randomGoodbyeFX.m_effectPrefabs[Random.Range(0, m_randomGoodbyeFX.m_effectPrefabs.Length)].m_prefab; prefab2.GetComponent<AudioSource>().outputAudioMixerGroup = AudioMan.instance.m_ambientMixer; Object.Instantiate<GameObject>(prefab2, ((Component)this).transform.position, Quaternion.identity); } } } else { m_animator.SetBool(Stand, false); m_lookAt.ResetTarget(); } } private void RandomTalk() { //IL_001f: 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_005f: Unknown result type (might be due to invalid IL or missing references) if (m_animator.GetBool(Stand) && !StoreGui.IsVisible() && Player.IsPlayerInRange(((Component)this).transform.position, m_greetRange)) { Say(m_randomTalk, "Talk"); if (global::Trader20.Trader20.KnarrPlaySound.Value) { m_randomTalkFX.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1); } } } public string GetHoverText() { return Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $raven_interact"); } public string GetHoverName() { return Localization.instance.Localize(m_name); } public bool Interact(Humanoid character, bool hold, bool alt) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (hold) { return false; } if ((Object)(object)OdinStore.instance != (Object)null) { OdinStore.instance.Show(); } Say(m_randomStartTrade, "Talk"); m_randomStartTradeFX.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1); return false; } private void Say(List<string> texts, string trigger) { Say(texts[Random.Range(0, texts.Count)], trigger); } private void Say(string text, string trigger) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) Chat.instance.SetNpcText(((Component)this).gameObject, Vector3.up * 1.5f, 20f, m_hideDialogDelay, "", text, false); if (trigger.Length > 0) { m_animator.SetTrigger(trigger); } } public bool UseItem(Humanoid user, ItemData item) { return false; } public void OnSold() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Say(m_randomSell, "Sell"); EffectData[] array = RandomSellFX(1); GameObject prefab = array[Random.Range(0, array.Length)].m_prefab; Object.Instantiate<GameObject>(prefab, ((Component)this).transform.position, Quaternion.identity); } private EffectData[] RandomSellFX(int numRequired) { EffectData[] array = (EffectData[])(object)new EffectData[numRequired]; int num = numRequired; for (int num2 = m_randomSellFX.m_effectPrefabs.Length; num2 > 0; num2--) { float num3 = (float)num / (float)num2; if (Random.value <= num3) { num--; array[num] = m_randomSellFX.m_effectPrefabs[num2 - 1]; if (num == 0) { break; } } } return array; } } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] public class OdinStore : MonoBehaviour { [Serializable] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(2)] public class ElementFormat { private int? _inventoryCount; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(1)] private GameObject _element; private GameObject _itemObject; private Sprite _icon; private string _itemName; private int? _price; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(1)] internal GameObject Element { [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] get { return _element; } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] set { _element = value; } } internal Sprite Icon { get { return _icon; } set { _icon = value; } } internal string ItemName { get { return _itemName; } set { _itemName = value; } } internal int? Price { get { return _price; } set { _price = value; } } internal GameObject ItemObject { get { return _itemObject; } set { _itemObject = value; } } internal int? InventoryCount { get { return _inventoryCount; } set { _inventoryCount = value; } } internal UITooltip _uiTooltip { get; set; } public ElementFormat(GameObject element) { Element = element; } } [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [Header("Store instance")] private static OdinStore m_instance; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] private GameObject m_StorePanel; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] private TextMeshProUGUI StoreTitle_TMP; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [SerializeField] internal Image Bkg1; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [SerializeField] internal Image Bkg2; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal RectTransform TabRect; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [SerializeField] [Header("Items Panel")] [Space] private RectTransform ListRoot; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [SerializeField] private Image ItemDropIcon; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [SerializeField] internal TextMeshProUGUI SelectedCost_TMP; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [SerializeField] private TextMeshProUGUI SelectedItemDescription_TMP; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] private TextMeshProUGUI SelectedName_TMP; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [Space] [Header("Sell Panel")] [SerializeField] private Button SellButton; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] private RectTransform SellListRoot; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [SerializeField] private TextMeshProUGUI InventoryCount_TMP; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal TextMeshProUGUI repairText_TMP; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal GameObject InvCountPanel; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal Image SellButtonImage; [SerializeField] internal bool SellPageActive; [Header("Buy Panel")] [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [Space] private Button BuyButton; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [SerializeField] internal Image BuyButtonImage; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [SerializeField] internal Image Coins; [SerializeField] internal bool BuyPageActive = true; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [Space] [Header("Elements")] private GameObject ElementGO; [SerializeField] [Header("Repair Tab")] [Space] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal RectTransform RepairRect; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] [SerializeField] internal Image repairImage; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal Button repairButton; [SerializeField] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal Image repairHammerImage; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal InventoryGui gui; internal GameObject splitDiagGO; internal Transform m_splitPanel; internal Slider m_splitSlider; internal Text m_splitAmount; internal Button m_splitCancelButton; internal Button m_splitOkButton; internal Image m_splitIcon; internal Text m_splitIconName; internal ItemData m_splitItem; private string m_splitInput = ""; private DateTime m_lastSplitInput; public float m_splitNumInputTimeoutSec = 0.5f; internal Dictionary<ItemDrop, StoreInfo<int, int, int>> _storeInventory = new Dictionary<ItemDrop, StoreInfo<int, int, int>>(); [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal static ElementFormat tempElement; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] internal static Material litpanel; internal List<ElementFormat> _knarSellElements = new List<ElementFormat>(); internal List<ElementFormat> _playerSellElements; private List<ItemData> m_tempItems = new List<ItemData>(); internal GameObject ElementPoolGO; internal List<ElementFormat> ElementPoolObjects = new List<ElementFormat>(); internal int currentIdx; internal bool iscurrentlysplitting; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] public static OdinStore instance { [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(2)] get { return m_instance; } } private void Awake() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) _playerSellElements = new List<ElementFormat>(); m_instance = this; Transform transform = m_StorePanel.transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); val.anchoredPosition = Vector2.op_Implicit(global::Trader20.Trader20.StoreScreenPos.Value); ((TMP_Text)StoreTitle_TMP).SetText("Knarr's Shop"); CreateAndFillElementPool(); m_StorePanel.SetActive(false); } private void Start() { ConfigEntry<bool> configShowRepair = global::Trader20.Trader20.ConfigShowRepair; if (configShowRepair != null && !configShowRepair.Value && (Object)(object)RepairRect != (Object)null) { ((Component)RepairRect).gameObject.SetActive(false); } ConfigEntry<bool> configShowTabs = global::Trader20.Trader20.ConfigShowTabs; if (configShowTabs != null && !configShowTabs.Value) { ((Component)TabRect).gameObject.SetActive(false); } } private void Update() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!IsActive()) { return; } if (IsActive()) { StoreGui.instance.m_hiddenFrames = 0; } Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { if (Vector3.Distance(((Component)NewTrader.instance).transform.position, ((Component)localPlayer).transform.position) > 15f) { Hide(); } if (Input.GetKeyDown((KeyCode)27) || ZInput.GetButtonDown("JoyButtonB")) { ZInput.ResetButtonStatus("JoyButtonB"); Hide(); } if (InventoryGui.IsVisible() || Minimap.IsOpen()) { Hide(); } if ((Object)(object)Player.m_localPlayer == (Object)null || ((Character)Player.m_localPlayer).IsDead() || ((Character)Player.m_localPlayer).InCutscene()) { Hide(); } UpdateRecipeGamepadInput(); if (iscurrentlysplitting) { UpdateSplitDialog(); } } } private void OnDestroy() { if ((Object)(object)m_instance == (Object)(object)this) { m_instance = null; } } private ElementFormat GetPooledElement() { for (int i = 0; i < ElementPoolObjects.Count; i++) { if (!ElementPoolObjects[i].Element.activeSelf && !ElementPoolObjects[i].Element.activeSelf) { return ElementPoolObjects[i]; } } return null; } private void ReturnPooledElement(ElementFormat element) { element.Element.transform.SetParent(ElementPoolGO.transform); element.Element.transform.SetSiblingIndex(-1); element.Element.SetActive(false); element._uiTooltip = null; element.Icon = null; element.Price = null; element.InventoryCount = null; element.ItemName = null; } private void CreateAndFillElementPool() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ElementPoolGO = new GameObject("ElementPool"); ElementPoolGO.transform.SetParent(((Component)this).transform); ElementPoolGO.transform.SetSiblingIndex(-1); ElementPoolGO.SetActive(false); for (int i = 0; i < ObjectDB.instance.m_items.Count; i++) { GameObject val = Object.Instantiate<GameObject>(ElementGO, ElementPoolGO.transform, false); val.SetActive(false); ElementFormat item = new ElementFormat(val); ElementPoolObjects.Add(item); } } private bool IsActive() { return m_StorePanel.activeSelf; } internal void ClearStore() { if (BuyPageActive && _knarSellElements.Count != _storeInventory.Count) { foreach (ElementFormat knarSellElement in _knarSellElements) { ReturnPooledElement(knarSellElement); } _knarSellElements.Clear(); ReadStoreItems(); } if (SellPageActive) { FillPlayerItemListVoid(); } } public void AddItemToDisplayList(GameObject dropObj, int stack, int cost, int invCount, RectTransform rectForElements, bool isPlayerItem) { //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Expected O, but got Unknown //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Expected O, but got Unknown //IL_0845: Unknown result type (might be due to invalid IL or missing references) //IL_084f: Expected O, but got Unknown ElementFormat newElement; ItemDrop drop; switch (Utilities.GetConnectionState()) { case Utilities.ConnectionState.Client: { newElement = GetPooledElement(); newElement.ItemObject = dropObj; drop = dropObj.GetComponent<ItemDrop>(); newElement.Icon = drop.m_itemData.m_shared.m_icons.FirstOrDefault(); newElement.ItemName = drop.m_itemData.m_shared.m_name; newElement._uiTooltip = newElement.Element.GetComponent<UITooltip>(); newElement._uiTooltip.m_text = Localization.instance.Localize(drop.m_itemData.m_shared.m_name); if ((Object)(object)Player.m_localPlayer != (Object)null) { string tooltip2 = drop.m_itemData.GetTooltip(); if (!Utility.IsNullOrWhiteSpace(tooltip2)) { newElement._uiTooltip.m_topic = Localization.instance.Localize(tooltip2); } } newElement.InventoryCount = invCount; ((Component)newElement.Element.transform.Find("icon")).GetComponent<Image>().sprite = newElement.Icon; Text component = ((Component)newElement.Element.transform.Find("name")).GetComponent<Text>(); component.text = newElement.ItemName; ((Component)component).gameObject.AddComponent<Localize>(); ((Component)newElement.Element.transform.Find("price")).GetComponent<Text>().text = cost.ToString(); Text component3 = ((Component)newElement.Element.transform.Find("stack")).GetComponent<Text>(); string text = ((stack > 1) ? ("x" + stack) : ((stack != 1) ? ((Component)newElement.Element.transform.Find("stack")).GetComponent<Text>().text : "")); component3.text = text; ((UnityEvent)newElement.Element.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { UpdateGenDescription(newElement); if (invCount <= 0) { InvCountPanel.SetActive(false); } else { InvCountPanel.SetActive(true); ((TMP_Text)InventoryCount_TMP).SetText(_storeInventory.ElementAt(FindIndex(drop)).Value.InvCount.ToString()); } }); newElement.Element.transform.SetParent((Transform)(object)rectForElements, false); newElement.Element.transform.SetSiblingIndex(((Component)rectForElements).transform.GetSiblingIndex() - 1); ((Component)newElement.Element.transform.Find("coin_bkg/coin icon")).GetComponent<Image>().sprite = global::Trader20.Trader20.Coins; if (isPlayerItem) { _playerSellElements.Add(newElement); } else { _knarSellElements.Add(newElement); } newElement.Element.SetActive(true); break; } case Utilities.ConnectionState.Local: { newElement = GetPooledElement(); newElement.ItemObject = dropObj; drop = dropObj.GetComponent<ItemDrop>(); newElement.Icon = drop.m_itemData.m_shared.m_icons.FirstOrDefault(); newElement.ItemName = drop.m_itemData.m_shared.m_name; newElement._uiTooltip = newElement.Element.GetComponent<UITooltip>(); newElement._uiTooltip.m_text = Localization.instance.Localize(drop.m_itemData.m_shared.m_name); if (!Utility.IsNullOrWhiteSpace(drop.m_itemData.m_shared.m_description)) { string tooltip3 = drop.m_itemData.GetTooltip(); if (!Utility.IsNullOrWhiteSpace(tooltip3)) { newElement._uiTooltip.m_topic = Localization.instance.Localize(tooltip3); } } newElement.InventoryCount = invCount; ((Component)newElement.Element.transform.Find("icon")).GetComponent<Image>().sprite = newElement.Icon; Text component = ((Component)newElement.Element.transform.Find("name")).GetComponent<Text>(); component.text = newElement.ItemName; ((Component)component).gameObject.AddComponent<Localize>(); ((Component)newElement.Element.transform.Find("price")).GetComponent<Text>().text = cost.ToString(); Text component4 = ((Component)newElement.Element.transform.Find("stack")).GetComponent<Text>(); string text = ((stack > 1) ? ("x" + stack) : ((stack != 1) ? ((Component)newElement.Element.transform.Find("stack")).GetComponent<Text>().text : "")); component4.text = text; ((UnityEvent)newElement.Element.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { UpdateGenDescription(newElement); if (invCount <= 0) { InvCountPanel.SetActive(false); } else { InvCountPanel.SetActive(true); ((TMP_Text)InventoryCount_TMP).SetText(_storeInventory.ElementAt(FindIndex(drop)).Value.InvCount.ToString()); } }); newElement.Element.transform.SetParent((Transform)(object)rectForElements, false); newElement.Element.transform.SetSiblingIndex(((Component)rectForElements).transform.GetSiblingIndex() - 1); ((Component)newElement.Element.transform.Find("coin_bkg/coin icon")).GetComponent<Image>().sprite = global::Trader20.Trader20.Coins; if (isPlayerItem) { _playerSellElements.Add(newElement); } else { _knarSellElements.Add(newElement); } newElement.Element.SetActive(true); break; } case Utilities.ConnectionState.Unknown: { newElement = GetPooledElement(); newElement.ItemObject = dropObj; drop = dropObj.GetComponent<ItemDrop>(); newElement.Icon = drop.m_itemData.m_shared.m_icons.FirstOrDefault(); newElement.ItemName = drop.m_itemData.m_shared.m_name; newElement._uiTooltip = newElement.Element.GetComponent<UITooltip>(); newElement._uiTooltip.m_text = Localization.instance.Localize(drop.m_itemData.m_shared.m_name); if (!Utility.IsNullOrWhiteSpace(drop.m_itemData.m_shared.m_description)) { string tooltip = drop.m_itemData.GetTooltip(); if (!Utility.IsNullOrWhiteSpace(tooltip)) { newElement._uiTooltip.m_topic = Localization.instance.Localize(tooltip); } } newElement.InventoryCount = invCount; ((Component)newElement.Element.transform.Find("icon")).GetComponent<Image>().sprite = newElement.Icon; Text component = ((Component)newElement.Element.transform.Find("name")).GetComponent<Text>(); component.text = newElement.ItemName; ((Component)component).gameObject.AddComponent<Localize>(); ((Component)newElement.Element.transform.Find("price")).GetComponent<Text>().text = cost.ToString(); Text component2 = ((Component)newElement.Element.transform.Find("stack")).GetComponent<Text>(); string text = ((stack > 1) ? ("x" + stack) : ((stack != 1) ? ((Component)newElement.Element.transform.Find("stack")).GetComponent<Text>().text : "")); component2.text = text; ((UnityEvent)newElement.Element.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { UpdateGenDescription(newElement); if (invCount <= 0) { InvCountPanel.SetActive(false); } else { InvCountPanel.SetActive(true); ((TMP_Text)InventoryCount_TMP).SetText(_storeInventory.ElementAt(FindIndex(drop)).Value.InvCount.ToString()); } }); newElement.Element.transform.SetParent((Transform)(object)rectForElements, false); newElement.Element.transform.SetSiblingIndex(((Component)rectForElements).transform.GetSiblingIndex() - 1); ((Component)newElement.Element.transform.Find("coin_bkg/coin icon")).GetComponent<Image>().sprite = global::Trader20.Trader20.Coins; if (isPlayerItem) { _playerSellElements.Add(newElement); } else { _knarSellElements.Add(newElement); } newElement.Element.SetActive(true); break; } case Utilities.ConnectionState.Server: break; } } private void ReadStoreItems() { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Invalid comparison between Unknown and I4 try { if (_knarSellElements.Count >= 1) { _knarSellElements.Clear(); } if (_storeInventory.Count <= 0) { return; } foreach (KeyValuePair<ItemDrop, StoreInfo<int, int, int>> item in _storeInventory) { ConfigEntry<bool> onlySellKnownItems = global::Trader20.Trader20.OnlySellKnownItems; if (onlySellKnownItems != null && onlySellKnownItems.Value) { if (item.Value.InvCount != 0) { if (Player.m_localPlayer.m_knownRecipes.Contains(item.Key.m_itemData.m_shared.m_name) || Player.m_localPlayer.m_knownMaterial.Contains(item.Key.m_itemData.m_shared.m_name)) { AddItemToDisplayList(((Component)item.Key).gameObject, item.Value.Stack, item.Value.Cost, item.Value.InvCount, ListRoot, isPlayerItem: false); } else if ((int)item.Key.m_itemData.m_shared.m_itemType == 1 && global::Trader20.Trader20.ShowMatsWhenHidingRecipes.Value) { AddItemToDisplayList(((Component)item.Key).gameObject, item.Value.Stack, item.Value.Cost, item.Value.InvCount, ListRoot, isPlayerItem: false); } } } else if (item.Value.InvCount != 0) { AddItemToDisplayList(((Component)item.Key).gameObject, item.Value.Stack, item.Value.Cost, item.Value.InvCount, ListRoot, isPlayerItem: false); } } } catch (Exception ex) { global::Trader20.Trader20.knarrlogger.LogDebug((object)ex); } } public void SellItem(int i) { //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_0161: 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_0168: Unknown result type (might be due to invalid IL or missing references) Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); ItemDrop key = _storeInventory.ElementAt(i).Key; if ((Object)(object)key == (Object)null || key.m_itemData == null) { return; } int num = Mathf.Min(_storeInventory.ElementAt(i).Value.Stack, key.m_itemData.m_shared.m_maxStackSize); int quality = key.m_itemData.m_quality; int variant = key.m_itemData.m_variant; key.m_itemData.m_dropPrefab = ObjectDB.instance.GetItemPrefab(((Object)((Component)key).gameObject).name); key.m_itemData.m_durability = key.m_itemData.GetMaxDurability(); if (inventory.AddItem(((Object)key).name, num, quality, variant, 0L, "", false) != null) { ((Character)Player.m_localPlayer).ShowPickupMessage(key.m_itemData, num); Gogan.LogEvent("Game", "BoughtItem", ((Object)key.m_itemData.m_dropPrefab).name, 0L); } else { Vector3 val = Random.insideUnitSphere * 0.5f; Transform transform = ((Component)Player.m_localPlayer).transform; GameObject val2 = Object.Instantiate<GameObject>(((Component)_storeInventory.ElementAt(i).Key).gameObject, transform.position + transform.forward * 2f + Vector3.up + val, Quaternion.identity); val2.GetComponent<ItemDrop>().m_itemData.m_stack = num; } int invCount = _storeInventory.ElementAt(i).Value.InvCount; if (invCount < 1) { if (invCount <= -1) { } } else { _storeInventory.ElementAt(i).Value.InvCount -= _storeInventory.ElementAt(i).Value.Stack; ((TMP_Text)InventoryCount_TMP).SetText(_storeInventory.ElementAt(i).Value.InvCount.ToString()); int? num2 = _storeInventory.ElementAt(i).Value.InvCount; UpdateYmlFileFromSaleOrBuy(_storeInventory.ElementAt(i).Key.m_itemData, num2.Value, isPlayerItem: false); if (num2 <= 0) { try { UpdateGenDescription(_knarSellElements[0]); ((TMP_Text)InventoryCount_TMP).SetText(_knarSellElements[0].InventoryCount.ToString()); tempElement = null; UpdateYmlFileFromSaleOrBuy(_storeInventory.ElementAt(i).Key.m_itemData, num2.Value, isPlayerItem: false); if (RemoveItemFromDict(key)) { ClearStore(); } } catch (Exception ex) { global::Trader20.Trader20.knarrlogger.LogDebug((object)ex); } } } if (!global::Trader20.Trader20.LOGStoreSales.Value) { return; } string text = Player.m_localPlayer.GetPlayerID().ToString(); string text2 = Player.m_localPlayer.GetPlayerName() ?? throw new ArgumentNullException("i"); string text3 = _storeInventory.ElementAt(i).Value.Cost.ToString(); EnvMan val3 = EnvMan.instance; DateTime dateTime = DateTime.Now; string text4 = ""; switch (Utilities.GetConnectionState()) { case Utilities.ConnectionState.Server: if (Object.op_Implicit((Object)(object)val3)) { float smoothDayFraction2 = val3.m_smoothDayFraction; int num5 = (int)(smoothDayFraction2 * 24f); int num6 = (int)((smoothDayFraction2 * 24f - (float)num5) * 60f); int second2 = (int)(((smoothDayFraction2 * 24f - (float)num5) * 60f - (float)num6) * 60f); DateTime now2 = DateTime.Now; dateTime = new DateTime(now2.Year, now2.Month, now2.Day, num5, num6, second2); int currentDay2 = EnvMan.instance.GetCurrentDay(); } text4 = "[" + dateTime.ToString() + "] " + text + " - " + text2 + " Purchased: " + Localization.instance.Localize(key.m_itemData.m_shared.m_name) + " For: " + text3; Gogan.LogEvent("Game", "Knarr Sold Item", text4, 0L); ZLog.Log((object)("Knarr Sold Item " + text4)); LogSales(text4).ConfigureAwait(continueOnCapturedContext: false); break; case Utilities.ConnectionState.Client: ZRoutedRpc.instance.InvokeRoutedRPC("SendLogItemToServer", new object[2] { ((Object)key.m_itemData.m_dropPrefab).name, _storeInventory.ElementAt(i).Value.Cost }); break; case Utilities.ConnectionState.Local: if (Object.op_Implicit((Object)(object)val3)) { float smoothDayFraction = val3.m_smoothDayFraction; int num3 = (int)(smoothDayFraction * 24f); int num4 = (int)((smoothDayFraction * 24f - (float)num3) * 60f); int second = (int)(((smoothDayFraction * 24f - (float)num3) * 60f - (float)num4) * 60f); DateTime now = DateTime.Now; dateTime = new DateTime(now.Year, now.Month, now.Day, num3, num4, second); int currentDay = EnvMan.instance.GetCurrentDay(); text4 = "[" + dateTime.ToString() + "] " + text + " - " + text2 + " Purchased: " + Localization.instance.Localize(key.m_itemData.m_shared.m_name) + " For: " + text3; Gogan.LogEvent("Game", "Knarr Sold Item", text4, 0L); ZLog.Log((object)("Knarr Sold Item " + text4)); LogSales(text4).ConfigureAwait(continueOnCapturedContext: false); } break; case Utilities.ConnectionState.Unknown: break; } } internal void UpdateYmlFileFromSaleOrBuy(ItemData sellableItem, int newInvCount, bool isPlayerItem) { ConfigEntry<bool> configWriteSalesBuysToYml = global::Trader20.Trader20.ConfigWriteSalesBuysToYml; if (configWriteSalesBuysToYml == null || !configWriteSalesBuysToYml.Value) { return; } string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; StreamReader streamReader = File.OpenText(configPath + directorySeparatorChar + "trader_config.yaml"); Dictionary<string, ItemDataEntry> dictionary = YMLParser.ReadSerializedData(streamReader.ReadToEnd()); streamReader.Close(); switch (Utilities.GetConnectionState()) { case Utilities.ConnectionState.Server: if (YMLParser.CheckForEntry(dictionary, ((Object)sellableItem.m_dropPrefab).name)) { if (dictionary.TryGetValue(((Object)sellableItem.m_dropPrefab).name, out var value3)) { if (isPlayerItem) { value3.Invcount += sellableItem.m_stack; } else { value3.Invcount = newInvCount; } dictionary[((Object)sellableItem.m_dropPrefab).name] = value3; string contents2 = YMLParser.Serializers(dictionary); string configPath3 = Paths.ConfigPath; directorySeparatorChar = Path.DirectorySeparatorChar; File.WriteAllText(configPath3 + directorySeparatorChar + "trader_config.yaml", contents2); } } else { ItemDataEntry value4 = default(ItemDataEntry); value4.Invcount += sellableItem.m_stack; value4.ItemCount += sellableItem.m_stack; Dictionary<string, ItemDataEntry> dictionary3 = new Dictionary<string, ItemDataEntry>(); dictionary3.Add(((Object)sellableItem.m_dropPrefab).name, value4); string s2 = YMLParser.Serializers(dictionary3); YMLParser.AppendYmLfile(s2); } break; case Utilities.ConnectionState.Client: ZRoutedRpc.instance.InvokeRoutedRPC("SendItemInfoToServer", new object[3] { ((Object)sellableItem.m_dropPrefab).name, newInvCount, isPlayerItem }); break; case Utilities.ConnectionState.Local: if (YMLParser.CheckForEntry(dictionary, ((Object)sellableItem.m_dropPrefab).name)) { if (!dictionary.TryGetValue(((Object)sellableItem.m_dropPrefab).name, out var value)) { break; } if (isPlayerItem) { if (iscurrentlysplitting) { value.Invcount += newInvCount; } else { value.Invcount += sellableItem.m_stack; } } else { value.Invcount = newInvCount; } dictionary[((Object)sellableItem.m_dropPrefab).name] = value; string contents = YMLParser.Serializers(dictionary); string configPath2 = Paths.ConfigPath; directorySeparatorChar = Path.DirectorySeparatorChar; File.WriteAllText(configPath2 + directorySeparatorChar + "trader_config.yaml", contents); } else { ItemDataEntry value2 = default(ItemDataEntry); value2.Invcount += sellableItem.m_stack; value2.ItemCount += sellableItem.m_stack; Dictionary<string, ItemDataEntry> dictionary2 = new Dictionary<string, ItemDataEntry>(); dictionary2.Add(((Object)sellableItem.m_dropPrefab).name, value2); string s = YMLParser.Serializers(dictionary2); YMLParser.AppendYmLfile(s); } break; case Utilities.ConnectionState.Unknown: break; } } internal async Task LogSales(string saleinfo) { await WriteSales(saleinfo).ConfigureAwait(continueOnCapturedContext: false); } private static async Task WriteSales(string saleInfo) { UnicodeEncoding encoding = new UnicodeEncoding(); string path = Paths.ConfigPath + "/TraderSales.log"; byte[] bytes = encoding.GetBytes(saleInfo); using FileStream sourceStream = File.Open(path, FileMode.OpenOrCreate); sourceStream.Seek(0L, SeekOrigin.End); await sourceStream.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(continueOnCapturedContext: false); await sourceStream.WriteAsync(encoding.GetBytes(Environment.NewLine), 0, Environment.NewLine.Length).ConfigureAwait(continueOnCapturedContext: false); } public void AddItemToDict(ItemDrop itemDrop, int price, int stack, int invCount) { _storeInventory.Add(itemDrop, new StoreInfo<int, int, int>(price, stack, invCount)); } private bool RemoveItemFromDict(ItemDrop itemDrop) { Dictionary<string, ItemDataEntry> dictionary = new Dictionary<string, ItemDataEntry>(); foreach (KeyValuePair<ItemDrop, StoreInfo<int, int, int>> item in _storeInventory) { ItemDataEntry value = default(ItemDataEntry); value.Invcount = item.Value.InvCount; value.ItemCount = item.Value.Stack; value.ItemCostInt = item.Value.Cost; dictionary.Add(((Object)item.Key).name, value); } global::Trader20.Trader20.TraderConfig.Value = dictionary; return _storeInventory.Remove(itemDrop); } private int FindIndex(ItemDrop itemDrop) { List<ItemDrop> list = _storeInventory.Keys.ToList(); return list.IndexOf(itemDrop); } public void UpdateGenDescription(ElementFormat element) { ((Component)SelectedItemDescription_TMP).gameObject.SetActive(true); ((Component)ItemDropIcon).gameObject.SetActive(true); ((TMP_Text)SelectedItemDescription_TMP).SetText(element.ItemObject.GetComponent<ItemDrop>().m_itemData.m_shared.m_description); ((Component)SelectedItemDescription_TMP).gameObject.AddComponent<Localize>(); ItemDropIcon.sprite = element.Icon; tempElement = element; } public void DisableGenDescription() { ((Component)SelectedItemDescription_TMP).gameObject.SetActive(false); ((Component)ItemDropIcon).gameObject.SetActive(false); tempElement = null; } public void UpdateCoins() { ((TMP_Text)SelectedCost_TMP).SetText(GetPlayerCoins().ToString()); } public void BuyButtonAction() { try { if (!((Object)(object)tempElement?.ItemObject == (Object)null)) { int i = FindIndex(tempElement.ItemObject.GetComponent<ItemDrop>()); if (CanBuy(i)) { SellItem(i); NewTrader.instance.OnSold(); UpdateCoins(); } } } catch (Exception ex) { global::Trader20.Trader20.knarrlogger.LogDebug((object)ex); } } private bool CanBuy(int i) { int playerCoins = GetPlayerCoins(); int cost = _storeInventory.ElementAt(i).Value.Cost; if (playerCoins < cost) { return false; } ((Humanoid)Player.m_localPlayer).GetInventory().RemoveItem(ObjectDB.instance.GetItemPrefab(global::Trader20.Trader20.CurrencyPrefabName?.Value).GetComponent<ItemDrop>().m_itemData.m_shared.m_name, cost, -1, true); return true; } public void Hide() { m_StorePanel.SetActive(false); } public void Show() { if (_storeInventory.Count <= 0) { global::Trader20.Trader20.knarrlogger.LogWarning((object)"Store is empty not showing UI"); return; } m_StorePanel.SetActive(true); ClearStore(); if (_knarSellElements.Count >= 1) { UpdateGenDescription(_knarSellElements[0]); int? inventoryCount = _knarSellElements[0].InventoryCount; if (inventoryCount.HasValue) { int valueOrDefault = inventoryCount.GetValueOrDefault(); if (valueOrDefault >= 1) { ((TMP_Text)InventoryCount_TMP).SetText(_storeInventory.ElementAt(0).Value.InvCount.ToString()); } else { InvCountPanel.SetActive(false); } } } UpdateCoins(); } public void SetBuyBool() { if (SellPageActive) { SellPageActive = false; } BuyPageActive = true; } public void SetSellBool() { if (BuyPageActive) { BuyPageActive = false; } SellPageActive = true; } public void SelectKnarrFirstItemForDisplay() { if (_knarSellElements.Count > 0) { UpdateGenDescription(_knarSellElements[0]); } } public void SelectPlayerFirstItemForDisplay() { if (_playerSellElements.Count <= 0) { return; } int count = _playerSellElements.Count; if (count < 1) { if (count == 0) { DisableGenDescription(); } } else { UpdateGenDescription(_playerSellElements[0]); } } private static GameObject CurrentCurrency() { return ZNetScene.instance.GetPrefab(global::Trader20.Trader20.CurrencyPrefabName.Value); } private static int GetPlayerCoins() { return ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(CurrentCurrency().GetComponent<ItemDrop>().m_itemData.m_shared.m_name, -1, true); } public void DumpDict() { _storeInventory.Clear(); } internal int RollTheDice() { int num = 0; int num2 = 0; for (int i = 0; i <= 20; i++) { num = Random.Range(0, 6); } return num + 1; } public async void FillPlayerItemListVoid() { await FillPlayerSaleList().ConfigureAwait(continueOnCapturedContext: true); } private Task FillPlayerSaleList() { SetupPlayerItemListTask(); return Task.CompletedTask; } private void SetupPlayerItemListTask() { Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); List<ItemData> allItems = inventory.GetAllItems(); m_tempItems = allItems; if (_playerSellElements.Count() > 0) { foreach (ElementFormat playerSellElement in _playerSellElements) { ReturnPooledElement(playerSellElement); } _playerSellElements.Clear(); } foreach (ItemData tempItem in m_tempItems) { if (YMLContainsKey(((Object)tempItem.m_dropPrefab).name) && ReturnYMLPlayerPurchaseValue(((Object)tempItem.m_dropPrefab).name) != 0) { AddItemToDisplayList(tempItem.m_dropPrefab, tempItem.m_stack, ReturnYMLPlayerPurchaseValue(((Object)tempItem.m_dropPrefab).name), tempItem.m_stack, SellListRoot, isPlayerItem: true); } } } public void OnBuyItem() { Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); ElementFormat elementFormat = tempElement; ItemData item = inventory.GetItem((elementFormat == null) ? null : elementFormat.ItemObject.GetComponent<ItemDrop>()?.m_itemData?.m_shared.m_name, -1, false); if (item == null) { return; } if (item.m_stack > 1) { ShowSplitDialog(item); } else { int num = ReturnYMLPlayerPurchaseValue(((Object)item.m_dropPrefab).name) * item.m_stack; if (((Humanoid)Player.m_localPlayer).GetInventory().RemoveItem(item)) { ((Humanoid)Player.m_localPlayer).GetInventory().AddItem(((Object)CurrentCurrency()).name, num, CurrentCurrency().GetComponent<ItemDrop>().m_itemData.m_quality, CurrentCurrency().GetComponent<ItemDrop>().m_itemData.m_variant, 0L, "", false); string text = ""; text = ((item.m_stack <= 1) ? item.m_shared.m_name : (item.m_stack + "x" + item.m_shared.m_name)); ((Character)Player.m_localPlayer).Message((MessageType)1, Localization.instance.Localize("$msg_sold", new string[2] { text, num.ToString() }), num, item.m_shared.m_icons[0]); Gogan.LogEvent("Game", "SoldItem", text, 0L); UpdateYmlFileFromSaleOrBuy(item, item.m_stack, isPlayerItem: true); } int num2 = FindIndex(item.m_dropPrefab.GetComponent<ItemDrop>()); if (!global::Trader20.Trader20.LOGStoreSales.Value) { return; } string text2 = Player.m_localPlayer.GetPlayerID().ToString(); string text3 = Player.m_localPlayer.GetPlayerName() ?? throw new ArgumentNullException("i"); EnvMan val = EnvMan.instance; DateTime dateTime = DateTime.Now; string text4 = ""; switch (Utilities.GetConnectionState()) { case Utilities.ConnectionState.Server: if (Object.op_Implicit((Object)(object)val)) { float smoothDayFraction2 = val.m_smoothDayFraction; int num5 = (int)(smoothDayFraction2 * 24f); int num6 = (int)((smoothDayFraction2 * 24f - (float)num5) * 60f); int second2 = (int)(((smoothDayFraction2 * 24f - (float)num5) * 60f - (float)num6) * 60f); DateTime now2 = DateTime.Now; dateTime = new DateTime(now2.Year, now2.Month, now2.Day, num5, num6, second2); int currentDay2 = EnvMan.instance.GetCurrentDay(); } text4 = "[" + dateTime.ToString() + "] " + text2 + " - " + text3 + " Sold: " + Localization.instance.Localize(item.m_shared.m_name) + " For: " + num; Gogan.LogEvent("Game", "Knarr Bought Item", text4, 0L); ZLog.Log((object)("Knarr Bought Item " + text4)); LogSales(text4).ConfigureAwait(continueOnCapturedContext: false); break; case Utilities.ConnectionState.Client: ZRoutedRpc.instance.InvokeRoutedRPC("SendLogItemToServer", new object[2] { ((Object)item.m_dropPrefab).name, num }); break; case Utilities.ConnectionState.Local: if (Object.op_Implicit((Object)(object)val)) { float smoothDayFraction = val.m_smoothDayFraction; int num3 = (int)(smoothDayFraction * 24f); int num4 = (int)((smoothDayFraction * 24f - (float)num3) * 60f); int second = (int)(((smoothDayFraction * 24f - (float)num3) * 60f - (float)num4) * 60f); DateTime now = DateTime.Now; dateTime = new DateTime(now.Year, now.Month, now.Day, num3, num4, second); int currentDay = EnvMan.instance.GetCurrentDay(); text4 = "[" + dateTime.ToString() + "] " + text2 + " - " + text3 + " Purchased: " + Localization.instance.Localize(item.m_shared.m_name) + " For: " + num; Gogan.LogEvent("Game", "Knarr Bought Item", text4, 0L); ZLog.Log((object)("Knarr Bought Item " + text4)); LogSales(text4).ConfigureAwait(continueOnCapturedContext: false); } break; } ClearStore(); int count = _playerSellElements.Count; if (count > 0) { UpdateGenDescription(_playerSellElements[0]); } else { DisableGenDescription(); } } UpdateCoins(); } private int ReturnYMLPlayerPurchaseValue(string s) { Dictionary<string, ItemDataEntry> dictionary = new Dictionary<string, ItemDataEntry>(); switch (Utilities.GetConnectionState()) { case Utilities.ConnectionState.Server: { string configPath2 = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; StreamReader streamReader = File.OpenText(configPath2 + directorySeparatorChar + "trader_config.yaml"); dictionary = YMLParser.ReadSerializedData(streamReader.ReadToEnd()); streamReader.Close(); return dictionary[s].PurchaseFromPlayerCost; } case Utilities.ConnectionState.Client: return global::Trader20.Trader20.TraderConfig.Value[s].PurchaseFromPlayerCost; case Utilities.ConnectionState.Local: { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; StreamReader streamReader = File.OpenText(configPath + directorySeparatorChar + "trader_config.yaml"); dictionary = YMLParser.ReadSerializedData(streamReader.ReadToEnd()); streamReader.Close(); return dictionary[s].PurchaseFromPlayerCost; } default: return 0; } } private bool YMLContainsKey(string s) { Dictionary<string, ItemDataEntry> dictionary = new Dictionary<string, ItemDataEntry>(); switch (Utilities.GetConnectionState()) { case Utilities.ConnectionState.Server: { string configPath2 = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; StreamReader streamReader = File.OpenText(configPath2 + directorySeparatorChar + "trader_config.yaml"); dictionary = YMLParser.ReadSerializedData(streamReader.ReadToEnd()); streamReader.Close(); return dictionary.ContainsKey(s); } case Utilities.ConnectionState.Client: if (global::Trader20.Trader20.TraderConfig.Value.ContainsKey(s)) { return true; } break; case Utilities.ConnectionState.Local: { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; StreamReader streamReader = File.OpenText(configPath + directorySeparatorChar + "trader_config.yaml"); dictionary = YMLParser.ReadSerializedData(streamReader.ReadToEnd()); streamReader.Close(); return dictionary.ContainsKey(s); } } return false; } private void SetActiveSelection() { int num = 0; foreach (ElementFormat knarSellElement in _knarSellElements) { num++; if (num == currentIdx) { ((Component)knarSellElement.Element.gameObject.transform.Find("selected")).gameObject.SetActive(true); } ((Component)knarSellElement.Element.gameObject.transform.Find("selected")).gameObject.SetActive(false); } num = 0; } private void UpdateRecipeGamepadInput() { if (BuyPageActive) { if (ZInput.GetButtonDown("JoyLStickDown")) { currentIdx++; if (currentIdx >= _knarSellElements.Count) { currentIdx = _knarSellElements.Count - 1; } if (_knarSellElements.Count >= 1) { UpdateGenDescription(_knarSellElements[currentIdx]); SetActiveSelection(); } } if (ZInput.GetButtonDown("JoyLStickUp")) { currentIdx--; if (currentIdx <= 0) { currentIdx = 0; } if (_knarSellElements.Count >= 1) { UpdateGenDescription(_knarSellElements[currentIdx]); SetActiveSelection(); } } if (ZInput.GetButtonDown("JoyTabRight")) { SetSellBool(); SelectPlayerFirstItemForDisplay(); } } else { if (!SellPageActive) { return; } if (ZInput.GetButtonDown("JoyLStickDown")) { currentIdx++; if (currentIdx >= _playerSellElements.Count) { currentIdx = _playerSellElements.Count - 1; } if (_playerSellElements.Count >= 1) { UpdateGenDescription(_playerSellElements[currentIdx]); SetActiveSelection(); } } if (ZInput.GetButtonDown("JoyLStickUp")) { currentIdx--; if (currentIdx <= 0) { currentIdx = 0; } if (_playerSellElements.Count >= 1) { UpdateGenDescription(_playerSellElements[currentIdx]); SetActiveSelection(); } } if (ZInput.GetButtonDown("JoyTabLeft")) { SetBuyBool(); SelectKnarrFirstItemForDisplay(); } } } [UsedImplicitly] internal void BuildKnarrSplitDialog() { //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Expected O, but got Unknown if (API.IsLoaded()) { splitDiagGO = Object.Instantiate<GameObject>(((Component)gui.m_splitPanel).gameObject, ((Component)this).transform, false); m_splitPanel = splitDiagGO.transform; m_splitIcon = ((Component)splitDiagGO.transform.Find("Dialog/InventoryElement/icon")).gameObject.GetComponent<Image>(); m_splitSlider = splitDiagGO.GetComponentInChildren<Slider>(); m_splitCancelButton = ((Component)splitDiagGO.transform.Find("Dialog/ButtonCancel")).gameObject.GetComponent<Button>(); m_splitOkButton = ((Component)splitDiagGO.transform.Find("Dialog/ButtonOk")).gameObject.GetComponent<Button>(); m_splitIconName = ((Component)splitDiagGO.transform.Find("Dialog/InventoryElement/DummyText")).gameObject.GetComponent<Text>(); m_splitAmount = ((Component)splitDiagGO.transform.Find("Dialog/InventoryElement/amount")).gameObject.GetComponent<Text>(); ((Component)splitDiagGO.transform.Find("Dialog/Background")).gameObject.GetComponent<Image>().sprite = Resources.FindObjectsOfTypeAll<Sprite>().ToList().Find([<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(0)] (Sprite x) => ((Object)x).name == "Background"); ((UnityEvent)m_splitCancelButton.onClick).AddListener((UnityAction)delegate { OnSplitCancel(); }); ((UnityEvent)m_splitOkButton.onClick).AddListener((UnityAction)delegate { OnSplitOK(); }); ((UnityEvent<float>)(object)m_splitSlider.onValueChanged).AddListener((UnityAction<float>)delegate(float val) { OnSplitSliderChanged(val); }); } else { splitDiagGO = Object.Instantiate<GameObject>(((Component)gui.m_splitPanel).gameObject, ((Component)this).transform, false); m_splitPanel = splitDiagGO.transform; m_splitIcon = ((Component)splitDiagGO.transform.Find("win_bkg/Icon_bkg/Icon")).gameObject.GetComponent<Image>(); m_splitSlider = splitDiagGO.GetComponentInChildren<Slider>(); m_splitCancelButton = ((Component)splitDiagGO.transform.Find("win_bkg/Button_cancel")).gameObject.GetComponent<Button>(); m_splitOkButton = ((Component)splitDiagGO.transform.Find("win_bkg/Button_ok")).gameObject.GetComponent<Button>(); m_splitIconName = ((Component)splitDiagGO.transform.Find("win_bkg/Icon_bkg/res_name")).gameObject.GetComponent<Text>(); m_splitAmount = ((Component)splitDiagGO.transform.Find("win_bkg/amount")).gameObject.GetComponent<Text>(); ((UnityEvent)m_splitCancelButton.onClick).AddListener((UnityAction)delegate { OnSplitCancel(); }); ((UnityEvent)m_splitOkButton.onClick).AddListener((UnityAction)delegate { OnSplitOK(); }); ((UnityEvent<float>)(object)m_splitSlider.onValueChanged).AddListener((UnityAction<float>)delegate(float val) { OnSplitSliderChanged(val); }); } } private void OnSplitCancel() { m_splitItem = null; iscurrentlysplitting = false; ((Component)m_splitPanel).gameObject.SetActive(false); } private void OnSplitSliderChanged(float value) { Text splitAmount = m_splitAmount; string text = ((int)value).ToString(); string text2 = ((int)m_splitSlider.maxValue).ToString(); string text3 = text + "/" + text2; splitAmount.text = text3; } private void ShowSplitDialog(ItemData item) { int num = (Input.GetKey((KeyCode)306) ? 1 : (Input.GetKey((KeyCode)305) ? 1 : 0)); m_splitSlider.minValue = 1f; m_splitSlider.maxValue = item.m_stack; if (num == 0) { m_splitSlider.value = Mathf.CeilToInt((float)item.m_stack / 2f); } else if ((double)m_splitSlider.value / (double)item.m_stack > 0.5) { m_splitSlider.value = Mathf.Min(m_splitSlider.value, (float)item.m_stack); } m_splitIcon.sprite = item.GetIcon(); m_splitIconName.text = Localization.instance.Localize(item.m_shared.m_name); ((Component)m_splitPanel).gameObject.SetActive(true); m_splitItem = item; iscurrentlysplitting = true; OnSplitSliderChanged(m_splitSlider.value); } private void UpdateSplitDialog() { if (!((Component)m_splitSlider).gameObject.activeInHierarchy) { return; } for (int i = 0; i < 10; i++) { if (Input.GetKeyDown((KeyCode)(256 + i)) || Input.GetKeyDown((KeyCode)(48 + i))) { if (m_lastSplitInput + TimeSpan.FromSeconds(m_splitNumInputTimeoutSec) < DateTime.Now) { m_splitInput = ""; } m_lastSplitInput = DateTime.Now; m_splitInput += i; if (int.TryParse(m_splitInput, out var result)) { m_splitSlider.value = Mathf.Clamp((float)result, 1f, m_splitSlider.maxValue); OnSplitSliderChanged(m_splitSlider.value); } } } if (Input.GetKeyDown((KeyCode)276) && (double)m_splitSlider.value > 1.0) { Slider splitSlider = m_splitSlider; float value = splitSlider.value - 1f; splitSlider.value = value; OnSplitSliderChanged(m_splitSlider.value); } if (Input.GetKeyDown((KeyCode)275) && (double)m_splitSlider.value < (double)m_splitSlider.maxValue) { Slider splitSlider2 = m_splitSlider; float value = splitSlider2.value + 1f; splitSlider2.value = value; OnSplitSliderChanged(m_splitSlider.value); } if (Input.GetKeyDown((KeyCode)271) || Input.GetKeyDown((KeyCode)13)) { OnSplitOK(); } } private void OnSplitOK() { int num = (int)((float)ReturnYMLPlayerPurchaseValue(((Object)m_splitItem.m_dropPrefab).name) * m_splitSlider.value); ((Humanoid)Player.m_localPlayer).GetInventory().RemoveItem(m_splitItem, (int)m_splitSlider.value); ((Humanoid)Player.m_localPlayer).GetInventory().AddItem(((Object)CurrentCurrency()).name, num, CurrentCurrency().GetComponent<ItemDrop>().m_itemData.m_quality, CurrentCurrency().GetComponent<ItemDrop>().m_itemData.m_variant, 0L, "", false); string text = ""; text = ((m_splitItem.m_stack <= 1) ? m_splitItem.m_shared.m_name : (m_splitItem.m_stack + "x" + m_splitItem.m_shared.m_name)); ((Character)Player.m_localPlayer).Message((MessageType)1, Localization.instance.Localize("$msg_sold", new string[2] { text, m_splitSlider.value.ToString() }), (int)m_splitSlider.value, m_splitItem.m_shared.m_icons[0]); Gogan.LogEvent("Game", "SoldItem", text, 0L); UpdateYmlFileFromSaleOrBuy(m_splitItem, (int)m_splitSlider.value, isPlayerItem: true); ClearStore(); int count = _playerSellElements.Count; if (count > 0) { UpdateGenDescription(_playerSellElements[0]); } else { DisableGenDescription(); } ((Component)m_splitPanel).gameObject.SetActive(false); iscurrentlysplitting = false; UpdateCoins(); } } [Serializable] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] public class StoreInfo<[<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] ItemCost, [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] ItemStack, [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] ItemInventoryCount> { public ItemCost Cost { get; set; } public ItemStack Stack { get; set; } public ItemInventoryCount InvCount { get; set; } public StoreInfo(ItemCost cost, ItemStack stack, ItemInventoryCount count) { Cost = cost; Stack = stack; InvCount = count; } } namespace Trader20 { [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] public class YMLParser { public static string Serializers(Dictionary<string, ItemDataEntry> data) { ISerializer serializer = new SerializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build(); return serializer.Serialize(data); } public static Dictionary<string, ItemDataEntry> ReadSerializedData(string s) { IDeserializer deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build(); return deserializer.Deserialize<Dictionary<string, ItemDataEntry>>(s); } internal static bool CheckForEntry(Dictionary<string, ItemDataEntry> dataEntries, string keyName) { return dataEntries.ContainsKey(keyName); } internal static void AppendYmLfile(string s) { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; string path = configPath + directorySeparatorChar + "trader_config.yaml"; using StreamWriter streamWriter = File.AppendText(path); streamWriter.WriteLine(s); } } public struct ItemDataEntry { [YamlMember(Alias = "cost", ApplyNamingConventions = false)] public int ItemCostInt { get; set; } [YamlMember(Alias = "stack", ApplyNamingConventions = false)] public int ItemCount { get; set; } [YamlMember(Alias = "inventory count", ApplyNamingConventions = false)] public int Invcount { get; set; } [YamlMember(Alias = "purchase price", ApplyNamingConventions = false)] public int PurchaseFromPlayerCost { get; set; } } [BepInDependency(/*Could not decode attribute arguments.*/)] [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(2)] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] [BepInPlugin("com.zarboz.KnarrTheTrader", "KnarrTheTrader", "0.5.2")] public class Trader20 : BaseUnityPlugin { [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(1)] private const string ModName = "KnarrTheTrader"; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(1)] public const string ModVersion = "0.5.2"; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(1)] private const string ModGUID = "com.zarboz.KnarrTheTrader"; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(1)] internal static ConfigSync configSync = new ConfigSync("com.zarboz.KnarrTheTrader") { DisplayName = "KnarrTheTrader", CurrentVersion = "0.5.2", MinimumRequiredVersion = "0.5.2", ModRequired = true }; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(1)] public static readonly CustomSyncedValue<Dictionary<string, ItemDataEntry>> TraderConfig = new CustomSyncedValue<Dictionary<string, ItemDataEntry>>(configSync, "trader config", new Dictionary<string, ItemDataEntry>()); internal static GameObject Knarr; internal static GameObject CustomTraderScreen; internal static Sprite Coins; internal static ConfigEntry<bool> _serverConfigLocked; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(new byte[] { 2, 1 })] internal static ConfigEntry<string> CurrencyPrefabName; internal static ConfigEntry<Vector3> StoreScreenPos; internal static ConfigEntry<bool> RandomlySpawnKnarr; internal static ConfigEntry<bool> LOGStoreSales; internal static ConfigEntry<bool> OnlySellKnownItems; internal static ConfigEntry<int> LuckyNumber; internal static ConfigEntry<bool> ShowMatsWhenHidingRecipes; internal static ConfigEntry<bool> ConfigWriteSalesBuysToYml; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(new byte[] { 2, 1 })] internal static ConfigEntry<string> BuyPageLocalization; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(new byte[] { 2, 1 })] internal static ConfigEntry<string> SellPageLocalization; internal static ConfigEntry<bool> ConfigShowTabs; internal static ConfigEntry<bool> ConfigShowRepair; internal static ConfigEntry<bool> KnarrPlaySound; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(1)] internal static ManualLogSource knarrlogger = new ManualLogSource("KnarrTheTrader"); [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(1)] [field: <a546a844-44b5-4146-be53-ef59919185cc>Nullable(1)] private static Dictionary<string, ItemDataEntry> entry_ { [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] get; [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] set; } = null; internal static AssetBundle AssetBundle { get; private set; } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] private ConfigEntry<T> config<[<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] T>(string group, string configName, T value, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, configName, value, description); SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val; } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] private ConfigEntry<T> config<[<a546a844-44b5-4146-be53-ef59919185cc>Nullable(2)] T>(string group, string configName, T value, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, configName, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } public void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown knarrlogger = ((BaseUnityPlugin)this).Logger; Assembly executingAssembly = Assembly.GetExecutingAssembly(); Harmony val = new Harmony("com.zarboz.KnarrTheTrader"); val.PatchAll(executingAssembly); AssetBundle = Utilities.LoadAssetBundle("traderbundle"); _serverConfigLocked = config("General", "Lock Configuration", value: false, "Lock Configuration"); configSync.AddLockingConfigEntry<bool>(_serverConfigLocked); string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; if (!File.Exists(configPath + directorySeparatorChar + "trader_config.yaml")) { string configPath2 = Paths.ConfigPath; directorySeparatorChar = Path.DirectorySeparatorChar; File.Create(configPath2 + directorySeparatorChar + "trader_config.yaml").Close(); } ReadYamlConfigFile(null, null); TraderConfig.ValueChanged += OnValChangUpdateStore; CurrencyPrefabName = config("General", "Config Prefab Name", "Coins", "This is the prefab name for the currency that Knarr uses in his trades"); StoreScreenPos = config<Vector3>("General", "Position Of Trader Prefab On Screen", Vector3.zero, "This is the location on screen of the traders for sale screen", synchronizedSetting: false); RandomlySpawnKnarr = config("General", "Should Knarr randomly spawn around your BRAND NEW world?", value: false, "Whether or not knarr should spawn using locationsystem on fresh worlds"); LOGStoreSales = config("General", "Log what/when/to whom knarr sells things", value: false, "This is to log when a player buys an item from Knarr and in what volume"); OnlySellKnownItems = config("General", "Only sell known recipes and materials", value: false, "If set true Knarr will only vend a player recipes and materials the player has discovered already"); ShowMatsWhenHidingRecipes = config("General", "Sell ALL Materials when hiding unknown recipes", value: false, "If set true Knarr will still vend ALL materials"); ConfigWriteSalesBuysToYml = config("General", "Change the YML file on sells/buys", value: true, "If set true Knarr will edit the values in the YML file when a player buys or sells items to him"); LuckyNumber = config("General", "Lucky Number for repairs", 6, new ConfigDescription("This is the lucky number for your repair button if you roll this number your repairs will go through", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 6), Array.Empty<object>())); BuyPageLocalization = config("Localization", "Buy Page Tab", "Buy", "The Translation for the Buy Page Tab"); SellPageLocalization = config("Localization", "Sell Page Tab", "Sell", "The Translation for the Sell Page Tab"); ConfigShowTabs = config("General", "Show the Buy/Sell tabs", value: true, "This is the setting to enable/disable the selling interface"); ConfigShowRepair = config("General", "Show the Repair Icon", value: true, "This is the setting to enable/disable showing of the repair icon"); KnarrPlaySound = config("General", "Should Knarr play his audio?", value: true, "This is the setting to enable/disable the audio playback when walking up to knarr"); SetupWatcher(); if (LOGStoreSales.Value) { string configPath3 = Paths.ConfigPath; directorySeparatorChar = Path.DirectorySeparatorChar; if (!File.Exists(configPath3 + directorySeparatorChar + "TraderSales.log")) { string configPath4 = Paths.ConfigPath; directorySeparatorChar = Path.DirectorySeparatorChar; File.Create(configPath4 + directorySeparatorChar + "TraderSales.log"); } } Game.isModded = true; } private static void OnValChangUpdateStore() { if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || ObjectDB.instance.m_items.Count <= 0 || (Object)(object)ObjectDB.instance.GetItemPrefab("Wood") == (Object)null) { return; } OdinStore.instance.DumpDict(); foreach (KeyValuePair<string, ItemDataEntry> item in TraderConfig.Value) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(item.Key); ItemDrop val = null; if (Object.op_Implicit((Object)(object)itemPrefab)) { val = itemPrefab.GetComponent<ItemDrop>(); if ((Object)(object)val == (Object)null) { knarrlogger.LogError((object)("Failed to load ItemDrop for trader's item: " + item.Key)); continue; } OdinStore.instance.AddItemToDict(val, item.Value.ItemCostInt, item.Value.ItemCount, item.Value.Invcount); } if (!Object.op_Implicit((Object)(object)itemPrefab)) { knarrlogger.LogError((object)("Failed to load trader's item: " + item.Key)); knarrlogger.LogError((object)("Please Check your Prefab name " + item.Key)); } } if ((Object)(object)OdinStore.instance != (Object)null) { OdinStore.instance.ClearStore(); } } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, "trader_config.yaml"); fileSystemWatcher.Changed += ReadYamlConfigFile; fileSystemWatcher.Created += ReadYamlConfigFile; fileSystemWatcher.Renamed += ReadYamlConfigFile; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] private void ReadYamlConfigFile(object sender, FileSystemEventArgs e) { try { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; StreamReader streamReader = File.OpenText(configPath + directorySeparatorChar + "trader_config.yaml"); entry_ = YMLParser.ReadSerializedData(streamReader.ReadToEnd()); streamReader.Close(); TraderConfig.AssignLocalValue(entry_); } catch { knarrlogger.LogError((object)"There was an issue loading your trader_config.yaml"); knarrlogger.LogError((object)"Please check your config entries for spelling and format!"); } } internal void SaveConfig() { ((BaseUnityPlugin)this).Config.Save(); } } public class Patches { [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class ZNetPatch { [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] [UsedImplicitly] public static void Prefix(ZNetScene __instance) { if (__instance.m_prefabs.Count > 0) { Utilities.LoadAssets(Trader20.AssetBundle, __instance); Trader20.Knarr = __instance.GetPrefab("Knarr"); } } } [HarmonyPatch(typeof(Game), "Start")] public static class RegisterRPCPatch { [UsedImplicitly] [HarmonyPostfix] public static void Postfix() { ZRoutedRpc.instance.Register<bool>("RemoveKnarrDone", (Action<long, bool>)RPC_RemoveKnarrResponse); ZRoutedRpc.instance.Register<bool>("RequestRemoveKnarr", (Action<long, bool>)RPC_RemoveKnarrReq); ZRoutedRpc.instance.Register<bool>("FindKnarrDone", (Action<long, bool>)RPC_FindKnarrResponse); ZRoutedRpc.instance.Register<Vector3>("SetKnarrMapPin", (Action<long, Vector3>)RPC_SetKnarrMapIcon); ZRoutedRpc.instance.Register<string, int, bool>("SendItemInfoToServer", (Action<long, string, int, bool>)RPC_ServerRecvItemInfo); ZRoutedRpc.instance.Register<string, int>("SendLogItemToServer", (Action<long, string, int>)RPC_SendSaleLogInfoToServer); ZRoutedRpc.instance.Register("DumpAllLoadedItemsReq", (Action<long>)RPC_DumpAllLoadedItemsToYamlReq); ZRoutedRpc.instance.Register<bool>("DumpAllLoadedItems", (Action<long, bool>)RPC_DumpAllLoadedItemsToYaml); } } [HarmonyPatch(typeof(FejdStartup), "SetupGui")] public static class TestPatch { [HarmonyPostfix] [UsedImplicitly] public static void Postfix() { Localization.instance.AddWord("BuyPage", Trader20.BuyPageLocalization?.Value); Localization.instance.AddWord("SellPage", Trader20.SellPageLocalization?.Value); } } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(1)] [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] [HarmonyPatch(typeof(StoreGui), "Awake")] [HarmonyAfter(new string[] { "randyknapp.mods.auga" })] public static class ItemListPatch { [Serializable] [CompilerGenerated] private sealed class <>c { [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] public static readonly <>c <>9 = new <>c(); [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] public static Predicate<Sprite> <>9__7_0; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] public static Func<ItemData, bool> <>9__7_2; [<a546a844-44b5-4146-be53-ef59919185cc>Nullable(0)] public static UnityAction <>9__7_1; [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(0)] internal bool <Postfix>b__7_0(Sprite x) { return ((Object)x).name == "RepairButtonOver"; } internal void <Postfix>b__7_1() { if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } ((Character)Player.m_localPlayer).Message((MessageType)1, "Rolling dice", 0, (Sprite)null); int num = OdinStore.instance.RollTheDice(); ((Character)Player.m_localPlayer).Message((MessageType)2, "Result is " + num, 0, (Sprite)null); if (num != Trader20.LuckyNumber.Value) { return; } ((Humanoid)Player.m_localPlayer).GetInventory().GetWornItems(m_wornItems); using IEnumerator<ItemData> enumerator = m_wornItems.Where([<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(0)] (ItemData itemData) => itemData.m_durability < itemData.GetMaxDurability()).GetEnumerator(); if (enumerator.MoveNext()) { ItemData current = enumerator.Current; current.m_durability = current.GetMaxDurability(); ((Character)Player.m_localPlayer).Message((MessageType)2, Localization.instance.Localize("$msg_repaired", new string[1] { current.m_shared.m_name }), 0, (Sprite)null); } } [<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(0)] internal bool <Postfix>b__7_2(ItemData itemData) { return itemData.m_durability < itemData.GetMaxDurability(); } } internal static bool AuguaSetupRan = false; internal static List<ItemData> m_wornItems = new List<ItemData>(); private static readonly Color Topleft = new Color(0.1254902f, 0.1019608f, 7f / 85f, 1f); private static readonly Color TopRight = new Color(0.282353f, 0.2352941f, 16f / 85f, 1f); private static readonly Color LowerLeft = new Color(0.1803922f, 0.1529412f, 0.1254902f, 1f); private static readonly Color LowerRight = new Color(0.3215686f, 0.2666667f, 0.2156863f, 1f); internal static UIGradient SetGradient(UIGradient gradient) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) gradient.GradientType = UIGradient.UIGradientType.Corner; gradient.CornerColorUpperLeft = Topleft; gradient.CornerColorLowerLeft = LowerLeft; gradient.CornerColorLowerRight = LowerRight; gradient.CornerColorUpperRight = TopRight; return gradient; } public static void Postfix(StoreGui __instance) { //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Unknown result type (might be due to invalid IL or missing references) //IL_0629: Unknown result type (might be due to invalid IL or missing references) //IL_062e: Unknown result type (might be due to invalid IL or missing references) //IL_0634: Expected O, but got Unknown GameObject prefab = ZNetScene.instance.GetPrefab("CustomTrader"); if (Object.op_Implicit((Object)(object)prefab)) { if (API.IsLoaded()) { if (AuguaSetupRan) { return; } Trader20.CustomTraderScreen = Object.Instantiate<GameObject>(prefab, ((Component)((Component)__instance).GetComponent<Localize>()).transform.parent, false); Trader20.Coins = ZNetScene.instance.GetPrefab(Trader20.CurrencyPrefabName.Value).GetComponent<ItemDrop>().m_itemData.GetIcon(); Trader20.Coins = ZNetScene.instance.GetPrefab(Trader20.CurrencyPrefabName.Value).GetComponent<ItemDrop>().m_itemData.GetIcon(); Transform transform = Trader20.CustomTraderScreen.transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); val.anchoredPosition = Vector2.op_Implicit(Trader20.StoreScreenPos.Value); GameObject gameObject = ((Component)((Component)__instance).transform.Find("Store/AugaPanelBase/Background")).gameObject; Image component = gameObject.GetComponent<Image>(); OdinStore.instance.Bkg2.sprite = component.sprite; ((Graphic)OdinStore.instance.Bkg2).material = ((Graphic)component).material; ((Component)OdinStore.instance.Bkg2).gameObject.AddComponent<UIGradient>(); Image component2 = ((Component)((Component)__instance).transform.Find("Store/AugaPanelBase/Darken")).GetComponent<Image>(); OdinStore.instance.Bkg1.sprite = component2.sprite; ((Graphic)OdinStore.instance.Bkg1).material = ((Graphic)component2).material; OdinStore.instance.Coins.sprite = Trader20.Coins; ((Component)OdinStore.instance.Coins).transform.localPosition = new Vector3(-174.054f, 308.3599f, 0f); ((TMP_Text)OdinStore.instance.SelectedCost_TMP).transform.localPosition = new Vector3(-57.6711f, 324.26f, 0f); OdinStore.instance.InvCountPanel.transform.localPosition = new Vector3(200f, -175f, 0f); OdinStore.instance.BuyButtonImage.sprite = ((Component)((Component)__instance).transform.Find("Store/BuyButton/Image")).GetComponent<Image>().sprite; OdinStore.instance.SellButtonImage.sprite = OdinStore.instance.BuyButtonImage.sprite; ((Graphic)OdinStore.instance.SellButtonImage).material = ((Graphic)component).material; SetGradient(((Component)OdinStore.instance.RepairRect).gameObject.AddComponent<UIGradient>()); SetGradient(((Component)OdinStore.instance.repairImage).gameObject.AddComponent<UIGradient>()); SetGradient(((Component)((Component)OdinStore.instance.TabRect).transform.Find("BuyTab/BuyTabButton")).gameObject.AddComponent<UIGradient>()); SetGradient(((Component)((Component)OdinStore.instance.TabRect).transform.Find("SellTab/SellTabButton/Selected")).gameObject.AddComponent<UIGradient>()); SetGradient(((Component)((Component)OdinStore.instance.TabRect).transform.Find("SellTab/SellTabButton/Selected")).gameObject.GetComponent<UIGradient>()); SetGradient(((Component)((Component)OdinStore.instance.TabRect).transform.Find("SellTab/SellTabButton")).gameObject.AddComponent<UIGradient>()); SetGradient(((Component)OdinStore.instance.Bkg2).gameObject.GetComponent<UIGradient>()); OdinStore.instance.repairHammerImage.sprite = Resources.FindObjectsOfTypeAll<Sprite>().ToList().Find([<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(0)] (Sprite x) => ((Object)x).name == "RepairButtonOver"); OdinStore.instance.gui = ((Component)((Component)((Component)__instance).transform.parent).transform.Find("Inventory_screen")).gameObject.GetComponent<InventoryGui>(); OdinStore.instance.BuildKnarrSplitDialog(); AuguaSetupRan = true; } else { Sprite icon = ZNetScene.instance.GetPrefab(Trader20.CurrencyPrefabName.Value).GetComponent<ItemDrop>().m_itemData.GetIcon(); if ((Object)(object)icon == (Object)null) { Debug.LogError((object)"I cant locate your coin prefab please check the mod loading it or the spelling "); return; } Trader20.Coins = icon; Trader20.CustomTraderScreen = Object.Instantiate<GameObject>(prefab, ((Component)((Component)__instance).GetComponentInParent<Localize>()).transform, false); Transform transform2 = Trader20.CustomTraderScreen.transform; RectTransform val2 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null); val2.anchoredPosition = __instance.m_listRoot.anchoredPosition; OdinStore.instance.Coins.sprite = Trader20.Coins; OdinStore.instance.BuyButtonImage.sprite = Object.Instantiate<Sprite>(((Component)((Component)__instance).transform.Find("Store/BuyButton")).GetComponent<Image>().sprite); OdinStore.instance.SellButtonImage.sprite = OdinStore.instance.BuyButtonImage.sprite; Image val3 = Object.Instantiate<Image>(((Component)((Component)__instance).transform.Find("Store/bkg")).GetComponent<Image>()); OdinStore.instance.Bkg1.sprite = val3.sprite; ((Graphic)OdinStore.instance.Bkg1).material = ((Graphic)val3).material; Image val4 = Object.Instantiate<Image>(((Component)((Component)__instance).transform.Find("Store/border (1)")).GetComponent<Image>()); OdinStore.instance.Bkg2.sprite = val4.sprite; ((Graphic)OdinStore.instance.Bkg2).material = ((Graphic)val4).material; GameObject val5 = Object.Instantiate<GameObject>(((Component)((Component)InventoryGui.instance).transform.Find("root/Crafting/RepairButton")).gameObject); Button component3 = val5.GetComponent<Button>(); Image component4 = ((Component)val5.transform.Find("Image")).gameObject.GetComponent<Image>(); Image component5 = ((Component)((Component)InventoryGui.instance).transform.Find("root/Crafting/RepairSimple")).gameObject.GetComponent<Image>(); ((Component)OdinStore.instance.RepairRect).gameObject.GetComponent<Image>().sprite = component5.sprite; ((Graphic)((Component)OdinStore.instance.RepairRect).gameObject.GetComponent<Image>()).material = ((Graphic)component5).material; OdinStore.instance.repairHammerImage.sprite = component4.sprite; ((Selectable)OdinStore.instance.repairButton).image.sprite = ((Selectable)component3).image.sprite; ButtonClickedEvent onClick = OdinStore.instance.repairButton.onClick; object obj = <>c.<>9__7_1; if (obj == null) { UnityAction val6 = delegate { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { ((Character)Player.m_localPlayer).Message((MessageType)1, "Rolling dice", 0, (Sprite)null); int num = OdinStore.instance.RollTheDice(); ((Character)Player.m_localPlayer).Message((MessageType)2, "Result is " + num, 0, (Sprite)null); if (num == Trader20.LuckyNumber.Value) { ((Humanoid)Player.m_localPlayer).GetInventory().GetWornItems(m_wornItems); using IEnumerator<ItemData> enumerator3 = m_wornItems.Where([<6b3368ed-19e4-4b9e-87d4-a3d784686383>NullableContext(0)] (ItemData itemData) => itemData.m_durability < itemData.GetMaxDurability()).GetEnumerator(); if (enumerator3.MoveNext()) { ItemData current3 = enumerator3.Current; current3.m_durability = current3.GetMaxDurability(); ((Character)Player.m_localPlayer).Message((MessageType)2, Localization.instance.Localize("$msg_repaired", new string[1] { current3.m_shared.m_name }), 0, (Sprite)null); } } } }; <>c.<>9__7_1 = val6; obj = (object)val6; } ((UnityEvent)onClick).AddListener((UnityAction)obj); ((Selectable)OdinStore.instance.repairButton).transition = (Transition)2; ((Selectable)OdinStore.instance.repairButton).spriteState = ((Selectable)component3).spriteState; OdinStore.instance.gui = ((Component