Integration Phase 1c: Setting up a World

The World is a core runtime object that contains one or more sets of NavData, and other dynamic objects that use that NavData.

You can create as many Worlds as you need in your game:

When you create a World, you indicate the number of Databases the World should create and maintain. For the purposes of this tutorial, you need only one Database. Eventually, you will need to create a separate Database for each set of NavData you plan to load into the World: i.e. one for each type of character whose physical characteristics and/or movement capabilities are different enough to require its own set of NavData.

For example: [code from Tutorial_FirstIntegration.cpp]

#include "gwnavruntime/world/world.h"
...
 
class MyGameWorld
{
public:
    MyGameWorld() : m_gameFrameIdx(0), m_navWorld(KY_NULL) {}
    bool Initialize(bool doVisualDebugTutorial);
    void Update(float deltaTimeInSeconds);
    void Destroy();

    ...

public: // internal
    KyUInt32               m_gameFrameIdx;
    Kaim::Ptr<Kaim::World> m_navWorld;
    ...
};
 
bool MyGameWorld::Initialize(bool doVisualDebugTutorial)
{
    ...
    const KyUInt32 databaseCount = 1;
    m_navWorld = *KY_NEW Kaim::World(databaseCount);
    ...
}
 
void MyGameWorld::Update(float deltaTimeInSeconds)
{
    ...
    UpdateLogic(deltaTimeInSeconds);
    
    UpdateNavigation(deltaTimeInSeconds);
    
    UpdatePhysics(deltaTimeInSeconds);
    ...
}
 
void MyGameWorld::Destroy()
{
    ...
    m_navWorld = KY_NULL;
}
...
 
class MyGame
{
public:
    bool Initialize(bool doVisualDebugTutorial);
    void Update(float deltaTimeInSeconds);
    void Destroy();
    ... 

protected:
    MyGameWorld m_world;
};

bool MyGame::Initialize(bool doVisualDebugTutorial)
{
    ...
    return m_world.Initialize(doVisualDebugTutorial);
}

...

void MyGame::Update(float deltaTimeInSeconds)
{
    m_world.Update(deltaTimeInSeconds);
}

void MyGame::Destroy()
{
    m_world.Destroy();
    ...
}