void OnEnter()
{
	SetPlayerRunSpeedMul(1.1f);
	CheckPoint("asdf", "PlayerStartArea_1", "CheckPointDIE", "", "");
	AddEntityCollideCallback("Player", "DIE", "FellOffStage", true, 0);
	AddEntityCollideCallback("Player", "WIN", "WeHaveAWinner", true, 0);
	AddEntityCollideCallback("Player", "FALL", "FallsDown", true, 0);
	AddEntityCollideCallback("TheHatch", "TheArea", "AlmostThere", true, 0);
	PlayMusic("Tension.ogg", true, 2.0f, 0, 10, true);
	FadeIn(3.0f);
	AddTimer("Meteor0", RandFloat(20, 30), "CreateMeteor");
	AddTimer("Meteor1", RandFloat(20, 30), "CreateMeteor");
	AddTimer("Meteor2", RandFloat(20, 30), "CreateMeteor");
	AddTimer("Meteor3", RandFloat(20, 30), "CreateMeteor");
	PreloadSound("general_wind_whirl");
	PreloadSound("scare_whine_loop4");
}

void FellOffStage(string &in asParent, string &in asChild, int alState)
{
	GivePlayerDamage(500, "ui_elec_damage", true, true);
}

void WeHaveAWinner(string &in asParent, string &in asChild, int alState)
{
	ChangeMap("Dream2.map","PlayerStartArea_1", "", "");
	TeleportPlayer("TeleportHere");
	FadeOut(0.0f);
	StopMusic(1.0f, 10);
}

void AlmostThere(string &in asParent, string &in asChild, int alState)
{
	GiveSanityBoostSmall();
	PlayMusic("amb_guardian.ogg", true, 2.0f, 0, 10, true);
}

void FallsDown(string &in asParent, string &in asChild, int alState)
{
	PlaySoundAtEntity("", "general_wind_whirl.snt", "Player", 1.0f, true);
}

void CheckPointDIE(string &in asName, int alCount)
{
	AddTimer("ChangeMap", 2.0, "TimerChangeMap");
}
	
void TimerChangeMap(string &in asChangeMap)
{
	ChangeMap("Dream1Failure.map","PlayerStartArea_1", "", "");
}

void CreateMeteor(string &in asTimer)
{
	
	if(asTimer == "Meteor0") 
	{
	CreateEntityAtArea("Meteor", "contained_awesome.ent", "Area_"+RandInt(1, 100), false);
	AddTimer("Meteor0", RandFloat(30, 30), "CreateMeteor");
	}
	
	else if(asTimer == "Meteor1")
	{
	CreateEntityAtArea("Meteor", "contained_grunt.ent", "Area_"+RandInt(1, 100), false);
	AddTimer("Meteor1", RandFloat(40, 40), "CreateMeteor");
	}
	
	else if(asTimer == "Meteor2") 
	{
	CreateEntityAtArea("Meteor", "contained_brute.ent", "Area_"+RandInt(1, 100), false);
	AddTimer("Meteor2", RandFloat(50, 50), "CreateMeteor");
	}
	
	else if(asTimer == "Meteor3") 
	{
	CreateEntityAtArea("Meteor", "contained_infected.ent", "Area_"+RandInt(1, 100), false);
	AddTimer("Meteor3", RandFloat(60, 60), "CreateMeteor");
	}
} 