From 06ddb86b17d19b35fd3fc107d4bb8c935001fc42 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Tue, 18 Feb 2014 11:33:36 +0100 Subject: [PATCH] GL - GetAllDynamicObjects , dennis order --- Code/Game/GameLogic/Game.h | 2 ++ Code/Game/GameLogic/GameAPI.h | 2 ++ Code/Game/GameLogic/Game_LevelData.cpp | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h index 93e130f5..b8f6d4b3 100644 --- a/Code/Game/GameLogic/Game.h +++ b/Code/Game/GameLogic/Game.h @@ -61,6 +61,8 @@ namespace GameLogic ObjectSpecialType GetObjectType() const override; int getNrOfDynamicObj()const override; IObjectData* GetObjectAt(int ID) const override; + Utility::DynamicMemory::DynamicArray GetAllDynamicObjects() const override; + Level *level; }; diff --git a/Code/Game/GameLogic/GameAPI.h b/Code/Game/GameLogic/GameAPI.h index 30e86e8c..2a24c99e 100644 --- a/Code/Game/GameLogic/GameAPI.h +++ b/Code/Game/GameLogic/GameAPI.h @@ -13,6 +13,7 @@ #include "GameLogicStates.h" #include #include "LevelLoader\ObjectDefines.h" +#include "DynamicArray.h" namespace GameLogic @@ -107,6 +108,7 @@ namespace GameLogic public: virtual int getNrOfDynamicObj()const = 0; virtual IObjectData* GetObjectAt(int ID) const = 0; + virtual Utility::DynamicMemory::DynamicArray GetAllDynamicObjects() const = 0; }; class DANBIAS_GAMELOGIC_DLL GameAPI diff --git a/Code/Game/GameLogic/Game_LevelData.cpp b/Code/Game/GameLogic/Game_LevelData.cpp index b007ce01..4529e787 100644 --- a/Code/Game/GameLogic/Game_LevelData.cpp +++ b/Code/Game/GameLogic/Game_LevelData.cpp @@ -50,4 +50,16 @@ int Game::LevelData::getNrOfDynamicObj()const IObjectData* Game::LevelData::GetObjectAt(int ID) const { return this->level->GetObj(ID); +} + +Utility::DynamicMemory::DynamicArray Game::LevelData::GetAllDynamicObjects() const +{ + Utility::DynamicMemory::DynamicArray objects(level->dynamicObjects.Size()); + + for(int i = 0; i < level->dynamicObjects.Size(); i++) + { + objects[i] = level->dynamicObjects[i]; + } + + return objects; } \ No newline at end of file