Initial convertion of a_Dt to std::chrono
also refactored cWorld::m_WorldAge and cWorld::m_TimeOfDay
This commit is contained in:
parent
4f75b94c99
commit
2a9664d6ca
@ -839,6 +839,13 @@ void cLuaState::Push(void * a_Ptr)
|
|||||||
m_NumCurrentFunctionArgs += 1;
|
m_NumCurrentFunctionArgs += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cLuaState::Push(std::chrono::milliseconds a_Value)
|
||||||
|
{
|
||||||
|
ASSERT(IsValid());
|
||||||
|
|
||||||
|
tolua_pushnumber(m_LuaState, a_Value.count());
|
||||||
|
m_NumCurrentFunctionArgs += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -217,6 +217,7 @@ public:
|
|||||||
void Push(Vector3d * a_Vector);
|
void Push(Vector3d * a_Vector);
|
||||||
void Push(Vector3i * a_Vector);
|
void Push(Vector3i * a_Vector);
|
||||||
void Push(void * a_Ptr);
|
void Push(void * a_Ptr);
|
||||||
|
void Push(std::chrono::milliseconds a_time);
|
||||||
|
|
||||||
/** Retrieve value at a_StackPos, if it is a valid bool. If not, a_Value is unchanged */
|
/** Retrieve value at a_StackPos, if it is a valid bool. If not, a_Value is unchanged */
|
||||||
void GetStackValue(int a_StackPos, bool & a_Value);
|
void GetStackValue(int a_StackPos, bool & a_Value);
|
||||||
|
@ -104,7 +104,7 @@ public:
|
|||||||
virtual bool OnWeatherChanged (cWorld & a_World) = 0;
|
virtual bool OnWeatherChanged (cWorld & a_World) = 0;
|
||||||
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) = 0;
|
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) = 0;
|
||||||
virtual bool OnWorldStarted (cWorld & a_World) = 0;
|
virtual bool OnWorldStarted (cWorld & a_World) = 0;
|
||||||
virtual bool OnWorldTick (cWorld & a_World, float a_Dt, int a_LastTickDurationMSec) = 0;
|
virtual bool OnWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec) = 0;
|
||||||
|
|
||||||
/** Handles the command split into a_Split, issued by player a_Player.
|
/** Handles the command split into a_Split, issued by player a_Player.
|
||||||
Command permissions have already been checked.
|
Command permissions have already been checked.
|
||||||
|
@ -1430,7 +1430,7 @@ bool cPluginLua::OnWorldStarted(cWorld & a_World)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cPluginLua::OnWorldTick(cWorld & a_World, float a_Dt, int a_LastTickDurationMSec)
|
bool cPluginLua::OnWorldTick(cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CriticalSection);
|
cCSLock Lock(m_CriticalSection);
|
||||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WORLD_TICK];
|
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WORLD_TICK];
|
||||||
|
@ -128,7 +128,7 @@ public:
|
|||||||
virtual bool OnWeatherChanged (cWorld & a_World) override;
|
virtual bool OnWeatherChanged (cWorld & a_World) override;
|
||||||
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) override;
|
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) override;
|
||||||
virtual bool OnWorldStarted (cWorld & a_World) override;
|
virtual bool OnWorldStarted (cWorld & a_World) override;
|
||||||
virtual bool OnWorldTick (cWorld & a_World, float a_Dt, int a_LastTickDurationMSec) override;
|
virtual bool OnWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec) override;
|
||||||
|
|
||||||
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player) override;
|
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player) override;
|
||||||
|
|
||||||
|
@ -1394,7 +1394,7 @@ bool cPluginManager::CallHookWorldStarted(cWorld & a_World)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt, int a_LastTickDurationMSec)
|
bool cPluginManager::CallHookWorldTick(cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
|
||||||
{
|
{
|
||||||
FIND_HOOK(HOOK_WORLD_TICK);
|
FIND_HOOK(HOOK_WORLD_TICK);
|
||||||
VERIFY_HOOK;
|
VERIFY_HOOK;
|
||||||
|
@ -237,7 +237,7 @@ public:
|
|||||||
bool CallHookWeatherChanged (cWorld & a_World);
|
bool CallHookWeatherChanged (cWorld & a_World);
|
||||||
bool CallHookWeatherChanging (cWorld & a_World, eWeather & a_NewWeather);
|
bool CallHookWeatherChanging (cWorld & a_World, eWeather & a_NewWeather);
|
||||||
bool CallHookWorldStarted (cWorld & a_World);
|
bool CallHookWorldStarted (cWorld & a_World);
|
||||||
bool CallHookWorldTick (cWorld & a_World, float a_Dt, int a_LastTickDurationMSec);
|
bool CallHookWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec);
|
||||||
|
|
||||||
bool DisablePlugin(const AString & a_PluginName); // tolua_export
|
bool DisablePlugin(const AString & a_PluginName); // tolua_export
|
||||||
bool LoadPlugin (const AString & a_PluginName); // tolua_export
|
bool LoadPlugin (const AString & a_PluginName); // tolua_export
|
||||||
|
@ -266,7 +266,7 @@ void cBeaconEntity::GiveEffects(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cBeaconEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
bool cBeaconEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
// Update the beacon every 4 seconds
|
// Update the beacon every 4 seconds
|
||||||
if ((GetWorld()->GetWorldAge() % 80) == 0)
|
if ((GetWorld()->GetWorldAge() % 80) == 0)
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
|
|
||||||
// cBlockEntity overrides:
|
// cBlockEntity overrides:
|
||||||
virtual void SendTo(cClientHandle & a_Client) override;
|
virtual void SendTo(cClientHandle & a_Client) override;
|
||||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void UsedBy(cPlayer * a_Player) override;
|
virtual void UsedBy(cPlayer * a_Player) override;
|
||||||
|
|
||||||
/** Modify the beacon level. (It is needed to load the beacon corectly) */
|
/** Modify the beacon level. (It is needed to load the beacon corectly) */
|
||||||
|
@ -110,7 +110,7 @@ public:
|
|||||||
virtual void SendTo(cClientHandle & a_Client) = 0;
|
virtual void SendTo(cClientHandle & a_Client) = 0;
|
||||||
|
|
||||||
/// Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. By default does nothing.
|
/// Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. By default does nothing.
|
||||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk)
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
UNUSED(a_Dt);
|
UNUSED(a_Dt);
|
||||||
return false;
|
return false;
|
||||||
|
@ -125,7 +125,7 @@ void cCommandBlockEntity::SetRedstonePower(bool a_IsPowered)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cCommandBlockEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
bool cCommandBlockEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
UNUSED(a_Dt);
|
UNUSED(a_Dt);
|
||||||
UNUSED(a_Chunk);
|
UNUSED(a_Chunk);
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
/// Creates a new empty command block entity
|
/// Creates a new empty command block entity
|
||||||
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
|
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
|
||||||
|
|
||||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void SendTo(cClientHandle & a_Client) override;
|
virtual void SendTo(cClientHandle & a_Client) override;
|
||||||
virtual void UsedBy(cPlayer * a_Player) override;
|
virtual void UsedBy(cPlayer * a_Player) override;
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ void cDropSpenserEntity::SetRedstonePower(bool a_IsPowered)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cDropSpenserEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
bool cDropSpenserEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
UNUSED(a_Dt);
|
UNUSED(a_Dt);
|
||||||
if (!m_ShouldDropSpense)
|
if (!m_ShouldDropSpense)
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
virtual ~cDropSpenserEntity();
|
virtual ~cDropSpenserEntity();
|
||||||
|
|
||||||
// cBlockEntity overrides:
|
// cBlockEntity overrides:
|
||||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void SendTo(cClientHandle & a_Client) override;
|
virtual void SendTo(cClientHandle & a_Client) override;
|
||||||
virtual void UsedBy(cPlayer * a_Player) override;
|
virtual void UsedBy(cPlayer * a_Player) override;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ bool cFurnaceEntity::ContinueCooking(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cFurnaceEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
bool cFurnaceEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
UNUSED(a_Dt);
|
UNUSED(a_Dt);
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
// cBlockEntity overrides:
|
// cBlockEntity overrides:
|
||||||
virtual void SendTo(cClientHandle & a_Client) override;
|
virtual void SendTo(cClientHandle & a_Client) override;
|
||||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void UsedBy(cPlayer * a_Player) override;
|
virtual void UsedBy(cPlayer * a_Player) override;
|
||||||
virtual void Destroy() override
|
virtual void Destroy() override
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ bool cHopperEntity::GetOutputBlockPos(NIBBLETYPE a_BlockMeta, int & a_OutputX, i
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cHopperEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
bool cHopperEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
UNUSED(a_Dt);
|
UNUSED(a_Dt);
|
||||||
Int64 CurrentTick = a_Chunk.GetWorld()->GetWorldAge();
|
Int64 CurrentTick = a_Chunk.GetWorld()->GetWorldAge();
|
||||||
|
@ -48,7 +48,7 @@ protected:
|
|||||||
Int64 m_LastMoveItemsOutTick;
|
Int64 m_LastMoveItemsOutTick;
|
||||||
|
|
||||||
// cBlockEntity overrides:
|
// cBlockEntity overrides:
|
||||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void SendTo(cClientHandle & a_Client) override;
|
virtual void SendTo(cClientHandle & a_Client) override;
|
||||||
virtual void UsedBy(cPlayer * a_Player) override;
|
virtual void UsedBy(cPlayer * a_Player) override;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ void cMobSpawnerEntity::UpdateActiveState(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cMobSpawnerEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
bool cMobSpawnerEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
// Update the active flag every 5 seconds
|
// Update the active flag every 5 seconds
|
||||||
if ((m_World->GetWorldAge() % 100) == 0)
|
if ((m_World->GetWorldAge() % 100) == 0)
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
|
|
||||||
virtual void SendTo(cClientHandle & a_Client) override;
|
virtual void SendTo(cClientHandle & a_Client) override;
|
||||||
virtual void UsedBy(cPlayer * a_Player) override;
|
virtual void UsedBy(cPlayer * a_Player) override;
|
||||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
|
@ -601,7 +601,7 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::Tick(float a_Dt)
|
void cChunk::Tick(std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
BroadcastPendingBlockChanges();
|
BroadcastPendingBlockChanges();
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ public:
|
|||||||
/** Try to Spawn Monsters inside chunk */
|
/** Try to Spawn Monsters inside chunk */
|
||||||
void SpawnMobs(cMobSpawner& a_MobSpawner);
|
void SpawnMobs(cMobSpawner& a_MobSpawner);
|
||||||
|
|
||||||
void Tick(float a_Dt);
|
void Tick(std::chrono::milliseconds a_Dt);
|
||||||
|
|
||||||
/** Ticks a single block. Used by cWorld::TickQueuedBlocks() to tick the queued blocks */
|
/** Ticks a single block. Used by cWorld::TickQueuedBlocks() to tick the queued blocks */
|
||||||
void TickBlock(int a_RelX, int a_RelY, int a_RelZ);
|
void TickBlock(int a_RelX, int a_RelY, int a_RelZ);
|
||||||
|
@ -2720,7 +2720,7 @@ void cChunkMap::SpawnMobs(cMobSpawner& a_MobSpawner)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunkMap::Tick(float a_Dt)
|
void cChunkMap::Tick(std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSLayers);
|
cCSLock Lock(m_CSLayers);
|
||||||
for (cChunkLayerList::iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr)
|
for (cChunkLayerList::iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr)
|
||||||
@ -2948,7 +2948,7 @@ void cChunkMap::cChunkLayer::SpawnMobs(cMobSpawner& a_MobSpawner)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunkMap::cChunkLayer::Tick(float a_Dt)
|
void cChunkMap::cChunkLayer::Tick(std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++)
|
for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++)
|
||||||
{
|
{
|
||||||
|
@ -348,7 +348,7 @@ public:
|
|||||||
/** Try to Spawn Monsters inside all Chunks */
|
/** Try to Spawn Monsters inside all Chunks */
|
||||||
void SpawnMobs(cMobSpawner& a_MobSpawner);
|
void SpawnMobs(cMobSpawner& a_MobSpawner);
|
||||||
|
|
||||||
void Tick(float a_Dt);
|
void Tick(std::chrono::milliseconds a_Dt);
|
||||||
|
|
||||||
/** Ticks a single block. Used by cWorld::TickQueuedBlocks() to tick the queued blocks */
|
/** Ticks a single block. Used by cWorld::TickQueuedBlocks() to tick the queued blocks */
|
||||||
void TickBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
|
void TickBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||||
@ -415,7 +415,7 @@ private:
|
|||||||
/** Try to Spawn Monsters inside all Chunks */
|
/** Try to Spawn Monsters inside all Chunks */
|
||||||
void SpawnMobs(cMobSpawner& a_MobSpawner);
|
void SpawnMobs(cMobSpawner& a_MobSpawner);
|
||||||
|
|
||||||
void Tick(float a_Dt);
|
void Tick(std::chrono::milliseconds a_Dt);
|
||||||
|
|
||||||
void RemoveClient(cClientHandle * a_Client);
|
void RemoveClient(cClientHandle * a_Client);
|
||||||
|
|
||||||
|
@ -174,10 +174,10 @@ void cArrowEntity::CollectedBy(cPlayer & a_Dest)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cArrowEntity::Tick(float 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);
|
||||||
m_Timer += a_Dt;
|
m_Timer += a_Dt.count();
|
||||||
|
|
||||||
if (m_bIsCollected)
|
if (m_bIsCollected)
|
||||||
{
|
{
|
||||||
@ -209,7 +209,7 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_HitGroundTimer += a_Dt;
|
m_HitGroundTimer += a_Dt.count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +103,6 @@ protected:
|
|||||||
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
|
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
|
||||||
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
||||||
virtual void CollectedBy(cPlayer & a_Player) override;
|
virtual void CollectedBy(cPlayer & a_Player) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
}; // tolua_export
|
}; // tolua_export
|
||||||
|
@ -91,7 +91,7 @@ void cBoat::OnRightClicked(cPlayer & a_Player)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cBoat::Tick(float 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);
|
||||||
BroadcastMovementUpdate();
|
BroadcastMovementUpdate();
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||||
virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
|
virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override;
|
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override;
|
||||||
|
|
||||||
cBoat(double a_X, double a_Y, double a_Z);
|
cBoat(double a_X, double a_Y, double a_Z);
|
||||||
|
@ -29,7 +29,7 @@ void cEnderCrystal::SpawnOn(cClientHandle & a_ClientHandle)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cEnderCrystal::Tick(float a_Dt, cChunk & a_Chunk)
|
void cEnderCrystal::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
UNUSED(a_Dt);
|
UNUSED(a_Dt);
|
||||||
// No further processing (physics e.t.c.) is needed
|
// No further processing (physics e.t.c.) is needed
|
||||||
|
@ -23,7 +23,7 @@ private:
|
|||||||
|
|
||||||
// cEntity overrides:
|
// cEntity overrides:
|
||||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
||||||
|
|
||||||
}; // tolua_export
|
}; // tolua_export
|
||||||
|
@ -772,7 +772,7 @@ void cEntity::SetHealth(int a_Health)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
void cEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
m_TicksAlive++;
|
m_TicksAlive++;
|
||||||
|
|
||||||
@ -841,7 +841,7 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
int BlockX = POSX_TOINT;
|
int BlockX = POSX_TOINT;
|
||||||
int BlockY = POSY_TOINT;
|
int BlockY = POSY_TOINT;
|
||||||
@ -851,15 +851,15 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
|||||||
GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, BlockX, BlockZ)
|
GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, BlockX, BlockZ)
|
||||||
|
|
||||||
// TODO Add collision detection with entities.
|
// TODO Add collision detection with entities.
|
||||||
a_Dt /= 1000; // Convert from msec to sec
|
auto DtSec = std::chrono::duration_cast<std::chrono::duration<double>>(a_Dt);
|
||||||
Vector3d NextPos = Vector3d(GetPosX(), GetPosY(), GetPosZ());
|
Vector3d NextPos = Vector3d(GetPosX(), GetPosY(), GetPosZ());
|
||||||
Vector3d NextSpeed = Vector3d(GetSpeedX(), GetSpeedY(), GetSpeedZ());
|
Vector3d NextSpeed = Vector3d(GetSpeedX(), GetSpeedY(), GetSpeedZ());
|
||||||
|
|
||||||
if ((BlockY >= cChunkDef::Height) || (BlockY < 0))
|
if ((BlockY >= cChunkDef::Height) || (BlockY < 0))
|
||||||
{
|
{
|
||||||
// Outside of the world
|
// Outside of the world
|
||||||
AddSpeedY(m_Gravity * a_Dt);
|
AddSpeedY(m_Gravity * DtSec.count());
|
||||||
AddPosition(GetSpeed() * a_Dt);
|
AddPosition(GetSpeed() * DtSec.count());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -930,8 +930,8 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
|||||||
float fallspeed;
|
float fallspeed;
|
||||||
if (IsBlockWater(BlockIn))
|
if (IsBlockWater(BlockIn))
|
||||||
{
|
{
|
||||||
fallspeed = m_Gravity * a_Dt / 3; // Fall 3x slower in water
|
fallspeed = m_Gravity * DtSec.count() / 3; // Fall 3x slower in water
|
||||||
ApplyFriction(NextSpeed, 0.7, a_Dt);
|
ApplyFriction(NextSpeed, 0.7, DtSec.count());
|
||||||
}
|
}
|
||||||
else if (BlockIn == E_BLOCK_COBWEB)
|
else if (BlockIn == E_BLOCK_COBWEB)
|
||||||
{
|
{
|
||||||
@ -941,13 +941,13 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Normal gravity
|
// Normal gravity
|
||||||
fallspeed = m_Gravity * a_Dt;
|
fallspeed = m_Gravity * DtSec.count();
|
||||||
}
|
}
|
||||||
NextSpeed.y += fallspeed;
|
NextSpeed.y += fallspeed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ApplyFriction(NextSpeed, 0.7, a_Dt);
|
ApplyFriction(NextSpeed, 0.7, DtSec.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust X and Z speed for COBWEB temporary. This speed modification should be handled inside block handlers since we
|
// Adjust X and Z speed for COBWEB temporary. This speed modification should be handled inside block handlers since we
|
||||||
@ -1002,14 +1002,14 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
|||||||
{
|
{
|
||||||
cTracer Tracer(GetWorld());
|
cTracer Tracer(GetWorld());
|
||||||
// Distance traced is an integer, so we round up from the distance we should go (Speed * Delta), else we will encounter collision detection failurse
|
// Distance traced is an integer, so we round up from the distance we should go (Speed * Delta), else we will encounter collision detection failurse
|
||||||
int DistanceToTrace = (int)(ceil((NextSpeed * a_Dt).SqrLength()) * 2);
|
int DistanceToTrace = (int)(ceil((NextSpeed * DtSec.count()).SqrLength()) * 2);
|
||||||
bool HasHit = Tracer.Trace(NextPos, NextSpeed, DistanceToTrace);
|
bool HasHit = Tracer.Trace(NextPos, NextSpeed, DistanceToTrace);
|
||||||
|
|
||||||
if (HasHit)
|
if (HasHit)
|
||||||
{
|
{
|
||||||
// Oh noez! We hit something: verify that the (hit position - current) was smaller or equal to the (position that we should travel without obstacles - current)
|
// Oh noez! We hit something: verify that the (hit position - current) was smaller or equal to the (position that we should travel without obstacles - current)
|
||||||
// This is because previously, we traced with a length that was rounded up (due to integer limitations), and in the case that something was hit, we don't want to overshoot our projected movement
|
// This is because previously, we traced with a length that was rounded up (due to integer limitations), and in the case that something was hit, we don't want to overshoot our projected movement
|
||||||
if ((Tracer.RealHit - NextPos).SqrLength() <= (NextSpeed * a_Dt).SqrLength())
|
if ((Tracer.RealHit - NextPos).SqrLength() <= (NextSpeed * DtSec.count()).SqrLength())
|
||||||
{
|
{
|
||||||
// Block hit was within our projected path
|
// Block hit was within our projected path
|
||||||
// Begin by stopping movement in the direction that we hit something. The Normal is the line perpendicular to a 2D face and in this case, stores what block face was hit through either -1 or 1.
|
// Begin by stopping movement in the direction that we hit something. The Normal is the line perpendicular to a 2D face and in this case, stores what block face was hit through either -1 or 1.
|
||||||
@ -1044,13 +1044,13 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
|||||||
// and that this piece of software will come to be hailed as the epitome of performance and functionality in C++, never before seen, and of such a like that will never
|
// and that this piece of software will come to be hailed as the epitome of performance and functionality in C++, never before seen, and of such a like that will never
|
||||||
// be henceforth seen again in the time of programmers and man alike
|
// be henceforth seen again in the time of programmers and man alike
|
||||||
// </&sensationalist>
|
// </&sensationalist>
|
||||||
NextPos += (NextSpeed * a_Dt);
|
NextPos += (NextSpeed * DtSec.count());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We didn't hit anything, so move =]
|
// We didn't hit anything, so move =]
|
||||||
NextPos += (NextSpeed * a_Dt);
|
NextPos += (NextSpeed * DtSec.count());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,10 +326,10 @@ public:
|
|||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk);
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk);
|
||||||
|
|
||||||
/// Handles the physics of the entity - updates position based on speed, updates speed based on environment
|
/// Handles the physics of the entity - updates position based on speed, updates speed based on environment
|
||||||
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk);
|
virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk);
|
||||||
|
|
||||||
/// Updates the state related to this entity being on fire
|
/// Updates the state related to this entity being on fire
|
||||||
virtual void TickBurning(cChunk & a_Chunk);
|
virtual void TickBurning(cChunk & a_Chunk);
|
||||||
|
@ -42,7 +42,7 @@ void cExpOrb::SpawnOn(cClientHandle & a_Client)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
|
void cExpOrb::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
cPlayer * a_ClosestPlayer(m_World->FindClosestPlayer(Vector3f(GetPosition()), 5));
|
cPlayer * a_ClosestPlayer(m_World->FindClosestPlayer(Vector3f(GetPosition()), 5));
|
||||||
if (a_ClosestPlayer != nullptr)
|
if (a_ClosestPlayer != nullptr)
|
||||||
@ -69,7 +69,7 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
HandlePhysics(a_Dt, a_Chunk);
|
HandlePhysics(a_Dt, a_Chunk);
|
||||||
|
|
||||||
m_Timer += a_Dt;
|
m_Timer += a_Dt.count();
|
||||||
if (m_Timer >= 1000 * 60 * 5) // 5 minutes
|
if (m_Timer >= 1000 * 60 * 5) // 5 minutes
|
||||||
{
|
{
|
||||||
Destroy(true);
|
Destroy(true);
|
||||||
|
@ -22,7 +22,7 @@ public:
|
|||||||
cExpOrb(const Vector3d & a_Pos, int a_Reward);
|
cExpOrb(const Vector3d & a_Pos, int a_Reward);
|
||||||
|
|
||||||
// Override functions
|
// Override functions
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||||
|
|
||||||
/** Returns the number of ticks that this entity has existed */
|
/** Returns the number of ticks that this entity has existed */
|
||||||
|
@ -31,7 +31,7 @@ void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
|
void cFallingBlock::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
// GetWorld()->BroadcastTeleportEntity(*this); // Test position
|
// GetWorld()->BroadcastTeleportEntity(*this); // Test position
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float MilliDt = a_Dt * 0.001f;
|
float MilliDt = a_Dt.count() * 0.001f;
|
||||||
AddSpeedY(MilliDt * -9.8f);
|
AddSpeedY(MilliDt * -9.8f);
|
||||||
AddPosition(GetSpeed() * MilliDt);
|
AddPosition(GetSpeed() * MilliDt);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
|
|
||||||
// cEntity overrides:
|
// cEntity overrides:
|
||||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BLOCKTYPE m_BlockType;
|
BLOCKTYPE m_BlockType;
|
||||||
|
@ -19,7 +19,7 @@ cFireworkEntity::cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, do
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
void cFireworkEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
int RelX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width;
|
int RelX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width;
|
||||||
int RelZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width;
|
int RelZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width;
|
||||||
@ -28,7 +28,7 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
|||||||
if ((PosY < 0) || (PosY >= cChunkDef::Height))
|
if ((PosY < 0) || (PosY >= cChunkDef::Height))
|
||||||
{
|
{
|
||||||
AddSpeedY(1);
|
AddSpeedY(1);
|
||||||
AddPosition(GetSpeed() * (a_Dt / 1000));
|
AddPosition(GetSpeed() * (a_Dt.count() / 1000));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,14 +53,14 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AddSpeedY(1);
|
AddSpeedY(1);
|
||||||
AddPosition(GetSpeed() * (a_Dt / 1000));
|
AddPosition(GetSpeed() * (a_Dt.count() / 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cFireworkEntity::Tick(float 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);
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
// cProjectileEntity overrides:
|
// cProjectileEntity overrides:
|
||||||
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
|
virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ void cFloater::SpawnOn(cClientHandle & a_Client)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
|
void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
HandlePhysics(a_Dt, a_Chunk);
|
HandlePhysics(a_Dt, a_Chunk);
|
||||||
if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())) && m_World->GetBlockMeta((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()) == 0)
|
if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())) && m_World->GetBlockMeta((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()) == 0)
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime);
|
cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime);
|
||||||
|
|
||||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
bool CanPickup(void) const { return m_CanPickupItem; }
|
bool CanPickup(void) const { return m_CanPickupItem; }
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override {}
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override {}
|
||||||
|
|
||||||
eBlockFace m_Facing;
|
eBlockFace m_Facing;
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
void cMinecart::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
if (IsDestroyed()) // Mainly to stop detector rails triggering again after minecart is dead
|
if (IsDestroyed()) // Mainly to stop detector rails triggering again after minecart is dead
|
||||||
{
|
{
|
||||||
@ -165,19 +165,19 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
|||||||
|
|
||||||
switch (InsideType)
|
switch (InsideType)
|
||||||
{
|
{
|
||||||
case E_BLOCK_RAIL: HandleRailPhysics(InsideMeta, a_Dt); break;
|
case E_BLOCK_RAIL: HandleRailPhysics(InsideMeta, a_Dt.count()); break;
|
||||||
case E_BLOCK_ACTIVATOR_RAIL: break;
|
case E_BLOCK_ACTIVATOR_RAIL: break;
|
||||||
case E_BLOCK_POWERED_RAIL: HandlePoweredRailPhysics(InsideMeta); break;
|
case E_BLOCK_POWERED_RAIL: HandlePoweredRailPhysics(InsideMeta); break;
|
||||||
case E_BLOCK_DETECTOR_RAIL:
|
case E_BLOCK_DETECTOR_RAIL:
|
||||||
{
|
{
|
||||||
HandleDetectorRailPhysics(InsideMeta, a_Dt);
|
HandleDetectorRailPhysics(InsideMeta, a_Dt.count());
|
||||||
WasDetectorRail = true;
|
WasDetectorRail = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: VERIFY(!"Unhandled rail type despite checking if block was rail!"); break;
|
default: VERIFY(!"Unhandled rail type despite checking if block was rail!"); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddPosition(GetSpeed() * (a_Dt / 1000)); // Commit changes; as we use our own engine when on rails, this needs to be done, whereas it is normally in Entity.cpp
|
AddPosition(GetSpeed() * (a_Dt.count() / 1000)); // Commit changes; as we use our own engine when on rails, this needs to be done, whereas it is normally in Entity.cpp
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1213,7 +1213,7 @@ void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cMinecartWithFurnace::Tick(float 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);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
|
|
||||||
// cEntity overrides:
|
// cEntity overrides:
|
||||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||||
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
|
virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
|
virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
|
||||||
virtual void Destroyed() override;
|
virtual void Destroyed() override;
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ public:
|
|||||||
|
|
||||||
// cEntity overrides:
|
// cEntity overrides:
|
||||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
// Set functions.
|
// Set functions.
|
||||||
void SetIsFueled(bool a_IsFueled, int a_FueledTimeLeft = -1) {m_IsFueled = a_IsFueled; m_FueledTimeLeft = a_FueledTimeLeft;}
|
void SetIsFueled(bool a_IsFueled, int a_FueledTimeLeft = -1) {m_IsFueled = a_IsFueled; m_FueledTimeLeft = a_FueledTimeLeft;}
|
||||||
|
@ -31,7 +31,7 @@ void cPainting::SpawnOn(cClientHandle & a_Client)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPainting::Tick(float a_Dt, cChunk & a_Chunk)
|
void cPainting::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
UNUSED(a_Dt);
|
UNUSED(a_Dt);
|
||||||
UNUSED(a_Chunk);
|
UNUSED(a_Chunk);
|
||||||
|
@ -31,7 +31,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
|
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
|
||||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override
|
virtual void KilledBy(TakeDamageInfo & a_TDI) override
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) :
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
|
void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
// Iterate through this entity's applied effects
|
// Iterate through this entity's applied effects
|
||||||
for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();)
|
for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();)
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
|
|
||||||
cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
|
cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
@ -110,12 +110,12 @@ void cPickup::SpawnOn(cClientHandle & a_Client)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPickup::Tick(float 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);
|
||||||
BroadcastMovementUpdate(); // Notify clients of position
|
BroadcastMovementUpdate(); // Notify clients of position
|
||||||
|
|
||||||
m_Timer += a_Dt;
|
m_Timer += a_Dt.count();
|
||||||
|
|
||||||
if (!m_bCollected)
|
if (!m_bCollected)
|
||||||
{
|
{
|
||||||
@ -142,7 +142,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
{
|
{
|
||||||
m_bCollected = true;
|
m_bCollected = true;
|
||||||
m_Timer = 0; // We have to reset the timer.
|
m_Timer = 0; // We have to reset the timer.
|
||||||
m_Timer += a_Dt; // In case we have to destroy the pickup in the same tick.
|
m_Timer += a_Dt.count(); // In case we have to destroy the pickup in the same tick.
|
||||||
if (m_Timer > 500.f)
|
if (m_Timer > 500.f)
|
||||||
{
|
{
|
||||||
Destroy(true);
|
Destroy(true);
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
|
|
||||||
bool CollectedBy(cPlayer & a_Dest); // tolua_export
|
bool CollectedBy(cPlayer & a_Dest); // tolua_export
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
/** Returns the number of ticks that this entity has existed */
|
/** Returns the number of ticks that this entity has existed */
|
||||||
int GetAge(void) const { return static_cast<int>(m_Timer / 50); } // tolua_export
|
int GetAge(void) const { return static_cast<int>(m_Timer / 50); } // tolua_export
|
||||||
|
@ -191,7 +191,7 @@ void cPlayer::SpawnOn(cClientHandle & a_Client)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
|
void cPlayer::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
if (m_ClientHandle != nullptr)
|
if (m_ClientHandle != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -46,9 +46,9 @@ public:
|
|||||||
|
|
||||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); }
|
virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk &) override { UNUSED(a_Dt); }
|
||||||
|
|
||||||
/** Returns the curently equipped weapon; empty item if none */
|
/** Returns the curently equipped weapon; empty item if none */
|
||||||
virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); }
|
virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); }
|
||||||
|
@ -331,7 +331,7 @@ AString cProjectileEntity::GetMCAClassName(void) const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProjectileEntity::Tick(float 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);
|
||||||
|
|
||||||
@ -346,7 +346,7 @@ void cProjectileEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
void cProjectileEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
if (m_IsInGround)
|
if (m_IsInGround)
|
||||||
{
|
{
|
||||||
|
@ -118,8 +118,8 @@ protected:
|
|||||||
bool m_IsInGround;
|
bool m_IsInGround;
|
||||||
|
|
||||||
// cEntity overrides:
|
// cEntity overrides:
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
|
virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||||
|
|
||||||
} ; // tolua_export
|
} ; // tolua_export
|
||||||
|
@ -58,7 +58,7 @@ protected:
|
|||||||
// cProjectileEntity overrides:
|
// cProjectileEntity overrides:
|
||||||
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
|
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
|
||||||
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
||||||
virtual void Tick (float a_Dt, cChunk & a_Chunk) override
|
virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override
|
||||||
{
|
{
|
||||||
if (m_DestroyTimer > 0)
|
if (m_DestroyTimer > 0)
|
||||||
{
|
{
|
||||||
|
@ -50,7 +50,7 @@ void cTNTEntity::Explode(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cTNTEntity::Tick(float 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);
|
||||||
BroadcastMovementUpdate();
|
BroadcastMovementUpdate();
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
|
|
||||||
// cEntity overrides:
|
// cEntity overrides:
|
||||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cThrownEggEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
void cThrownEggEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
if (m_DestroyTimer > 0)
|
if (m_DestroyTimer > 0)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ protected:
|
|||||||
// cProjectileEntity overrides:
|
// cProjectileEntity overrides:
|
||||||
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
|
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
|
||||||
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
// Randomly decides whether to spawn a chicken where the egg lands.
|
// Randomly decides whether to spawn a chicken where the egg lands.
|
||||||
void TrySpawnChicken(const Vector3d & a_HitPos);
|
void TrySpawnChicken(const Vector3d & a_HitPos);
|
||||||
|
@ -46,7 +46,7 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cThrownEnderPearlEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
void cThrownEnderPearlEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
if (m_DestroyTimer > 0)
|
if (m_DestroyTimer > 0)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ protected:
|
|||||||
// cProjectileEntity overrides:
|
// cProjectileEntity overrides:
|
||||||
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
|
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
|
||||||
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
/** Teleports the creator where the ender pearl lands */
|
/** Teleports the creator where the ender pearl lands */
|
||||||
void TeleportCreator(const Vector3d & a_HitPos);
|
void TeleportCreator(const Vector3d & a_HitPos);
|
||||||
|
@ -48,7 +48,7 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cThrownSnowballEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
void cThrownSnowballEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
if (m_DestroyTimer > 0)
|
if (m_DestroyTimer > 0)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ protected:
|
|||||||
// cProjectileEntity overrides:
|
// cProjectileEntity overrides:
|
||||||
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
|
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
|
||||||
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -421,6 +421,7 @@ std::unique_ptr<T> make_unique(Args&&... args)
|
|||||||
|
|
||||||
// a tick is 50 ms
|
// a tick is 50 ms
|
||||||
using cTickTime = std::chrono::duration<int, std::ratio_multiply<std::chrono::milliseconds::period, std::ratio<50>>>;
|
using cTickTime = std::chrono::duration<int, std::ratio_multiply<std::chrono::milliseconds::period, std::ratio<50>>>;
|
||||||
|
using cTickTimeLong = std::chrono::duration<Int64, cTickTime::period>;
|
||||||
|
|
||||||
#ifndef TOLUA_TEMPLATE_BIND
|
#ifndef TOLUA_TEMPLATE_BIND
|
||||||
#define TOLUA_TEMPLATE_BIND(x)
|
#define TOLUA_TEMPLATE_BIND(x)
|
||||||
|
@ -61,7 +61,7 @@ void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cAggressiveMonster::Tick(float 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);
|
||||||
|
|
||||||
@ -93,9 +93,9 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cAggressiveMonster::Attack(float a_Dt)
|
void cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
m_AttackInterval += a_Dt * m_AttackRate;
|
m_AttackInterval += a_Dt.count() * m_AttackRate;
|
||||||
|
|
||||||
if ((m_Target == nullptr) || (m_AttackInterval < 3.0))
|
if ((m_Target == nullptr) || (m_AttackInterval < 3.0))
|
||||||
{
|
{
|
||||||
|
@ -16,11 +16,11 @@ public:
|
|||||||
|
|
||||||
cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
||||||
|
|
||||||
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void InStateChasing(float a_Dt) override;
|
virtual void InStateChasing(float a_Dt) override;
|
||||||
|
|
||||||
virtual void EventSeePlayer(cEntity *) override;
|
virtual void EventSeePlayer(cEntity *) override;
|
||||||
virtual void Attack(float a_Dt);
|
virtual void Attack(std::chrono::milliseconds a_Dt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Whether this mob's destination is the same as its target's position. */
|
/** Whether this mob's destination is the same as its target's position. */
|
||||||
|
@ -30,9 +30,9 @@ void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cBlaze::Attack(float a_Dt)
|
void cBlaze::Attack(std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
m_AttackInterval += a_Dt * m_AttackRate;
|
m_AttackInterval += a_Dt.count() * m_AttackRate;
|
||||||
|
|
||||||
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
||||||
{
|
{
|
||||||
|
@ -18,5 +18,5 @@ public:
|
|||||||
CLASS_PROTODEF(cBlaze)
|
CLASS_PROTODEF(cBlaze)
|
||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
virtual void Attack(float a_Dt) override;
|
virtual void Attack(std::chrono::milliseconds a_Dt) override;
|
||||||
} ;
|
} ;
|
||||||
|
@ -16,7 +16,7 @@ cCaveSpider::cCaveSpider(void) :
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cCaveSpider::Tick(float 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);
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cCaveSpider::Attack(float a_Dt)
|
void cCaveSpider::Attack(std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
super::Attack(a_Dt);
|
super::Attack(a_Dt);
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ public:
|
|||||||
|
|
||||||
CLASS_PROTODEF(cCaveSpider)
|
CLASS_PROTODEF(cCaveSpider)
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void Attack(float a_Dt) override;
|
virtual void Attack(std::chrono::milliseconds a_Dt) override;
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ cChicken::cChicken(void) :
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChicken::Tick(float 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);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
CLASS_PROTODEF(cChicken)
|
CLASS_PROTODEF(cChicken)
|
||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_SEEDS); }
|
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_SEEDS); }
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ cCreeper::cCreeper(void) :
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cCreeper::Tick(float 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);
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ bool cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cCreeper::Attack(float a_Dt)
|
void cCreeper::Attack(std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
UNUSED(a_Dt);
|
UNUSED(a_Dt);
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ public:
|
|||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
||||||
virtual void Attack(float a_Dt) override;
|
virtual void Attack(std::chrono::milliseconds a_Dt) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||||
|
|
||||||
bool IsBlowing(void) const {return m_bIsBlowing; }
|
bool IsBlowing(void) const {return m_bIsBlowing; }
|
||||||
|
@ -186,7 +186,7 @@ bool cEnderman::CheckLight()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cEnderman::Tick(float 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);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
virtual void CheckEventSeePlayer(void) override;
|
virtual void CheckEventSeePlayer(void) override;
|
||||||
virtual void CheckEventLostPlayer(void) override;
|
virtual void CheckEventLostPlayer(void) override;
|
||||||
virtual void EventLosePlayer(void) override;
|
virtual void EventLosePlayer(void) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
bool IsScreaming(void) const {return m_bIsScreaming; }
|
bool IsScreaming(void) const {return m_bIsScreaming; }
|
||||||
BLOCKTYPE GetCarriedBlock(void) const {return CarriedBlock; }
|
BLOCKTYPE GetCarriedBlock(void) const {return CarriedBlock; }
|
||||||
|
@ -32,9 +32,9 @@ void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cGhast::Attack(float a_Dt)
|
void cGhast::Attack(std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
m_AttackInterval += a_Dt * m_AttackRate;
|
m_AttackInterval += a_Dt.count() * m_AttackRate;
|
||||||
|
|
||||||
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ public:
|
|||||||
CLASS_PROTODEF(cGhast)
|
CLASS_PROTODEF(cGhast)
|
||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
virtual void Attack(float a_Dt) override;
|
virtual void Attack(std::chrono::milliseconds a_Dt) override;
|
||||||
|
|
||||||
bool IsCharging(void) const {return false; }
|
bool IsCharging(void) const {return false; }
|
||||||
} ;
|
} ;
|
||||||
|
@ -35,7 +35,7 @@ void cGuardian::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cGuardian::Tick(float a_Dt, cChunk & a_Chunk)
|
void cGuardian::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
|
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
|
||||||
// that is not where the entity currently resides (FS #411)
|
// that is not where the entity currently resides (FS #411)
|
||||||
|
@ -15,7 +15,7 @@ class cGuardian :
|
|||||||
public:
|
public:
|
||||||
cGuardian();
|
cGuardian();
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
CLASS_PROTODEF(cGuardian)
|
CLASS_PROTODEF(cGuardian)
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cHorse::Tick(float 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);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public:
|
|||||||
CLASS_PROTODEF(cHorse)
|
CLASS_PROTODEF(cHorse)
|
||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||||
|
|
||||||
bool IsSaddled (void) const {return m_bIsSaddled; }
|
bool IsSaddled (void) const {return m_bIsSaddled; }
|
||||||
|
@ -252,14 +252,14 @@ bool cMonster::ReachedFinalDestination()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cMonster::Tick(float 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 (m_Health <= 0)
|
if (m_Health <= 0)
|
||||||
{
|
{
|
||||||
// The mob is dead, but we're still animating the "puff" they leave when they die
|
// The mob is dead, but we're still animating the "puff" they leave when they die
|
||||||
m_DestroyTimer += a_Dt / 1000;
|
m_DestroyTimer += a_Dt.count() / 1000;
|
||||||
if (m_DestroyTimer > 1)
|
if (m_DestroyTimer > 1)
|
||||||
{
|
{
|
||||||
Destroy(true);
|
Destroy(true);
|
||||||
@ -275,8 +275,6 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
// Burning in daylight
|
// Burning in daylight
|
||||||
HandleDaylightBurning(a_Chunk);
|
HandleDaylightBurning(a_Chunk);
|
||||||
|
|
||||||
a_Dt /= 1000;
|
|
||||||
|
|
||||||
if (m_bMovingToDestination)
|
if (m_bMovingToDestination)
|
||||||
{
|
{
|
||||||
if (m_bOnGround)
|
if (m_bOnGround)
|
||||||
@ -347,18 +345,18 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
case IDLE:
|
case IDLE:
|
||||||
{
|
{
|
||||||
// If enemy passive we ignore checks for player visibility
|
// If enemy passive we ignore checks for player visibility
|
||||||
InStateIdle(a_Dt);
|
InStateIdle(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CHASING:
|
case CHASING:
|
||||||
{
|
{
|
||||||
// If we do not see a player anymore skip chasing action
|
// If we do not see a player anymore skip chasing action
|
||||||
InStateChasing(a_Dt);
|
InStateChasing(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESCAPING:
|
case ESCAPING:
|
||||||
{
|
{
|
||||||
InStateEscaping(a_Dt);
|
InStateEscaping(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
|
|
||||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ bool cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPassiveMonster::Tick(float 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);
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class cPassiveMonster :
|
|||||||
public:
|
public:
|
||||||
cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
/// When hit by someone, run away
|
/// When hit by someone, run away
|
||||||
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
||||||
|
@ -80,7 +80,7 @@ void cPig::OnRightClicked(cPlayer & a_Player)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPig::Tick(float 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);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public:
|
|||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); }
|
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); }
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cSheep::Tick(float 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);
|
||||||
int PosX = POSX_TOINT;
|
int PosX = POSX_TOINT;
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
|
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
|
||||||
|
|
||||||
|
@ -67,9 +67,9 @@ void cSkeleton::MoveToPosition(const Vector3d & a_Position)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cSkeleton::Attack(float a_Dt)
|
void cSkeleton::Attack(std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
m_AttackInterval += a_Dt * m_AttackRate;
|
m_AttackInterval += a_Dt.count() * m_AttackRate;
|
||||||
|
|
||||||
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
virtual void MoveToPosition(const Vector3d & a_Position) override;
|
virtual void MoveToPosition(const Vector3d & a_Position) override;
|
||||||
virtual void Attack(float a_Dt) override;
|
virtual void Attack(std::chrono::milliseconds a_Dt) override;
|
||||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||||
|
|
||||||
virtual bool IsUndead(void) override { return true; }
|
virtual bool IsUndead(void) override { return true; }
|
||||||
|
@ -46,7 +46,7 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cSlime::Attack(float a_Dt)
|
void cSlime::Attack(std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
if (m_Size > 1)
|
if (m_Size > 1)
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
|
|
||||||
// cAggressiveMonster overrides:
|
// cAggressiveMonster overrides:
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
virtual void Attack(float a_Dt) override;
|
virtual void Attack(std::chrono::milliseconds a_Dt) override;
|
||||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
||||||
|
|
||||||
int GetSize(void) const { return m_Size; }
|
int GetSize(void) const { return m_Size; }
|
||||||
|
@ -27,7 +27,7 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cSnowGolem::Tick(float 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 (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ()))))
|
if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ()))))
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
|
|
||||||
CLASS_PROTODEF(cSnowGolem)
|
CLASS_PROTODEF(cSnowGolem)
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cSquid::Tick(float a_Dt, cChunk & a_Chunk)
|
void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
|
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
|
||||||
// that is not where the entity currently resides (FS #411)
|
// that is not where the entity currently resides (FS #411)
|
||||||
|
@ -15,7 +15,7 @@ class cSquid :
|
|||||||
public:
|
public:
|
||||||
cSquid();
|
cSquid();
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
CLASS_PROTODEF(cSquid)
|
CLASS_PROTODEF(cSquid)
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ bool cVillager::DoTakeDamage(TakeDamageInfo & a_TDI)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cVillager::Tick(float 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);
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public:
|
|||||||
|
|
||||||
// cEntity overrides
|
// cEntity overrides
|
||||||
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
||||||
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
// cVillager functions
|
// cVillager functions
|
||||||
/** return true if the given blocktype are: crops, potatoes or carrots.*/
|
/** return true if the given blocktype are: crops, potatoes or carrots.*/
|
||||||
|
@ -66,7 +66,7 @@ bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cWither::Tick(float 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);
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user