diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
index c1a893ee..3d601691 100644
--- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
+++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
@@ -211,6 +211,10 @@ namespace DanBias
HRESULT DanBiasGame::CleanUp()
{
+ Oyster::Graphics::API::Clean();
+ EventHandler::Instance().Clean();
+ GameServerAPI::ServerStop();
+
m_data->recieverObj->gameClientState->Release();
delete m_data->recieverObj->gameClientState;
m_data->recieverObj->Disconnect();
@@ -218,11 +222,7 @@ namespace DanBias
delete m_data->inputObj;
delete m_data;
- EventHandler::Instance().Clean();
-
- Oyster::Graphics::API::Clean();
-
- GameServerAPI::ServerStop();
+
return S_OK;
}
diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp
index 0a732062..b060b539 100644
--- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp
+++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp
@@ -80,7 +80,6 @@ GameState::gameStateState GameState::LoadGame()
LoadModels("../Content/Worlds/ccc.bias");
// hardcoded objects
- //LoadModels();
Float3 startPos = Float3(0,0,20.0f);
InitCamera(startPos);
return gameStateState_playing;
diff --git a/Code/Game/GameLogic/AttatchmentSocket.cpp b/Code/Game/GameLogic/AttatchmentSocket.cpp
index 453387fe..7a8076b1 100644
--- a/Code/Game/GameLogic/AttatchmentSocket.cpp
+++ b/Code/Game/GameLogic/AttatchmentSocket.cpp
@@ -14,10 +14,10 @@ AttatchmentSocket::AttatchmentSocket(void)
AttatchmentSocket::~AttatchmentSocket(void)
{
- //if(this->attatchment)
- //delete this->attatchment;
+ if(this->attatchment)
+ delete this->attatchment;
- //this->attatchment = 0;
+ this->attatchment = 0;
}
IAttatchment* AttatchmentSocket::GetAttatchment()
diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp
index c3b70cce..e254b93b 100644
--- a/Code/Game/GameLogic/CollisionManager.cpp
+++ b/Code/Game/GameLogic/CollisionManager.cpp
@@ -8,12 +8,15 @@
#include "CollisionManager.h"
#include "JumpPad.h"
#include "Portal.h"
+#include "CrystalFormation.h"
+#include "ExplosiveCrate.h"
using namespace Oyster;
using namespace GameLogic;
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss);
+ void PlayerVLethalObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss, Oyster::Math::Float ExtraDamage);
void SendObjectFlying(Oyster::Physics::ICustomBody &obj, Oyster::Math::Float3 force);
void Teleport(Oyster::Physics::ICustomBody &obj, Oyster::Math::Float3 target);
@@ -26,18 +29,27 @@ using namespace GameLogic;
switch (realObj->GetObjectType())
{
- case ObjectSpecialType_StandarsBox:
+ case ObjectSpecialType::ObjectSpecialType_Generic:
PlayerVObject(*player,*realObj, kineticEnergyLoss);
//return Physics::ICustomBody::SubscriptMessage_none;
break;
- case ObjectSpecialType_Player:
+
+ case ObjectSpecialType::ObjectSpecialType_StandardBox:
+ PlayerVObject(*player,*realObj, kineticEnergyLoss);
//return Physics::ICustomBody::SubscriptMessage_none;
break;
- case ObjectSpecialType_World:
+ case ObjectSpecialType::ObjectSpecialType_Player:
+ //return Physics::ICustomBody::SubscriptMessage_none;
+ break;
+ case ObjectSpecialType::ObjectSpecialType_World:
PlayerVObject(*player,*realObj, kineticEnergyLoss);
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
break;
-
+
+ case ObjectSpecialType::ObjectSpecialType_CrystalFormation:
+ PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,((CrystalFormation*)realObj)->getShreddingDamage());
+ //player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
+ break;
}
//return Physics::ICustomBody::SubscriptMessage_none;
@@ -50,14 +62,13 @@ using namespace GameLogic;
switch (realObj->GetObjectType())
{
- case ObjectSpecialType_Generic:
+ case ObjectSpecialType::ObjectSpecialType_Generic:
break;
- case ObjectSpecialType_StandarsBox:
- break;
- case ObjectSpecialType_Player:
+ case ObjectSpecialType::ObjectSpecialType_StandardBox:
SendObjectFlying(*obj, jumpPad->pushForce);
break;
- case ObjectSpecialType_World:
+ case ObjectSpecialType::ObjectSpecialType_Player:
+ SendObjectFlying(*obj, jumpPad->pushForce);
break;
}
}
@@ -80,7 +91,44 @@ using namespace GameLogic;
{
obj.SetPosition(target);
}
+
+ void ExplosiveCrate::ExplosiveCrateCollision(Oyster::Physics::ICustomBody *rigidBodyCrate, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
+ {
+ int forceThreashHold = 200000; //how much force for the box to explode of the impact
+
+
+
+ if(kineticEnergyLoss > forceThreashHold)
+ {
+ ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag());
+
+
+ Oyster::Math::Float3 pos = rigidBodyCrate->GetState().centerPos;
+ Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,crate->ExplosionRadius);
+
+ Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode);
+
+ delete hitSphere;
+ }
+ }
+ void ExplosiveCrate::Explode(Oyster::Physics::ICustomBody *obj, void* args)
+ {
+ Object *realObj = (Object*)obj->GetCustomTag();
+ ExplosiveCrate* ExplosionSource = ((ExplosiveCrate*)args);
+
+
+ if(realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_Player)
+ {
+ Player *hitPlayer = (Player*)realObj;
+
+ hitPlayer->DamageLife(ExplosionSource->shreddingDamage);
+ //do shredding damage
+ }
+
+ realObj->GetRigidBody()->ApplyImpulse(ExplosionSource->pushForce);
+
+ }
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss)
{
@@ -98,6 +146,20 @@ using namespace GameLogic;
}
+
+ void PlayerVLethalObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss, Oyster::Math::Float ExtraDamage)
+ {
+ int damageDone = 0;
+ int forceThreashHold = 200000;
+
+ if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
+ {
+ damageDone = (int)(kineticEnergyLoss * 0.10f);
+ damageDone += ExtraDamage;
+ //player.DamageLife(damageDone);
+ }
+ }
+
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
return Physics::ICustomBody::SubscriptMessage_none;
@@ -123,7 +185,7 @@ using namespace GameLogic;
Object *realObj = (Object*)obj->GetCustomTag();
- if(realObj->GetObjectType() == ObjectSpecialType_Player || realObj->GetObjectType() == ObjectSpecialType_World)
+ if(realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_Player || realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_World)
return;
obj->ApplyImpulse(((forcePushData*)(args))->pushForce);
@@ -146,9 +208,7 @@ using namespace GameLogic;
switch(realObj->GetObjectType())
{
- case ObjectSpecialType_StandarsBox:
- //move obj to limbo in physics to make sure it wont collide with anything
-// Oyster::Physics::API::Instance().MoveToLimbo(obj);
+ case ObjectSpecialType::ObjectSpecialType_StandardBox:
weapon->heldObject = obj; //weapon now holds the object
weapon->hasObject = true;
diff --git a/Code/Game/GameLogic/CrystalFormation.cpp b/Code/Game/GameLogic/CrystalFormation.cpp
index 00709660..e9c6dd73 100644
--- a/Code/Game/GameLogic/CrystalFormation.cpp
+++ b/Code/Game/GameLogic/CrystalFormation.cpp
@@ -8,8 +8,8 @@ CrystalFormation::CrystalFormation(void)
this->shreddingDamage = 0;
}
-CrystalFormation::CrystalFormation(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float shreddingDamage)
- :StaticObject(rigidBody, collisionFuncAfter, type)
+CrystalFormation::CrystalFormation(Oyster::Physics::ICustomBody *rigidBody, int objectID,Oyster::Math::Float shreddingDamage)
+ :StaticObject(rigidBody, CrystalFormation::DefaultCollisionAfter, ObjectSpecialType::ObjectSpecialType_CrystalFormation, objectID)
{
this->shreddingDamage = shreddingDamage;
}
@@ -18,3 +18,8 @@ CrystalFormation::CrystalFormation(Oyster::Physics::ICustomBody *rigidBody, void
CrystalFormation::~CrystalFormation(void)
{
}
+
+Oyster::Math::Float CrystalFormation::getShreddingDamage()
+{
+ return this->shreddingDamage;
+}
diff --git a/Code/Game/GameLogic/CrystalFormation.h b/Code/Game/GameLogic/CrystalFormation.h
index 693460fe..6e07942b 100644
--- a/Code/Game/GameLogic/CrystalFormation.h
+++ b/Code/Game/GameLogic/CrystalFormation.h
@@ -8,12 +8,13 @@ namespace GameLogic
public:
CrystalFormation(void);
- CrystalFormation(Oyster::Physics::ICustomBody *rigidBody
- ,void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
- ,OBJECT_TYPE type, Oyster::Math::Float shreddingDamage);
+ CrystalFormation(Oyster::Physics::ICustomBody *rigidBody
+ ,int objectID,Oyster::Math::Float shreddingDamage);
~CrystalFormation(void);
+ Oyster::Math::Float getShreddingDamage();
+
private:
Oyster::Math::Float shreddingDamage;
};
diff --git a/Code/Game/GameLogic/DynamicObject.cpp b/Code/Game/GameLogic/DynamicObject.cpp
index b6193f30..8096b4aa 100644
--- a/Code/Game/GameLogic/DynamicObject.cpp
+++ b/Code/Game/GameLogic/DynamicObject.cpp
@@ -9,29 +9,14 @@ DynamicObject::DynamicObject()
{
}
-DynamicObject::DynamicObject(ObjectSpecialType type)
- :Object(type)
+
+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)
{
}
-DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type)
- :Object(rigidBody,type)
-{
-
-}
-
-DynamicObject::DynamicObject( void* collisionFuncAfter, ObjectSpecialType type)
- :Object(collisionFuncAfter,type)
-{
-
-}
-DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, ObjectSpecialType type)
- :Object(rigidBody, collisionFuncAfter, type)
-{
-
-}
-DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type)
- :Object(rigidBody, collisionFuncAfter, type)
+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)
{
}
diff --git a/Code/Game/GameLogic/DynamicObject.h b/Code/Game/GameLogic/DynamicObject.h
index e8aa25ce..3341e94d 100644
--- a/Code/Game/GameLogic/DynamicObject.h
+++ b/Code/Game/GameLogic/DynamicObject.h
@@ -14,12 +14,8 @@ namespace GameLogic
public:
DynamicObject();
-
- DynamicObject(ObjectSpecialType type);
- DynamicObject(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type);
- DynamicObject( void* collisionFuncAfter, ObjectSpecialType type);
- DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, ObjectSpecialType type);
- DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type);
+ DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
+ 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);
~DynamicObject(void);
diff --git a/Code/Game/GameLogic/ExplosiveCrate.cpp b/Code/Game/GameLogic/ExplosiveCrate.cpp
new file mode 100644
index 00000000..534fd6bb
--- /dev/null
+++ b/Code/Game/GameLogic/ExplosiveCrate.cpp
@@ -0,0 +1,29 @@
+#include "ExplosiveCrate.h"
+
+using namespace GameLogic;
+
+ExplosiveCrate::ExplosiveCrate(void)
+ :DynamicObject()
+{
+ this->shreddingDamage = 0;
+ this->pushForce = 0;
+ this->ExplosionRadius = 0;
+}
+
+ExplosiveCrate::ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type, int objectID,Oyster::Math::Float shreddingDamage, Oyster::Math::Float3 pushForce, Oyster::Math::Float ExplosionRadius)
+ :DynamicObject(rigidBody,ExplosiveCrate::ExplosiveCrateCollision, type, objectID)
+{
+ this->shreddingDamage = shreddingDamage;
+ this->pushForce = pushForce;
+ this->ExplosionRadius = ExplosionRadius;
+}
+
+ExplosiveCrate::~ExplosiveCrate(void)
+{
+
+}
+
+
+
+
+
diff --git a/Code/Game/GameLogic/ExplosiveCrate.h b/Code/Game/GameLogic/ExplosiveCrate.h
new file mode 100644
index 00000000..3cf0c9a4
--- /dev/null
+++ b/Code/Game/GameLogic/ExplosiveCrate.h
@@ -0,0 +1,24 @@
+#ifndef EXPLOSIVECRATE_H
+#define EXPLOSIVECRATE_H
+#include "DynamicObject.h"
+namespace GameLogic
+{
+ class ExplosiveCrate : public DynamicObject
+ {
+ public:
+ ExplosiveCrate(void);
+
+ ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type,int objectID,Oyster::Math::Float shreddingDamage, Oyster::Math::Float3 pushForce, Oyster::Math::Float ExplosionRadius);
+
+ ~ExplosiveCrate(void);
+
+ static void ExplosiveCrateCollision(Oyster::Physics::ICustomBody *rigidBodyCrate, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
+ static void Explode(Oyster::Physics::ICustomBody *obj, void* args);
+
+ private:
+ Oyster::Math::Float shreddingDamage;
+ Oyster::Math::Float3 pushForce;
+ Oyster::Math::Float ExplosionRadius;
+ };
+}
+#endif
\ No newline at end of file
diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp
index 5bf18dc4..900799e3 100644
--- a/Code/Game/GameLogic/Game.cpp
+++ b/Code/Game/GameLogic/Game.cpp
@@ -84,6 +84,7 @@ Game::LevelData* Game::CreateLevel()
//this->level->level->InitiateLevel(1000);
this->level->level->InitiateLevel("../Content/Worlds/ccc.bias");
+
return this->level;
}
diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj
index b19ffef0..48af6d60 100644
--- a/Code/Game/GameLogic/GameLogic.vcxproj
+++ b/Code/Game/GameLogic/GameLogic.vcxproj
@@ -176,7 +176,9 @@
+
+
@@ -202,7 +204,9 @@
+
+
diff --git a/Code/Game/GameLogic/GameLogicStates.h b/Code/Game/GameLogic/GameLogicStates.h
index 9ae0d482..3e9bcdf5 100644
--- a/Code/Game/GameLogic/GameLogicStates.h
+++ b/Code/Game/GameLogic/GameLogicStates.h
@@ -43,6 +43,12 @@ namespace GameLogic
Oyster::Math::Float3 pushForce;
};
+ struct ExplosionData
+ {
+ Oyster::Math::Float3 pushForce;
+ Oyster::Math::Float3 ShreddingDamage;
+ };
+
};
diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp
index acdcd2f3..30082130 100644
--- a/Code/Game/GameLogic/Game_PlayerData.cpp
+++ b/Code/Game/GameLogic/Game_PlayerData.cpp
@@ -20,13 +20,14 @@ Game::PlayerData::PlayerData()
Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f );
rigidBody->SetAngularFactor(0.0f);
//create player with this rigid body
- this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player);
+ this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,0,0);
this->player->GetRigidBody()->SetCustomTag(this);
player->EndFrame();
}
Game::PlayerData::PlayerData(int playerID,int teamID)
{
+ Oyster::Physics::ICustomBody* rigidBody;
this->player = new Player();
}
Game::PlayerData::~PlayerData()
diff --git a/Code/Game/GameLogic/JumpPad.cpp b/Code/Game/GameLogic/JumpPad.cpp
index d52acb45..424340ad 100644
--- a/Code/Game/GameLogic/JumpPad.cpp
+++ b/Code/Game/GameLogic/JumpPad.cpp
@@ -8,8 +8,8 @@ JumpPad::JumpPad(void)
{
}
-JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, Oyster::Math::Float3 pushForce)
- :StaticObject(rigidBody, collisionFuncAfter, type)
+JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type,int objectID ,Oyster::Math::Float3 pushForce)
+ :StaticObject(rigidBody, JumpPad::JumpPadActivated, type, objectID)
{
this->pushForce = pushForce;
}
diff --git a/Code/Game/GameLogic/JumpPad.h b/Code/Game/GameLogic/JumpPad.h
index 4fad54e4..a88a0cc5 100644
--- a/Code/Game/GameLogic/JumpPad.h
+++ b/Code/Game/GameLogic/JumpPad.h
@@ -8,9 +8,8 @@ namespace GameLogic
public:
JumpPad(void);
- JumpPad(Oyster::Physics::ICustomBody *rigidBody
- ,void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
- ,ObjectSpecialType type, Oyster::Math::Float3 pushForce);
+ JumpPad(Oyster::Physics::ICustomBody *rigidBody
+ ,ObjectSpecialType type, int objectID,Oyster::Math::Float3 pushForce);
~JumpPad(void);
diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp
index 9a91744e..1184cc49 100644
--- a/Code/Game/GameLogic/Level.cpp
+++ b/Code/Game/GameLogic/Level.cpp
@@ -240,14 +240,9 @@ void Level::InitiateLevel(std::string levelPath)
if(rigidBody_Static != NULL)
{
- // create game object
- Object* staticGameObj = createGameObj(staticObjData, rigidBody_Static);
- if(staticGameObj != NULL)
- {
- this->staticObjects.Push((StaticObject*)staticGameObj);
- this->staticObjects[this->staticObjects.Size()-1]->objectID = modelCount++;
- rigidBody_Static->SetCustomTag(this->staticObjects[this->staticObjects.Size()-1]);
- }
+ this->staticObjects.Push(new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID, 0));
+ //this->staticObjects[staticObjCount]->objectID = modelCount++;
+
}
}
@@ -277,14 +272,9 @@ void Level::InitiateLevel(std::string levelPath)
if(rigidBody_Dynamic != NULL)
{
- // create game object
- Object* dynamicGameObj = createGameObj(dynamicObjData, rigidBody_Dynamic);
- if (dynamicGameObj != NULL)
- {
- this->dynamicObjects.Push((DynamicObject*)dynamicGameObj);
- this->dynamicObjects[this->dynamicObjects.Size()-1]->objectID = modelCount++;
- rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[this->dynamicObjects.Size()-1]);
- }
+
+ this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic , Object::DefaultCollisionAfter, (ObjectSpecialType)dynamicObjData->specialTypeID, 0));
+ //this->dynamicObjects[dynamicObjCount]->objectID = modelCount++;
}
}
@@ -305,9 +295,9 @@ void Level::InitiateLevel(float radius)
// add level sphere
ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
- levelObj = new StaticObject(rigidBody, LevelCollisionAfter, ObjectSpecialType_World);
+ levelObj = new StaticObject(rigidBody, LevelCollisionAfter, ObjectSpecialType_World, idCount++);
- this->levelObj->objectID = idCount++;
+ //this->levelObj->objectID = idCount++;
rigidBody->SetCustomTag(levelObj);
@@ -319,9 +309,9 @@ void Level::InitiateLevel(float radius)
{
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f);
- this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandarsBox));
+ this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
- this->dynamicObjects[i]->objectID = idCount++;
+ //this->dynamicObjects[i]->objectID = idCount++;
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
}
/*offset += nrOfBoxex;
@@ -358,24 +348,24 @@ void Level::InitiateLevel(float radius)
// add crystal
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5, 0.5f, 0.8f, 0.6f);
- this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandarsBox));
+ this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]);
- this->dynamicObjects[nrOfBoxex]->objectID = idCount++;
+ //this->dynamicObjects[nrOfBoxex]->objectID = idCount++;
// add house
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f);
- this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic));
+ this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic, idCount++));
rigidBody_House->SetCustomTag(this->staticObjects[0]);
- this->staticObjects[0]->objectID = idCount++;
+ //this->staticObjects[0]->objectID = idCount++;
// add jumppad
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f);
- this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, JumpPad::JumpPadActivated, ObjectSpecialType_JumpPad, Oyster::Math::Float3(0,2000,0)));
+ this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
rigidBody_Jumppad->SetCustomTag(this->staticObjects[1]);
- this->staticObjects[1]->objectID = idCount++;
+ //this->staticObjects[1]->objectID = idCount++;
}
void Level::AddPlayerToTeam(Player *player, int teamID)
diff --git a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp
index c5dfa8cc..038b9a40 100644
--- a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp
+++ b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp
@@ -75,7 +75,7 @@ std::vector> LevelParser::Parse(std::string filen
case ObjectSpecialType_Spike:
case ObjectSpecialType_SpikeBox:
case ObjectSpecialType_RedExplosiveBox:
- case ObjectSpecialType_StandarsBox:
+ case ObjectSpecialType_StandardBox:
case ObjectSpecialType_Stone:
case ObjectSpecialType_Building:
{
diff --git a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h
index 4cf34366..50c722b6 100644
--- a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h
+++ b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h
@@ -30,7 +30,7 @@ namespace GameLogic
ObjectSpecialType_World, //Always the main celestial body
ObjectSpecialType_Building,
ObjectSpecialType_Stone,
- ObjectSpecialType_StandarsBox,
+ ObjectSpecialType_StandardBox,
ObjectSpecialType_RedExplosiveBox,
ObjectSpecialType_SpikeBox,
ObjectSpecialType_Spike,
diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp
index 80ff0ad6..cfd2d255 100644
--- a/Code/Game/GameLogic/Object.cpp
+++ b/Code/Game/GameLogic/Object.cpp
@@ -19,55 +19,28 @@ Object::Object()
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
this->type = ObjectSpecialType_Unknown;
- this->objectID = GID();
+ this->objectID = -1;
}
-Object::Object(ObjectSpecialType type)
-{
- this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
- this->type = type;
- this->objectID = GID();
-}
-
-Object::Object(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type)
-{
- this->rigidBody = rigidBody;
- this->type = type;
- this->objectID = GID();
-}
-
-Object::Object( void* collisionFuncAfter, ObjectSpecialType type)
-
-{
- this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
-
- this->type = type;
- this->objectID = GID();
-}
-
-Object::Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, ObjectSpecialType type)
+Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
{
this->rigidBody = rigidBody;
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
this->type = type;
- this->objectID = GID();
+ this->objectID = objectID;
+ this->rigidBody->SetCustomTag(this);
}
-Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type)
+Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
{
this->rigidBody = rigidBody;
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
this->type = type;
- this->objectID = GID();
+ this->objectID = objectID;
+ this->rigidBody->SetCustomTag(this);
}
-void Object::ApplyLinearImpulse(Oyster::Math::Float3 force)
-{
-
-}
-
-
Object::~Object(void)
{
diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h
index 83e12277..7e7e3f08 100644
--- a/Code/Game/GameLogic/Object.h
+++ b/Code/Game/GameLogic/Object.h
@@ -18,11 +18,9 @@ namespace GameLogic
{
public:
Object();
- Object(ObjectSpecialType type);
- Object(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type);
- Object(void* collisionFuncAfter, ObjectSpecialType type);
- Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, ObjectSpecialType type);
- Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type);
+
+ Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
+ Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
~Object(void);
ObjectSpecialType GetObjectType() const override;
@@ -38,7 +36,6 @@ namespace GameLogic
Oyster::Physics::ICustomBody* GetRigidBody();
- void ApplyLinearImpulse(Oyster::Math::Float3 force);
virtual void BeginFrame();
virtual void EndFrame();
@@ -50,8 +47,7 @@ namespace GameLogic
public: //TODO: Hax This should be private when level is dynamic
- ObjectSpecialType type;
- int objectID;
+
protected:
Oyster::Physics::ICustomBody *rigidBody;
@@ -59,6 +55,9 @@ namespace GameLogic
static const Game* gameInstance;
Oyster::Math::Float3 currLook;
Oyster::Math::Float3 newLook;
+
+ ObjectSpecialType type;
+ int objectID;
};
}
diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp
index f6dddb85..3b022220 100644
--- a/Code/Game/GameLogic/Player.cpp
+++ b/Code/Game/GameLogic/Player.cpp
@@ -13,34 +13,9 @@ Player::Player()
{
}
-Player::Player(ObjectSpecialType type)
- :DynamicObject(type)
-{
- InitPlayer();
-}
-Player::Player(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type)
- :DynamicObject(rigidBody,type)
-{
- InitPlayer();
-}
-Player::Player( void* collisionFuncAfter, ObjectSpecialType type)
- :DynamicObject(collisionFuncAfter,type)
-{
- InitPlayer();
-}
-Player::Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, ObjectSpecialType type)
- :DynamicObject(rigidBody, collisionFuncAfter, type)
-{
- InitPlayer();
-}
-Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type)
- :DynamicObject(rigidBody, collisionFuncAfter, type)
-{
- InitPlayer();
-}
-
-void Player::InitPlayer()
+Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID)
+ :DynamicObject(rigidBody, EventOnCollision, type, objectID)
{
weapon = new Weapon(2,this);
@@ -55,6 +30,36 @@ void Player::InitPlayer()
key_strafeLeft = 0;
}
+Player::Player(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, int teamID)
+ :DynamicObject(rigidBody, EventOnCollision, type, objectID)
+{
+ this->rigidBody = rigidBody;
+
+ Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,400,0);
+
+ Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,1.0f,0.5f);
+ Oyster::Math::Float mass = 60;
+ Oyster::Math::Float restitutionCoeff = 0.5;
+ Oyster::Math::Float frictionCoeff_Static = 0.4;
+ Oyster::Math::Float frictionCoeff_Dynamic = 0.3;
+
+
+ this->rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f );
+ this->rigidBody->SetAngularFactor(0.0f);
+
+ weapon = new Weapon(2,this);
+
+ this->life = 100;
+ this->teamID = teamID;
+ this->playerState = PLAYER_STATE_IDLE;
+ this->lookDir = Oyster::Math::Float3(0,0,-1);
+ this->moveDir = Oyster::Math::Float3(0,0,0);
+ key_forward = 0;
+ key_backward = 0;
+ key_strafeRight = 0;
+ key_strafeLeft = 0;
+}
+
Player::~Player(void)
{
if(weapon)
diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h
index b10d1114..17ad2095 100644
--- a/Code/Game/GameLogic/Player.h
+++ b/Code/Game/GameLogic/Player.h
@@ -16,15 +16,12 @@ namespace GameLogic
{
public:
Player(void);
- Player(ObjectSpecialType type);
- Player(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type);
- Player( void* collisionFuncAfter, ObjectSpecialType type);
- Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, ObjectSpecialType type);
- Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type);
+
+ Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID);
+ Player(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, int teamID);
~Player(void);
- void InitPlayer();
-
+
/********************************************************
* Moves the player based on input
* @param movement: enum value on what kind of action is to be taken
@@ -81,7 +78,7 @@ namespace GameLogic
void Jump();
private:
- int life;
+ Oyster::Math::Float life;
int teamID;
Weapon *weapon;
PLAYER_STATE playerState;
diff --git a/Code/Game/GameLogic/Portal.cpp b/Code/Game/GameLogic/Portal.cpp
index 6fc787fa..66671a8d 100644
--- a/Code/Game/GameLogic/Portal.cpp
+++ b/Code/Game/GameLogic/Portal.cpp
@@ -9,8 +9,13 @@ Portal::Portal(void)
this->portalExit = Float3(0,0,0);
}
+<<<<<<< HEAD
Portal::Portal(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, Oyster::Math::Float3 portalExit)
:StaticObject(rigidBody, collisionFuncAfter, type)
+=======
+Portal::Portal(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type,int objectID ,Oyster::Math::Float3 portalExit)
+ :StaticObject(rigidBody, EventOnCollision, type, objectID)
+>>>>>>> GL - fixed constructors to ease creation of objects, also fixed weapon crash on destruction
{
this->portalExit = portalExit;
}
diff --git a/Code/Game/GameLogic/Portal.h b/Code/Game/GameLogic/Portal.h
index a8d308f4..ab88d934 100644
--- a/Code/Game/GameLogic/Portal.h
+++ b/Code/Game/GameLogic/Portal.h
@@ -9,8 +9,8 @@ namespace GameLogic
Portal(void);
Portal(Oyster::Physics::ICustomBody *rigidBody
- ,void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
- ,ObjectSpecialType type, Oyster::Math::Float3 portalExit);
+ ,void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
+ ,ObjectSpecialType type,int objectID ,Oyster::Math::Float3 portalExit);
~Portal(void);
diff --git a/Code/Game/GameLogic/StaticObject.cpp b/Code/Game/GameLogic/StaticObject.cpp
index f9156e3c..68140cbe 100644
--- a/Code/Game/GameLogic/StaticObject.cpp
+++ b/Code/Game/GameLogic/StaticObject.cpp
@@ -10,32 +10,17 @@ StaticObject::StaticObject()
{
}
-StaticObject::StaticObject(ObjectSpecialType type)
- :Object(type)
-{
-}
-StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type)
- :Object(rigidBody,type)
+StaticObject::StaticObject(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)
{
- //this->rigidBody->SetGravity(true);
- //this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(CollisionManager::IgnoreCollision));
+ //use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static
}
-StaticObject::StaticObject( void* collisionFuncAfter, ObjectSpecialType type)
- :Object(collisionFuncAfter,type)
+StaticObject::StaticObject(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)
{
-
-}
-StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, ObjectSpecialType type)
- :Object(rigidBody, collisionFuncAfter, type)
-{
-
-}
-StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type)
- :Object(rigidBody, collisionFuncAfter, type)
-{
-
+ //use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static
}
StaticObject::~StaticObject(void)
diff --git a/Code/Game/GameLogic/StaticObject.h b/Code/Game/GameLogic/StaticObject.h
index 4e655808..a7b9fbff 100644
--- a/Code/Game/GameLogic/StaticObject.h
+++ b/Code/Game/GameLogic/StaticObject.h
@@ -18,11 +18,8 @@ namespace GameLogic
public:
StaticObject();
- StaticObject(ObjectSpecialType type);
- StaticObject(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type);
- StaticObject( void* collisionFuncAfter, ObjectSpecialType type);
- StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, ObjectSpecialType type);
- StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type);
+ StaticObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
+ StaticObject(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);
~StaticObject(void);
diff --git a/Code/Game/GameLogic/Weapon.cpp b/Code/Game/GameLogic/Weapon.cpp
index 66de8e33..379f53dc 100644
--- a/Code/Game/GameLogic/Weapon.cpp
+++ b/Code/Game/GameLogic/Weapon.cpp
@@ -19,7 +19,11 @@ Weapon::Weapon()
Weapon::Weapon(int MaxNrOfSockets,Player *owner)
{
attatchmentSockets.Resize(MaxNrOfSockets);
- attatchmentSockets[0] = new AttatchmentSocket();
+ for(int i = 0; i < MaxNrOfSockets; i++)
+ {
+ attatchmentSockets[i] = new AttatchmentSocket();
+ }
+
weaponState = WEAPON_STATE_IDLE;
currentNrOfAttatchments = 0;
@@ -38,8 +42,12 @@ Weapon::~Weapon(void)
{
for (unsigned int i = 0; i < this->attatchmentSockets.Size(); i++)
{
- delete this->attatchmentSockets[i];
- this->attatchmentSockets[i] = 0;
+ if(this->attatchmentSockets[i])
+ {
+ delete this->attatchmentSockets[i];
+ this->attatchmentSockets[i] = 0;
+ }
+
}
}