2012-09-09 20:50:15 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2013-06-25 19:28:22 +00:00
|
|
|
#include <random>
|
2013-03-29 17:34:51 +00:00
|
|
|
|
|
|
|
#include <SFML/System.hpp>
|
2012-09-09 20:50:15 +00:00
|
|
|
|
2013-06-25 15:44:40 +00:00
|
|
|
#include <Thor/Time.hpp>
|
|
|
|
|
2013-06-25 16:28:18 +00:00
|
|
|
#include "../util/Yaml.h"
|
2012-09-09 20:50:15 +00:00
|
|
|
|
2013-05-26 18:44:59 +00:00
|
|
|
class Character;
|
2013-03-29 16:59:35 +00:00
|
|
|
class World;
|
|
|
|
class Particle;
|
2013-05-26 18:44:59 +00:00
|
|
|
class Yaml;
|
2012-09-14 18:39:56 +00:00
|
|
|
|
2013-06-25 18:59:03 +00:00
|
|
|
class Weapon {
|
2012-09-09 20:50:15 +00:00
|
|
|
public:
|
2013-05-26 18:44:59 +00:00
|
|
|
explicit Weapon(World& world, Character& holder, const Yaml& config);
|
2012-09-09 20:50:15 +00:00
|
|
|
|
2012-12-24 00:14:22 +00:00
|
|
|
void pullTrigger();
|
|
|
|
void releaseTrigger();
|
2013-03-09 15:25:04 +00:00
|
|
|
void onThink(int elapsed);
|
2013-06-25 15:44:40 +00:00
|
|
|
int getMagazineAmmo() const;
|
|
|
|
int getTotalAmmo() const;
|
|
|
|
void reload();
|
2013-04-04 21:00:52 +00:00
|
|
|
|
2013-06-25 18:59:03 +00:00
|
|
|
private:
|
|
|
|
void fire();
|
|
|
|
void insertProjectile(float angle);
|
2012-09-09 20:50:15 +00:00
|
|
|
|
|
|
|
private:
|
2013-06-25 18:59:03 +00:00
|
|
|
World& mWorld;
|
2013-05-26 18:44:59 +00:00
|
|
|
Character& mHolder;
|
2012-10-12 17:04:34 +00:00
|
|
|
|
2013-06-25 15:44:40 +00:00
|
|
|
thor::Timer mTimer;
|
2013-06-25 16:28:18 +00:00
|
|
|
const Yaml mProjectile;
|
|
|
|
const int mDamage;
|
|
|
|
const float mProjectileSpeed;
|
2013-06-25 15:44:40 +00:00
|
|
|
const int mFireInterval;
|
|
|
|
const int mReloadTime;
|
2013-06-25 18:59:03 +00:00
|
|
|
bool mFiring;
|
|
|
|
const bool mAutomatic;
|
2013-06-25 15:44:40 +00:00
|
|
|
const int mMagazineSize;
|
|
|
|
int mMagazineAmmo;
|
|
|
|
const int mMaxTotalAmmo;
|
|
|
|
int mTotalAmmo;
|
|
|
|
bool mIsReloading = false;
|
2013-06-25 18:59:03 +00:00
|
|
|
const int mPellets;
|
|
|
|
const float mPelletSpread;
|
|
|
|
const bool mReloadSingle;
|
2013-06-25 19:28:22 +00:00
|
|
|
const float mSpread;
|
2013-06-25 19:35:58 +00:00
|
|
|
const float mSpreadMoving;
|
2013-06-25 19:28:22 +00:00
|
|
|
std::default_random_engine mGenerator;
|
2012-10-19 13:44:45 +00:00
|
|
|
|
2012-09-09 20:50:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* DG_WEAPON_H_ */
|