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

// Token: 0x020002D7 RID: 727
[Token(Token = "0x20002D7")]
public class UIUpgradeHandler : UIHandlerBase
{
	// Token: 0x06001B3F RID: 6975 RVA: 0x000426C4 File Offset: 0x000408C4
	[Token(Token = "0x6001B3F")]
	[Address(RVA = "0xCB8A70", Offset = "0xCB7A70", VA = "0x180CB8A70")]
	public void Init(UpgradeDataHandler handler)
	{
		this.upgradeDataHandler = handler;
		this.InitTween();
	}

	// Token: 0x06001B40 RID: 6976 RVA: 0x000426E0 File Offset: 0x000408E0
	[Token(Token = "0x6001B40")]
	[Address(RVA = "0xCB8840", Offset = "0xCB7840", VA = "0x180CB8840")]
	public void InitDisplayInfo()
	{
		int num = 0;
		int num2 = 0;
		this.UpdateHandlerInfo((float)num2, (float)num);
	}

	// Token: 0x06001B41 RID: 6977 RVA: 0x000426FC File Offset: 0x000408FC
	[Token(Token = "0x6001B41")]
	[Address(RVA = "0x9D57D0", Offset = "0x9D47D0", VA = "0x1809D57D0")]
	public void BindUpgradeFailedHandlerEvent(Action handler)
	{
		/*
An exception occurred when decompiling this method (06001B41)

ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void UIUpgradeHandler::BindUpgradeFailedHandlerEvent(System.Action)

 ---> System.Exception: Basic block has to end with unconditional control flow. 
{; 	Block_0:; 	stfld:Action(UIUpgradeHandler::upgradeFailedHandler, ldloc:UIUpgradeHandler(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: 0x06001B42 RID: 6978 RVA: 0x00042710 File Offset: 0x00040910
	[Token(Token = "0x6001B42")]
	[Address(RVA = "0xCB92F0", Offset = "0xCB82F0", VA = "0x180CB92F0")]
	public void StartUpgrade()
	{
		if (this.UpdateUpgradingData())
		{
			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: 0x06001B43 RID: 6979 RVA: 0x00042754 File Offset: 0x00040954
	[Token(Token = "0x6001B43")]
	[Address(RVA = "0xCB87B0", Offset = "0xCB77B0", VA = "0x180CB87B0")]
	public void CancelUpgrade()
	{
		Game.FadeOutUpgradeSE();
		Tween tween = this.tweenBarIcon;
		if (tween != 0)
		{
			tween.PlayBackwards();
		}
		if (this.tweenBar.IsActive())
		{
			this.tweenBar.PlayBackwards();
			return;
		}
	}

	// Token: 0x06001B44 RID: 6980 RVA: 0x00042794 File Offset: 0x00040994
	[Token(Token = "0x6001B44")]
	[Address(RVA = "0xCB60F0", Offset = "0xCB50F0", VA = "0x180CB60F0")]
	public void UpdateHoldingState(bool isHolding)
	{
		this.holdingUpgrade = isHolding;
	}

	// Token: 0x06001B45 RID: 6981 RVA: 0x000427A8 File Offset: 0x000409A8
	[Token(Token = "0x6001B45")]
	[Address(RVA = "0xCB8B40", Offset = "0xCB7B40", VA = "0x180CB8B40")]
	public void Localize(LocalizationData data)
	{
		Text text = this.title;
		GameTextData systemText = data.systemText;
		int num = this.index;
		num += 185;
		string text2 = systemText.GetText(num);
		text.text = text2;
		GameFontPack fontPack = data.fontPack;
		Text text3 = this.title;
		Font regular = fontPack.regular;
		text3.font = regular;
		GameFontPack fontPack2 = data.fontPack;
		Text text4 = this.level;
		Font regular2 = fontPack2.regular;
		text4.font = regular2;
		GameFontPack fontPack3 = data.fontPack;
		Text text5 = this.cost;
		Font regular3 = fontPack3.regular;
		text5.font = regular3;
	}

	// Token: 0x06001B46 RID: 6982 RVA: 0x00042850 File Offset: 0x00040A50
	[Token(Token = "0x6001B46")]
	[Address(RVA = "0xCB8C60", Offset = "0xCB7C60", VA = "0x180CB8C60", Slot = "8")]
	public override void OnSelect()
	{
		Action<UIHandlerBase> onSelectedHandler = this.onSelectedHandler;
		if (onSelectedHandler != 0)
		{
			onSelectedHandler(this);
			return;
		}
	}

	// Token: 0x06001B47 RID: 6983 RVA: 0x00042870 File Offset: 0x00040A70
	[Token(Token = "0x6001B47")]
	[Address(RVA = "0xCB8C10", Offset = "0xCB7C10", VA = "0x180CB8C10", Slot = "9")]
	public override void OnDeselect()
	{
		Action<UIHandlerBase> onDeselectedHandler = this.onDeselectedHandler;
		if (onDeselectedHandler != 0)
		{
			onDeselectedHandler(this);
			return;
		}
	}

	// Token: 0x06001B48 RID: 6984 RVA: 0x00042890 File Offset: 0x00040A90
	[Token(Token = "0x6001B48")]
	[Address(RVA = "0xCB8AE0", Offset = "0xCB7AE0", VA = "0x180CB8AE0")]
	private void KeepUpgrade()
	{
		if (this.UpdateUpgradingData())
		{
			Tween tween = this.tweenBar;
			if (tween != 0)
			{
				Tween tween2 = tween.Play<Tween>();
				return;
			}
		}
	}

	// Token: 0x06001B49 RID: 6985 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B49")]
	[Address(RVA = "0xCB9AB0", Offset = "0xCB8AB0", VA = "0x180CB9AB0")]
	private bool UpdateUpgradingData()
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B4A RID: 6986 RVA: 0x000428BC File Offset: 0x00040ABC
	[Token(Token = "0x6001B4A")]
	[Address(RVA = "0xCB8AA0", Offset = "0xCB7AA0", VA = "0x180CB8AA0")]
	private bool IsTweenBarPlaying()
	{
		bool flag = this.tweenBar.IsActive();
		if (!flag)
		{
			return flag;
		}
		return this.tweenBar.IsPlaying();
	}

	// Token: 0x06001B4B RID: 6987 RVA: 0x000428E8 File Offset: 0x00040AE8
	[Token(Token = "0x6001B4B")]
	[Address(RVA = "0xCB9410", Offset = "0xCB8410", VA = "0x180CB9410")]
	private void UpdateExpGroupScale()
	{
		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: 0x06001B4C RID: 6988 RVA: 0x0004291C File Offset: 0x00040B1C
	[Token(Token = "0x6001B4C")]
	[Address(RVA = "0xCB92D0", Offset = "0xCB82D0", VA = "0x180CB92D0")]
	private void ResetExpGroupScale()
	{
		Tween tween = this.tweenBarIcon;
		if (tween != 0)
		{
			tween.PlayBackwards();
			return;
		}
	}

	// Token: 0x06001B4D RID: 6989 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B4D")]
	[Address(RVA = "0xCB8850", Offset = "0xCB7850", VA = "0x180CB8850")]
	private void InitTween()
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B4E RID: 6990 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B4E")]
	[Address(RVA = "0xCB9940", Offset = "0xCB8940", VA = "0x180CB9940")]
	private void UpdateInfo(string levelStr, string costStr, float barScale)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B4F RID: 6991 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B4F")]
	[Address(RVA = "0xCB94B0", Offset = "0xCB84B0", VA = "0x180CB94B0")]
	private void UpdateHandlerInfo(float needExp = 0f, float tweenExp = 0f)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B50 RID: 6992 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001B50")]
	[Address(RVA = "0xCB8F20", Offset = "0xCB7F20", VA = "0x180CB8F20")]
	private void ProcessUpgrade(Action<float, float> onUpdated, Action<bool> onCompleted)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001B51 RID: 6993 RVA: 0x0004293C File Offset: 0x00040B3C
	[Token(Token = "0x6001B51")]
	[Address(RVA = "0xCB8E80", Offset = "0xCB7E80", VA = "0x180CB8E80")]
	private void OnUpgradeUpdated(float need, float tweenValue)
	{
		float num = this.originalMoney;
		this.currentMoney = num;
		Game.UpdateMoney(num);
		this.UpdateHandlerInfo(need, tweenValue);
	}

	// Token: 0x06001B52 RID: 6994 RVA: 0x00042968 File Offset: 0x00040B68
	[Token(Token = "0x6001B52")]
	[Address(RVA = "0xCB8CB0", Offset = "0xCB7CB0", VA = "0x180CB8CB0")]
	private void OnUpgradeCompleted(bool success)
	{
		while (success)
		{
			this.upgradeDataHandler.UpdateStatsLevel();
			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.holdingUpgrade)
			{
			}
			if (this.UpdateUpgradingData())
			{
				Tween tween = this.tweenBar;
				while (tween == 0)
				{
				}
				Tween tween2 = tween.Play<Tween>();
				return;
			}
		}
		Game.FadeOutUpgradeSE();
		Game.PlayHandlerSE(UIHandlerSFX.Error);
		Action action = this.upgradeFailedHandler;
		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: 0x06001B53 RID: 6995 RVA: 0x00042A58 File Offset: 0x00040C58
	[Token(Token = "0x6001B53")]
	[Address(RVA = "0x41ED30", Offset = "0x41DD30", VA = "0x18041ED30")]
	public UIUpgradeHandler()
	{
	}

	// Token: 0x0400253B RID: 9531
	[FieldOffset(Offset = "0x68")]
	[Token(Token = "0x400253B")]
	[SerializeField]
	private Text title;

	// Token: 0x0400253C RID: 9532
	[FieldOffset(Offset = "0x70")]
	[Token(Token = "0x400253C")]
	[SerializeField]
	private Text level;

	// Token: 0x0400253D RID: 9533
	[FieldOffset(Offset = "0x78")]
	[Token(Token = "0x400253D")]
	[SerializeField]
	private Text cost;

	// Token: 0x0400253E RID: 9534
	[FieldOffset(Offset = "0x80")]
	[Token(Token = "0x400253E")]
	[SerializeField]
	private RectTransform rtLevel;

	// Token: 0x0400253F RID: 9535
	[FieldOffset(Offset = "0x88")]
	[Token(Token = "0x400253F")]
	[SerializeField]
	private RectTransform rtBar;

	// Token: 0x04002540 RID: 9536
	[FieldOffset(Offset = "0x90")]
	[Token(Token = "0x4002540")]
	[SerializeField]
	private RectTransform rtExpGroup;

	// Token: 0x04002541 RID: 9537
	[FieldOffset(Offset = "0x98")]
	[Token(Token = "0x4002541")]
	private Tween tweenBarIcon;

	// Token: 0x04002542 RID: 9538
	[FieldOffset(Offset = "0xA0")]
	[Token(Token = "0x4002542")]
	private Tween tweenBar;

	// Token: 0x04002543 RID: 9539
	[FieldOffset(Offset = "0xA8")]
	[Token(Token = "0x4002543")]
	private UpgradeDataHandler upgradeDataHandler;

	// Token: 0x04002544 RID: 9540
	[FieldOffset(Offset = "0xB0")]
	[Token(Token = "0x4002544")]
	private Action upgradeFailedHandler;

	// Token: 0x04002545 RID: 9541
	[FieldOffset(Offset = "0xB8")]
	[Token(Token = "0x4002545")]
	private float originalMoney;

	// Token: 0x04002546 RID: 9542
	[FieldOffset(Offset = "0xBC")]
	[Token(Token = "0x4002546")]
	private float currentMoney;

	// Token: 0x04002547 RID: 9543
	[FieldOffset(Offset = "0xC0")]
	[Token(Token = "0x4002547")]
	private bool holdingUpgrade;
}
