diff options
author | archshift <admin@archshift.com> | 2014-04-27 02:35:31 +0200 |
---|---|---|
committer | archshift <admin@archshift.com> | 2014-04-27 02:35:31 +0200 |
commit | de7eaa573560253c9e78fbfa6614cd60763383bf (patch) | |
tree | f2f5837b30a6578929c8a754da2bf9f542fe82e3 /src | |
parent | Moved cThrownSnowballEntity out of ProjectileEntity.h (diff) | |
download | cuberite-de7eaa573560253c9e78fbfa6614cd60763383bf.tar cuberite-de7eaa573560253c9e78fbfa6614cd60763383bf.tar.gz cuberite-de7eaa573560253c9e78fbfa6614cd60763383bf.tar.bz2 cuberite-de7eaa573560253c9e78fbfa6614cd60763383bf.tar.lz cuberite-de7eaa573560253c9e78fbfa6614cd60763383bf.tar.xz cuberite-de7eaa573560253c9e78fbfa6614cd60763383bf.tar.zst cuberite-de7eaa573560253c9e78fbfa6614cd60763383bf.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/ProjectileEntity.cpp | 56 | ||||
-rw-r--r-- | src/Entities/ProjectileEntity.h | 28 | ||||
-rw-r--r-- | src/Entities/ProjectileFireCharge.cpp | 50 | ||||
-rw-r--r-- | src/Entities/ProjectileFireCharge.h | 36 | ||||
-rw-r--r-- | src/Mobs/Blaze.cpp | 1 | ||||
-rw-r--r-- | src/WorldStorage/WSSAnvil.cpp | 1 |
6 files changed, 90 insertions, 82 deletions
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 6b137ebe7..ab7753d41 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -18,6 +18,7 @@ #include "ProjectileEnderPearl.h" #include "ProjectileExpBottle.h" #include "ProjectileSnowball.h" +#include "ProjectileFireCharge.h" @@ -520,57 +521,4 @@ void cGhastFireballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a { Destroy(); Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cFireChargeEntity : - -cFireChargeEntity::cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkFireCharge, a_Creator, a_X, a_Y, a_Z, 0.3125, 0.3125) -{ - SetSpeed(a_Speed); - SetGravity(0); -} - - - - - -void cFireChargeEntity::Explode(int a_BlockX, int a_BlockY, int a_BlockZ) -{ - if (m_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR) - { - m_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 1); - } -} - - - - - -void cFireChargeEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) -{ - Destroy(); - Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); -} - - - - - -void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) -{ - Destroy(); - Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); - - // TODO: Some entities are immune to hits - a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning -} - - - - +}
\ No newline at end of file diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index 2c461d546..d2cca9c75 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -165,34 +165,6 @@ protected: -class cFireChargeEntity : - public cProjectileEntity -{ - typedef cProjectileEntity super; - -public: - - // tolua_end - - CLASS_PROTODEF(cFireChargeEntity); - - cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); - -protected: - - void Explode(int a_BlockX, int a_BlockY, int a_BlockZ); - - // cProjectileEntity overrides: - virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; - virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override; - - // tolua_begin - -} ; - - - - // tolua_end diff --git a/src/Entities/ProjectileFireCharge.cpp b/src/Entities/ProjectileFireCharge.cpp new file mode 100644 index 000000000..38ba95724 --- /dev/null +++ b/src/Entities/ProjectileFireCharge.cpp @@ -0,0 +1,50 @@ +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "ProjectileFireCharge.h" +#include "../World.h" + + + + + +cFireChargeEntity::cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : +super(pkFireCharge, a_Creator, a_X, a_Y, a_Z, 0.3125, 0.3125) +{ + SetSpeed(a_Speed); + SetGravity(0); +} + + + + + +void cFireChargeEntity::Explode(int a_BlockX, int a_BlockY, int a_BlockZ) +{ + if (m_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR) + { + m_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 1); + } +} + + + + + +void cFireChargeEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) +{ + Destroy(); + Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); +} + + + + + +void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) +{ + Destroy(); + Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); + + // TODO: Some entities are immune to hits + a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning +}
\ No newline at end of file diff --git a/src/Entities/ProjectileFireCharge.h b/src/Entities/ProjectileFireCharge.h new file mode 100644 index 000000000..6c088c547 --- /dev/null +++ b/src/Entities/ProjectileFireCharge.h @@ -0,0 +1,36 @@ +// +// ProjectileFireCharge.h +// + +#pragma once + +#include "ProjectileEntity.h" + + + + + +class cFireChargeEntity : +public cProjectileEntity +{ + typedef cProjectileEntity super; + +public: + + // tolua_end + + CLASS_PROTODEF(cFireChargeEntity); + + cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + +protected: + + void Explode(int a_BlockX, int a_BlockY, int a_BlockZ); + + // cProjectileEntity overrides: + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; + virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override; + + // tolua_begin + +} ;
\ No newline at end of file diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index 84ff8929b..74683da94 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -3,6 +3,7 @@ #include "Blaze.h" #include "../World.h" +#include "../Entities/ProjectileFireCharge.h" diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index c8d9dd25a..43b5ab4a7 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -39,6 +39,7 @@ #include "../Entities/ProjectileEgg.h" #include "../Entities/ProjectileEnderPearl.h" #include "../Entities/ProjectileSnowball.h" +#include "../Entities/ProjectileFireCharge.h" #include "../Entities/TNTEntity.h" #include "../Entities/ExpOrb.h" #include "../Entities/HangingEntity.h" |