PGE API 0.4
PR00F's Game Engine full documentation
Loading...
Searching...
No Matches
Bullet Class Reference

Bullet class for PR00F's Game Engine Weapon Manager. More...

Detailed Description

Bullet class for PR00F's Game Engine Weapon Manager.

Definition at line 34 of file WeaponManager.h.

#include <WeaponManager.h>

+ Inheritance diagram for Bullet:

Public Types

enum  ParticleType { None , Smoke }
 
enum  DamageAreaEffect { Constant , Linear }
 
typedef uint32_t BulletId
 

Public Member Functions

 Bullet (const WeaponId &wpnId, PR00FsUltimateRenderingEngine &gfx, pge_network::PgeNetworkConnectionHandle connHandle, TPureFloat wpn_px, TPureFloat wpn_py, TPureFloat wpn_pz, TPureFloat wpn_ax, TPureFloat wpn_ay, TPureFloat wpn_az, bool visible, TPureFloat sx, TPureFloat sy, TPureFloat sz, TPureFloat speed, TPureFloat gravity, TPureFloat drag, TPureBool fragile, TPureFloat fDistMax, const ParticleType &particleType, int nDamageAp, int nDamageHp, TPureFloat fDamageAreaSize, const DamageAreaEffect &eDamageAreaEffect, TPureFloat fDamageAreaPulse)
 Ctor to be used by PGE server instance.
 
 Bullet (const WeaponId &wpnId, PR00FsUltimateRenderingEngine &gfx, TPureFloat wpn_px, TPureFloat wpn_py, TPureFloat wpn_pz, TPureFloat wpn_ax, TPureFloat wpn_ay, TPureFloat wpn_az, bool visible, TPureFloat sx, TPureFloat sy, TPureFloat sz, TPureFloat speed, TPureFloat gravity, TPureFloat drag, const ParticleType &particleType, int nDamageHp, const TPureFloat &fDamageAreaSize, const DamageAreaEffect &eDamageAreaEffect, const TPureFloat &fDamageAreaPulse)
 Ctor to be used by PGE client instance.
 
virtual ~Bullet ()
 User is expected to explicitly call Bullet::destroyReferenceObject() after they freed up all Bullet instances.
 
 Bullet (const Bullet &)=delete
 
Bulletoperator= (const Bullet &)=delete
 
 Bullet (Bullet &&)=delete
 
Bulletoperator= (Bullet &&)=delete
 
CConsole & getConsole () const
 Returns access to console preset with logger module name as this class.
 
BulletId getId () const
 
const WeaponIdgetWeaponId () const
 
pge_network::PgeNetworkConnectionHandle getOwner () const
 
const PurePosUpTarget & getPut () const
 
TPureFloat getSpeed () const
 
TPureFloat getGravity () const
 
TPureFloat getDrag () const
 
TPureBool isFragile () const
 
const ParticleTypegetParticleType () const
 
int & getParticleEmitPerNthPhysicsIterationCntr ()
 
const int & getParticleEmitPerNthPhysicsIterationCntr () const
 
int & getParticlesEmittedTotal ()
 
const int & getParticlesEmittedTotal () const
 
TPureFloat getTravelDistanceMax () const
 
TPureFloat getTravelledDistance () const
 
int getDamageAp () const
 Maximum damage to Player AP this bullet can cause.
 
int getDamageHp () const
 Maximum damage to Player HP this bullet can cause.
 
TPureFloat getAreaDamageSize () const
 
const DamageAreaEffectgetAreaDamageEffect () const
 
TPureFloat getAreaDamagePulse () const
 
bool & isCreateSentToClients ()
 
void init (const WeaponId &wpnId, PR00FsUltimateRenderingEngine &gfx, pge_network::PgeNetworkConnectionHandle connHandle, TPureFloat wpn_px, TPureFloat wpn_py, TPureFloat wpn_pz, TPureFloat wpn_ax, TPureFloat wpn_ay, TPureFloat wpn_az, bool visible, TPureFloat sx, TPureFloat sy, TPureFloat sz, TPureFloat speed, TPureFloat gravity, TPureFloat drag, TPureBool fragile, TPureFloat fDistMax, const ParticleType &particleType, int nDamageAp, int nDamageHp, TPureFloat fDamageAreaSize, const DamageAreaEffect &eDamageAreaEffect, TPureFloat fDamageAreaPulse)
 Init to be used by PGE server instance.
 
