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

// Token: 0x020002D4 RID: 724
[Token(Token = "0x20002D4")]
public class UITradeHandler : UIHandlerBase
{
	// Token: 0x1700011B RID: 283
	// (get) Token: 0x06001B1D RID: 6941 RVA: 0x00042278 File Offset: 0x00040478
	// (set) Token: 0x06001B1E RID: 6942 RVA: 0x0004228C File Offset: 0x0004048C
	[Token(Token = "0x1700011B")]
	public string Description
	{
		[Token(Token = "0x6001B1D")]
		[Address(RVA = "0x49DC30", Offset = "0x49CC30", VA = "0x18049DC30")]
		[CompilerGenerated]
		get
		{
			return this.<Description>k__BackingField;
		}
		[Token(Token = "0x6001B1E")]
		[Address(RVA = "0x67B3B0", Offset = "0x67A3B0", VA = "0x18067B3B0")]
		[CompilerGenerated]
		private set
		{
			/*
An exception occurred when decompiling this method (06001B1E)

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: 0x06001B1F RID: 6943 RVA: 0x000422A0 File Offset: 0x000404A0
	[Token(Token = "0x6001B1F")]
	[Address(RVA = "0xCB56B0", Offset = "0xCB46B0", VA = "0x180CB56B0")]
	public void Init()
	{
		this.InitTween();
	}

	// Token: 0x06001B20 RID: 6944 RVA: 0x000422B4 File Offset: 0x000404B4
	[Token(Token = "0x6001B20")]
	[Address(RVA = "0x5226F0", Offset = "0x5216F0", VA = "0x1805226F0")]
	public void BindTradeFailedHandlerEvent(Action handler)
	{
		/*
An exception occurred when decompiling this method (06001B20)

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: 0x06001B21 RID: 6945 RVA: 0x000422C8 File Offset: 0x000404C8
	[Token(Token = "0x6001B21")]
	[Address(RVA = "0xCB5F00", Offset = "0xCB4F00", VA = "0x180CB5F00")]
	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: 0x06001B22 RID: 6946 RVA: 0x0004230C File Offset: 0x0004050C
	[Token(Token = "0x6001B22")]
	[Address(RVA = "0xCB5230", Offset = "0xCB4230", VA = "0x180CB5230")]
	public void CancelTrade()
	{
		Game.FadeOutUpgradeSE();
		Tween tween = this.tweenBarIcon;
		if (tween != 0)
		{
			tween.PlayBackwards();
		}
		if (this.tweenBar.IsActive())
		{
			this.tweenBar.PlayBackwards();
			return;
		}
	}

	// Token: 0x06001B23 RID: 6947 RVA: 0x0004234C File Offset: 0x0004054C
	[Token(Token = "0x6001B23")]
	[Address(RVA = "0xCB60F0", Offset = "0xCB50F0", VA = "0x180CB60F0")]
	public void UpdateHoldingState(bool isHolding)
	{
		this.holdingTrade = isHolding;
	}

	// Token: 0x06001B24 RID: 6948 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B24")]
	[Address(RVA = "0xCB6170", Offset = "0xCB5170", VA = "0x180CB6170")]
	public void UpdateItemInfo(ItemSystem.ItemType type)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B25 RID: 6949 RVA: 0x00042360 File Offset: 0x00040560
	[Token(Token = "0x6001B25")]
	[Address(RVA = "0xCB52C0", Offset = "0xCB42C0", VA = "0x180CB52C0")]
	private string GetMagicLevelSuffix(int value, int maxLevel)
	{
		if (value > maxLevel)
		{
			string text = Game.<UISystemText>k__BackingField.GetText(322);
			return " " + text;
		}
		string text2 = Game.<UISystemText>k__BackingField.GetText(321);
		return string.Format(" {0}{1}", text2, text2);
	}

	// Token: 0x06001B26 RID: 6950 RVA: 0x000423B0 File Offset: 0x000405B0
	[Token(Token = "0x6001B26")]
	[Address(RVA = "0xCB5EB0", Offset = "0xCB4EB0", VA = "0x180CB5EB0")]
	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: 0x06001B27 RID: 6951 RVA: 0x000423F0 File Offset: 0x000405F0
	[Token(Token = "0x6001B27")]
	[Address(RVA = "0xCB5800", Offset = "0xCB4800", VA = "0x180CB5800", Slot = "8")]
	public override void OnSelect()
	{
		Action<UIHandlerBase> onSelectedHandler = this.onSelectedHandler;
		if (onSelectedHandler != 0)
		{
			onSelectedHandler(this);
			return;
		}
	}

	// Token: 0x06001B28 RID: 6952 RVA: 0x00042410 File Offset: 0x00040610
	[Token(Token = "0x6001B28")]
	[Address(RVA = "0xCB57B0", Offset = "0xCB47B0", VA = "0x180CB57B0", Slot = "9")]
	public override void OnDeselect()
	{
		Action<UIHandlerBase> onDeselectedHandler = this.onDeselectedHandler;
		if (onDeselectedHandler != 0)
		{
			onDeselectedHandler(this);
			return;
		}
	}

	// Token: 0x06001B29 RID: 6953 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B29")]
	[Address(RVA = "0xCB5490", Offset = "0xCB4490", VA = "0x180CB5490")]
	private void InitTween()
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B2A RID: 6954 RVA: 0x00042430 File Offset: 0x00040630
	[Token(Token = "0x6001B2A")]
	[Address(RVA = "0xCB5750", Offset = "0xCB4750", VA = "0x180CB5750")]
	private void KeepTrade()
	{
		if (this.UpdateTradingData())
		{
			Tween tween = this.tweenBar;
			if (tween != 0)
			{
				Tween tween2 = tween.Play<Tween>();
				return;
			}
		}
	}

	// Token: 0x06001B2B RID: 6955 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B2B")]
	[Address(RVA = "0xCB69B0", Offset = "0xCB59B0", VA = "0x180CB69B0")]
	private bool UpdateTradingData()
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B2C RID: 6956 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B2C")]
	[Address(RVA = "0xCB5A70", Offset = "0xCB4A70", VA = "0x180CB5A70")]
	private void OnTradeUpdated(float need, float tweenValue)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B2D RID: 6957 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B2D")]
	[Address(RVA = "0xCB5BA0", Offset = "0xCB4BA0", VA = "0x180CB5BA0")]
	private void ProcessTrade(Action<float, float> onUpdated, Action<bool> onCompleted)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B2E RID: 6958 RVA: 0x0004245C File Offset: 0x0004065C
	[Token(Token = "0x6001B2E")]
	[Address(RVA = "0xCB5850", Offset = "0xCB4850", VA = "0x180CB5850")]
	private void OnTradeCompleted(bool success)
	{
		if (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);
			Tween tween2;
			if (this.holdingTrade && this.UpdateTradingData())
			{
				Tween tween = this.tweenBar;
				if (tween != 0)
				{
					tween2 = tween.Play<Tween>();
				}
			}
			ItemSystem.ItemType itemType2 = this.itemType;
			if (tween2 > (ulong)4L)
			{
				while (itemType2 != ItemSystem.ItemType.MagicNull)
				{
				}
			}
			this.CancelTrade();
			ItemSystem.ItemType itemType3 = this.itemType;
			this.UpdateItemInfo(itemType3);
			Action<UIHandlerBase> onSelectedHandler = this.onSelectedHandler;
			while (onSelectedHandler == 0)
			{
			}
			onSelectedHandler(this);
			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: 0x06001B2F RID: 6959 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B2F")]
	[Address(RVA = "0xCB56C0", Offset = "0xCB46C0", VA = "0x180CB56C0")]
	private bool IsItemFull()
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B30 RID: 6960 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B30")]
	[Address(RVA = "0xCB6100", Offset = "0xCB5100", VA = "0x180CB6100")]
	private void UpdateInfo(string costStr, float barScale)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B31 RID: 6961 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B31")]
	[Address(RVA = "0xCB6020", Offset = "0xCB5020", VA = "0x180CB6020")]
	private void UpdateHandlerInfo(float needExp = 0f, float tweenExp = 0f)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B32 RID: 6962 RVA: 0x0004259C File Offset: 0x0004079C
	[Token(Token = "0x6001B32")]
	[Address(RVA = "0xCB6910", Offset = "0xCB5910", VA = "0x180CB6910")]
	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: 0x06001B33 RID: 6963 RVA: 0x000425D0 File Offset: 0x000407D0
	[Token(Token = "0x6001B33")]
	[Address(RVA = "0xCB5E90", Offset = "0xCB4E90", VA = "0x180CB5E90")]
	private void ResetTradeHandlerGroupScale()
	{
		Tween tween = this.tweenBarIcon;
		if (tween != 0)
		{
			tween.PlayBackwards();
			return;
		}
	}

	// Token: 0x06001B34 RID: 6964 RVA: 0x000425F0 File Offset: 0x000407F0
	[Token(Token = "0x6001B34")]
	[Address(RVA = "0x41ED30", Offset = "0x41DD30", VA = "0x18041ED30")]
	public UITradeHandler()
	{
	}

	// Token: 0x04002525 RID: 9509
	[FieldOffset(Offset = "0x68")]
	[Token(Token = "0x4002525")]
	[SerializeField]
	private Image icon;

	// Token: 0x04002526 RID: 9510
	[FieldOffset(Offset = "0x70")]
	[Token(Token = "0x4002526")]
	[SerializeField]
	private Text number;

	// Token: 0x04002527 RID: 9511
	[FieldOffset(Offset = "0x78")]
	[Token(Token = "0x4002527")]
	[SerializeField]
	private Text cost;

	// Token: 0x04002528 RID: 9512
	[FieldOffset(Offset = "0x80")]
	[Token(Token = "0x4002528")]
	[SerializeField]
	private RectTransform rtBar;

	// Token: 0x04002529 RID: 9513
	[FieldOffset(Offset = "0x88")]
	[Token(Token = "0x4002529")]
	[SerializeField]
	private RectTransform rtExpGroup;

	// Token: 0x0400252B RID: 9515
	[FieldOffset(Offset = "0x98")]
	[Token(Token = "0x400252B")]
	private UIItemSprite itemIconCache;

	// Token: 0x0400252C RID: 9516
	[FieldOffset(Offset = "0xA0")]
	[Token(Token = "0x400252C")]
	private Tween tweenBarIcon;

	// Token: 0x0400252D RID: 9517
	[FieldOffset(Offset = "0xA8")]
	[Token(Token = "0x400252D")]
	private Tween tweenBar;

	// Token: 0x0400252E RID: 9518
	[FieldOffset(Offset = "0xB0")]
	[Token(Token = "0x400252E")]
	private ItemSystem.ItemType itemType;

	// Token: 0x0400252F RID: 9519
	[FieldOffset(Offset = "0xB4")]
	[Token(Token = "0x400252F")]
	private float itemPrice;

	// Token: 0x04002530 RID: 9520
	[FieldOffset(Offset = "0xB8")]
	[Token(Token = "0x4002530")]
	private Action tradeFailedHandler;

	// Token: 0x04002531 RID: 9521
	[FieldOffset(Offset = "0xC0")]
	[Token(Token = "0x4002531")]
	private bool holdingTrade;

	// Token: 0x04002532 RID: 9522
	[FieldOffset(Offset = "0xC4")]
	[Token(Token = "0x4002532")]
	private float originalMoney;

	// Token: 0x04002533 RID: 9523
	[FieldOffset(Offset = "0xC8")]
	[Token(Token = "0x4002533")]
	private float currentMoney;
}
