2013-09-09 00:18:36 +01:00
|
|
|
#pragma once
|
2014-02-28 11:23:51 +00:00
|
|
|
#ifndef _GAMEOBJECT_HPP_
|
|
|
|
#define _GAMEOBJECT_HPP_
|
2013-09-09 00:18:36 +01:00
|
|
|
|
2013-12-20 14:03:32 +00:00
|
|
|
#include <engine/GTATypes.hpp>
|
|
|
|
#include <loaders/LoaderIDE.hpp>
|
|
|
|
#include <loaders/LoaderIPL.hpp>
|
2013-09-09 00:18:36 +01:00
|
|
|
#include <glm/gtc/quaternion.hpp>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class GTAAIController;
|
|
|
|
class Model;
|
2014-03-01 04:12:35 +00:00
|
|
|
class ModelFrame;
|
2013-09-11 00:26:13 +01:00
|
|
|
class Animator;
|
2013-09-09 00:18:36 +01:00
|
|
|
|
2013-12-20 16:02:46 +00:00
|
|
|
class GameWorld;
|
2013-09-09 00:18:36 +01:00
|
|
|
|
|
|
|
/**
|
2014-02-13 10:55:11 +00:00
|
|
|
* Stores data used by call types of object instances.
|
2013-09-09 00:18:36 +01:00
|
|
|
*/
|
2014-02-28 11:23:51 +00:00
|
|
|
struct GameObject
|
2013-09-09 00:18:36 +01:00
|
|
|
{
|
|
|
|
glm::vec3 position;
|
|
|
|
glm::quat rotation;
|
|
|
|
|
|
|
|
Model* model; /// Cached pointer to Object's Model.
|
|
|
|
|
2013-12-20 16:02:46 +00:00
|
|
|
GameWorld* engine;
|
2013-09-09 00:18:36 +01:00
|
|
|
|
2013-09-11 00:26:13 +01:00
|
|
|
Animator* animator; /// Object's animator.
|
2013-12-06 21:25:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Health value
|
|
|
|
*/
|
2014-06-02 00:08:48 +01:00
|
|
|
float mHealth;
|
|
|
|
|
2014-02-28 11:23:51 +00:00
|
|
|
GameObject(GameWorld* engine, const glm::vec3& pos, const glm::quat& rot, Model* model)
|
2014-06-02 04:58:41 +01:00
|
|
|
: position(pos), rotation(rot), model(model), engine(engine), animator(nullptr), mHealth(0.f)
|
2014-06-02 00:08:48 +01:00
|
|
|
{}
|
2013-12-12 02:55:31 +00:00
|
|
|
|
2014-06-02 00:08:48 +01:00
|
|
|
virtual ~GameObject() {}
|
2013-09-09 00:18:36 +01:00
|
|
|
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
Instance,
|
|
|
|
Character,
|
2014-03-01 11:19:33 +00:00
|
|
|
Vehicle,
|
|
|
|
Unknown
|
2013-09-09 00:18:36 +01:00
|
|
|
};
|
|
|
|
|
2014-03-01 11:19:33 +00:00
|
|
|
virtual Type type() { return Unknown; }
|
2013-09-09 00:18:36 +01:00
|
|
|
|
|
|
|
virtual void setPosition(const glm::vec3& pos);
|
|
|
|
|
|
|
|
virtual glm::vec3 getPosition() const;
|
2013-09-09 04:04:21 +01:00
|
|
|
|
|
|
|
virtual glm::quat getRotation() const;
|
2013-12-06 21:25:34 +00:00
|
|
|
|
|
|
|
struct DamageInfo
|
|
|
|
{
|
|
|
|
enum DamageType
|
|
|
|
{
|
|
|
|
Explosion,
|
|
|
|
Burning,
|
|
|
|
Bullet,
|
|
|
|
Physics
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* World position of damage
|
|
|
|
*/
|
|
|
|
glm::vec3 damageLocation;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* World position of the source (used for direction)
|
|
|
|
*/
|
|
|
|
glm::vec3 damageSource;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Magnitude of destruction
|
|
|
|
*/
|
|
|
|
float hitpoints;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Type of the damage
|
|
|
|
*/
|
|
|
|
DamageType type;
|
|
|
|
};
|
|
|
|
|
2014-03-01 04:12:35 +00:00
|
|
|
virtual bool takeDamage(const DamageInfo& damage) { return false; }
|
|
|
|
|
|
|
|
virtual bool isFrameVisible(ModelFrame* frame) const { return true; }
|
2014-06-02 04:58:41 +01:00
|
|
|
|
|
|
|
virtual bool isAnimationFixed() const { return true; }
|
2013-09-09 00:18:36 +01:00
|
|
|
};
|
|
|
|
|
2014-02-28 11:23:51 +00:00
|
|
|
#endif // __GAMEOBJECTS_HPP__
|