void init (const BulletId &id, const WeaponId &wpnId, PR00FsUltimateRenderingEngine &gfx, TPureFloat wpn_px, TPureFloat wpn_py, TPureFloat wpn_pz, TPureFloat wpn_ax, TPureFloat wpn_ay, TPureFloat wpn_az, bool visible, TPureFloat sx, TPureFloat sy, TPureFloat sz, TPureFloat speed, TPureFloat gravity, TPureFloat drag, const ParticleType &particleType, int nDamageHp, TPureFloat fDamageAreaSize, const DamageAreaEffect &eDamageAreaEffect, TPureFloat fDamageAreaPulse)
 Init to be used by PGE client instance.
 
void Update (const unsigned int &nFactor)
 
PureObject3D & getObject3D ()
 
const PureObject3D & getObject3D () const
 

Static Public Member Functions

static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 
static BulletId getGlobalBulletId ()
 
static void resetGlobalBulletId ()
 
static void destroyReferenceObject ()
 

Private Member Functions

void build3dObject ()
 

Private Attributes

BulletId m_id
 Unique bullet id for identifying.
 
WeaponId m_wpnId
 Unique weapon id.
 
PR00FsUltimateRenderingEngine & m_gfx
 
pge_network::PgeNetworkConnectionHandle m_connHandle
 Owner (shooter) of this bullet.
 
PurePosUpTarget m_put
 PUT to calculate next position.
 
TPureFloat m_speed
 Speed as defined by weapon file.
 
TPureFloat m_gravity
 Gravity as defined by weapon file.
 
TPureFloat m_drag
 Drag as defined by weapon file.
 
TPureBool m_fragile
 Fragile flag as defined by weapon file.
 
TPureFloat m_fDistMax
 Max distance as defined by weapon file.
 
TPureFloat m_fDistTravelled
 Distance travelled so far.
 
ParticleType m_particleType
 Emitted particle type.
 
int m_nParticleEmitPerNthPhysicsIterCntr
 Counter to be used by particle emitter logic.
 
int m_nParticlesEmittedCurrent
 Counter to be used by particle emitter logic.
 
int m_nDamageAp
 Damage to AP as defined by weapon file.
 
int m_nDamageHp
 Damage to HP as defined by weapon file.
 
TPureFloat m_fDamageAreaSize
 Area damage size as defined by weapon file.
 
DamageAreaEffect m_eDamageAreaEffect
 Area damage effect as defined by weapon file.
 
TPureFloat m_fDamageAreaPulse
 Area damage pulse to HP as defined by weapon file.
 
PureObject3D * m_obj
 Associated Pure object to be rendered.
 
bool m_bCreateSentToClients
 Server should send update to clients about creation of new bullets.
 

Static Private Attributes

static BulletId m_globalBulletId = 0
 Next unique bullet id for identifying.
 
static PureObject3D * m_pObjRef = nullptr
 Reference object for cloned bullet objects.
 

Member Typedef Documentation

◆ BulletId

uint32_t Bullet::BulletId

Definition at line 58 of file WeaponManager.h.

Member Enumeration Documentation

◆ DamageAreaEffect

Enumerator
Constant 
Linear 

Definition at line 47 of file WeaponManager.h.

◆ ParticleType

Enumerator
None 
Smoke 

Definition at line 41 of file WeaponManager.h.

Constructor & Destructor Documentation

◆ Bullet() [1/4]

Bullet::Bullet ( const WeaponId & wpnId,
PR00FsUltimateRenderingEngine & gfx,
pge_network::PgeNetworkConnectionHandle connHandle,
TPureFloat wpn_px,
TPureFloat wpn_py,
TPureFloat wpn_pz,
TPureFloat wpn_ax,
TPureFloat wpn_ay,
TPureFloat wpn_az,
bool visible,
TPureFloat sx,
TPureFloat sy,
TPureFloat sz,
TPureFloat speed,
TPureFloat gravity,
TPureFloat drag,
TPureBool fragile,
TPureFloat fDistMax,
const ParticleType & particleType,
int nDamageAp,
int nDamageHp,
TPureFloat fDamageAreaSize,
const DamageAreaEffect & eDamageAreaEffect,
TPureFloat fDamageAreaPulse )

Ctor to be used by PGE server instance.

Definition at line 53 of file WeaponManager.cpp.

◆ Bullet() [2/4]

