2013-12-10 09:57:05 +01:00
|
|
|
#include "AttatchmentMassDriver.h"
|
2013-12-12 12:16:13 +01:00
|
|
|
#include "PhysicsAPI.h"
|
2013-12-10 09:57:05 +01:00
|
|
|
|
|
|
|
using namespace GameLogic;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AttatchmentMassDriver::AttatchmentMassDriver(void)
|
|
|
|
{
|
2013-12-12 12:16:13 +01:00
|
|
|
this->owner = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
|
|
|
|
{
|
2014-01-21 15:46:54 +01:00
|
|
|
|
2013-12-12 12:16:13 +01:00
|
|
|
this->owner = &owner;
|
2013-12-10 09:57:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AttatchmentMassDriver::~AttatchmentMassDriver(void)
|
|
|
|
{
|
2014-01-21 15:46:54 +01:00
|
|
|
|
2013-12-10 09:57:05 +01:00
|
|
|
}
|
|
|
|
|
2013-12-10 11:17:25 +01:00
|
|
|
/********************************************************
|
|
|
|
* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used
|
|
|
|
********************************************************/
|
2014-01-21 15:46:54 +01:00
|
|
|
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, float dt)
|
2013-12-10 11:17:25 +01:00
|
|
|
{
|
2013-12-12 12:16:13 +01:00
|
|
|
//switch case to determin what functionallity to use in the attatchment
|
2014-01-16 11:17:19 +01:00
|
|
|
switch (usage)
|
2013-12-12 12:16:13 +01:00
|
|
|
{
|
|
|
|
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
|
2014-01-21 15:46:54 +01:00
|
|
|
ForcePush(usage,dt);
|
2013-12-12 12:16:13 +01:00
|
|
|
break;
|
|
|
|
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
|
2014-01-21 15:46:54 +01:00
|
|
|
ForcePull(usage,dt);
|
2013-12-12 12:16:13 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-12-10 11:17:25 +01:00
|
|
|
}
|
2013-12-10 09:57:05 +01:00
|
|
|
|
2013-12-10 11:17:25 +01:00
|
|
|
/********************************************************
|
2013-12-12 12:21:19 +01:00
|
|
|
* Pushes objects in a cone in front of the weapon when fired
|
2013-12-10 11:17:25 +01:00
|
|
|
********************************************************/
|
2014-01-21 15:46:54 +01:00
|
|
|
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt)
|
2013-12-10 09:57:05 +01:00
|
|
|
{
|
2014-01-21 15:46:54 +01:00
|
|
|
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
|
2014-01-22 13:02:13 +01:00
|
|
|
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
|
|
|
|
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
|
|
|
|
Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));
|
2014-01-21 15:46:54 +01:00
|
|
|
|
2014-01-22 13:02:13 +01:00
|
|
|
//Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,ForcePushAction);
|
2014-01-21 15:46:54 +01:00
|
|
|
//create frustum that will then collide with object and push them in the aimed direction
|
|
|
|
|
|
|
|
//sample with frustum using visitor pattern(needs a function ptr sent with it that idicates what happens when a collision has been made)
|
2013-12-12 12:16:13 +01:00
|
|
|
}
|
|
|
|
|
2014-01-22 13:02:13 +01:00
|
|
|
void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj)
|
|
|
|
{
|
|
|
|
Oyster::Physics::ICustomBody::State state = obj->GetState();
|
|
|
|
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500);
|
|
|
|
state.ApplyLinearImpulse(pushForce);
|
|
|
|
obj->SetState(state);
|
|
|
|
}
|
|
|
|
|
2013-12-12 12:21:19 +01:00
|
|
|
/********************************************************
|
|
|
|
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
|
|
|
|
********************************************************/
|
2014-01-21 15:46:54 +01:00
|
|
|
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
|
2013-12-12 12:16:13 +01:00
|
|
|
{
|
2014-01-21 15:46:54 +01:00
|
|
|
Oyster::Physics::Struct::CustomBodyState state = this->owner->GetRigidBody()->GetState();
|
|
|
|
|
|
|
|
//do something with state
|
|
|
|
state.ApplyLinearImpulse(Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt));
|
|
|
|
|
|
|
|
this->owner->GetRigidBody()->SetState(state);
|
2013-12-10 09:57:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|