void OnStart()
{
	SetEntityPlayerInteractCallback("level_cellar_1", "Loading_1", false);
	SetEntityPlayerInteractCallback("level_wood_2", "Loading_2", false);
	SetEntityPlayerInteractCallback("level_wood_1", "Loading_3", false);
	AddUseItemCallback("", "key_torture_chamber_1", "castle_2", "CellarDoor", true);
	AddUseItemCallback("", "key_laboratory_1", "castle_1", "CellarDoor2", true);
	AddUseItemCallback("", "FakeVitae", "slime_6way_1", "SlimeRemove_1", true);
	AddEntityCollideCallback("Player", "FlashBackArea_1", "FlashBack_1", true, 1);

}

void FlashBack_1(string &in asParent, string &in asChild, int alState)
{StartEffectFlash(1, 1.0, 1); PlaySoundAtEntity("", "flashback_flash.snt", "Player", 0.1f, false); FadeImageTrailTo(3, 0.1f); FadeSepiaColorTo(5, 0.1f); SetPlayerMoveSpeedMul(0.5); AddTimer("", 2, "FlashBack_2"); SetEntityInteractionDisabled("", true);}
void FlashBack_2(string &in asTimer)
{SetMessage("Flashbacks", "FlashbackMainHall_01", 4); AddTimer("", 4, "FlashBack_3");}
void FlashBack_3(string &in asTimer)
{SetMessage("Flashbacks", "FlashbackMainHall_02", 4); AddTimer("", 4, "FlashBack_4");}
void FlashBack_4(string &in asTimer)
{SetMessage("Flashbacks", "FlashbackMainHall_03", 4); AddTimer("", 4, "FlashBack_5");}
void FlashBack_5(string &in asTimer)
{SetMessage("Flashbacks", "FlashbackMainHall_04", 3); AddTimer("", 3, "FlashBack_End");}
void FlashBack_End(string &in asTimer)
{StartEffectFlash(1, 1.0, 1); PlaySoundAtEntity("", "flashback_flash.snt", "Player", 0.1f, false); FadeImageTrailTo(0, 1.0f); FadeSepiaColorTo(0, 1.0f); SetPlayerMoveSpeedMul(1); SetEntityInteractionDisabled("", false);}

void GoToChapel(string &in asEntity)
{
	ChangeMap("chapel.map", "PlayerStartArea_1", "door_large_castle_open", "close_security");
}

void TouchSlime(string &in asEntity)
{
	SetMessage("Messages", "SlimeTouch", 0);
	PlaySoundAtEntity("", "26_touch_fungu.snt", "Player", 0.1f, false);	

}

void SlimeRemove_1(string &in asItem, string &in asEntity)
{
	PlaySoundAtEntity("", "puzzle_acid.snt", "Player", 0.1f, false);	
	SetPlayerActive(false);
	FadeOut(3);
	AddTimer("", 3, "SlimeRemove_2");
	RemoveItem("FakeVitae");
	SetMessage("Messages", "SlimeRemove", 3);

}
void SlimeRemove_2(string &in asTimer)
{
	PlaySoundAtEntity("", "26_squeeze_gland.snt", "Player", 0.1f, false);
	AddTimer("", 1, "SlimeRemove_3");
	SetEntityActive("slime_6way_1", false);
	SetEntityActive("slime_6way_3", true);
	SetEntityActive("slime_6way_2", true);
	SetEntityActive("ScriptArea_1", true);

}
void SlimeRemove_3(string &in asTimer)
{
	FadeIn(2);
	SetPlayerActive(true);
}

void CellarDoor(string &in asItem, string &in asEntity)
{
	SetSwingDoorLocked("castle_2", false, true);
	PlaySoundAtEntity("", "unlock_door", "castle_2", 0, false);
	RemoveItem("key_torture_chamber_1");
}
void CellarDoor2(string &in asItem, string &in asEntity)
{
	SetSwingDoorLocked("castle_1", false, true);
	PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
	RemoveItem("key_laboratory_1");
}


void OnEnter()
{
	PlayMusic("Fabricated_Background.ogg", true, 1, 5, 1, false);
}

void OnLeave()
{

	StopMusic(3, 1);
}