#include "scripts/bp_common.txt"
#include "scripts/map/common_level_script.txt"

kActor @portal;
//------------------------------------------------------------------------------------------------------------------------
// Start
//------------------------------------------------------------------------------------------------------------------------
$script 0 {
	GameVariables.SetValue("BP.reachedEnd", "1");

	ActorFactory.Spawn("ShopPoint", 1801, 168, 2099, Math::Deg2Rad(45), 0); //Spawn Shop Portal
	
	@portal = ActorFactory.Spawn("BP_CommonPortalExit", 2380, 455, 2099, Math::Deg2Rad(0), 0); //Exit to hub
	portal.Scale() = kVec3(0.35f, 0.35f, 0.35f);

	Game.CallDelayedMapScript(1, instigator, 0);
}
//------------------------------------------------------------------------------------------------------------------------
// Update Game
//------------------------------------------------------------------------------------------------------------------------
$script 1 {
	if (InArea(portal.Origin(), 60, 100) and Player.Actor().OnGround()) {
		PlayLoop.StartFreeWarp(Player.Actor().CastToActor(),
					   kVec3(-1834, 4732, 972), //pos
					   0, //yaw
					   535, //sectorindex
					   5); //mapid
		return;
	}
	
	UpdateGeneralGame();
	//ActorInWorldTestUpdate();
	$restart;
}
//------------------------------------------------------------------------------------------------------------------------
