diff options
author | Tycho <work.tycho+git@gmail.com> | 2015-01-16 15:38:21 +0100 |
---|---|---|
committer | Tycho <work.tycho+git@gmail.com> | 2015-01-16 15:38:21 +0100 |
commit | bfe1960191e902013b5ac75e8a3a487496d63bb9 (patch) | |
tree | 85a8f57b7bcc1dcd17c9f315e0b957d91c6fef86 /src/Mobs/Monster.cpp | |
parent | Converted cPickupEntity to std::chrono (diff) | |
download | cuberite-bfe1960191e902013b5ac75e8a3a487496d63bb9.tar cuberite-bfe1960191e902013b5ac75e8a3a487496d63bb9.tar.gz cuberite-bfe1960191e902013b5ac75e8a3a487496d63bb9.tar.bz2 cuberite-bfe1960191e902013b5ac75e8a3a487496d63bb9.tar.lz cuberite-bfe1960191e902013b5ac75e8a3a487496d63bb9.tar.xz cuberite-bfe1960191e902013b5ac75e8a3a487496d63bb9.tar.zst cuberite-bfe1960191e902013b5ac75e8a3a487496d63bb9.zip |
Diffstat (limited to 'src/Mobs/Monster.cpp')
-rw-r--r-- | src/Mobs/Monster.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 30bbd0ff2..6e07bfbb6 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -259,8 +259,8 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) if (m_Health <= 0) { // The mob is dead, but we're still animating the "puff" they leave when they die - m_DestroyTimer += a_Dt.count() / 1000; - if (m_DestroyTimer > 1) + m_DestroyTimer += a_Dt; + if (m_DestroyTimer > std::chrono::seconds(1)) { Destroy(true); } @@ -345,18 +345,18 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) case IDLE: { // If enemy passive we ignore checks for player visibility - InStateIdle(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count()); + InStateIdle(a_Dt); break; } case CHASING: { // If we do not see a player anymore skip chasing action - InStateChasing(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count()); + InStateChasing(a_Dt); break; } case ESCAPING: { - InStateEscaping(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count()); + InStateEscaping(a_Dt); break; } @@ -555,7 +555,7 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI) { m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward); } - m_DestroyTimer = 0; + m_DestroyTimer = std::chrono::milliseconds(0); } @@ -638,7 +638,7 @@ void cMonster::EventLosePlayer(void) -void cMonster::InStateIdle(float a_Dt) +void cMonster::InStateIdle(std::chrono::milliseconds a_Dt) { if (m_bMovingToDestination) { @@ -647,11 +647,11 @@ void cMonster::InStateIdle(float a_Dt) m_IdleInterval += a_Dt; - if (m_IdleInterval > 1) + if (m_IdleInterval > std::chrono::seconds(1)) { // At this interval the results are predictable int rem = m_World->GetTickRandomNumber(6) + 1; - m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds + m_IdleInterval -= std::chrono::seconds(1); // So nothing gets dropped when the server hangs for a few seconds Vector3d Dist; Dist.x = (double)m_World->GetTickRandomNumber(10) - 5; @@ -678,7 +678,7 @@ void cMonster::InStateIdle(float a_Dt) // What to do if in Chasing State // This state should always be defined in each child class -void cMonster::InStateChasing(float a_Dt) +void cMonster::InStateChasing(std::chrono::milliseconds a_Dt) { UNUSED(a_Dt); } @@ -688,7 +688,7 @@ void cMonster::InStateChasing(float a_Dt) // What to do if in Escaping State -void cMonster::InStateEscaping(float a_Dt) +void cMonster::InStateEscaping(std::chrono::milliseconds a_Dt) { UNUSED(a_Dt); |