src/Weapon.hh
author terom
Sat, 06 Dec 2008 22:47:08 +0000
changeset 233 ff4ecea83cf5
parent 223 2fcaf54ed37b
child 235 0a0c729365ee
permissions -rw-r--r--
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     1
#ifndef WEAPON_HH
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     2
#define WEAPON_HH
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     3
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     4
// forward-declare
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     5
class Weapon;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     6
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     7
#include "GameState.hh"
222
293ddf4c067d reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents: 221
diff changeset
     8
#include "Projectile.hh"
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     9
#include "Timer.hh"
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    10
#include <string>
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    11
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    12
class Weapon {
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    13
protected:
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    14
    GameState &st;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    15
    std::string name;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    16
    float velocity;
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    17
    float explosionRadius;
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    18
    int reloadTime; //in ms
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    19
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    20
    int clipSize;
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    21
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    22
    bool visible;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    23
    TickCount age;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    24
    int reloadTimer;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    25
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    26
public:
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    27
    Weapon (GameState &st, TickCount age, float velocity, float explosionRadius, int reloadTime, std::string name);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    28
    Weapon (const Weapon& orig);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    29
    Weapon& operator= (const Weapon& orig);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    30
    
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    31
    // advance the reload timer
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    32
    void tickReload (TimeMS dt);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    33
    
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    34
    // can the weapon be fired (not reloading, have a clip, etc)
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    35
    bool canShoot (void);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    36
    
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    37
    // get weapon parameters
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 223
diff changeset
    38
    std::string getName (void) { return name; }
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    39
    float getVelocity (void) { return velocity; }
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    40
    float getExplosionRadius (void) { return explosionRadius; }
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    41
    TickCount getExpireTicks (void) { return age; }
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    42
    
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    43
    // start reloading
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    44
    void reload (void);
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    45
};
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    46
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    47
#endif