2013-12-12 09:36:14 +01:00
|
|
|
#include "PhysicsAPI.h"
|
|
|
|
#include "Object.h"
|
|
|
|
#include "DynamicObject.h"
|
|
|
|
#include "Player.h"
|
2014-01-21 15:46:54 +01:00
|
|
|
#include "Level.h"
|
2014-01-22 14:26:45 +01:00
|
|
|
#include "AttatchmentMassDriver.h"
|
2014-01-27 13:54:57 +01:00
|
|
|
#include "Game.h"
|
2014-02-03 15:32:46 +01:00
|
|
|
#include "CollisionManager.h"
|
2014-02-04 16:24:37 +01:00
|
|
|
#include "JumpPad.h"
|
2013-11-26 09:19:59 +01:00
|
|
|
|
2013-12-03 11:47:04 +01:00
|
|
|
using namespace Oyster;
|
2013-11-26 09:19:59 +01:00
|
|
|
|
2013-12-19 10:21:03 +01:00
|
|
|
using namespace GameLogic;
|
2013-11-28 09:26:29 +01:00
|
|
|
|
2014-01-22 15:47:44 +01:00
|
|
|
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss);
|
2014-02-04 16:24:37 +01:00
|
|
|
void SendObjectFlying(Oyster::Physics::ICustomBody &obj, Oyster::Math::Float3 force);
|
2013-11-28 11:23:11 +01:00
|
|
|
|
2014-01-22 15:47:44 +01:00
|
|
|
//Physics::ICustomBody::SubscriptMessage
|
2014-01-27 08:54:25 +01:00
|
|
|
void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
2013-12-19 10:21:03 +01:00
|
|
|
{
|
2014-01-27 13:54:57 +01:00
|
|
|
|
|
|
|
Player *player = ((Game::PlayerData*)(rigidBodyPlayer->GetCustomTag()))->player;
|
|
|
|
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
|
2014-01-21 15:46:54 +01:00
|
|
|
|
2014-01-30 09:40:58 +01:00
|
|
|
switch (realObj->GetObjectType())
|
2014-01-21 15:46:54 +01:00
|
|
|
{
|
2014-01-27 08:54:25 +01:00
|
|
|
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
|
2014-01-22 15:47:44 +01:00
|
|
|
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
|
|
|
//return Physics::ICustomBody::SubscriptMessage_none;
|
2014-01-21 15:46:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
2014-02-03 16:20:50 +01:00
|
|
|
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
2014-01-22 15:47:44 +01:00
|
|
|
//return Physics::ICustomBody::SubscriptMessage_none;
|
2014-01-21 15:46:54 +01:00
|
|
|
break;
|
|
|
|
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
|
2014-01-22 15:47:44 +01:00
|
|
|
//return Physics::ICustomBody::SubscriptMessage_none;
|
2014-01-21 15:46:54 +01:00
|
|
|
break;
|
2014-01-23 08:57:46 +01:00
|
|
|
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
|
2014-02-04 11:13:02 +01:00
|
|
|
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
2014-01-23 08:57:46 +01:00
|
|
|
break;
|
2014-01-21 15:46:54 +01:00
|
|
|
}
|
2013-12-19 10:21:03 +01:00
|
|
|
|
2014-01-22 15:47:44 +01:00
|
|
|
//return Physics::ICustomBody::SubscriptMessage_none;
|
2013-12-19 10:21:03 +01:00
|
|
|
}
|
2014-02-04 16:24:37 +01:00
|
|
|
|
|
|
|
void JumpPad::JumpPadActivated(Oyster::Physics::ICustomBody *rigidBodyJumpPad, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
|
|
|
{
|
|
|
|
JumpPad *jumpPad = (JumpPad*)(rigidBodyJumpPad->GetCustomTag());
|
|
|
|
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
|
|
|
|
|
|
|
|
switch (realObj->GetObjectType())
|
|
|
|
{
|
|
|
|
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
|
|
|
|
break;
|
|
|
|
case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
|
|
|
break;
|
|
|
|
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
|
|
|
|
SendObjectFlying(*obj, jumpPad->pushForce);
|
|
|
|
break;
|
|
|
|
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SendObjectFlying(Oyster::Physics::ICustomBody &obj, Oyster::Math::Float3 force)
|
|
|
|
{
|
|
|
|
Oyster::Physics::ICustomBody::State state;
|
|
|
|
|
|
|
|
state = obj.GetState();
|
2014-02-09 21:24:09 +01:00
|
|
|
//state.ApplyLinearImpulse(force);
|
2014-02-04 16:24:37 +01:00
|
|
|
obj.SetState(state);
|
|
|
|
}
|
2014-02-03 16:20:50 +01:00
|
|
|
|
2013-12-19 10:21:03 +01:00
|
|
|
|
2014-01-22 15:47:44 +01:00
|
|
|
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss)
|
2014-01-21 15:46:54 +01:00
|
|
|
{
|
|
|
|
//Collision between a player and a general static or dynamic object
|
|
|
|
//use kinetic energyloss of the collision in order too determin how much damage to take
|
|
|
|
//use as part of the damage algorithm
|
2014-01-27 08:54:25 +01:00
|
|
|
int damageDone = 0;
|
2014-02-04 13:58:37 +01:00
|
|
|
int forceThreashHold = 200000;
|
2014-01-27 08:54:25 +01:00
|
|
|
|
|
|
|
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
|
|
|
|
{
|
2014-02-09 16:42:26 +01:00
|
|
|
damageDone = (int)(kineticEnergyLoss * 0.10f);
|
2014-02-05 09:06:33 +01:00
|
|
|
//player.DamageLife(damageDone);
|
2014-01-27 08:54:25 +01:00
|
|
|
}
|
2014-01-21 15:46:54 +01:00
|
|
|
|
2014-01-27 08:54:25 +01:00
|
|
|
}
|
2014-01-29 14:33:21 +01:00
|
|
|
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
|
|
|
|
{
|
|
|
|
return Physics::ICustomBody::SubscriptMessage_none;
|
|
|
|
}
|
2014-01-31 10:58:03 +01:00
|
|
|
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
2014-02-05 11:46:04 +01:00
|
|
|
{
|
|
|
|
return Physics::ICustomBody::SubscriptMessage_none;
|
|
|
|
}
|
|
|
|
Oyster::Physics::ICustomBody::SubscriptMessage Player::PlayerCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
|
|
|
|
{
|
|
|
|
return Physics::ICustomBody::SubscriptMessage_player_collision_response;
|
|
|
|
}
|
|
|
|
Oyster::Physics::ICustomBody::SubscriptMessage Player::PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
2014-01-31 10:58:03 +01:00
|
|
|
{
|
|
|
|
return Physics::ICustomBody::SubscriptMessage_none;
|
2014-01-29 14:33:21 +01:00
|
|
|
}
|
2014-01-22 15:47:44 +01:00
|
|
|
//Oyster::Physics::ICustomBody::SubscriptMessage
|
2014-01-29 14:33:21 +01:00
|
|
|
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
|
|
|
|
{
|
|
|
|
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
|
|
|
}
|
2014-02-03 15:32:46 +01:00
|
|
|
|
|
|
|
Oyster::Physics::ICustomBody::SubscriptMessage CollisionManager::IgnoreCollision(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody *obj)
|
|
|
|
{
|
|
|
|
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-29 14:33:21 +01:00
|
|
|
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
2014-01-16 11:40:29 +01:00
|
|
|
{
|
2014-01-29 14:33:21 +01:00
|
|
|
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
2014-01-16 11:40:29 +01:00
|
|
|
}
|
2014-01-22 14:26:45 +01:00
|
|
|
|
2014-01-30 11:11:45 +01:00
|
|
|
void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args)
|
2014-01-22 14:39:10 +01:00
|
|
|
{
|
2014-01-27 14:43:39 +01:00
|
|
|
Oyster::Physics::ICustomBody::State state;
|
2014-01-30 15:12:53 +01:00
|
|
|
Object *realObj = (Object*)obj->GetCustomTag();
|
2014-01-31 09:12:15 +01:00
|
|
|
|
2014-01-31 09:39:44 +01:00
|
|
|
if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD)
|
2014-01-30 15:12:53 +01:00
|
|
|
return;
|
2014-01-31 14:05:52 +01:00
|
|
|
|
2014-01-27 14:43:39 +01:00
|
|
|
state = obj->GetState();
|
2014-02-09 21:24:09 +01:00
|
|
|
//state.ApplyLinearImpulse(((forcePushData*)(args))->pushForce);
|
2014-01-27 14:43:39 +01:00
|
|
|
obj->SetState(state);
|
2014-02-03 15:32:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args)
|
|
|
|
{
|
|
|
|
AttatchmentMassDriver *weapon = ((AttatchmentMassDriver*)args);
|
|
|
|
|
|
|
|
if(weapon->hasObject)
|
|
|
|
{
|
|
|
|
//do nothing
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Object* realObj = (Object*)(obj->GetCustomTag());
|
|
|
|
//check so that it is an object that you can pickup
|
|
|
|
|
|
|
|
switch(realObj->GetObjectType())
|
|
|
|
{
|
|
|
|
case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
|
|
|
//move obj to limbo in physics to make sure it wont collide with anything
|
2014-02-03 15:45:48 +01:00
|
|
|
Oyster::Physics::API::Instance().MoveToLimbo(obj);
|
2014-02-03 15:32:46 +01:00
|
|
|
weapon->heldObject = obj; //weapon now holds the object
|
|
|
|
weapon->hasObject = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-30 11:11:45 +01:00
|
|
|
}
|