summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Monster.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs/Monster.h')
-rw-r--r--src/Mobs/Monster.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 2155a4a7c..62c2a3564 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -161,20 +161,16 @@ public:
// tolua_end
/** Sets the target that this mob will chase. Pass a nullptr to unset. */
- void SetTarget (cPawn * a_NewTarget);
-
- /** Unset the target without notifying the target entity. Do not use this, use SetTarget(nullptr) instead.
- This is only used by cPawn internally. */
- void UnsafeUnsetTarget();
+ void SetTarget(cPawn * a_NewTarget);
/** Returns the current target. */
- cPawn * GetTarget ();
+ cPawn * GetTarget();
/** Creates a new object of the specified mob.
a_MobType is the type of the mob to be created
Asserts and returns null if mob type is not specified
*/
- static cMonster * NewMonsterFromType(eMonsterType a_MobType);
+ static std::unique_ptr<cMonster> NewMonsterFromType(eMonsterType a_MobType);
protected:
@@ -200,7 +196,11 @@ protected:
bool ReachedFinalDestination(void) { return ((m_FinalDestination - GetPosition()).SqrLength() < WAYPOINT_RADIUS * WAYPOINT_RADIUS); }
/** Returns whether or not the target is close enough for attack. */
- bool TargetIsInRange(void) { ASSERT(m_Target != nullptr); return ((m_Target->GetPosition() - GetPosition()).SqrLength() < (m_AttackRange * m_AttackRange)); }
+ bool TargetIsInRange(void)
+ {
+ ASSERT(GetTarget() != nullptr);
+ return ((GetTarget()->GetPosition() - GetPosition()).SqrLength() < (m_AttackRange * m_AttackRange));
+ }
/** Returns if a monster can reach a given height by jumping. */
inline bool DoesPosYRequireJump(int a_PosY)
@@ -267,7 +267,9 @@ protected:
void AddRandomWeaponDropItem(cItems & a_Drops, unsigned int a_LootingLevel);
private:
- /** A pointer to the entity this mobile is aiming to reach */
+ /** A pointer to the entity this mobile is aiming to reach.
+ The validity of this pointer SHALL be guaranteed by the pointee;
+ it MUST be reset when the pointee changes worlds or is destroyed. */
cPawn * m_Target;
} ; // tolua_export