namespace BP
{
	const int TEAM_COUNT = 2; //number of teams
	array<BP::Team@> teams;
	
	namespace Maps
	{
		class Arena : BP::ScriptActor
		{
			//------------------------------------------------------------------------------------------------------------------------
			Arena(kActor@ actor)
			{
				super(actor);
				
				//Start/End DeathMatch
				BP::teams.resize(0);
				for (int i = 0; i < BP::TEAM_COUNT; i++)
				{
					BP::teams.insertLast(@BP::Team(i));
				}
			}
			//------------------------------------------------------------------------------------------------------------------------
			void BP_OnStart()
			{
				//DebugLog("768h86h8878h78h7878h787h87h8h797h89789h789h789h789h7987h98h789789798798h798h7987");
				// World.SetGlobalAmbience(255);
				
				//setup bots
				for (int i = 0; i < BP::TEAM_COUNT; i++)
				{
					if (i == 1)
					BP::teams[i].AddBot(kActor_AI_Endtrail);
				}
				
				// DM AI
				// - Attack: Look for enemies on a enemy team and get the enemy that the ai considers is most hostile
				// - Movement: move to health pickup if health is below a certain amount, if not then move to targeted enemy,
				// if no enemy then move to a random (Hot Spot on the map), if reached the hot spot then pick another random hot spot

				// General AI
				// - if enemy targets you then increase there hostile count towards you
				// - When hit by an enemy increase that actors hostile count
				// - if enemy is the player then hostile count starts at a higher value
				// - hostility resets OnDeath
			}
			//------------------------------------------------------------------------------------------------------------------------
			void BP_OnSerialize(kDict dict)
			{
				//length of teams always the same
				for (int i = 0; i < BP::TEAM_COUNT; i++)
				{
					teams[i].Serialize(dict, "team" + i);
					DebugError("=====BP_OnSerialize=====");
					DebugError(teams[i].ToString());
				}
			}
			//------------------------------------------------------------------------------------------------------------------------
			void BP_OnDeserialize(kDict& in dict)
			{
				//length of teams always the same
				for (int i = 0; i < BP::TEAM_COUNT; i++)
				{
					teams[i].Deserialize(dict, "team" + i);
					DebugError("=====BP_OnDeserialize=====");
					DebugError(teams[i].ToString());
				}
			}
			//------------------------------------------------------------------------------------------------------------------------
			void BP_OnDeserializeStart()
			{
				for (int i = 0; i < BP::TEAM_COUNT; i++)
				{
					teams[i].OnDeserializeStart();
					DebugError("=====BP_OnDeserializeStart=====");
					DebugError(teams[i].ToString());
				}
			}
			//------------------------------------------------------------------------------------------------------------------------
			void BP_OnTick()
			{
				for (int i = 0; i < BP::TEAM_COUNT; i++)
				{
					BP::teams[i].OnTick();
				}
			}
			//------------------------------------------------------------------------------------------------------------------------
		};
	}
}
