This repository has been archived on 2019-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
dungeon-gunner/source/items/Weapon.h
2013-06-25 17:44:40 +02:00

60 lines
1 KiB
C++
Executable file

/*
* Weapon.h
*
* Created on: 12.08.2012
* Author: Felix
*/
#ifndef DG_WEAPON_H_
#define DG_WEAPON_H_
#include <string>
#include <SFML/System.hpp>
#include <Thor/Time.hpp>
#include "../particle/Emitter.h"
class Character;
class World;
class Particle;
class Yaml;
/**
* Loading mechanism:
* - pass enum value and load mapped xml
* - pass xml filename
*/
class Weapon : public Emitter {
public:
explicit Weapon(World& world, Character& holder, const Yaml& config);
void pullTrigger();
void releaseTrigger();
void onThink(int elapsed);
int getMagazineAmmo() const;
int getTotalAmmo() const;
void reload();
protected:
std::shared_ptr<Sprite> createParticle();
private:
Character& mHolder;
thor::Timer mTimer;
const std::string mBullet;
const int mFireInterval;
const int mReloadTime;
bool mFire;
bool mAutomatic;
const int mMagazineSize;
int mMagazineAmmo;
const int mMaxTotalAmmo;
int mTotalAmmo;
bool mIsReloading = false;
};
#endif /* DG_WEAPON_H_ */