function check_hitstop()
{
	if global.hitstop > 0
		return true;
	else
		return false;
}
/// @desc 优雅地检测该实例的sprite当前动画是否到达最后一帧
function animation_end()
{
	if animation_spd == 0
		return false;
    return (image_index + animation_spd >= image_number);
}
/// @desc 优雅地将该实例的sprite替换为给定值，并将sprite_index归零
/// @param {Asset.GMSprite} _sprite 将要替换为的sprite
function set_sprite(_sprite)
{
	if sprite_index != _sprite
	{
        sprite_index = _sprite;
        image_index = 0;
    }
}

function camera_snap()
{
	oCamera.x = oCamera.follow.x;
	oCamera.y = oCamera.follow.y;	
}

/// @desc 触发屏幕震动
/// @param {Real} _magnitude 以像素计算的震动强度
// @param {Real} _frames 以帧计算的持续时间
function screen_shake(_magnitude)//, _duration)
{
    // 只有当新的震动比当前的更强时才覆盖
    with(oCamera)
	{
        if _magnitude > shake_magnitude
		{
            shake_magnitude = _magnitude;
            //shake_duration = _duration;
        }
    }
}

function self_check_destroy()
{
	if struct_exists(global.save_data.world.destroyed_objects, uuid)
		instance_destroy();
}
function self_record_destroy(_callback = undefined)
{
	var _list = global.save_data.world.destroyed_objects;

	_list[$ uuid] = true;

	if is_method(_callback)
		_callback();

	save_game_to_disk();

	instance_destroy();
}

function player_add_INK(_amount)
{
	if global.playerINK + _amount >
	global.save_data.player.maxINK
	
		global.playerINK = global.save_data.player.maxINK;
	
	else
		global.playerINK += _amount;
		
	oUI.flash_timer = 10;
	oUI.flash_duration = 10;
}
function player_add_HP(_amount)
{
	if global.playerHP + _amount >
	global.save_data.player.maxHP
	
		global.playerHP = global.save_data.player.maxHP;
	
	else
		global.playerHP += _amount;
}