From 6a888cb15462b7236f2a78a6038a53b3ef835d32 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Wed, 22 Jan 2014 15:47:44 +0100 Subject: [PATCH] GL - adjusting collisionManager --- Code/Game/GameLogic/CollisionManager.cpp | 31 ++++++++++++------------ Code/Game/GameLogic/Level.cpp | 2 +- Code/Game/GameLogic/Level.h | 2 +- Code/Game/GameLogic/Player.h | 2 +- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 73681b8e..eaafd59a 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -9,11 +9,11 @@ using namespace Oyster; using namespace GameLogic; - void PlayerVBox(Player &player, DynamicObject &box); - void PlayerVObject(Player &player, Object &obj); + void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss); + void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss); - - Physics::ICustomBody::SubscriptMessage Player::PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj) + //Physics::ICustomBody::SubscriptMessage + void Player::PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) { Player *player = ((Player*)(rigidBodyPlayer->GetCustomTag())); Object *realObj = (Object*)obj->GetCustomTag(); @@ -21,31 +21,30 @@ using namespace GameLogic; switch (realObj->GetType()) { case OBJECT_H::OBJECT_TYPE_GENERIC: - PlayerVObject(*player,*realObj); - Physics::ICustomBody::SubscriptMessage_none; + PlayerVObject(*player,*realObj, kineticEnergyLoss); + //return Physics::ICustomBody::SubscriptMessage_none; break; case OBJECT_TYPE::OBJECT_TYPE_BOX: - PlayerVBox(*player,(*(DynamicObject*) realObj)); - Physics::ICustomBody::SubscriptMessage_none; + PlayerVBox(*player,(*(DynamicObject*) realObj), kineticEnergyLoss); + //return Physics::ICustomBody::SubscriptMessage_none; break; case OBJECT_TYPE::OBJECT_TYPE_PLAYER: - Physics::ICustomBody::SubscriptMessage_none; + //return Physics::ICustomBody::SubscriptMessage_none; break; - } - return Physics::ICustomBody::SubscriptMessage_none; + //return Physics::ICustomBody::SubscriptMessage_none; } - void PlayerVBox(Player &player, DynamicObject &box) + void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss) { //use kinetic energyloss of the collision in order too determin how much damage to take //use as part of the damage algorithm player.DamageLife(20); } - void PlayerVObject(Player &player, Object &obj) + void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss) { //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 @@ -53,10 +52,10 @@ using namespace GameLogic; player.DamageLife(20); } - - Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj) + //Oyster::Physics::ICustomBody::SubscriptMessage + void Level::LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) { - return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; + //return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; } void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj) diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index b2bbe60c..8335ea8e 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -25,7 +25,7 @@ void Level::InitiateLevel(float radius) sbDesc.radius = 8; //radius; sbDesc.mass = 10e12f; //sbDesc.mass = 0; //10^16 - sbDesc.subscription_onCollision = CollisionManager::LevelCollision; + sbDesc.subscription_onCollisionResponse = Level::LevelCollision; ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); API::Instance().AddObject(rigidBody); diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index 4a28fabe..71e7ed06 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -57,7 +57,7 @@ namespace GameLogic * @param rigidBodyLevel: physics object of the level * @param obj: physics object for the object that collided with the level ********************************************************/ - static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj); + static void LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); private: TeamManager teamManager; diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index 14359554..6d1f0424 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -50,7 +50,7 @@ namespace GameLogic * @param rigidBodyPlayer: physics object of the player * @param obj: physics object for the object that collided with the player ********************************************************/ - static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj); + static void PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); bool IsWalking();