1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 19:32:49 +01:00
openrw/rwengine/include/objects/ProjectileObject.hpp
2015-04-27 02:09:56 +01:00

67 lines
1.2 KiB
C++

#pragma once
#ifndef _PROJECTILEOBJECT_HPP_
#define _PROJECTILEOBJECT_HPP_
#include <objects/GameObject.hpp>
#include <data/WeaponData.hpp>
#include <bullet/btBulletDynamicsCommon.h>
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
/**
* @brief Implements weapon projectile (e.g. molotovs, RPGs etc.)
*/
class ProjectileObject : public GameObject
{
public:
enum ProjectileType {
Grenade,
Molotov,
RPG,
};
struct ProjectileInfo {
ProjectileType type;
glm::vec3 direction;
float velocity;
/** Time to dentonation or removal */
float time;
std::shared_ptr<WeaponData> weapon;
};
private:
ProjectileInfo _info;
btSphereShape* _shape;
btRigidBody* _body;
/** Used for RPGs and Molotov collision detection */
btPairCachingGhostObject* _ghostBody;
bool _exploded;
void checkPhysicsContact();
void explode();
void cleanup();
public:
/**
* @brief ProjectileObject constructor
*/
ProjectileObject(GameWorld* world, const glm::vec3& position, const ProjectileInfo& info);
~ProjectileObject();
void tick(float dt);
Type type() { return Projectile; }
const ProjectileInfo& getProjectileInfo() const { return _info; }
};
#endif