Entities now bail out of ticks if destroyed (#3363)
This commit is contained in:
parent
5625598afa
commit
90be4e7efd
|
@ -180,6 +180,11 @@ void cArrowEntity::CollectedBy(cPlayer & a_Dest)
|
||||||
void cArrowEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cArrowEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_Timer += a_Dt;
|
m_Timer += a_Dt;
|
||||||
|
|
||||||
if (m_bIsCollected)
|
if (m_bIsCollected)
|
||||||
|
|
|
@ -102,6 +102,11 @@ void cBoat::OnRightClicked(cPlayer & a_Player)
|
||||||
void cBoat::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cBoat::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
BroadcastMovementUpdate();
|
BroadcastMovementUpdate();
|
||||||
|
|
||||||
SetSpeed(GetSpeed() * 0.97); // Slowly decrease the speed
|
SetSpeed(GetSpeed() * 0.97); // Slowly decrease the speed
|
||||||
|
|
|
@ -65,6 +65,11 @@ void cFireworkEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_C
|
||||||
void cFireworkEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cFireworkEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_TicksToExplosion <= 0)
|
if (m_TicksToExplosion <= 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1264,6 +1264,11 @@ void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player)
|
||||||
void cMinecartWithFurnace::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cMinecartWithFurnace::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_IsFueled)
|
if (m_IsFueled)
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,7 +111,11 @@ void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
m_World->ForEachEntityInBox(cBoundingBox(GetPosition(), GetWidth(), GetHeight()), Callback);
|
m_World->ForEachEntityInBox(cBoundingBox(GetPosition(), GetWidth(), GetHeight()), Callback);
|
||||||
|
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
HandleFalling();
|
HandleFalling();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,11 @@ void cPickup::SpawnOn(cClientHandle & a_Client)
|
||||||
void cPickup::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cPickup::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
BroadcastMovementUpdate(); // Notify clients of position
|
BroadcastMovementUpdate(); // Notify clients of position
|
||||||
|
|
||||||
m_Timer += a_Dt;
|
m_Timer += a_Dt;
|
||||||
|
|
|
@ -369,6 +369,11 @@ AString cProjectileEntity::GetMCAClassName(void) const
|
||||||
void cProjectileEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cProjectileEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
BroadcastMovementUpdate();
|
BroadcastMovementUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,11 @@ void cTNTEntity::Explode(void)
|
||||||
void cTNTEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cTNTEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
BroadcastMovementUpdate();
|
BroadcastMovementUpdate();
|
||||||
|
|
||||||
m_FuseTicks -= 1;
|
m_FuseTicks -= 1;
|
||||||
|
|
|
@ -52,6 +52,11 @@ void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity, cChunk & a_Chunk)
|
||||||
void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_EMState == CHASING)
|
if (m_EMState == CHASING)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,11 @@ cCaveSpider::cCaveSpider(void) :
|
||||||
void cCaveSpider::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cCaveSpider::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_EMPersonality = (GetWorld()->GetTimeOfDay() < (12000 + 1000)) ? PASSIVE : AGGRESSIVE;
|
m_EMPersonality = (GetWorld()->GetTimeOfDay() < (12000 + 1000)) ? PASSIVE : AGGRESSIVE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,11 @@ cChicken::cChicken(void) :
|
||||||
void cChicken::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cChicken::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsBaby())
|
if (IsBaby())
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,11 @@ cCreeper::cCreeper(void) :
|
||||||
void cCreeper::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cCreeper::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((GetTarget() == nullptr) || (!TargetIsInRange() && !m_BurnedWithFlintAndSteel))
|
if ((GetTarget() == nullptr) || (!TargetIsInRange() && !m_BurnedWithFlintAndSteel))
|
||||||
{
|
{
|
||||||
|
|
|
@ -189,6 +189,11 @@ bool cEnderman::CheckLight()
|
||||||
void cEnderman::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cEnderman::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO take damage in rain
|
// TODO take damage in rain
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,11 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
|
||||||
void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_bIsMouthOpen)
|
if (!m_bIsMouthOpen)
|
||||||
{
|
{
|
||||||
|
|
|
@ -231,6 +231,11 @@ void cMonster::StopMovingToPosition()
|
||||||
void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
GET_AND_VERIFY_CURRENT_CHUNK(Chunk, POSX_TOINT, POSZ_TOINT);
|
GET_AND_VERIFY_CURRENT_CHUNK(Chunk, POSX_TOINT, POSZ_TOINT);
|
||||||
|
|
||||||
ASSERT((GetTarget() == nullptr) || (GetTarget()->IsPawn() && (GetTarget()->GetWorld() == GetWorld())));
|
ASSERT((GetTarget() == nullptr) || (GetTarget()->IsPawn() && (GetTarget()->GetWorld() == GetWorld())));
|
||||||
|
|
|
@ -81,6 +81,11 @@ void cPassiveMonster::Destroyed()
|
||||||
void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_EMState == ESCAPING)
|
if (m_EMState == ESCAPING)
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,6 +85,11 @@ void cPig::OnRightClicked(cPlayer & a_Player)
|
||||||
void cPig::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cPig::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If the attachee player is holding a carrot-on-stick, let them drive this pig:
|
// If the attachee player is holding a carrot-on-stick, let them drive this pig:
|
||||||
if (m_bIsSaddled && (m_Attachee != nullptr))
|
if (m_bIsSaddled && (m_Attachee != nullptr))
|
||||||
|
|
|
@ -88,6 +88,11 @@ void cSheep::OnRightClicked(cPlayer & a_Player)
|
||||||
void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
int PosX = POSX_TOINT;
|
int PosX = POSX_TOINT;
|
||||||
int PosY = POSY_TOINT - 1;
|
int PosY = POSY_TOINT - 1;
|
||||||
int PosZ = POSZ_TOINT;
|
int PosZ = POSZ_TOINT;
|
||||||
|
|
|
@ -30,6 +30,11 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||||
void cSnowGolem::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cSnowGolem::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (IsBiomeNoDownfall(m_World->GetBiomeAt(POSX_TOINT, POSZ_TOINT)))
|
if (IsBiomeNoDownfall(m_World->GetBiomeAt(POSX_TOINT, POSZ_TOINT)))
|
||||||
{
|
{
|
||||||
TakeDamage(*this);
|
TakeDamage(*this);
|
||||||
|
|
|
@ -54,6 +54,11 @@ bool cVillager::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||||
void cVillager::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cVillager::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_ActionCountDown > -1)
|
if (m_ActionCountDown > -1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,6 +69,11 @@ bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||||
void cWither::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
void cWither::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_WitherInvulnerableTicks > 0)
|
if (m_WitherInvulnerableTicks > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -263,6 +263,12 @@ void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsTicking())
|
||||||
|
{
|
||||||
|
// The base class tick destroyed us
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (GetTarget() == nullptr)
|
if (GetTarget() == nullptr)
|
||||||
{
|
{
|
||||||
cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), static_cast<float>(m_SightDistance));
|
cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), static_cast<float>(m_SightDistance));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user