Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <MobSpawnerEntity.h>
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 |
short | GetMaxNearbyEntities (void) const |
short | GetMaxSpawnDelay (void) const |
short | GetMinSpawnDelay (void) const |
int | GetNearbyMonsterNum (eMonsterType a_EntityType) |
int | GetNearbyPlayersNum (void) |
short | GetRequiredPlayerRange (void) const |
short | GetSpawnCount (void) const |
short | GetSpawnDelay (void) const |
short | GetSpawnRange (void) const |
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) |
void | SetMaxNearbyEntities (short a_MaxNearbyEntities) |
void | SetMaxSpawnDelay (short a_Max) |
void | SetMinSpawnDelay (short a_Min) |
void | SetRequiredPlayerRange (short a_RequiredPlayerRange) |
void | SetSpawnCount (short a_SpawnCount) |
void | SetSpawnDelay (short a_Delay) |
void | SetSpawnRange (short a_SpawnRange) |
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) |
Update 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 | |
OwnedBlockEntity | Clone (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 cItems | ConvertToPickups () const |
Returns the contents of this block entity that it would drop if broken. More... | |
virtual void | Destroy () |
Called when this block entity's associated block is destroyed. More... | |
BLOCKTYPE | GetBlockType () const |
int | GetChunkX () const |
int | GetChunkZ () const |
Vector3i | GetPos () const |
int | GetPosX () const |
int | GetPosY () const |
int | GetPosZ () const |
Vector3i | GetRelPos () const |
int | GetRelX () const |
int | GetRelZ () const |
cWorld * | GetWorld () const |
virtual void | OnAddToWorld (cWorld &a_World, cChunk &a_Chunk) |
Called when the block entity object is added to a world. More... | |
virtual void | OnRemoveFromWorld () |
Called when the block entity object is removed from a world. More... | |
void | SetPos (Vector3i a_NewPos) |
Updates the internally stored position. More... | |
void | SetWorld (cWorld *a_World) |
virtual | ~cBlockEntity ()=default |
Private Types | |
using | Super = cBlockEntity |
Private Attributes | |
eMonsterType | m_Entity |
The entity to spawn. More... | |
bool | m_IsActive |
short | m_MaxNearbyEntities = 6 |
Maximum amount of the same entity type in proximity. More... | |
short | m_MaxSpawnDelay = 800 |
short | m_MinSpawnDelay = 200 |
short | m_RequiredPlayerRange = 16 |
Maximum distance to player for activation. More... | |
short | m_SpawnCount = 4 |
Number of entities the spawner tries to spawn each activation. More... | |
short | m_SpawnDelay |
Time in ticks until the next entity spawns. More... | |
short | m_SpawnRange = 8 |
Diameter of the square the new monsters are spawned in. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from cBlockEntity | |
static OwnedBlockEntity | CreateByBlockType (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 bool | IsBlockEntityBlockType (BLOCKTYPE a_BlockType) |
Returns true if the specified blocktype is supposed to have an associated block entity. More... | |
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 |
cWorld * | m_World |
Definition at line 19 of file MobSpawnerEntity.h.
|
private |
Definition at line 24 of file MobSpawnerEntity.h.
cMobSpawnerEntity::cMobSpawnerEntity | ( | BLOCKTYPE | a_BlockType, |
NIBBLETYPE | a_BlockMeta, | ||
Vector3i | a_Pos, | ||
cWorld * | a_World | ||
) |
Definition at line 16 of file MobSpawnerEntity.cpp.
|
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.
|
inline |
Definition at line 51 of file MobSpawnerEntity.h.
|
inline |
Definition at line 57 of file MobSpawnerEntity.h.
|
inline |
Definition at line 56 of file MobSpawnerEntity.h.
|
inline |
Definition at line 55 of file MobSpawnerEntity.h.
int cMobSpawnerEntity::GetNearbyMonsterNum | ( | eMonsterType | a_EntityType | ) |
Definition at line 229 of file MobSpawnerEntity.cpp.
int cMobSpawnerEntity::GetNearbyPlayersNum | ( | void | ) |
Definition at line 202 of file MobSpawnerEntity.cpp.
|
inline |
Definition at line 58 of file MobSpawnerEntity.h.
|
inline |
Definition at line 52 of file MobSpawnerEntity.h.
|
inline |
Definition at line 54 of file MobSpawnerEntity.h.
|
inline |
Definition at line 53 of file MobSpawnerEntity.h.
void cMobSpawnerEntity::ResetTimer | ( | void | ) |
Sets the spawn delay to a new random value.
Definition at line 125 of file MobSpawnerEntity.cpp.
|
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 48 of file MobSpawnerEntity.cpp.
|
inline |
Definition at line 61 of file MobSpawnerEntity.h.
|
inline |
Definition at line 67 of file MobSpawnerEntity.h.
|
inline |
Definition at line 66 of file MobSpawnerEntity.h.
|
inline |
Definition at line 65 of file MobSpawnerEntity.h.
|
inline |
Definition at line 68 of file MobSpawnerEntity.h.
|
inline |
Definition at line 63 of file MobSpawnerEntity.h.
|
inline |
Definition at line 62 of file MobSpawnerEntity.h.
|
inline |
Definition at line 64 of file MobSpawnerEntity.h.
void cMobSpawnerEntity::SpawnEntity | ( | void | ) |
Spawns the entity.
This function automatically change the spawn delay!
Definition at line 134 of file MobSpawnerEntity.cpp.
|
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 | ) |
Update the active flag from the mob spawner.
This function will called every 5 seconds from the Tick() function.
Definition at line 84 of file MobSpawnerEntity.cpp.
|
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 57 of file MobSpawnerEntity.cpp.
|
private |
The entity to spawn.
Definition at line 75 of file MobSpawnerEntity.h.
|
private |
Definition at line 80 of file MobSpawnerEntity.h.
|
private |
Maximum amount of the same entity type in proximity.
Definition at line 93 of file MobSpawnerEntity.h.
|
private |
Definition at line 90 of file MobSpawnerEntity.h.
|
private |
Definition at line 88 of file MobSpawnerEntity.h.
|
private |
Maximum distance to player for activation.
Definition at line 96 of file MobSpawnerEntity.h.
|
private |
Number of entities the spawner tries to spawn each activation.
Definition at line 83 of file MobSpawnerEntity.h.
|
private |
Time in ticks until the next entity spawns.
Definition at line 78 of file MobSpawnerEntity.h.
|
private |
Diameter of the square the new monsters are spawned in.
Definition at line 86 of file MobSpawnerEntity.h.