using System;
using Cute;
using UnityEngine;

namespace Wizard;

public class GatheringKickConfirm : MonoBehaviour
{
	[SerializeField]
	private UIToggle _toggleEternal;

	[SerializeField]
	private UserPlateBase _userPlate;

	private Action<bool> OnKickDecide;

	private bool _toggleClickFirst = true;

	public static void Create(GameObject prefab, GatheringUserInfo userInfo, Action<bool> onKickDecide)
	{
		GatheringKickConfirm component = UnityEngine.Object.Instantiate(prefab).GetComponent<GatheringKickConfirm>();
		DialogBase dialog = UIManager.GetInstance().CreateDialogClose();
		component.Initialize(dialog, userInfo, onKickDecide);
	}

	private void Initialize(DialogBase dialog, GatheringUserInfo userInfo, Action<bool> onKickDecide)
	{
		OnKickDecide = onKickDecide;
		SystemText systemText = Data.SystemText;
		string titleLabel = systemText.Get("Gathering_Member_0012");
		string text_btn = systemText.Get("Gathering_Member_0005");
		dialog.SetTitleLabel(titleLabel);
		dialog.SetButtonText(text_btn);
		dialog.SetObj(base.gameObject);
		dialog.SetSize(DialogBase.Size.S);
		dialog.SetButtonLayout(DialogBase.ButtonLayout.RedBtn_CancelBtn);
		_userPlate.InitializeSimplePlate(userInfo);
		dialog.onPushButton1 = delegate
		{
			OnKickDecide.Call(_toggleEternal.value);
		};
		_toggleEternal.onChange.Add(new EventDelegate(delegate
		{
			OnClickToggle();
		}));
	}

	private void OnClickToggle()
	{
		if (!_toggleClickFirst)
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(_toggleEternal.value ? Se.TYPE.SYS_TOGGLE_ON : Se.TYPE.SYS_TOGGLE_OFF);
		}
		_toggleClickFirst = false;
	}
}
