#include "CS_JenkaAni.h"

CS_JenkaAni::CS_JenkaAni()
{
	ani.png = L"CS_CaveStoryMod";
	//ÆôÓÃÅö×²
	cbRect.enableCbRect = true;
	cbRect.enableSoild = true;
	//ÉèÖÃÅö×²¿ò
	cbRect.left = cbRect.right = 6;
	cbRect.top = 8;
	cbRect.bottom = 8;
}

void CS_JenkaAni::Step()
{
	auto& ani_no = ani.image_index;
	switch (act_no)
	{
	case 0:
		act_no = 1;
		ani_no = 0;
		ani_wait = 0;
		[[fallthrough]];
	case 1:
		if (Random(0, 120) == 10)
		{
			act_no = 2;
			act_wait = 0;
			ani_no = 1;
		}
		break;
	case 2:
		if (++act_wait > 8)
		{
			act_no = 1;
			ani_no = 0;
		}
		break;
	}
	ani.sprite_index = lr == 0 ? L"mc_jenka_l" : L"mc_jenka_r";
}

void CS_JenkaAni::SetState(int stateID, int lr)
{
	this->lr = lr;
	ani.sprite_index = lr == 0 ? L"mc_jenka_l" : L"mc_jenka_r";
}

std::shared_ptr<Entity> CreateCS_JenkaAni()
{
	return std::make_shared<CS_JenkaAni>();
}
