6 #include "../Mobs/Monster.h"
7 #include "../BoundingBox.h"
8 #include "../ClientHandle.h"
18 Super(etLeashKnot, a_BlockFace, a_Pos),
19 m_ShouldSelfDestroy(false),
20 m_TicksToSelfDestroy(20 * 1)
48 if (a_Entity.
GetEntityType() != cEntity::eEntityType::etMonster)
53 auto & PotentialLeashed =
static_cast<cMonster&
>(a_Entity);
56 if (!PotentialLeashed.CanBeLeashed())
63 !PotentialLeashed.IsLeashed() ||
64 !PotentialLeashed.GetLeashedTo()->IsPlayer() ||
65 (PotentialLeashed.GetLeashedTo()->GetUniqueID() != a_Player.
GetUniqueID())
72 PotentialLeashed.
Unleash(
false,
false);
73 PotentialLeashed.LeashTo(*
this, a_ShouldBroadcast);
149 LeashKnot = static_cast<cLeashKnot *>(&a_Entity);
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
virtual bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback)=0
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox.
Represents two sets of coords, minimum and maximum for each direction.
void SendSpawnEntity(const cEntity &a_Entity)
void SendEntityMetadata(const cEntity &a_Entity)
bool IsPlayer(void) const
UInt32 GetUniqueID(void) const
void Destroy()
Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet.
eEntityType GetEntityType(void) const
bool IsLeashKnot(void) const
virtual void OnRightClicked(cPlayer &a_Player)
Called when the specified player right-clicks this entity.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
long int m_TicksAlive
The number of ticks this entity has been alive for.
cWorld * GetWorld(void) const
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
virtual void SpawnOn(cClientHandle &a_ClientHandle) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
virtual void SpawnOn(cClientHandle &a_ClientHandle) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
void TiePlayersLeashedMobs(cPlayer &a_Player, bool a_ShouldBroadCast)
Looks for mobs leashed to a player and ties them to this knot.
bool m_ShouldSelfDestroy
When a fence is destroyed, the knot on it gets destroyed after a while.
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
cLeashKnot(eBlockFace a_BlockFace, Vector3d a_Pos)
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
virtual void GetDrops(cItems &a_Items, cEntity *a_Killer) override
Returns the list of drops for this pawn when it is killed.
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
static cLeashKnot * FindKnotAtPos(cWorldInterface &a_WorldInterface, Vector3i a_BlockPos)
Returns the leash knot entity representing the knot at the specified position.
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
This class bridges a vector of cItem for safe access via Lua.
void Unleash(bool a_ShouldDropLeashPickup)
Unleash the monster.
virtual void BroadcastEntityMetadata(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback) override
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox.
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override