local _charged_throw_ready = 3

_G.ChargedThrow = _G.ChargedThrow or {}

ChargedThrow.Do_Charged_Throw = false

local _btn_throw_press_time = 0

function PlayerCarry:_check_use_item(t, input)
	local new_action
	local action_wanted = input.btn_use_item_release and self._throw_time and t and t < self._throw_time
	if input.btn_use_item_press then
		self._throw_down = true
		self._second_press = false
		self._throw_time = t + PlayerCarry.throw_limit_t
	end
	if action_wanted then
		local action_forbidden = self._use_item_expire_t or self:_changing_weapon() or self:_interacting() or self._ext_movement:has_carry_restriction() or self:_is_throwing_projectile() or self:_on_zipline()
		if not action_forbidden then
			ChargedThrow.Do_Charged_Throw = false
			_btn_throw_press_time = 0
			managers.player:drop_carry()
			new_action = true
		end
	end
	if self._throw_down then
		if input.btn_use_item_release then
			self._throw_down = false
			self._second_press = false
			if _btn_throw_press_time then
				local _timer = (t - _btn_throw_press_time)
				if _timer >= _charged_throw_ready then
					ChargedThrow.Do_Charged_Throw = true
					managers.player:drop_carry()
					new_action = true
				end
				_btn_throw_press_time = 0
			end
			return PlayerCarry.super._check_use_item(self, t, input)
		elseif t > self._throw_time then
			if not self._second_press then
				input.btn_use_item_press = true
				self._second_press = true
			end
			if not _btn_throw_press_time or _btn_throw_press_time == 0 then
				_btn_throw_press_time = t
			end
			return PlayerCarry.super._check_use_item(self, t, input)
		end
	end
	return new_action
end