using System;
using System.Runtime.CompilerServices;
using Cpp2IlInjected;
using DG.Tweening;
using MarsSDK;
using UnityEngine;
using UnityEngine.UI;

// Token: 0x02000289 RID: 649
[Token(Token = "0x2000289")]
public class UITradeHandler : UIHandlerBase
{
	// Token: 0x1700010B RID: 267
	// (get) Token: 0x060018F1 RID: 6385 RVA: 0x0003C8D4 File Offset: 0x0003AAD4
	// (set) Token: 0x060018F2 RID: 6386 RVA: 0x0003C8E8 File Offset: 0x0003AAE8
	[Token(Token = "0x1700010B")]
	public string Description
	{
		[Token(Token = "0x60018F1")]
		[Address(RVA = "0x4593A0", Offset = "0x4581A0", VA = "0x1804593A0")]
		[CompilerGenerated]
		get
		{
			return this.<Description>k__BackingField;
		}
		[Token(Token = "0x60018F2")]
		[Address(RVA = "0x8E98E0", Offset = "0x8E86E0", VA = "0x1808E98E0")]
		[CompilerGenerated]
		private set
		{
			/*
An exception occurred when decompiling this method (060018F2)

ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void UITradeHandler::set_Description(System.String)

 ---> System.Exception: Basic block has to end with unconditional control flow. 
{; 	Block_0:; 	stfld:string(UITradeHandler::<Description>k__BackingField, ldloc:UITradeHandler(this), ldloc:string(value)); }; 
   at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1810
   at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, AutoPropertyProvider autoPropertyProvider, StateMachineKind& stateMachineKind, MethodDef& inlinedMethod, AsyncMethodDebugInfo& asyncInfo, ILAstOptimizationStep abortBeforeStep) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 344
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable`1 parameters, MethodDebugInfoBuilder& builder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 123
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 88
   --- End of inner exception stack trace ---
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 92
   at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethodBody(EntityDeclaration methodNode, EntityDeclaration& updatedNode, MethodDef method, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, MethodKind methodKind) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 1618
*/;
		}
	}

	// Token: 0x060018F3 RID: 6387 RVA: 0x0003C8FC File Offset: 0x0003AAFC
	[Token(Token = "0x60018F3")]
	[Address(RVA = "0x18B3F90", Offset = "0x18B2D90", VA = "0x1818B3F90")]
	public void Init()
	{
		this.InitTween();
	}

	// Token: 0x060018F4 RID: 6388 RVA: 0x0003C910 File Offset: 0x0003AB10
	[Token(Token = "0x60018F4")]
	[Address(RVA = "0x4F7390", Offset = "0x4F6190", VA = "0x1804F7390")]
	public void BindTradeFailedHandlerEvent(Action handler)
	{
		/*
An exception occurred when decompiling this method (060018F4)

ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void UITradeHandler::BindTradeFailedHandlerEvent(System.Action)

 ---> System.Exception: Basic block has to end with unconditional control flow. 
{; 	Block_0:; 	stfld:Action(UITradeHandler::tradeFailedHandler, ldloc:UITradeHandler(this), ldloc:Action(handler)); }; 
   at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1810
   at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, AutoPropertyProvider autoPropertyProvider, StateMachineKind& stateMachineKind, MethodDef& inlinedMethod, AsyncMethodDebugInfo& asyncInfo, ILAstOptimizationStep abortBeforeStep) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 344
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable`1 parameters, MethodDebugInfoBuilder& builder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 123
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 88
   --- End of inner exception stack trace ---
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 92
   at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethodBody(EntityDeclaration methodNode, EntityDeclaration& updatedNode, MethodDef method, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, MethodKind methodKind) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 1618
*/;
	}

	// Token: 0x060018F5 RID: 6389 RVA: 0x0003C924 File Offset: 0x0003AB24
	[Token(Token = "0x60018F5")]
	[Address(RVA = "0x18B4770", Offset = "0x18B3570", VA = "0x1818B4770")]
	public void StartTrade()
	{
		if (this.UpdateTradingData())
		{
			Game.PlayUpgradeSE();
			Tween tween = this.tweenBarIcon;
			TweenCallback tweenCallback = delegate
			{
				Tween tween3 = this.tweenBar;
				if (tween3 != 0)
				{
					tween3.PlayForward();
					return;
				}
			};
			Tween tween2 = tween.OnComplete(tweenCallback);
			this.tweenBarIcon.PlayForward();
		}
	}

	// Token: 0x060018F6 RID: 6390 RVA: 0x0003C968 File Offset: 0x0003AB68
	[Token(Token = "0x60018F6")]
	[Address(RVA = "0x18B3CE0", Offset = "0x18B2AE0", VA = "0x1818B3CE0")]
	public void CancelTrade()
	{
		Game.FadeOutUpgradeSE();
		Tween tween = this.tweenBarIcon;
		if (tween != 0)
		{
			tween.PlayBackwards();
		}
		if (this.tweenBar.IsActive())
		{
			this.tweenBar.PlayBackwards();
			return;
		}
	}

