#include "CS_Pushcart.h"

CS_Pushcart::CS_Pushcart()
{
	ani.png = L"CS_CaveStoryMod";
	//设置碰撞
	cbRect.enableCbRect = true;
	cbRect.enableSelfSoild = true;
	cbRect.enableMovePlatform = true;
	cbRect.left = 8;
	cbRect.right = 88;
	cbRect.bottom = 8;
	cbRect.top = -4;
}

void CS_Pushcart::Step()
{
	//执行运动
	Entity::Step();
}

void CS_Pushcart::SetState(int stateID, int lr)
{
	this->lr = lr;
	switch (stateID)
	{
	case 0:
		vx = 0;
		ani.sprite_index = lr == 0 ? L"pushcart_stand_l" : L"pushcart_stand_r";
		break;//静止
	case 1:
		vx = lr == 0 ? -0x200 / ts : 0x200 / ts;
		ani.sprite_index = lr == 0 ? L"pushcart_move_l" : L"pushcart_move_r";
		break;//运动
	}
}

void CS_Pushcart::SetState(std::wstring stateName, int lr)
{
	if (stateName == L"normal" || stateName == L"stop")
		SetState(0, lr);
	else if(stateName == L"move")
		SetState(1, lr);
}

std::shared_ptr<Entity> CreateCS_Pushcart()
{
	return std::make_shared<CS_Pushcart>();
}
