using System.Collections.Generic;
using UnityEngine;

namespace Game
{
	[CreateAssetMenu(menuName = "Managers/Visited Screens Manager")]
	public class VisitedScreensManager : ScriptableObject
	{
		public List<GameScreenAsset> visitedScreens = new List<GameScreenAsset>();
		public List<RoomScreenAsset> visitedRooms = new List<RoomScreenAsset>();
		public void Visit(GameScreenAsset currentScreen)
		{
			if(!visitedScreens.Contains(currentScreen))
				visitedScreens.Add(currentScreen);

			var roomScreenAsset = currentScreen as RoomScreenAsset;
			if (roomScreenAsset != null && !visitedRooms.Contains(roomScreenAsset))
			{
				visitedRooms.Add(roomScreenAsset);
			}
		}

		public bool WasVisited(GameScreenAsset currentScreen)
		{
			return visitedScreens.Contains(currentScreen);
		}

		public void Clear()
		{
			visitedScreens.Clear();
		}

		public bool CanUnlockBedroom()
		{
			return visitedRooms.Count > 3;
		}

		public bool CanUnlockDisturbingMusic()
		{
			return visitedRooms.Count > 2;
		}

		private void OnEnable()
		{
			visitedScreens.Clear();
			visitedRooms.Clear();
		}
	}
}