#include "CS_Lock.h"

CS_Lock::CS_Lock()
{
	type = 0;
	cbRect.enableCbRect = true;
	cbRect.enableSoild = true;
	cbRect.enableSelfSoild = true;
	ani.png = L"CS_CaveStoryMod";
	ani.sprite_index = L"ls_lock";
	ani.image_index = 0;
	drawAfterPlayer = true;
	action_timecounter_max = 60;
	action_timecounter = action_timecounter_max;
}

void CS_Lock::Step()
{
	//ÏûÊ§
	if (leave)
	{
		if (action_timecounter > 0)
		{
			action_timecounter--;
			if (action_timecounter == 0)
				inUsing = false;
		}
	}
	color = RGBA(0xff, 0xff, 0xff, BYTE(action_timecounter * 0xff / action_timecounter_max));
}

void CS_Lock::SetState(int stateID, int lr)
{
	this->lr = lr;
	if (stateID == 0)
	{
		if (lr != 0)
		{
			leave = true;
			ani.image_index = 1;
			//¹Ø±ÕÅö×²
			cbRect.enableSelfSoild = false;
			cbRect.enableSoild = false;
			cbRect.enableCbRect = false;
		}
	}
}

std::shared_ptr<Entity> CreateCS_Lock()
{
	return std::make_shared<CS_Lock>();
}
