#ifndef _H_WEAPON_H #define _H_WEAPON_H #include #include #include #include "util.h" #include "gameplay/entity.h" #include "gameplay/weapons/bullet.h" #include "utility/direction.h" // TODO: Put all weapons inside of this base, we don't need a class for every weapon, we only need one class! class Shader; class Component; class Camera; class BulletManager; class EventManager; class ResourceManager; class GameActor; struct WeaponData; class Weapon : public Entity { public: Weapon(const WeaponData* data, const std::shared_ptr& weaponShader, const std::shared_ptr& bulletShader, ResourceManager* resourceManager); void setWielder(const std::shared_ptr& wielder) { this->wielder = wielder; } void addComponent(const std::shared_ptr& component); void hookEventManager(const std::shared_ptr& eventManager); void shoot(); void update(float deltaTime); void render(const std::shared_ptr& camera); private: struct BulletData { glm::vec3 origin; glm::vec2 direction; float mass; float sizeMod; float speedMod; float dropMod; }; void adjustWeapon(); BulletData genBulletData(); std::shared_ptr createBullet(const BulletData& data); glm::vec2 weaponSize; glm::vec2 weaponOffset; float bulletSpeed; float bulletDrop; // in ms float fireSpeed; glm::vec2 bulletSize; std::shared_ptr bulletShader; std::shared_ptr bulletSprite; std::shared_ptr bulletManager; std::shared_ptr eventManager; std::shared_ptr bulletSpread; std::shared_ptr bulletModifer; std::shared_ptr wielder; int lastFireTime = 0; Direction lastDir; std::vector > components; }; #endif // _H_WEAPON_H