Bullet::Bullet ( const WeaponId & wpnId,
PR00FsUltimateRenderingEngine & gfx,
TPureFloat wpn_px,
TPureFloat wpn_py,
TPureFloat wpn_pz,
TPureFloat wpn_ax,
TPureFloat wpn_ay,
TPureFloat wpn_az,
bool visible,
TPureFloat sx,
TPureFloat sy,
TPureFloat sz,
TPureFloat speed,
TPureFloat gravity,
TPureFloat drag,
const ParticleType & particleType,
int nDamageHp,
const TPureFloat & fDamageAreaSize,
const DamageAreaEffect & eDamageAreaEffect,
const TPureFloat & fDamageAreaPulse )

Ctor to be used by PGE client instance.

Definition at line 96 of file WeaponManager.cpp.

◆ ~Bullet()

Bullet::~Bullet ( )
virtual

User is expected to explicitly call Bullet::destroyReferenceObject() after they freed up all Bullet instances.

PGE also calls it when destroying the game, but the game might do it based on their use case.

Definition at line 134 of file WeaponManager.cpp.

◆ Bullet() [3/4]

Bullet::Bullet ( const Bullet & )
delete

◆ Bullet() [4/4]

Bullet::Bullet ( Bullet && )
delete

Member Function Documentation

◆ build3dObject()

void Bullet::build3dObject ( )
private

Definition at line 414 of file WeaponManager.cpp.

◆ destroyReferenceObject()

void Bullet::destroyReferenceObject ( )
static

Definition at line 40 of file WeaponManager.cpp.

◆ getAreaDamageEffect()

const Bullet::DamageAreaEffect & Bullet::getAreaDamageEffect ( ) const

Definition at line 254 of file WeaponManager.cpp.

◆ getAreaDamagePulse()

TPureFloat Bullet::getAreaDamagePulse ( ) const

Definition at line 259 of file WeaponManager.cpp.

◆ getAreaDamageSize()

TPureFloat Bullet::getAreaDamageSize ( ) const

Definition at line 249 of file WeaponManager.cpp.

◆ getConsole()

CConsole & Bullet::getConsole ( ) const

Returns access to console preset with logger module name as this class.

Definition at line 142 of file WeaponManager.cpp.

◆ getDamageAp()

int Bullet::getDamageAp ( ) const

Maximum damage to Player AP this bullet can cause.

Definition at line 227 of file WeaponManager.cpp.

◆ getDamageHp()

int Bullet::getDamageHp ( ) const

Maximum damage to Player HP this bullet can cause.

It is the game's responsibility to calculate actual damage to player. A recommendation I was also doing in PRooFPS v0.2.7:

  • Player has AP and HP;
  • explosive bullets make radius damage where damage amount is linear decreasing from radius center until edge;
  • non-explosive bullets make damage upon hitting target;
  • Player has takeDamage() function which is responsible for calculating the damage taken by AP and HP, based on input Bullet::getDamageAp() and Bullet::getDamageHp();
  • if AP is non-0, then it decreases the damage caused to HP.

Definition at line 244 of file WeaponManager.cpp.

◆ getDrag()

TPureFloat Bullet::getDrag ( ) const

Definition at line 177 of file WeaponManager.cpp.

◆ getGlobalBulletId()

Bullet::BulletId Bullet::getGlobalBulletId ( )
static

Definition at line 30 of file WeaponManager.cpp.

◆ getGravity()

TPureFloat Bullet::getGravity ( ) const

Definition at line 172 of file WeaponManager.cpp.

◆ getId()

Bullet::BulletId Bullet::getId ( ) const

Definition at line 147 of file WeaponManager.cpp.

◆ getLoggerModuleName()

const char * Bullet::getLoggerModuleName ( )
static

Returns the logger module name of this class.

Definition at line 25 of file WeaponManager.cpp.

◆ getObject3D() [1/2]

PureObject3D & Bullet::getObject3D ( )

Definition at line 404 of file WeaponManager.cpp.

◆ getObject3D() [2/2]

const PureObject3D & Bullet::getObject3D ( ) const

Definition at line 409 of file WeaponManager.cpp.

◆ getOwner()

pge_network::PgeNetworkConnectionHandle Bullet::getOwner ( ) const

Definition at line 157 of file WeaponManager.cpp.

◆ getParticleEmitPerNthPhysicsIterationCntr() [1/2]

int & Bullet::getParticleEmitPerNthPhysicsIterationCntr ( )

Definition at line 192 of file WeaponManager.cpp.

◆ getParticleEmitPerNthPhysicsIterationCntr() [2/2]