	// Token: 0x060018F7 RID: 6391 RVA: 0x0003C9A8 File Offset: 0x0003ABA8
	[Token(Token = "0x60018F7")]
	[Address(RVA = "0x8B0A70", Offset = "0x8AF870", VA = "0x1808B0A70")]
	public void UpdateHoldingState(bool isHolding)
	{
		this.holdingTrade = isHolding;
	}

	// Token: 0x060018F8 RID: 6392 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x60018F8")]
	[Address(RVA = "0x18B49D0", Offset = "0x18B37D0", VA = "0x1818B49D0")]
	public void UpdateItemInfo(ItemSystem.ItemType type)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x060018F9 RID: 6393 RVA: 0x0003C9BC File Offset: 0x0003ABBC
	[Token(Token = "0x60018F9")]
	[Address(RVA = "0x18B4720", Offset = "0x18B3520", VA = "0x1818B4720")]
	public void SetFont(GameFontPack fontPack)
	{
		Text text = this.number;
		Font regular = fontPack.regular;
		text.font = regular;
		Text text2 = this.cost;
		Font regular2 = fontPack.regular;
		text2.font = regular2;
	}

	// Token: 0x060018FA RID: 6394 RVA: 0x0003C9FC File Offset: 0x0003ABFC
	[Token(Token = "0x60018FA")]
	[Address(RVA = "0x18B40C0", Offset = "0x18B2EC0", VA = "0x1818B40C0", Slot = "8")]
	public override void OnSelect()
	{
		Action<UIHandlerBase> onSelectedHandler = this.onSelectedHandler;
		if (onSelectedHandler != 0)
		{
			onSelectedHandler(this);
			return;
		}
	}

	// Token: 0x060018FB RID: 6395 RVA: 0x0003CA1C File Offset: 0x0003AC1C
	[Token(Token = "0x60018FB")]
	[Address(RVA = "0x18B4070", Offset = "0x18B2E70", VA = "0x1818B4070", Slot = "9")]
	public override void OnDeselect()
	{
		Action<UIHandlerBase> onDeselectedHandler = this.onDeselectedHandler;
		if (onDeselectedHandler != 0)
		{
			onDeselectedHandler(this);
			return;
		}
	}

	// Token: 0x060018FC RID: 6396 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x60018FC")]
	[Address(RVA = "0x18B3D70", Offset = "0x18B2B70", VA = "0x1818B3D70")]
	private void InitTween()
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x060018FD RID: 6397 RVA: 0x0003CA3C File Offset: 0x0003AC3C
	[Token(Token = "0x60018FD")]
	[Address(RVA = "0x18B4010", Offset = "0x18B2E10", VA = "0x1818B4010")]
	private void KeepTrade()
	{
		if (this.UpdateTradingData())
		{
			Tween tween = this.tweenBar;
			if (tween != 0)
			{
				Tween tween2 = tween.Play<Tween>();
				return;
			}
		}
	}

	// Token: 0x060018FE RID: 6398 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x60018FE")]
	[Address(RVA = "0x18B4EC0", Offset = "0x18B3CC0", VA = "0x1818B4EC0")]
	private bool UpdateTradingData()
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x060018FF RID: 6399 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x60018FF")]
	[Address(RVA = "0x18B42E0", Offset = "0x18B30E0", VA = "0x1818B42E0")]
	private void OnTradeUpdated(float need, float tweenValue)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001900 RID: 6400 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001900")]
	[Address(RVA = "0x18B4410", Offset = "0x18B3210", VA = "0x1818B4410")]
	private void ProcessTrade(Action<float, float> onUpdated, Action<bool> onCompleted)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001901 RID: 6401 RVA: 0x0003CA68 File Offset: 0x0003AC68
	[Token(Token = "0x6001901")]
	[Address(RVA = "0x18B4110", Offset = "0x18B2F10", VA = "0x1818B4110")]
	private void OnTradeCompleted(bool success)
	{
		while (success)
		{
			PlayerItem g_PlayerItem = Game.GetPlayerManager().g_PlayerItem;
			ItemSystem.ItemType itemType = this.itemType;
			bool flag = g_PlayerItem.BuyItem(itemType);
			PlayerStatsData stats = Game.GameSave.stats;
			float num = this.currentMoney;
			stats.currentMoney = num;
			int num2 = 0;
			int num3 = 0;
			this.UpdateHandlerInfo((float)num3, (float)num2);
			while (!this.holdingTrade)
			{
			}
			if (this.UpdateTradingData())
			{
				Tween tween = this.tweenBar;
				while (tween == 0)
				{
				}
				Tween tween2 = tween.Play<Tween>();
				return;
			}
		}
		Game.FadeOutUpgradeSE();
		Game.PlayHandlerSE(UIHandlerSFX.Error);
		Action action = this.tradeFailedHandler;
		if (action != 0)
		{
			action();
		}
		Tween tween3 = this.tweenBarIcon;
		if (tween3 != 0)
		{
			tween3.PlayBackwards();
		}
		float num4 = this.originalMoney;
		int num5 = 0;
		Tween tween4 = this.tweenBar;
		if (num4 <= (float)num5)
		{
			if (tween4 != 0)
			{
				int num6 = 0;
				tween4.Kill(num6 != 0);
			}
			return;
		}
		while (tween4 == 0)
		{
		}
		tween4.SetAutoKill(true).PlayBackwards();
	}

