#include "CS_PuppyResist.h"
#include "EntityStateResist.h"
const int& CS_PuppySTATENAME_RESIST = ES_STATENAME_RESIST;
CS_PuppyResist::CS_PuppyResist()
{
	SetPhysice(false);
	resist = resist_default;
	enable = true;
	stateID = CS_PuppySTATENAME_RESIST;
}

void CS_PuppyResist::State()
{
	auto we = e.lock();
	if (!we)
		return;

	resist = resist_default;
	//µØÃæ×èÁ¦
	if (we->cbRect.cbBottom && !PxaIsIce(we->cbRect.pxaBottom) && !(we->cbRect.cbLeft || we->cbRect.cbRight))
	{
		if (we->vx < 0)
			if (we->vx > -resist)
				we->vx = 0;
			else
				we->vx += resist;
		if (we->vx > 0)
			if (we->vx < resist)
				we->vx = 0;
			else
				we->vx -= resist;
	}
}

void CS_PuppyResist::SetPhysice(bool bInWater)
{
	if (bInWater)
		resist_default = inwater_resist_default;
	else
		resist_default = ground_resist_default;
}
