From 586031aa948fdf7199d91873d7d4a991f118f6bd Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Fri, 10 Jan 2014 10:08:42 +0100 Subject: [PATCH] GameLogic - making sure GameLogic uses the new physics api --- Code/Game/GameLogic/Level.cpp | 2 +- Code/Game/GameLogic/Object.cpp | 4 ++++ Code/Game/GameLogic/Object.h | 11 ++--------- Code/Game/GameLogic/Player.cpp | 17 ++++++++--------- Code/Game/GameLogic/Weapon.h | 2 -- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index f0d1b935..9f4416aa 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -10,7 +10,7 @@ using namespace GameLogic; struct Level::PrivateData { - PrivateData() + PrivateData() { } diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 9e516907..e824c1d5 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -23,6 +23,8 @@ Object::Object() this->objectID = GID(); this->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN; + + rigidBody->GetState(state); } Object::Object(void* collisionFunc, OBJECT_TYPE type) @@ -40,6 +42,8 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type) this->objectID = GID(); this->type = type; + + rigidBody->GetState(state); } diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index c199eb58..6d6437f1 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -9,15 +9,8 @@ #include "GameLogicStates.h" #include "GameLogicDef.h" +#include -namespace Oyster -{ - namespace Physics - { - class ICustomBody; - class State; - } -} namespace GameLogic { class DANBIAS_GAMELOGIC_DLL Object @@ -37,7 +30,7 @@ namespace GameLogic int objectID; protected: Oyster::Physics::ICustomBody *rigidBody; - Oyster::Physics::ICustomBody::State *state; + Oyster::Physics::ICustomBody::State state; }; diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index a9e5b1d0..626e565f 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -16,7 +16,7 @@ struct Player::PrivateData teamID = -1; playerState = PLAYER_STATE::PLAYER_STATE_IDLE; - lookDir = Oyster::Math::Float4(1,0,0); + lookDir = Oyster::Math::Float4(1,0,0,0); } ~PrivateData() @@ -75,23 +75,23 @@ void Player::Move(const PLAYER_MOVEMENT &movement) void Player::MoveForward() { - state->ApplyLinearImpulse(myData->lookDir * 100); + state.ApplyLinearImpulse(myData->lookDir * 100); } void Player::MoveBackwards() { - state->ApplyLinearImpulse(-myData->lookDir * 100); + state.ApplyLinearImpulse(-myData->lookDir * 100); } void Player::MoveRight() { //Do cross product with forward vector and negative gravity vector Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir); - state->ApplyLinearImpulse(r * 100); + state.ApplyLinearImpulse(r * 100); } void Player::MoveLeft() { //Do cross product with forward vector and negative gravity vector Oyster::Math::Float4 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir); - state->ApplyLinearImpulse(-r * 100); + state.ApplyLinearImpulse(-r * 100); } void Player::UseWeapon(const WEAPON_FIRE &fireInput) @@ -101,7 +101,7 @@ void Player::UseWeapon(const WEAPON_FIRE &fireInput) void Player::Respawn(Oyster::Math::Float3 spawnPoint) { - //API::Instance().SetCenter(rigidBody,spawnPoint); + myData->life = 100; myData->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; myData->lookDir = Oyster::Math::Float4(1,0,0); @@ -109,7 +109,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint) void Player::Jump() { - //API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-Oyster::Math::Float3(0,1,0) * 100); + } bool Player::IsWalking() @@ -127,8 +127,7 @@ bool Player::IsIdle() Oyster::Math::Float3 Player::GetPos() { - //return rigidBody->GetCenter(); - return Oyster::Math::Float3(0,0,0); + return (Oyster::Math::Float3)state.GetCenterPosition(); } Oyster::Math::Float3 Player::GetLookDir() diff --git a/Code/Game/GameLogic/Weapon.h b/Code/Game/GameLogic/Weapon.h index cdd1a3b7..719a853c 100644 --- a/Code/Game/GameLogic/Weapon.h +++ b/Code/Game/GameLogic/Weapon.h @@ -34,8 +34,6 @@ namespace GameLogic bool IsValidSocket(int socketID); int GetCurrentSocketID(); - - private: struct PrivateData;