	// Token: 0x06001902 RID: 6402 RVA: 0x0003CB68 File Offset: 0x0003AD68
	[Token(Token = "0x6001902")]
	[Address(RVA = "0x18B3FA0", Offset = "0x18B2DA0", VA = "0x1818B3FA0")]
	private bool IsItemFull()
	{
		return !Game.GetPlayerManager().g_PlayerItem.IsVacancy();
	}

	// Token: 0x06001903 RID: 6403 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001903")]
	[Address(RVA = "0x18B4960", Offset = "0x18B3760", VA = "0x1818B4960")]
	private void UpdateInfo(string costStr, float barScale)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001904 RID: 6404 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001904")]
	[Address(RVA = "0x18B4890", Offset = "0x18B3690", VA = "0x1818B4890")]
	private void UpdateHandlerInfo(float needExp = 0f, float tweenExp = 0f)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001905 RID: 6405 RVA: 0x0003CB90 File Offset: 0x0003AD90
	[Token(Token = "0x6001905")]
	[Address(RVA = "0x18B4E20", Offset = "0x18B3C20", VA = "0x1818B4E20")]
	private void UpdateTradeHandlerGroupScale()
	{
		Tween tween = this.tweenBarIcon;
		TweenCallback tweenCallback = delegate
		{
			Tween tween3 = this.tweenBar;
			if (tween3 != 0)
			{
				tween3.PlayForward();
				return;
			}
		};
		Tween tween2 = tween.OnComplete(tweenCallback);
		this.tweenBarIcon.PlayForward();
	}

	// Token: 0x06001906 RID: 6406 RVA: 0x0003CBC4 File Offset: 0x0003ADC4
	[Token(Token = "0x6001906")]
	[Address(RVA = "0x18B4700", Offset = "0x18B3500", VA = "0x1818B4700")]
	private void ResetTradeHandlerGroupScale()
	{
		Tween tween = this.tweenBarIcon;
		if (tween != 0)
		{
			tween.PlayBackwards();
			return;
		}
	}

	// Token: 0x06001907 RID: 6407 RVA: 0x0003CBE4 File Offset: 0x0003ADE4
	[Token(Token = "0x6001907")]
	[Address(RVA = "0x3FBF80", Offset = "0x3FAD80", VA = "0x1803FBF80")]
	public UITradeHandler()
	{
	}

	// Token: 0x040022D2 RID: 8914
	[FieldOffset(Offset = "0x68")]
	[Token(Token = "0x40022D2")]
	[SerializeField]
	private Image icon;

	// Token: 0x040022D3 RID: 8915
	[FieldOffset(Offset = "0x70")]
	[Token(Token = "0x40022D3")]
	[SerializeField]
	private Text number;

	// Token: 0x040022D4 RID: 8916
	[FieldOffset(Offset = "0x78")]
	[Token(Token = "0x40022D4")]
	[SerializeField]
	private Text cost;

	// Token: 0x040022D5 RID: 8917
	[FieldOffset(Offset = "0x80")]
	[Token(Token = "0x40022D5")]
	[SerializeField]
	private RectTransform rtBar;

	// Token: 0x040022D6 RID: 8918
	[FieldOffset(Offset = "0x88")]
	[Token(Token = "0x40022D6")]
	[SerializeField]
	private RectTransform rtExpGroup;

	// Token: 0x040022D8 RID: 8920
	[FieldOffset(Offset = "0x98")]
	[Token(Token = "0x40022D8")]
	private UIItemSprite itemIconCache;

	// Token: 0x040022D9 RID: 8921
	[FieldOffset(Offset = "0xA0")]
	[Token(Token = "0x40022D9")]
	private Tween tweenBarIcon;

	// Token: 0x040022DA RID: 8922
	[FieldOffset(Offset = "0xA8")]
	[Token(Token = "0x40022DA")]
	private Tween tweenBar;

	// Token: 0x040022DB RID: 8923
	[FieldOffset(Offset = "0xB0")]
	[Token(Token = "0x40022DB")]
	private ItemSystem.ItemType itemType;

	// Token: 0x040022DC RID: 8924
	[FieldOffset(Offset = "0xB4")]
	[Token(Token = "0x40022DC")]
	private float itemPrice;

	// Token: 0x040022DD RID: 8925
	[FieldOffset(Offset = "0xB8")]
	[Token(Token = "0x40022DD")]
	private Action tradeFailedHandler;

	// Token: 0x040022DE RID: 8926
	[FieldOffset(Offset = "0xC0")]
	[Token(Token = "0x40022DE")]
	private bool holdingTrade;

	// Token: 0x040022DF RID: 8927
	[FieldOffset(Offset = "0xC4")]
	[Token(Token = "0x40022DF")]
	private float originalMoney;

	// Token: 0x040022E0 RID: 8928
	[FieldOffset(Offset = "0xC8")]
	[Token(Token = "0x40022E0")]
	private float currentMoney;
}
