2013-11-20 14:25:37 +01:00
|
|
|
#include "DynamicObject.h"
|
2013-12-12 09:36:14 +01:00
|
|
|
#include "CollisionManager.h"
|
2014-02-25 10:37:33 +01:00
|
|
|
#include "Player.h"
|
2013-11-20 14:25:37 +01:00
|
|
|
|
2013-11-20 16:01:39 +01:00
|
|
|
using namespace GameLogic;
|
2014-02-20 16:52:36 +01:00
|
|
|
using namespace Oyster::Math;
|
2013-11-20 14:25:37 +01:00
|
|
|
|
2013-12-05 11:50:39 +01:00
|
|
|
|
|
|
|
DynamicObject::DynamicObject()
|
2013-12-12 09:36:14 +01:00
|
|
|
:Object()
|
2013-11-20 14:25:37 +01:00
|
|
|
{
|
2014-02-20 16:52:36 +01:00
|
|
|
this->isReleased = false;
|
|
|
|
this->isActive = true;
|
2014-02-25 10:37:33 +01:00
|
|
|
this->affectedBy = NULL;
|
2013-12-12 09:36:14 +01:00
|
|
|
}
|
|
|
|
|
2014-02-14 09:53:02 +01:00
|
|
|
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
|
|
|
:Object(rigidBody, EventOnCollision, type, objectID)
|
2014-01-29 14:33:21 +01:00
|
|
|
{
|
2014-02-20 16:52:36 +01:00
|
|
|
this->isReleased = false;
|
|
|
|
this->isActive = true;
|
2014-02-25 10:37:33 +01:00
|
|
|
this->affectedBy = NULL;
|
2014-01-29 14:33:21 +01:00
|
|
|
}
|
2014-02-14 09:53:02 +01:00
|
|
|
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
|
|
|
:Object(rigidBody, EventOnCollision, type, objectID)
|
2014-01-29 14:33:21 +01:00
|
|
|
{
|
2014-02-20 16:52:36 +01:00
|
|
|
this->isReleased = false;
|
|
|
|
this->isActive = true;
|
2014-02-25 10:37:33 +01:00
|
|
|
this->affectedBy = NULL;
|
2014-01-29 14:33:21 +01:00
|
|
|
}
|
2013-12-05 11:50:39 +01:00
|
|
|
|
2014-02-14 11:16:02 +01:00
|
|
|
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
|
|
|
:Object(rigidBody, EventOnCollision, type, objectID)
|
|
|
|
{
|
|
|
|
this->extraDamageOnCollision = extraDamageOnCollision;
|
2014-02-20 16:52:36 +01:00
|
|
|
this->isReleased = false;
|
|
|
|
this->isActive = true;
|
2014-02-25 10:37:33 +01:00
|
|
|
this->affectedBy = NULL;
|
2014-02-14 11:16:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
|
|
|
:Object(rigidBody, EventOnCollision, type, objectID)
|
|
|
|
{
|
|
|
|
this->extraDamageOnCollision = extraDamageOnCollision;
|
2014-02-20 16:52:36 +01:00
|
|
|
this->isReleased = false;
|
|
|
|
this->isActive = true;
|
2014-02-25 10:37:33 +01:00
|
|
|
this->affectedBy = NULL;
|
2014-02-14 11:16:02 +01:00
|
|
|
}
|
2013-12-05 11:50:39 +01:00
|
|
|
DynamicObject::~DynamicObject(void)
|
2013-11-28 08:33:29 +01:00
|
|
|
{
|
2013-12-12 09:36:14 +01:00
|
|
|
|
2014-02-20 16:52:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DynamicObject::ReleaseDynamicObject()
|
|
|
|
{
|
|
|
|
//TODO: Inactivate the physics object
|
|
|
|
if(this->isReleased) return;
|
|
|
|
|
|
|
|
this->isReleased = true;
|
|
|
|
this->isActive = false;
|
|
|
|
this->lookDirection = Float3::null;
|
|
|
|
this->forwardDirection = Float3::null;
|
|
|
|
this->scale = Float3::null;
|
|
|
|
this->extraDamageOnCollision = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
bool DynamicObject::IsReleased()
|
|
|
|
{
|
|
|
|
return this->isReleased;
|
|
|
|
}
|
|
|
|
bool DynamicObject::IsActive()
|
|
|
|
{
|
|
|
|
return this->isActive;
|
|
|
|
}
|
|
|
|
void DynamicObject::Inactivate()
|
|
|
|
{
|
|
|
|
this->isActive = false;
|
|
|
|
}
|
|
|
|
void DynamicObject::Activate()
|
|
|
|
{
|
|
|
|
this->isActive = true;
|
|
|
|
this->isReleased = false;
|
2014-02-25 10:37:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DynamicObject::SetAffectedBy(Player &player)
|
|
|
|
{
|
|
|
|
this->affectedBy = &player;
|
|
|
|
if(this->type != ObjectSpecialType::ObjectSpecialType_Player) //should not add itself to its own list if its a player
|
|
|
|
{
|
|
|
|
player.AddAffectedObject(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Player* DynamicObject::getAffectingPlayer()
|
|
|
|
{
|
|
|
|
return this->affectedBy;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DynamicObject::RemoveAffectedBy()
|
|
|
|
{
|
|
|
|
this->affectedBy = NULL;
|
2013-11-28 08:33:29 +01:00
|
|
|
}
|