2013-08-20 10:47:40 -04:00
|
|
|
|
|
|
|
// ProjectileEntity.h
|
|
|
|
|
2013-08-22 02:55:58 -04:00
|
|
|
// Declares the cProjectileEntity class representing the common base class for projectiles, as well as individual projectile types
|
2013-08-20 10:47:40 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Entity.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
|
|
|
|
class cProjectileEntity :
|
|
|
|
public cEntity
|
|
|
|
{
|
|
|
|
typedef cEntity super;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// The kind of the projectile. The numbers correspond to the network type ID used for spawning via the 0x17 packet.
|
|
|
|
enum eKind
|
|
|
|
{
|
|
|
|
pkArrow = 60,
|
|
|
|
pkSnowball = 61,
|
|
|
|
pkEgg = 62,
|
2013-08-22 16:31:15 -04:00
|
|
|
pkGhastFireball = 63,
|
|
|
|
pkFireCharge = 64,
|
2013-08-20 10:47:40 -04:00
|
|
|
pkEnderPearl = 65,
|
|
|
|
pkExpBottle = 75,
|
|
|
|
pkSplashPotion = 73,
|
2013-11-16 15:58:17 -05:00
|
|
|
pkFirework = 76,
|
2013-08-20 10:47:40 -04:00
|
|
|
pkWitherSkull = 66,
|
|
|
|
pkFishingFloat = 90,
|
|
|
|
} ;
|
|
|
|
|
2013-08-22 02:55:58 -04:00
|
|
|
// tolua_end
|
|
|
|
|
2013-08-25 15:31:35 -04:00
|
|
|
CLASS_PROTODEF(cProjectileEntity);
|
|
|
|
|
2013-08-20 10:47:40 -04:00
|
|
|
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
|
|
|
|
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height);
|
|
|
|
|
2014-02-26 18:29:14 -05:00
|
|
|
static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item, const Vector3d * a_Speed = NULL);
|
2013-08-22 02:55:58 -04:00
|
|
|
|
2013-09-03 03:41:31 -04:00
|
|
|
/// Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given
|
2014-02-04 13:59:05 -05:00
|
|
|
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace);
|
2013-08-20 10:47:40 -04:00
|
|
|
|
2013-09-01 16:40:35 -04:00
|
|
|
/// Called by the physics blocktracer when the entity hits another entity
|
2013-12-22 08:46:55 -05:00
|
|
|
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
|
|
|
|
{
|
|
|
|
UNUSED(a_EntityHit);
|
|
|
|
UNUSED(a_HitPos);
|
|
|
|
}
|
2013-09-01 16:40:35 -04:00
|
|
|
|
2013-11-12 16:43:20 -05:00
|
|
|
/// Called by Chunk when the projectile is eligible for player collection
|
|
|
|
virtual void CollectedBy(cPlayer * a_Dest);
|
|
|
|
|
2013-08-22 02:55:58 -04:00
|
|
|
// tolua_begin
|
|
|
|
|
2013-08-22 16:31:15 -04:00
|
|
|
/// Returns the kind of the projectile (fast class identification)
|
|
|
|
eKind GetProjectileKind(void) const { return m_ProjectileKind; }
|
|
|
|
|
2013-08-22 02:55:58 -04:00
|
|
|
/// Returns the entity who created this projectile; may be NULL
|
|
|
|
cEntity * GetCreator(void) { return m_Creator; }
|
|
|
|
|
2013-08-22 16:31:15 -04:00
|
|
|
/// Returns the string that is used as the entity type (class name) in MCA files
|
|
|
|
AString GetMCAClassName(void) const;
|
|
|
|
|
|
|
|
/// Returns true if the projectile has hit the ground and is stuck there
|
|
|
|
bool IsInGround(void) const { return m_IsInGround; }
|
2013-08-20 10:47:40 -04:00
|
|
|
|
2013-09-07 15:26:17 -04:00
|
|
|
// tolua_end
|
|
|
|
|
|
|
|
/// Sets the internal InGround flag. To be used by MCA loader only!
|
|
|
|
void SetIsInGround(bool a_IsInGround) { m_IsInGround = a_IsInGround; }
|
|
|
|
|
2013-08-20 10:47:40 -04:00
|
|
|
protected:
|
2013-08-22 16:31:15 -04:00
|
|
|
eKind m_ProjectileKind;
|
2013-08-20 10:47:40 -04:00
|
|
|
|
|
|
|
/// The entity who has created this projectile; may be NULL (e. g. for dispensers)
|
|
|
|
cEntity * m_Creator;
|
2013-08-22 16:31:15 -04:00
|
|
|
|
|
|
|
/// True if the projectile has hit the ground and is stuck there
|
|
|
|
bool m_IsInGround;
|
2013-11-14 17:39:14 -05:00
|
|
|
|
2013-08-27 13:57:37 -04:00
|
|
|
// cEntity overrides:
|
|
|
|
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
|
|
|
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
|
2013-08-30 12:10:58 -04:00
|
|
|
virtual void SpawnOn(cClientHandle & a_Client) override;
|
2013-08-30 08:32:07 -04:00
|
|
|
|
2014-04-27 12:42:31 -04:00
|
|
|
} ; // tolua_export
|