const int & Bullet::getParticleEmitPerNthPhysicsIterationCntr ( ) const

Definition at line 197 of file WeaponManager.cpp.

◆ getParticlesEmittedTotal() [1/2]

int & Bullet::getParticlesEmittedTotal ( )

Definition at line 202 of file WeaponManager.cpp.

◆ getParticlesEmittedTotal() [2/2]

const int & Bullet::getParticlesEmittedTotal ( ) const

Definition at line 208 of file WeaponManager.cpp.

◆ getParticleType()

const Bullet::ParticleType & Bullet::getParticleType ( ) const

Definition at line 187 of file WeaponManager.cpp.

◆ getPut()

const PurePosUpTarget & Bullet::getPut ( ) const

Definition at line 162 of file WeaponManager.cpp.

◆ getSpeed()

TPureFloat Bullet::getSpeed ( ) const

Definition at line 167 of file WeaponManager.cpp.

◆ getTravelDistanceMax()

TPureFloat Bullet::getTravelDistanceMax ( ) const

Definition at line 214 of file WeaponManager.cpp.

◆ getTravelledDistance()

TPureFloat Bullet::getTravelledDistance ( ) const

Definition at line 219 of file WeaponManager.cpp.

◆ getWeaponId()

const WeaponId & Bullet::getWeaponId ( ) const

Definition at line 152 of file WeaponManager.cpp.

◆ init() [1/2]

void Bullet::init ( const BulletId & id,
const WeaponId & wpnId,
PR00FsUltimateRenderingEngine & gfx,
TPureFloat wpn_px,
TPureFloat wpn_py,
TPureFloat wpn_pz,
TPureFloat wpn_ax,
TPureFloat wpn_ay,
TPureFloat wpn_az,
bool visible,
TPureFloat sx,
TPureFloat sy,
TPureFloat sz,
TPureFloat speed,
TPureFloat gravity,
TPureFloat drag,
const ParticleType & particleType,
int nDamageHp,
TPureFloat fDamageAreaSize,
const DamageAreaEffect & eDamageAreaEffect,
TPureFloat fDamageAreaPulse )

Init to be used by PGE client instance.

This also gets invoked by PgeObjectPool::create() when PooledBullet instances are stored there.

Definition at line 338 of file WeaponManager.cpp.

◆ init() [2/2]

void Bullet::init ( const WeaponId & wpnId,
PR00FsUltimateRenderingEngine & gfx,
pge_network::PgeNetworkConnectionHandle connHandle,
TPureFloat wpn_px,
TPureFloat wpn_py,
TPureFloat wpn_pz,
TPureFloat wpn_ax,
TPureFloat wpn_ay,
TPureFloat wpn_az,
bool visible,
TPureFloat sx,
TPureFloat sy,
TPureFloat sz,
TPureFloat speed,
TPureFloat gravity,
TPureFloat drag,
TPureBool fragile,
TPureFloat fDistMax,
const ParticleType & particleType,
int nDamageAp,
int nDamageHp,
TPureFloat fDamageAreaSize,
const DamageAreaEffect & eDamageAreaEffect,
TPureFloat fDamageAreaPulse )

Init to be used by PGE server instance.

This also gets invoked by PgeObjectPool::create() when PooledBullet instances are stored there.

Definition at line 269 of file WeaponManager.cpp.

◆ isCreateSentToClients()

bool & Bullet::isCreateSentToClients ( )

Definition at line 264 of file WeaponManager.cpp.

◆ isFragile()

TPureBool Bullet::isFragile ( ) const

Definition at line 182 of file WeaponManager.cpp.

◆ operator=() [1/2]

Bullet & Bullet::operator= ( Bullet && )
delete

◆ operator=() [2/2]

Bullet & Bullet::operator= ( const Bullet & )
delete

◆ resetGlobalBulletId()

void Bullet::resetGlobalBulletId ( )
static

Definition at line 35 of file WeaponManager.cpp.

◆ Update()

void Bullet::Update ( const unsigned int & nFactor)

Definition at line 376 of file WeaponManager.cpp.

Member Data Documentation

◆ m_bCreateSentToClients

bool Bullet::m_bCreateSentToClients
private

Server should send update to clients about creation of new bullets.

By default false, client ignores.

Definition at line 262 of file WeaponManager.h.

◆ m_connHandle

pge_network::PgeNetworkConnectionHandle Bullet::m_connHandle
private

