-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathGothic2Game.cpp
More file actions
63 lines (45 loc) · 1.5 KB
/
Gothic2Game.cpp
File metadata and controls
63 lines (45 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <core/Gothic2Game.hpp>
#include <Components/BsCCamera.h>
#include <Scene/BsPrefab.h>
#include <components/Character.hpp>
#include <components/CharacterKeyboardInput.hpp>
#include <components/GameWorld.hpp>
#include <components/GameplayUI.hpp>
#include <components/Sky.hpp>
using namespace REGoth;
void Gothic2Game::setupMainCamera()
{
Engine::setupMainCamera();
mThirdPersonCamera = mMainCamera->SO()->addComponent<ThirdPersonCamera>();
}
void Gothic2Game::setupScene()
{
const bs::String WORLD = "NEWWORLD.ZEN";
const bs::String SAVEGAME = "WorldViewer-" + WORLD;
bs::HPrefab worldPrefab = GameWorld::load(SAVEGAME);
HGameWorld world;
if (!worldPrefab)
{
world = GameWorld::importZEN(WORLD);
HCharacter hero = world->insertCharacter("PC_HERO", world->getWorldStartpoint()->getName());
hero->useAsHero();
hero->SO()->addComponent<CharacterKeyboardInput>(world);
world->runInitScripts();
world->save(SAVEGAME);
}
else
{
bs::HSceneObject worldSO = worldPrefab->instantiate();
world = worldSO->getComponent<GameWorld>();
}
const bs::Color skyColor = bs::Color{120, 140, 180} / 255.0f;
world->SO()->addComponent<Sky>(world, config()->skyRenderMode, skyColor);
bs::HSceneObject heroSO = world->SO()->findChild("PC_HERO");
if (!heroSO)
{
REGOTH_THROW(InvalidStateException, "Expected PC_HERO in world");
}
HCharacter hero = heroSO->getComponent<Character>();
mThirdPersonCamera->follow(hero);
GameplayUI::createGlobal(mMainCamera);
}