using System;
using System.Collections.Generic;
using UnityEngine;
using Wizard.RoomMatch;

namespace Wizard;

public class GatheringChatSettings : MonoBehaviour, IChatSettings
{
	[SerializeField]
	private ChatLogPlate _prefabChatLogPlate;

	[SerializeField]
	private GatheringChatSendRoomMatchUI _sendRoomMatchUI;

	[SerializeField]
	private GatheringChatAutoJoinRoomMatch _autoJoinRoomMatchUI;

	public GatheringChatSendRoomMatchUI SendRoomMatchUI => _sendRoomMatchUI;

	public GatheringChatAutoJoinRoomMatch AutoJoinRoomMatchUI => _autoJoinRoomMatchUI;

	public KeyValuePair<string, int> PlayerPrefsKeyLatestReadChatMessageId => PlayerPrefsWrapper.READ_LATEST_GATHERING_CHAT_MESSAGE_ID;

	public IChatApiSettings ApiSettings { get; } = new GatheringChatApiSettings();

	public ChatLogPlate PrefabChatLogPlate => _prefabChatLogPlate;

	public UIManager.ViewScene ReplayBackScene => UIManager.ViewScene.Gathering;

	public UIManager.ChangeViewSceneParam ReplayBackSceneParam => new UIManager.ChangeViewSceneParam
	{
		IsUpdateFooterMenuTexture = true
	};

	public GatheringInfo GatheringInfo { get; private set; }

	public GatheringEntrySetting EntrySetting { get; private set; }

	public Action<GameObject> OnSetChatLogRoomInfoViewJoinButton => delegate(GameObject joinVisitorBtn)
	{
		bool active = true;
		if (GatheringInfo.Role == GatheringRule.eRole.OWNER && !GatheringInfo.Rule.IsOwnerEntryBattle)
		{
			active = false;
		}
		joinVisitorBtn.gameObject.SetActive(active);
	};

	public Action<string> OnClickBtnJoinRoomVisitor => delegate(string roomId)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		RoomConnectController.InitializeParameter param = new RoomConnectController.InitializeParameter(RoomConnectController.PositionMode.VISITOR, GatheringInfo.Rule.BattleParameterInstance, roomId)
		{
			IsGathering = true
		};
		UIManager.GetInstance().StartCoroutine(GatheringUtility.JoinRoom(param, ""));
	};

	public Action<string> OnClickBtnJoinRoomWatcher => delegate(string roomId)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		RoomConnectController.InitializeParameter param = new RoomConnectController.InitializeParameter(RoomConnectController.PositionMode.WATCHER, GatheringInfo.Rule.BattleParameterInstance, roomId)
		{
			IsGathering = true
		};
		UIManager.GetInstance().StartCoroutine(GatheringUtility.JoinRoom(param, ""));
	};

	public void SetGatheringInfo(GatheringInfo info, GatheringEntrySetting entrySetting)
	{
		GatheringInfo = info;
		EntrySetting = entrySetting;
	}
}
