1
0

Renamed Farmer functions and added doxycomments

This commit is contained in:
STRWarrior 2014-01-28 16:26:44 +01:00
parent b2bacf3a25
commit 8ca98e0c0e
2 changed files with 20 additions and 17 deletions

View File

@ -41,6 +41,7 @@ void cVillager::DoTakeDamage(TakeDamageInfo & a_TDI)
void cVillager::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
if (m_ActionCountDown > -1)
{
m_ActionCountDown--;
@ -50,7 +51,7 @@ void cVillager::Tick(float a_Dt, cChunk & a_Chunk)
{
case vtFarmer:
{
HandleFarmerEndCountDown();
HandleFarmerPlaceCrops();
}
}
}
@ -63,15 +64,10 @@ void cVillager::Tick(float a_Dt, cChunk & a_Chunk)
{
case vtFarmer:
{
HandleFarmerAction();
HandleFarmerTryHarvestCrops();
}
}
m_VillagerAction = false;
}
// The villager already has an special action activated.
if (m_VillagerAction)
{
return;
}
@ -85,7 +81,7 @@ void cVillager::Tick(float a_Dt, cChunk & a_Chunk)
{
case vtFarmer:
{
HandleFarmerAttemptSpecialAction();
HandleFarmerPrepareFarmCrops();
}
}
}
@ -95,7 +91,7 @@ void cVillager::Tick(float a_Dt, cChunk & a_Chunk)
////////////////////////////////////////////////////////////////////////////////
// Farmer functions.
void cVillager::HandleFarmerAttemptSpecialAction()
void cVillager::HandleFarmerPrepareFarmCrops()
{
if (!m_World->VillagersShouldHarvestCrops())
{
@ -144,7 +140,7 @@ void cVillager::HandleFarmerAttemptSpecialAction()
void cVillager::HandleFarmerAction()
void cVillager::HandleFarmerTryHarvestCrops()
{
// Harvest the crops if the villager isn't moving and if the crops are closer then 2 blocks.
if (!m_bMovingToDestination && (GetPosition() - m_CropsPos).Length() < 2)
@ -164,7 +160,7 @@ void cVillager::HandleFarmerAction()
void cVillager::HandleFarmerEndCountDown()
void cVillager::HandleFarmerPlaceCrops()
{
// Check if there is still farmland at the spot where the crops were.
if (m_World->GetBlock(m_CropsPos.x, m_CropsPos.y - 1, m_CropsPos.z) == E_BLOCK_FARMLAND)

View File

@ -34,17 +34,24 @@ public:
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
// cVillager functions
/** return true if the given blocktype are: crops, potatoes or carrots.*/
bool IsBlockFarmable(BLOCKTYPE a_BlockType);
//////////////////////////////////////////////////////////////////
// Farmer functions
void HandleFarmerAttemptSpecialAction();
void HandleFarmerAction();
void HandleFarmerEndCountDown();
/** It searches in a 11x7x11 area for crops. If it found some it will navigate to them.*/
void HandleFarmerPrepareFarmCrops();
/** Looks if the farmer has reached it's destination, and if it's still crops and the destination is closer then 2 blocks it will harvest them.*/
void HandleFarmerTryHarvestCrops();
/** Replaces the crops he harvested.*/
void HandleFarmerPlaceCrops();
// Get and set functions.
int GetVilType(void) const { return m_Type; }
Vector3i GetCropsPos(void) const { return m_CropsPos; }
bool DoesHaveActionActivated(void) const { return m_VillagerAction; }
int GetVilType(void) const { return m_Type; }
Vector3i GetCropsPos(void) const { return m_CropsPos; }
bool DoesHaveActionActivated(void) const { return m_VillagerAction; }
private: