Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | List of all members
cMobSpawnerEntity Class Reference

#include <MobSpawnerEntity.h>

Inheritance diagram for cMobSpawnerEntity:
Inheritance graph
[legend]
Collaboration diagram for cMobSpawnerEntity:
Collaboration graph
[legend]

Public Member Functions

 cMobSpawnerEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 
virtual void CopyFrom (const cBlockEntity &a_Src) override
 Copies all properties of a_Src into this entity, except for its m_World and location. More...
 
eMonsterType GetEntity (void) const
 Returns the entity type that will be spawn by this mob spawner. More...
 
int GetNearbyMonsterNum (eMonsterType a_EntityType)
 Returns the amount of this monster type in a 8-block radius (Y: 4-block radius). More...
 
int GetNearbyPlayersNum (void)
 Returns the amount of the nearby players in a 16-block radius. More...
 
short GetSpawnDelay (void) const
 Returns the spawn delay. More...
 
void ResetTimer (void)
 Sets the spawn delay to a new random value. More...
 
virtual void SendTo (cClientHandle &a_Client) override
 Sends the packet defining the block entity to the client specified. More...
 
void SetEntity (eMonsterType a_EntityType)
 Sets the entity type who will be spawn by this mob spawner. More...
 
void SetSpawnDelay (short a_Delay)
 Sets the spawn delay. More...
 
void SpawnEntity (void)
 Spawns the entity. More...
 
virtual bool Tick (std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
 Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. More...
 
void UpdateActiveState (void)
 Upate the active flag from the mob spawner. More...
 
virtual bool UsedBy (cPlayer *a_Player) override
 Called when a player uses this entity; should open the UI window. More...
 
- Public Member Functions inherited from cBlockEntity
cBlockEntityClone (Vector3i a_Pos)
 Makes an exact copy of this block entity, except for its m_World (set to nullptr), and at a new position. More...
 
virtual void Destroy ()
 
BLOCKTYPE GetBlockType () const
 
int GetChunkX () const
 
int GetChunkZ () const
 
virtual const char * GetClass () const
 Returns the name of the topmost class (the most descendant). More...
 
virtual const char * GetParentClass () const
 Returns the name of the parent class, or empty string if no parent class. More...
 
Vector3i GetPos () const
 
int GetPosX () const
 
int GetPosY () const
 
int GetPosZ () const
 
Vector3i GetRelPos () const
 
int GetRelX () const
 
int GetRelZ () const
 
cWorldGetWorld () const
 
virtual bool IsA (const char *a_ClassName) const
 Returns true if the object is the specified class, or its descendant. More...
 
void SetPos (Vector3i a_NewPos)
 Updates the internally stored position. More...
 
void SetWorld (cWorld *a_World)
 
virtual ~cBlockEntity ()
 

Static Public Member Functions

static const char * GetClassStatic (void)
 
- Static Public Member Functions inherited from cBlockEntity
static cBlockEntityCreateByBlockType (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World=nullptr)
 Creates a new block entity for the specified block type at the specified absolute pos. More...
 
static const char * GetClassStatic ()
 
static bool IsBlockEntityBlockType (BLOCKTYPE a_BlockType)
 Returns true if the specified blocktype is supposed to have an associated block entity. More...
 

Private Types

using super = cBlockEntity
 

Private Attributes

eMonsterType m_Entity
 The entity to spawn. More...
 
bool m_IsActive
 
short m_SpawnDelay
 

Additional Inherited Members

- Protected Member Functions inherited from cBlockEntity
 cBlockEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 
- Protected Attributes inherited from cBlockEntity
NIBBLETYPE m_BlockMeta
 The block meta representing this particular instance in the world Mainly used for directional entities, such as dispensers. More...
 
BLOCKTYPE m_BlockType
 The blocktype representing this particular instance in the world. More...
 
Vector3i m_Pos
 Position in absolute block coordinates. More...
 
int m_RelX
 Position relative to the chunk, used to speed up ticking. More...
 
int m_RelZ
 
cWorldm_World
 

Detailed Description

Definition at line 19 of file MobSpawnerEntity.h.

Member Typedef Documentation

Definition at line 24 of file MobSpawnerEntity.h.

Constructor & Destructor Documentation

cMobSpawnerEntity::cMobSpawnerEntity ( BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta,
Vector3i  a_Pos,
cWorld a_World 
)

Definition at line 16 of file MobSpawnerEntity.cpp.

Member Function Documentation

void cMobSpawnerEntity::CopyFrom ( const cBlockEntity a_Src)
overridevirtual

Copies all properties of a_Src into this entity, except for its m_World and location.

Each non-abstract descendant should override to copy its specific properties, and call Super::CopyFrom(a_Src) to copy the common ones.

Reimplemented from cBlockEntity.

Definition at line 29 of file MobSpawnerEntity.cpp.

static const char* cMobSpawnerEntity::GetClassStatic ( void  )
inlinestatic

Definition at line 67 of file MobSpawnerEntity.h.

eMonsterType cMobSpawnerEntity::GetEntity ( void  ) const
inline

Returns the entity type that will be spawn by this mob spawner.

Definition at line 48 of file MobSpawnerEntity.h.

int cMobSpawnerEntity::GetNearbyMonsterNum ( eMonsterType  a_EntityType)

Returns the amount of this monster type in a 8-block radius (Y: 4-block radius).

Definition at line 247 of file MobSpawnerEntity.cpp.

int cMobSpawnerEntity::GetNearbyPlayersNum ( void  )

Returns the amount of the nearby players in a 16-block radius.

Definition at line 204 of file MobSpawnerEntity.cpp.

short cMobSpawnerEntity::GetSpawnDelay ( void  ) const
inline

Returns the spawn delay.

This is the tick delay that is needed to spawn new monsters.

Definition at line 54 of file MobSpawnerEntity.h.

void cMobSpawnerEntity::ResetTimer ( void  )

Sets the spawn delay to a new random value.

Definition at line 122 of file MobSpawnerEntity.cpp.

void cMobSpawnerEntity::SendTo ( cClientHandle a_Client)
overridevirtual

Sends the packet defining the block entity to the client specified.

To send to all eligible clients, use cWorld::BroadcastBlockEntity()

Implements cBlockEntity.

Definition at line 42 of file MobSpawnerEntity.cpp.

void cMobSpawnerEntity::SetEntity ( eMonsterType  a_EntityType)
inline

Sets the entity type who will be spawn by this mob spawner.

Definition at line 51 of file MobSpawnerEntity.h.

void cMobSpawnerEntity::SetSpawnDelay ( short  a_Delay)
inline

Sets the spawn delay.

Definition at line 57 of file MobSpawnerEntity.h.

void cMobSpawnerEntity::SpawnEntity ( void  )

Spawns the entity.

This function automaticly change the spawn delay!

Definition at line 132 of file MobSpawnerEntity.cpp.

bool cMobSpawnerEntity::Tick ( std::chrono::milliseconds  a_Dt,
cChunk a_Chunk 
)
overridevirtual

Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking.

By default does nothing.

Reimplemented from cBlockEntity.

Definition at line 93 of file MobSpawnerEntity.cpp.

void cMobSpawnerEntity::UpdateActiveState ( void  )

Upate the active flag from the mob spawner.

This function will called every 5 seconds from the Tick() function.

Definition at line 77 of file MobSpawnerEntity.cpp.

bool cMobSpawnerEntity::UsedBy ( cPlayer a_Player)
overridevirtual

Called when a player uses this entity; should open the UI window.

returns true if the use was successful, return false to use the block as a "normal" block

Implements cBlockEntity.

Definition at line 51 of file MobSpawnerEntity.cpp.

Member Data Documentation

eMonsterType cMobSpawnerEntity::m_Entity
private

The entity to spawn.

Definition at line 71 of file MobSpawnerEntity.h.

bool cMobSpawnerEntity::m_IsActive
private

Definition at line 75 of file MobSpawnerEntity.h.

short cMobSpawnerEntity::m_SpawnDelay
private

Definition at line 73 of file MobSpawnerEntity.h.


The documentation for this class was generated from the following files: