1
0

Moved entity spawning into cEntity::Initialize().

It has been called in every descendant anyway, so it's better this way - reduced duplicate code.
This commit is contained in:
madmaxoft 2013-08-25 21:25:13 +02:00
parent 83811b6929
commit a7447b4c7e
9 changed files with 4 additions and 61 deletions

View File

@ -144,6 +144,10 @@ bool cEntity::Initialize(cWorld * a_World)
m_World->AddEntity(this);
cPluginManager::Get()->CallHookSpawnedEntity(*a_World, *this);
// Spawn the entity on the clients:
a_World->BroadcastSpawnEntity(*this);
return true;
}

View File

@ -22,20 +22,6 @@ cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_Block
bool cFallingBlock::Initialize(cWorld * a_World)
{
if (super::Initialize(a_World))
{
a_World->BroadcastSpawnEntity(*this);
return true;
}
return false;
}
void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle)
{
a_ClientHandle.SendSpawnFallingBlock(*this);

View File

@ -29,7 +29,6 @@ public:
NIBBLETYPE GetBlockMeta(void) const { return m_BlockMeta; }
// cEntity overrides:
virtual bool Initialize(cWorld * a_World) override;
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;

View File

@ -22,20 +22,6 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
bool cMinecart::Initialize(cWorld * a_World)
{
if (super::Initialize(a_World))
{
a_World->BroadcastSpawnEntity(*this);
return true;
}
return false;
}
void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
{
char Type = 0;

View File

@ -35,7 +35,6 @@ public:
} ;
// cEntity overrides:
virtual bool Initialize(cWorld * a_World) override;
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;

View File

@ -40,20 +40,6 @@ cPickup::cPickup(int a_MicroPosX, int a_MicroPosY, int a_MicroPosZ, const cItem
bool cPickup::Initialize(cWorld * a_World)
{
if (super::Initialize(a_World))
{
a_World->BroadcastSpawnEntity(*this);
return true;
}
return false;
}
void cPickup::SpawnOn(cClientHandle & a_Client)
{
a_Client.SendPickupSpawn(*this);

View File

@ -26,8 +26,6 @@ public:
cPickup(int a_MicroPosX, int a_MicroPosY, int a_MicroPosZ, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); // tolua_export
virtual bool Initialize(cWorld * a_World) override;
cItem & GetItem(void) {return m_Item; } // tolua_export
const cItem & GetItem(void) const {return m_Item; }

View File

@ -29,20 +29,6 @@ cTNTEntity::cTNTEntity(const Vector3d & a_Pos, double a_FuseTimeInSec) :
bool cTNTEntity::Initialize(cWorld * a_World)
{
if (super::Initialize(a_World))
{
a_World->BroadcastSpawnEntity(*this);
return true;
}
return false;
}
void cTNTEntity::SpawnOn(cClientHandle & a_ClientHandle)
{
a_ClientHandle.SendSpawnObject(*this, 50, 1, 0, 0); // 50 means TNT

View File

@ -19,7 +19,6 @@ public:
cTNTEntity(const Vector3d & a_Pos, double a_FuseTimeInSec);
// cEntity overrides:
virtual bool Initialize(cWorld * a_World) override;
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;