summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Entity.cpp19
-rw-r--r--src/Entities/Entity.h2
-rw-r--r--src/Entities/Pawn.cpp52
-rw-r--r--src/Entities/Pawn.h16
-rw-r--r--src/Entities/Player.cpp2
-rw-r--r--src/Entities/WitherSkullEntity.cpp1
6 files changed, 20 insertions, 72 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 33f5a6135..71647200d 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -236,8 +236,9 @@ void cEntity::Destroy(bool a_ShouldBroadcast)
m_World->BroadcastDestroyEntity(*this);
}
+ // Destroy the entity after two seconds, to give time for all cMobPointers to nullify.
auto ParentChunkCoords = cChunkDef::BlockToChunk(GetPosition());
- m_World->QueueTask([this, ParentChunkCoords](cWorld & a_World)
+ m_World->ScheduleTask(40, [this, ParentChunkCoords](cWorld & a_World)
{
LOGD("Destroying entity #%i (%s) from chunk (%d, %d)",
this->GetUniqueID(), this->GetClass(),
@@ -402,6 +403,16 @@ void cEntity::SetPitchFromSpeed(void)
+const Vector3i cEntity::GetHeadPosition(void)
+{
+ int HeadHeight = CeilC(GetPosY() + GetHeight()) - 1;
+ return Vector3i(POSX_TOINT, HeadHeight, POSZ_TOINT);
+}
+
+
+
+
+
bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (m_Health <= 0)
@@ -1598,12 +1609,12 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
// Stop all mobs from targeting this entity
// Stop this entity from targeting other mobs
- if (this->IsMob())
+ /* if (this->IsMob())
{
cMonster * Monster = static_cast<cMonster*>(this);
Monster->SetTarget(nullptr);
- Monster->StopEveryoneFromTargetingMe();
- }
+ Monster->StopEveryoneFromTargetingMe(); mobTodo MovingWorld event for all behaviors?
+ }*/
// Queue add to new world and removal from the old one
cWorld * OldWorld = GetWorld();
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 3dc2d8f42..a6ca390fd 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -304,6 +304,8 @@ public:
/** Exported in ManualBindings */
const Vector3d & GetPosition(void) const { return m_Position; }
+ const Vector3i GetHeadPosition(void);
+
/** Exported in ManualBindings */
const Vector3d & GetSpeed(void) const { return m_Speed; }
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 233cdfa85..0fa11997b 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -29,7 +29,7 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) :
cPawn::~cPawn()
{
- ASSERT(m_TargetingMe.size() == 0);
+
}
@@ -38,7 +38,6 @@ cPawn::~cPawn()
void cPawn::Destroyed()
{
- StopEveryoneFromTargetingMe();
super::Destroyed();
}
@@ -260,38 +259,6 @@ void cPawn::ClearEntityEffects()
-void cPawn::NoLongerTargetingMe(cMonster * a_Monster)
-{
- ASSERT(IsTicking()); // Our destroy override is supposed to clear all targets before we're destroyed.
- for (auto i = m_TargetingMe.begin(); i != m_TargetingMe.end(); ++i)
- {
- cMonster * Monster = *i;
- if (Monster == a_Monster)
- {
- ASSERT(Monster->GetTarget() != this); // The monster is notifying us it is no longer targeting us, assert if that's a lie
- m_TargetingMe.erase(i);
- return;
- }
- }
- ASSERT(false); // If this happens, something is wrong. Perhaps the monster never called TargetingMe() or called NoLongerTargetingMe() twice.
-}
-
-
-
-
-
-void cPawn::TargetingMe(cMonster * a_Monster)
-{
- ASSERT(IsTicking());
- ASSERT(m_TargetingMe.size() < 10000);
- ASSERT(a_Monster->GetTarget() == this);
- m_TargetingMe.push_back(a_Monster);
-}
-
-
-
-
-
void cPawn::HandleFalling(void)
{
/* Not pretty looking, and is more suited to wherever server-sided collision detection is implemented.
@@ -462,23 +429,6 @@ void cPawn::HandleFalling(void)
-void cPawn::StopEveryoneFromTargetingMe()
-{
- std::vector<cMonster*>::iterator i = m_TargetingMe.begin();
- while (i != m_TargetingMe.end())
- {
- cMonster * Monster = *i;
- ASSERT(Monster->GetTarget() == this);
- Monster->UnsafeUnsetTarget();
- i = m_TargetingMe.erase(i);
- }
- ASSERT(m_TargetingMe.size() == 0);
-}
-
-
-
-
-
std::map<cEntityEffect::eType, cEntityEffect *> cPawn::GetEntityEffects()
{
std::map<cEntityEffect::eType, cEntityEffect *> Effects;
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 480b523ea..935122012 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -33,11 +33,6 @@ public:
virtual void HandleAir(void) override;
virtual void HandleFalling(void);
- /** Tells all pawns which are targeting us to stop targeting us. */
- void StopEveryoneFromTargetingMe();
-
-
-
// tolua_begin
/** Applies an entity effect.
@@ -58,12 +53,6 @@ public:
// tolua_end
- /** Remove the monster from the list of monsters targeting this pawn. */
- void NoLongerTargetingMe(cMonster * a_Monster);
-
- /** Add the monster to the list of monsters targeting this pawn. (Does not check if already in list!) */
- void TargetingMe(cMonster * a_Monster);
-
/** Returns all entity effects */
std::map<cEntityEffect::eType, cEntityEffect *> GetEntityEffects();
@@ -76,11 +65,6 @@ protected:
double m_LastGroundHeight;
bool m_bTouchGround;
-
-private:
-
- /** A list of all monsters that are targeting this pawn. */
- std::vector<cMonster*> m_TargetingMe;
} ; // tolua_export
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 8d35d0bf5..7aef38b93 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2018,7 +2018,7 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
FreezeInternal(a_NewPosition, false);
// Stop all mobs from targeting this player
- StopEveryoneFromTargetingMe();
+ // StopEveryoneFromTargetingMe(); // mobTodo
cClientHandle * ch = this->GetClientHandle();
if (ch != nullptr)
diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp
index 354a08dc6..a82ea8e7a 100644
--- a/src/Entities/WitherSkullEntity.cpp
+++ b/src/Entities/WitherSkullEntity.cpp
@@ -1,4 +1,5 @@
+
// WitherSkullEntity.cpp
// Implements the cWitherSkullEntity class representing the entity used by both blue and black wither skulls