Owner (shooter) of this bullet.

Used by PGE server instance only.

Definition at line 242 of file WeaponManager.h.

◆ m_drag

TPureFloat Bullet::m_drag
private

Drag as defined by weapon file.

Used by both PGE client and server instances.

Definition at line 246 of file WeaponManager.h.

◆ m_eDamageAreaEffect

DamageAreaEffect Bullet::m_eDamageAreaEffect
private

Area damage effect as defined by weapon file.

Used by both PGE client and server instances.

Definition at line 256 of file WeaponManager.h.

◆ m_fDamageAreaPulse

TPureFloat Bullet::m_fDamageAreaPulse
private

Area damage pulse to HP as defined by weapon file.

Used by both PGE client and server instances.

Definition at line 257 of file WeaponManager.h.

◆ m_fDamageAreaSize

TPureFloat Bullet::m_fDamageAreaSize
private

Area damage size as defined by weapon file.

Used by both PGE client and server instances.

Definition at line 255 of file WeaponManager.h.

◆ m_fDistMax

TPureFloat Bullet::m_fDistMax
private

Max distance as defined by weapon file.

Used by PGE server instance only.

Definition at line 248 of file WeaponManager.h.

◆ m_fDistTravelled

TPureFloat Bullet::m_fDistTravelled
private

Distance travelled so far.

Used by both PGE client and server instances.

Definition at line 249 of file WeaponManager.h.

◆ m_fragile

TPureBool Bullet::m_fragile
private

Fragile flag as defined by weapon file.

Used by PGE server instance only.

Definition at line 247 of file WeaponManager.h.

◆ m_gfx

PR00FsUltimateRenderingEngine& Bullet::m_gfx
private

Definition at line 241 of file WeaponManager.h.

◆ m_globalBulletId

Bullet::BulletId Bullet::m_globalBulletId = 0
staticprivate

Next unique bullet id for identifying.

Used by PGE server instance only.

Definition at line 236 of file WeaponManager.h.

◆ m_gravity

TPureFloat Bullet::m_gravity
private

Gravity as defined by weapon file.

Used by both PGE client and server instances.

Definition at line 245 of file WeaponManager.h.

◆ m_id

BulletId Bullet::m_id
private

Unique bullet id for identifying.

Used by both PGE client and server instances.

Definition at line 239 of file WeaponManager.h.

◆ m_nDamageAp

int Bullet::m_nDamageAp
private

Damage to AP as defined by weapon file.

Used by PGE server instance only.

Definition at line 253 of file WeaponManager.h.

◆ m_nDamageHp

int Bullet::m_nDamageHp
private

Damage to HP as defined by weapon file.

Used by both PGE client and server instances.

Definition at line 254 of file WeaponManager.h.

◆ m_nParticleEmitPerNthPhysicsIterCntr

int Bullet::m_nParticleEmitPerNthPhysicsIterCntr
private

Counter to be used by particle emitter logic.

Used by both PGE client and server instances.

Definition at line 251 of file WeaponManager.h.

◆ m_nParticlesEmittedCurrent

int Bullet::m_nParticlesEmittedCurrent
private

Counter to be used by particle emitter logic.

Used by both PGE client and server instances.

Definition at line 252 of file WeaponManager.h.

◆ m_obj

PureObject3D* Bullet::m_obj
private

Associated Pure object to be rendered.

Used by PGE server and client instances. TODO: shared ptr would be better though, so deleting the obj earlier than bullet instance wouldn't be a problem.

Definition at line 259 of file WeaponManager.h.

◆ m_particleType

ParticleType Bullet::m_particleType
private

Emitted particle type.

Used by both PGE client and server instances.

Definition at line 250 of file WeaponManager.h.

◆ m_pObjRef

PureObject3D * Bullet::m_pObjRef = nullptr
staticprivate

Reference object for cloned bullet objects.

Definition at line 237 of file WeaponManager.h.

◆ m_put

PurePosUpTarget Bullet::m_put
private

PUT to calculate next position.

Used by both PGE client and server instances.

Definition at line 243 of file WeaponManager.h.

◆ m_speed

TPureFloat Bullet::m_speed
private

Speed as defined by weapon file.

Used by both PGE client and server instances.

Definition at line 244 of file WeaponManager.h.

◆ m_wpnId

WeaponId Bullet::m_wpnId
private

Unique weapon id.

Used by both PGE client and server instances.

Definition at line 240 of file WeaponManager.h.


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