#ifndef WEAPON_HH
#define WEAPON_HH
// forward-declare
class Weapon;
typedef unsigned int WeaponID;
#include "GameState.hh"
#include "Projectile.hh"
#include "Timer.hh"
#include <string>
/**
* A Weapon is something that a Player has in their list of weapons. It has a name, some parameters related to the
* weapon itself (name, reload time), and some parameters related to the projectiles that it creates (velocity,
* radius, etc).
*/
class Weapon {
protected:
/**
* weapon's index in player's weapons list
*/
WeaponID id;
/**
* weapon name
*/
std::string name;
/**
* projectile velocity
*/
float velocity;
/**
* Damage it does to player's health.
*/
int damage;
/**
* radius of damage done on impact
*/
float explosionRadius;
/**
* radius of projectile itself
*/
float radius;
/**
* how long it takes to reload
*/
TimeMS reloadTime;
/**
* recoil force, backwards
*/
float recoil;
/**
* XXX: unused
*/
int clipSize;
/**
* How many ticks projectiles last
*/
TickCount expire;
/**
* Remaining reload time
*/
TimeMS reloadTimer;
/**
* If nonzero, projectiles bounce off walls (it's the elasticity factor), else they explode on contact
*/
float bounce;
/**
* Projectile mass
*/
float mass;
public:
/**
* Create a weapon with the given parameters
*/
Weapon (WeaponID id, TickCount expire, float velocity, float recoil, int damage, float explosionRadius, float radius, TimeMS reloadTime, std::string name, float bounce, float mass);
/**
* Decrement the reload timer, if it's still going
*/
void tickReload (TimeMS dt);
/**
* Can the weapon be fired (not reloading, have a clip, etc)
*/
bool canShoot (void) const;
/*
* Get weapon parameters
*/
WeaponID getID (void) const { return id; }
std::string getName (void) const { return name; }
float getSpeed (void) const { return velocity; }
float getRecoil (void) const { return recoil; }
float getExplosionRadius (void) const { return explosionRadius; }
// XXX: int -> Health
Health getDamage (void) const { return (Health) damage; }
float getRadius (void) const { return radius; }
TickCount getExpire (void) const { return expire; }
float getBounce (void) const { return bounce; }
float getMass (void) const { return mass; }
// XXX: remove one of these
TimeMS getReloadTimer(void) const { return reloadTimer; }
TimeMS getReloadTime(void) const { return reloadTime; }
/**
* Start reloading
*/
void reload (void);
};
#endif