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

// Token: 0x0200028C RID: 652
[Token(Token = "0x200028C")]
public class UIUpgradeHandler : UIHandlerBase
{
	// Token: 0x06001912 RID: 6418 RVA: 0x0003CCB8 File Offset: 0x0003AEB8
	[Token(Token = "0x6001912")]
	[Address(RVA = "0x8AFBA0", Offset = "0x8AE9A0", VA = "0x1808AFBA0")]
	public void Init(UpgradeDataHandler handler)
	{
		this.upgradeDataHandler = handler;
		this.InitTween();
	}

	// Token: 0x06001913 RID: 6419 RVA: 0x0003CCD4 File Offset: 0x0003AED4
	[Token(Token = "0x6001913")]
	[Address(RVA = "0x8AF970", Offset = "0x8AE770", VA = "0x1808AF970")]
	public void InitDisplayInfo()
	{
		int num = 0;
		int num2 = 0;
		this.UpdateHandlerInfo((float)num2, (float)num);
	}

	// Token: 0x06001914 RID: 6420 RVA: 0x0003CCF0 File Offset: 0x0003AEF0
	[Token(Token = "0x6001914")]
	[Address(RVA = "0x8AF8D0", Offset = "0x8AE6D0", VA = "0x1808AF8D0")]
	public void BindUpgradeFailedHandlerEvent(Action handler)
	{
		/*
An exception occurred when decompiling this method (06001914)

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: 0x06001915 RID: 6421 RVA: 0x0003CD04 File Offset: 0x0003AF04
	[Token(Token = "0x6001915")]
	[Address(RVA = "0x8B0420", Offset = "0x8AF220", VA = "0x1808B0420")]
	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: 0x06001916 RID: 6422 RVA: 0x0003CD48 File Offset: 0x0003AF48
	[Token(Token = "0x6001916")]
	[Address(RVA = "0x8AF8E0", Offset = "0x8AE6E0", VA = "0x1808AF8E0")]
	public void CancelUpgrade()
	{
		Game.FadeOutUpgradeSE();
		Tween tween = this.tweenBarIcon;
		if (tween != 0)
		{
			tween.PlayBackwards();
		}
		if (this.tweenBar.IsActive())
		{
			this.tweenBar.PlayBackwards();
			return;
		}
	}

	// Token: 0x06001917 RID: 6423 RVA: 0x0003CD88 File Offset: 0x0003AF88
	[Token(Token = "0x6001917")]
	[Address(RVA = "0x8B0A70", Offset = "0x8AF870", VA = "0x1808B0A70")]
	public void UpdateHoldingState(bool isHolding)
	{
		this.holdingUpgrade = isHolding;
	}

	// Token: 0x06001918 RID: 6424 RVA: 0x0003CD9C File Offset: 0x0003AF9C
	[Token(Token = "0x6001918")]
	[Address(RVA = "0x8AFC70", Offset = "0x8AEA70", VA = "0x1808AFC70")]
	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: 0x06001919 RID: 6425 RVA: 0x0003CE44 File Offset: 0x0003B044
	[Token(Token = "0x6001919")]
	[Address(RVA = "0x8AFD90", Offset = "0x8AEB90", VA = "0x1808AFD90", Slot = "8")]
	public override void OnSelect()
	{
		Action<UIHandlerBase> onSelectedHandler = this.onSelectedHandler;
		if (onSelectedHandler != 0)
		{
			onSelectedHandler(this);
			return;
		}
	}

	// Token: 0x0600191A RID: 6426 RVA: 0x0003CE64 File Offset: 0x0003B064
	[Token(Token = "0x600191A")]
	[Address(RVA = "0x8AFD40", Offset = "0x8AEB40", VA = "0x1808AFD40", Slot = "9")]
	public override void OnDeselect()
	{
		Action<UIHandlerBase> onDeselectedHandler = this.onDeselectedHandler;
		if (onDeselectedHandler != 0)
		{
			onDeselectedHandler(this);
			return;
		}
	}

	// Token: 0x0600191B RID: 6427 RVA: 0x0003CE84 File Offset: 0x0003B084
	[Token(Token = "0x600191B")]
	[Address(RVA = "0x8AFC10", Offset = "0x8AEA10", VA = "0x1808AFC10")]
	private void KeepUpgrade()
	{
		if (this.UpdateUpgradingData())
		{
			Tween tween = this.tweenBar;
			if (tween != 0)
			{
				Tween tween2 = tween.Play<Tween>();
				return;
			}
		}
	}

	// Token: 0x0600191C RID: 6428 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x600191C")]
	[Address(RVA = "0x8B0BF0", Offset = "0x8AF9F0", VA = "0x1808B0BF0")]
	private bool UpdateUpgradingData()
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x0600191D RID: 6429 RVA: 0x0003CEB0 File Offset: 0x0003B0B0
	[Token(Token = "0x600191D")]
	[Address(RVA = "0x8AFBD0", Offset = "0x8AE9D0", VA = "0x1808AFBD0")]
	private bool IsTweenBarPlaying()
	{
		bool flag = this.tweenBar.IsActive();
		if (!flag)
		{
			return flag;
		}
		return this.tweenBar.IsPlaying();
	}

	// Token: 0x0600191E RID: 6430 RVA: 0x0003CEDC File Offset: 0x0003B0DC
	[Token(Token = "0x600191E")]
	[Address(RVA = "0x8B0540", Offset = "0x8AF340", VA = "0x1808B0540")]
	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: 0x0600191F RID: 6431 RVA: 0x0003CF10 File Offset: 0x0003B110
	[Token(Token = "0x600191F")]
	[Address(RVA = "0x8B0400", Offset = "0x8AF200", VA = "0x1808B0400")]
	private void ResetExpGroupScale()
	{
		Tween tween = this.tweenBarIcon;
		if (tween != 0)
		{
			tween.PlayBackwards();
			return;
		}
	}

	// Token: 0x06001920 RID: 6432 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001920")]
	[Address(RVA = "0x8AF980", Offset = "0x8AE780", VA = "0x1808AF980")]
	private void InitTween()
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001921 RID: 6433 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001921")]
	[Address(RVA = "0x8B0A80", Offset = "0x8AF880", VA = "0x1808B0A80")]
	private void UpdateInfo(string levelStr, string costStr, float barScale)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001922 RID: 6434 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001922")]
	[Address(RVA = "0x8B05E0", Offset = "0x8AF3E0", VA = "0x1808B05E0")]
	private void UpdateHandlerInfo(float needExp = 0f, float tweenExp = 0f)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001923 RID: 6435 RVA: 0x000020D3 File Offset: 0x000002D3
	[Token(Token = "0x6001923")]
	[Address(RVA = "0x8B0050", Offset = "0x8AEE50", VA = "0x1808B0050")]
	private void ProcessUpgrade(Action<float, float> onUpdated, Action<bool> onCompleted)
	{
		throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
	}

	// Token: 0x06001924 RID: 6436 RVA: 0x0003CF30 File Offset: 0x0003B130
	[Token(Token = "0x6001924")]
	[Address(RVA = "0x8AFFB0", Offset = "0x8AEDB0", VA = "0x1808AFFB0")]
	private void OnUpgradeUpdated(float need, float tweenValue)
	{
		float num = this.originalMoney;
		this.currentMoney = num;
		Game.UpdateMoney(num);
		this.UpdateHandlerInfo(need, tweenValue);
	}

	// Token: 0x06001925 RID: 6437 RVA: 0x0003CF5C File Offset: 0x0003B15C
	[Token(Token = "0x6001925")]
	[Address(RVA = "0x8AFDE0", Offset = "0x8AEBE0", VA = "0x1808AFDE0")]
	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: 0x06001926 RID: 6438 RVA: 0x0003D04C File Offset: 0x0003B24C
	[Token(Token = "0x6001926")]
	[Address(RVA = "0x3FBF80", Offset = "0x3FAD80", VA = "0x1803FBF80")]
	public UIUpgradeHandler()
	{
	}

	// Token: 0x040022E8 RID: 8936
	[FieldOffset(Offset = "0x68")]
	[Token(Token = "0x40022E8")]
	[SerializeField]
	private Text title;

	// Token: 0x040022E9 RID: 8937
	[FieldOffset(Offset = "0x70")]
	[Token(Token = "0x40022E9")]
	[SerializeField]
	private Text level;

	// Token: 0x040022EA RID: 8938
	[FieldOffset(Offset = "0x78")]
	[Token(Token = "0x40022EA")]
	[SerializeField]
	private Text cost;

	// Token: 0x040022EB RID: 8939
	[FieldOffset(Offset = "0x80")]
	[Token(Token = "0x40022EB")]
	[SerializeField]
	private RectTransform rtLevel;

	// Token: 0x040022EC RID: 8940
	[FieldOffset(Offset = "0x88")]
	[Token(Token = "0x40022EC")]
	[SerializeField]
	private RectTransform rtBar;

	// Token: 0x040022ED RID: 8941
	[FieldOffset(Offset = "0x90")]
	[Token(Token = "0x40022ED")]
	[SerializeField]
	private RectTransform rtExpGroup;

	// Token: 0x040022EE RID: 8942
	[FieldOffset(Offset = "0x98")]
	[Token(Token = "0x40022EE")]
	private Tween tweenBarIcon;

	// Token: 0x040022EF RID: 8943
	[FieldOffset(Offset = "0xA0")]
	[Token(Token = "0x40022EF")]
	private Tween tweenBar;

	// Token: 0x040022F0 RID: 8944
	[FieldOffset(Offset = "0xA8")]
	[Token(Token = "0x40022F0")]
	private UpgradeDataHandler upgradeDataHandler;

	// Token: 0x040022F1 RID: 8945
	[FieldOffset(Offset = "0xB0")]
	[Token(Token = "0x40022F1")]
	private Action upgradeFailedHandler;

	// Token: 0x040022F2 RID: 8946
	[FieldOffset(Offset = "0xB8")]
	[Token(Token = "0x40022F2")]
	private float originalMoney;

	// Token: 0x040022F3 RID: 8947
	[FieldOffset(Offset = "0xBC")]
	[Token(Token = "0x40022F3")]
	private float currentMoney;

	// Token: 0x040022F4 RID: 8948
	[FieldOffset(Offset = "0xC0")]
	[Token(Token = "0x40022F4")]
	private bool holdingUpgrade;
}
