Dawn/src/dawnrpg/scenes/WorldScene.cpp
2024-09-27 21:55:53 -05:00

67 lines
2.1 KiB
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "scenes/SceneList.hpp"
#include "prefab/PlayerPrefab.hpp"
#include "prefab/TestEntityPrefab.hpp"
#include "prefab/WorldPrefab.hpp"
#include "component/display/Camera.hpp"
// #include "prefab/SimpleSpinningCube.hpp"
// #include "component/display/material/SimpleTexturedMaterial.hpp"
// #include "display/mesh/CubeMesh.hpp"
// #include "component/ui/UICanvas.hpp"
// #include "ui/elements/UIRectangle.hpp"
// #include "ui/elements/UILabel.hpp"
// #include "ui/UIMenu.hpp"
// #include "ui/container/UIRowContainer.hpp"
// #include "ui/container/UIPaddingContainer.hpp"
// #include "poker/PokerGame.hpp"
using namespace Dawn;
void Dawn::worldScene(Scene &s) {
auto testj = s.getGame()->assetManager.get<json>("test");
while(!s.getGame()->assetManager.isEverythingLoaded()) {
s.getGame()->assetManager.update();
}
auto cameraItem = s.createSceneItem();
auto camera = cameraItem->addComponent<Camera>();
cameraItem->lookAt({ 3, 3, 3 }, { 0, 0, 0 }, { 0, 1, 0 });
camera->clipFar = 99999.99f;
// auto cube = s.createSceneItem();
// auto cubeMesh = std::make_shared<Mesh>();
// auto cubeRenderer = cube->addComponent<MeshRenderer>();
// auto cubeMaterial = cube->addComponent<SimpleTexturedMaterial>();
// cubeRenderer->mesh = cubeMesh;
// cubeMesh->createBuffers(CUBE_VERTICE_COUNT, CUBE_INDICE_COUNT);
// CubeMesh::buffer(cubeMesh, glm::vec3(0,0,0), glm::vec3(1, 1, 1), 0, 0);
// auto canvasItem = s.createSceneItem();
// auto canvas = canvasItem->addComponent<UICanvas>();
auto world = createWorldPrefab(s);
auto map = createMapPrefab(world.world);
map.map->setSize(
32, 32, 32,
3, 3, 3
);
auto chunk = map.map->getChunkAt({ 0, 0, 0 });
chunk = map.map->getChunkAt({ 1, 0, 0 });
chunk = map.map->getChunkAt({ 0, 1, 0 });
chunk = map.map->getChunkAt({ 0, 0, 1 });
auto player = createPlayerPrefab(map.map);
player.player->camera = camera;
auto test = createTestEntityPrefab(map.map);
test.entity->setPosition({ 5, 0, 0 });
}