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

75 lines
1.4 KiB
C
Raw Normal View History

/*
* Weapon.h
*
* Created on: 12.08.2012
* Author: Felix
*/
#ifndef DG_WEAPON_H_
#define DG_WEAPON_H_
2013-03-29 17:34:51 +00:00
#include <string>
#include <random>
2013-03-29 17:34:51 +00:00
#include <SFML/System.hpp>
#include <Thor/Time.hpp>
2013-07-14 19:56:44 +00:00
#include "Item.h"
#include "../util/Yaml.h"
2013-05-26 18:44:59 +00:00
class Character;
class World;
class Particle;
2013-05-26 18:44:59 +00:00
class Yaml;
2013-07-14 19:56:44 +00:00
class Weapon : public Item {
public:
2013-05-26 18:44:59 +00:00
explicit Weapon(World& world, Character& holder, const Yaml& config);
2012-12-24 00:14:22 +00:00
void pullTrigger();
void releaseTrigger();
2013-03-09 15:25:04 +00:00
void onThink(int elapsed);
int getMagazineAmmo() const;
int getTotalAmmo() const;
2013-07-06 11:38:15 +00:00
std::string getName() const;
void reload();
2013-06-25 20:00:40 +00:00
void cancelReload();
2013-07-21 08:52:50 +00:00
void setHolder(Character& holder);
private:
void fire();
void insertProjectile(float angle);
private:
World& mWorld;
2013-07-21 08:52:50 +00:00
/// Non-owning pointer instead of reference to allow reassigning.
Character* mHolder;
thor::Timer mTimer;
2013-07-06 11:38:15 +00:00
const std::string mName;
const Yaml mProjectile;
const int mDamage;
const float mProjectileSpeed;
const int mFireInterval;
const int mReloadTime;
bool mFiring;
const bool mAutomatic;
const int mMagazineSize;
int mMagazineAmmo;
const int mMaxTotalAmmo;
int mTotalAmmo;
bool mIsReloading = false;
const int mPellets;
const float mPelletSpread;
const bool mReloadSingle;
const float mSpread;
const float mSpreadMoving;
2013-07-06 11:22:55 +00:00
const float mMaxRange;
const float mRequiresAmmo;
std::default_random_engine mGenerator;
};
#endif /* DG_WEAPON_H_ */