1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-14 14:44:22 +01:00
openrw/rwengine/include/engine/GameObject.hpp

110 lines
1.9 KiB
C++
Raw Normal View History

2013-09-09 01:18:36 +02:00
#pragma once
#ifndef _GAMEOBJECT_HPP_
#define _GAMEOBJECT_HPP_
2013-09-09 01:18:36 +02:00
2014-06-06 18:04:00 +02:00
#include <engine/RWTypes.hpp>
#include <loaders/LoaderIDE.hpp>
#include <loaders/LoaderIPL.hpp>
2013-09-09 01:18:36 +02:00
#include <glm/gtc/quaternion.hpp>
#include <memory>
2014-06-06 18:04:00 +02:00
class CharacterController;
2014-03-01 05:12:35 +01:00
class ModelFrame;
2013-09-11 01:26:13 +02:00
class Animator;
2013-09-09 01:18:36 +02:00
2013-12-20 17:02:46 +01:00
class GameWorld;
2013-09-09 01:18:36 +02:00
/**
2014-02-13 11:55:11 +01:00
* Stores data used by call types of object instances.
2013-09-09 01:18:36 +02:00
*/
struct GameObject
2013-09-09 01:18:36 +02:00
{
glm::vec3 position;
glm::quat rotation;
2014-06-06 13:18:32 +02:00
ModelHandle* model; /// Cached pointer to Object's Model.
2013-09-09 01:18:36 +02:00
2013-12-20 17:02:46 +01:00
GameWorld* engine;
2013-09-09 01:18:36 +02:00
2013-09-11 01:26:13 +02:00
Animator* animator; /// Object's animator.
2014-06-13 22:54:17 +02:00
2013-12-06 22:25:34 +01:00
/**
* Health value
*/
float mHealth;
2014-06-13 22:54:17 +02:00
bool _inWater;
// Used to determine in water status
float _lastHeight;
2014-06-06 13:18:32 +02:00
GameObject(GameWorld* engine, const glm::vec3& pos, const glm::quat& rot, ModelHandle* model)
2014-06-13 22:54:17 +02:00
: position(pos), rotation(rot), model(model), engine(engine), animator(nullptr), mHealth(0.f),
_inWater(false), _lastHeight(0.f)
{}
2013-12-12 03:55:31 +01:00
virtual ~GameObject() {}
2013-09-09 01:18:36 +02:00
enum Type
{
Instance,
Character,
2014-03-01 12:19:33 +01:00
Vehicle,
Unknown
2013-09-09 01:18:36 +02:00
};
2014-03-01 12:19:33 +01:00
virtual Type type() { return Unknown; }
2013-09-09 01:18:36 +02:00
virtual void setPosition(const glm::vec3& pos);
virtual glm::vec3 getPosition() const;
2013-09-09 05:04:21 +02:00
virtual glm::quat getRotation() const;
2013-12-06 22:25:34 +01: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-06-11 22:00:53 +02:00
/**
* Physics impulse.
*/
float impulse;
2013-12-06 22:25:34 +01:00
};
2014-03-01 05:12:35 +01:00
virtual bool takeDamage(const DamageInfo& damage) { return false; }
virtual bool isFrameVisible(ModelFrame* frame) const { return true; }
virtual bool isAnimationFixed() const { return true; }
2014-06-13 22:54:17 +02:00
virtual bool isInWater() const { return _inWater; }
2013-09-09 01:18:36 +02:00
};
#endif // __GAMEOBJECTS_HPP__