summaryrefslogtreecommitdiffstats
path: root/src/graphics/engine/lightning.cpp
diff options
context:
space:
mode:
authorPiotr Dziwiński <piotr.dziwinski@nsn.com>2013-02-16 22:37:43 +0100
committerPiotr Dziwiński <piotr.dziwinski@nsn.com>2013-02-17 12:11:56 +0100
commit001d37b257b126dd6ef1dced70f94ff3d2806d28 (patch)
tree1025979c635c899f196d606f7d74170e33ef4f3a /src/graphics/engine/lightning.cpp
parent45040318b026f8864d244e39f1703685ad688470 (diff)
downloadcolobot-001d37b257b126dd6ef1dced70f94ff3d2806d28.tar.gz
colobot-001d37b257b126dd6ef1dced70f94ff3d2806d28.tar.bz2
colobot-001d37b257b126dd6ef1dced70f94ff3d2806d28.zip
CInstanceManager refactoring
* removed classes managed by CInstanceManager except for CObject, CPyro, CBrain and CPhysics because of dependencies * refactored instance searching to use existing singleton instances of CApplication, CEngine and CRobotMain and calling their getter functions
Diffstat (limited to 'src/graphics/engine/lightning.cpp')
-rw-r--r--src/graphics/engine/lightning.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/graphics/engine/lightning.cpp b/src/graphics/engine/lightning.cpp
index d256599..5fdae51 100644
--- a/src/graphics/engine/lightning.cpp
+++ b/src/graphics/engine/lightning.cpp
@@ -18,6 +18,8 @@
#include "graphics/engine/lightning.h"
+#include "app/app.h"
+
#include "common/logger.h"
#include "common/iman.h"
@@ -25,22 +27,20 @@
#include "graphics/engine/camera.h"
#include "graphics/engine/terrain.h"
+#include "math/geometry.h"
+
#include "object/object.h"
+#include "object/robotmain.h"
#include "object/auto/autopara.h"
-#include "math/geometry.h"
-
// Graphics module namespace
namespace Gfx {
-CLightning::CLightning(CInstanceManager* iMan, CEngine* engine)
+CLightning::CLightning(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_BLITZ, this);
-
m_engine = engine;
m_terrain = nullptr;
m_camera = nullptr;
@@ -187,13 +187,13 @@ bool CLightning::Create(float sleep, float delay, float magnetic)
m_speed = 1.0f / m_sleep;
if (m_terrain == nullptr)
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
if (m_camera == nullptr)
- m_camera = static_cast<CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_camera = CRobotMain::GetInstancePointer()->GetCamera();
if (m_sound == nullptr)
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = CApplication::GetInstancePointer()->GetSound();
return false;
}
@@ -312,12 +312,14 @@ CObject* CLightning::SearchObject(Math::Vector pos)
std::vector<Math::Vector> paraObjPos;
paraObjPos.reserve(100);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
// Seeking the object closest to the point of impact of lightning.
CObject* bestObj = 0;
float min = 100000.0f;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == nullptr) break;
if (!obj->GetActif()) continue; // inactive object?