openrw/rwengine/include/engine/GameObject.hpp
Daniel Evans e5cc47132f Initial documentation pass
Add a nice doxygen file.
2014-07-09 05:04:48 +01:00

122 lines
2.2 KiB
C++

#pragma once
#ifndef _GAMEOBJECT_HPP_
#define _GAMEOBJECT_HPP_
#include <engine/RWTypes.hpp>
#include <loaders/LoaderIDE.hpp>
#include <loaders/LoaderIPL.hpp>
#include <glm/gtc/quaternion.hpp>
#include <memory>
class CharacterController;
class ModelFrame;
class Animator;
class GameWorld;
/**
* @brief Base data and interface for all world "objects" like vehicles, peds.
*
* Contains handle to the world, and other useful properties like water level
* tracking used to make tunnels work.
*/
struct GameObject
{
glm::vec3 position;
glm::quat rotation;
ModelHandle* model; /// Cached pointer to Object's Model.
GameWorld* engine;
Animator* animator; /// Object's animator.
/**
* Health value
*/
float mHealth;
bool _inWater;
/**
* @brief stores the height of water at the last tick
*/
float _lastHeight;
GameObject(GameWorld* engine, const glm::vec3& pos, const glm::quat& rot, ModelHandle* model)
: position(pos), rotation(rot), model(model), engine(engine), animator(nullptr), mHealth(0.f),
_inWater(false), _lastHeight(std::numeric_limits<float>::max())
{}
virtual ~GameObject() {}
/**
* @brief Enumeration of possible object types.
*/
enum Type
{
Instance,
Character,
Vehicle,
Pickup,
Unknown
};
/**
* @brief determines what type of object this is.
* @return one of Type
*/
virtual Type type() { return Unknown; }
virtual void setPosition(const glm::vec3& pos);
virtual glm::vec3 getPosition() const;
virtual glm::quat getRotation() const;
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;
/**
* Physics impulse.
*/
float impulse;
};
virtual bool takeDamage(const DamageInfo& /*damage*/) { return false; }
virtual bool isAnimationFixed() const { return true; }
virtual bool isInWater() const { return _inWater; }
virtual void tick(float dt) = 0;
};
#endif // __GAMEOBJECTS_HPP__