if global.hitstop > 0
	global.hitstop--;
	
if global.developer_mode
{
	if mouse_check_button_pressed(mb_left)
	{
		oPlayer.x = mouse_x;
		oPlayer.y = mouse_y;
	}
}

if global.time_scale_t < 1.0
{
    global.time_scale_t += 1 / global.time_scale_duration;
    global.time_scale_t = min(global.time_scale_t, 1.0);
    
    global.time_scale = lerp(0.1, 1.0, power(global.time_scale_t, 6));
}

if oMain._inventory
{
	global.inventory = icl(oInventory);
	with(oMain) autoreg_handle("inventory", "inventory", 10);
}
else if oMain._close_inv
{
	with(global.inventory) instance_destroy();
	with(oMain) autodel_handle("inventory");
}
if oMain._pause && global.can_pause
{
	global.pauser = icl(oPauseMenu);
	with(oMain) autoreg_handle("pause", "pause", 20);
}
else if oMain._close_pause
{
	with(global.pauser) fan_darken_target = -0.2;
	with(oMain) autodel_handle("pause");
}
else if oMain._save_pause
{
	with(global.pauser) fan_darken_target = 0;
	with(oMain) autodel_handle("pause");
	save_game_to_disk();
	
	var _fade = icl(oFade);
	_fade._callback = function()
	{
		with(global.player) instance_destroy();
		with(global.pauser) instance_destroy();
		with(global.UI) instance_destroy();
		with(global.in_game_manager) instance_destroy();
	
		room_goto(rTitle);
		
		with(oMain)
		{
			autoreg_handle("title", "title", 100);
		}
	}
}