#ifndef PROJECTILE_HH
#define PROJECTILE_HH
class Projectile;
#include "GameState.hh"
#include "Player.hh"
#include "PhysicsObject.hh"
#include "Timer.hh"
#include "Types.hh"
#include "GraphicsPointer.hh"
/**
* A projectile is a flying PhysicsObject, created by firing a player's weapon. It has an initial velocity, is
* represented as a diamond-shape with the given "radius", can explode or bounce on collisions, expires at some point,
* and can remove ground around it upon exploding.
*/
class Projectile : public PhysicsObject {
protected:
/**
* Which player fired this projectile?
*/
Player *player;
/**
* Projectiles can be inivisble, e.g. for digging
*/
bool visible;
Weapon *weapon;
/**
* The tick we were spawned at
*/
TickCount birth_tick;
public:
/**
* Constructs this projectile using the given position/velocity, pulling the rest of the parameter values from the
* given weapon. The given player is assigned to this projectile.
*/
Projectile (Player *player, Vector position, Vector velocity, Weapon *weapon, bool visible = true);
/**
* Removes this from the world's list of projectiles
*/
virtual ~Projectile (void);
/**
* Draw
*/
virtual void draw (Graphics *g, PixelCoordinate camera) const;
protected:
/**
* Removes ground at given position if applicable, and destroys this PhysicsObject.
*
* This is overriden by Network.
*/
virtual void onDestroy (Vector position, bool removeGround);
/**
* This Projectile has hit the given player.
*
* This Projectile inflicts a certain amount of damage on the player. We are not destroyed, this can be called
* multiple times...
*/
virtual void onHitPlayer (Player *player, Health damage);
/**
* Call onDestroy, removingGround
*/
virtual void onCollision (Vector collisionPoint, PhysicsObject *other);
/**
* If we have expired, call onDestory and removeGround
*/
virtual void tick (TimeMS dt);
};
#endif