Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/importer rework #120

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ add_library(REGothEngine STATIC
scripting/daedalus/DaedalusVMForGameWorld.hpp
scripting/daedalus/REGothDaedalusVM.cpp
scripting/daedalus/REGothDaedalusVM.hpp
world/internals/ConstructFromZEN.cpp
world/internals/ConstructFromZEN.hpp
world/internals/ImportSingleVob.cpp
world/internals/ImportSingleVob.hpp
world/internals/ZenImporter.cpp
world/internals/ZenImporter.hpp
world/internals/ZenCache.cpp
world/internals/ZenCache.hpp
)

target_link_libraries(REGothEngine PUBLIC bsf BsZenLib)
Expand Down
5 changes: 1 addition & 4 deletions src/components/GameWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
#include <log/logging.hpp>
#include <original-content/VirtualFileSystem.hpp>
#include <scripting/ScriptVMForGameWorld.hpp>
#include <world/internals/ConstructFromZEN.hpp>

namespace REGoth
{
const char* const WORLD_STARTPOINT = "STARTPOINT";

GameWorld::GameWorld(const bs::HSceneObject& parent, const bs::String& zenFile)
: bs::Component(parent)
, mZenFile(zenFile)
Expand Down Expand Up @@ -67,7 +64,7 @@ namespace REGoth
if (!mZenFile.empty())
{
// Import the ZEN and add all scene objects as children to this SO.
bs::HSceneObject so = Internals::constructFromZEN(thisWorld, mZenFile);
bs::HSceneObject so = mZenImporter.constructFromZEN(thisWorld, mZenFile);

if (!so)
{
Expand Down
13 changes: 11 additions & 2 deletions src/components/GameWorld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <BsPrerequisites.h>
#include <Scene/BsComponent.h>
#include <world/internals/ZenImporter.hpp>

#include <RTTI/RTTIUtil.hpp>

Expand All @@ -28,8 +29,6 @@ namespace REGoth
class Waypoint;
using HWaypoint = bs::GameObjectHandle<Waypoint>;

extern const char* const WORLD_STARTPOINT;

namespace Scripting
{
class ScriptVMForGameWorld;
Expand Down Expand Up @@ -140,6 +139,11 @@ namespace REGoth
return mWaynet;
}

bs::HSceneObject getWorldStartpoint()
{
return mZenImporter.getStartpoint();
}

/**
* @return Handle to the GameClock of the world.
*/
Expand Down Expand Up @@ -376,6 +380,11 @@ namespace REGoth
void findAllItems();
void findAllFocusables();

/**
* ZEN-File Importer.
*/
ZenImporter mZenImporter;

/**
* ZEN-File this world was created from, e.g. `NEWWORLD.ZEN`.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/core/Gothic1Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void Gothic1Game::setupScene()
{
world = GameWorld::importZEN(WORLD);

HCharacter hero = world->insertCharacter("PC_HERO", WORLD_STARTPOINT);
HCharacter hero = world->insertCharacter("PC_HERO", world->getWorldStartpoint()->getName());
hero->useAsHero();
hero->SO()->addComponent<CharacterKeyboardInput>(world);

Expand Down
2 changes: 1 addition & 1 deletion src/core/Gothic2Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void Gothic2Game::setupScene()
{
world = GameWorld::importZEN(WORLD);

HCharacter hero = world->insertCharacter("PC_HERO", WORLD_STARTPOINT);
HCharacter hero = world->insertCharacter("PC_HERO", world->getWorldStartpoint()->getName());
hero->useAsHero();
hero->SO()->addComponent<CharacterKeyboardInput>(world);

Expand Down
5 changes: 3 additions & 2 deletions src/main_WorldMeshViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <Scene/BsSceneObject.h>

#include <core.hpp>
#include <world/internals/ConstructFromZEN.hpp>
#include <world/internals/ZenImporter.hpp>

class REGothWorldMeshViewer : public REGoth::EmptyGame
{
Expand All @@ -21,11 +21,12 @@ class REGothWorldMeshViewer : public REGoth::EmptyGame

void setupScene() override
{
REGoth::Internals::loadWorldMeshFromZEN("ADDONWORLD.ZEN");
mZenImporter.loadWorldMeshFromZEN("ADDONWORLD.ZEN");
}

protected:
bs::HFPSCamera mFPSCamera;
REGoth::ZenImporter mZenImporter;
};

int main(int argc, char** argv)
Expand Down
2 changes: 1 addition & 1 deletion src/main_WorldViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class REGothWorldViewer : public REGoth::Engine
{
world = GameWorld::importZEN(config()->world);

HCharacter hero = world->insertCharacter("PC_HERO", WORLD_STARTPOINT);
HCharacter hero = world->insertCharacter("PC_HERO", world->getWorldStartpoint()->getName());
hero->useAsHero();
hero->SO()->addComponent<CharacterKeyboardInput>(world);

Expand Down
231 changes: 0 additions & 231 deletions src/world/internals/ConstructFromZEN.cpp

This file was deleted.

35 changes: 0 additions & 35 deletions src/world/internals/ConstructFromZEN.hpp

This file was deleted.

Loading