src/Weapon.hh
author saiam
Mon, 08 Dec 2008 00:05:45 +0000
changeset 273 eeb699e1d908
parent 271 bf6784a95b08
child 276 87434abc1ba1
permissions -rw-r--r--
Made forceq to contain time again.
#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>

class Weapon {
protected:
    /**
     *  weapon's index in player's weapons list
     */
    WeaponID id;

    /**
     * weapon name
     */
    std::string name;

    /**
     * projectile velocity
     */
    float velocity;

    /**
     * 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;

    /**
     * current reload state
     */
    int reloadTimer;

public:
    /**
     * Create a weapon with the given parameters
     */
    Weapon (WeaponID id, TickCount expire, float velocity, float recoil, float explosionRadius, float radius, TimeMS reloadTime, std::string name);
    
    /**
     * 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
     */
    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; }
    float getRadius (void) const { return radius; }
    TickCount getExpire (void) const { return expire; }
    
    /**
     * Start reloading
     */
    void reload (void);
};

#endif