#include "CS_QuoteLock.h"
#include "CS_Quote.h"
const int CS_QuoteSTATENAME_LOCK = GetNextEntityStateID();
CS_QuoteLock::CS_QuoteLock()
{
	stateID = CS_QuoteSTATENAME_LOCK;
	cd_counter = 0;
	cd_counter_max = 1;
	iconIndex = 2;
}

const wchar_t* CS_QuoteLock::GetSaveName()
{
	return L"Lock";
}

const wchar_t* CS_QuoteLock::GetFuncName()
{
	return L"QuoteSkill_Lock";
}

const wchar_t* CS_QuoteLock::GetCheckFuncName()
{
	return L"QuoteSkill_Lock_Check";
}

void CS_QuoteLock::SubStep()
{
	auto we = e.lock();
	if (!we)
		return;

	auto mychar = std::static_pointer_cast<CS_Quote>(we);
	bUIShowDisableSkill = mychar->fishState;
	if (mychar->fishState)
	{
		bLock = false;
		return;
	}
	
	bool a1 = !lock;
	bool b1 = (mychar->input.key & keyMask);

	bool a = a1;
	bool b = b1;
	if (a && b)
	{
		mychar->lastSkill = this;
		mychar->ChangeState(GetStateID());
	}
	cd_counter = bLock ? cd_counter_max : 0;
	//无技能冷却时间
	EntitySkillState::SubStep();
}

void CS_QuoteLock::ChangeStateMsg(int stateID)
{
	if (stateID == GetStateID())
	{
		auto we = e.lock();
		if (!we)
			return;
		bLock = !bLock;
		//锁住按键
		we->inputLock.key |= keyMask;
	}
	else
		enable = false;
}
