Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #181 from GentenStudios/feat-voxels-static
Browse files Browse the repository at this point in the history
Feat voxels static
  • Loading branch information
apachano authored Dec 8, 2019
2 parents 9eaf81b + 6cf4d2b commit 3f52473
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 21 deletions.
Binary file added Phoenix/.DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion Phoenix/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/Tools/CMake")

add_subdirectory(Client)
add_subdirectory(Core)
add_subdirectory(Server)
8 changes: 4 additions & 4 deletions Phoenix/Client/Source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ int main(int argc, char* argv[])
// ===== Compare server mods.txt and local mods.txt, update if needed =====

// ===== Load lua =====
voxels::BlockRegistry registry = voxels::BlockRegistry();
registry.registerBlock("core:dirt", "Dirt");
registry.registerBlock("core:cobble", "CobbleStone");
registry.registerBlock("core:stone", "Stone");
voxels::BlockRegistry *registry = registry->getInstance();
registry->registerBlock("core:dirt", "Dirt");
registry->registerBlock("core:cobble", "CobbleStone");
registry->registerBlock("core:stone", "Stone");
// TODO: Replace these manual calls to register blocks with a call to run lua files based on what modules need loaded

// ===== Launch renderer outputting to main window =====
Expand Down
4 changes: 2 additions & 2 deletions Phoenix/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ add_subdirectory(Source)
add_library(${PROJECT_NAME} STATIC ${phoenixSources} ${phoenixHeaders})
target_link_libraries(${PROJECT_NAME} PRIVATE QuartzEngine)

set(dependencies ${CMAKE_CURRENT_LIST_DIR}/../Quartz/ThirdParty)
target_include_directories(${PROJECT_NAME} PRIVATE ${dependencies}/../Quartz/Engine/Include)
set(dependencies ${CMAKE_CURRENT_LIST_DIR}/../../Quartz/ThirdParty)
target_include_directories(${PROJECT_NAME} PRIVATE ${dependencies}/../Engine/Include)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Include)

foreach(FILE ${phoenixSources})
Expand Down
10 changes: 7 additions & 3 deletions Phoenix/Core/Include/Core/Voxels/Blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#pragma once

#include <Quartz/Utilities/Singleton.hpp>

#include <string>
#include <vector>

Expand All @@ -54,20 +56,22 @@ namespace phoenix
};

/// @brief Stores universal block definitions
class BlockRegistry
class BlockRegistry : public qz::utils::Singleton<BlockRegistry>
{
private:
std::vector<RegisteredBlock> Blocks;
int i;

public:

BlockRegistry();
~BlockRegistry();

/// @brief Registers a block in the registry
int registerBlock(const std::string& uniqueName,
int registerBlock(const std::string& uniqueName,
const std::string& displayName);
/// @brief Get the Display name for a block in the registry
const std::string& getDisplayName(int blockId);
/// @brief Get the ID for a block in the registry
int getBlockId(const std::string& uniqueName);
};

Expand Down
18 changes: 13 additions & 5 deletions Phoenix/Core/Source/Voxels/Blocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
// POSSIBILITY OF SUCH DAMAGE.

#include <Core/Voxels/Blocks.hpp>

#include <string>
#include <iostream>

using namespace phoenix::voxels;

Expand All @@ -38,15 +37,24 @@ RegisteredBlock::RegisteredBlock(const std::string& unique, int id,

RegisteredBlock::~RegisteredBlock() = default;

BlockRegistry::BlockRegistry() : i(0) {};
BlockRegistry::BlockRegistry(){
i = 0;
};

//BlockRegistry *BlockRegistry::instance = 0;

BlockRegistry::~BlockRegistry() {};
/*BlockRegistry *BlockRegistry::getInstance(){
if (!instance){instance = new BlockRegistry;}
return instance;
};*/

int BlockRegistry::registerBlock(const std::string& uniqueName,
const std::string& displayName)
{
std::cout << std::to_string(i) + "\n";
i++;
Blocks[i] = RegisteredBlock(uniqueName, i, displayName);
RegisteredBlock temp = RegisteredBlock(uniqueName, i, displayName);
Blocks.push_back(temp);
return i;
};

Expand Down
4 changes: 2 additions & 2 deletions Phoenix/Server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ add_subdirectory(Source)
add_executable(${PROJECT_NAME} ${serverSources} ${serverHeaders})
target_link_libraries(${PROJECT_NAME} PRIVATE Phoenix)

set(dependencies ${CMAKE_CURRENT_LIST_DIR}/../Quartz/ThirdParty)
target_include_directories(${PROJECT_NAME} PRIVATE ${dependencies}/SDL2/include ${dependencies}/../Quartz/Engine/Include ${dependencies}/luamod/include ${dependencies}/imgui/include)
set(dependencies ${CMAKE_CURRENT_LIST_DIR}/../../Quartz/ThirdParty)
target_include_directories(${PROJECT_NAME} PRIVATE ${dependencies}/SDL2/include ${dependencies}/../Engine/Include ${dependencies}/luamod/include ${dependencies}/imgui/include)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Include)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../Core/Include)

Expand Down
14 changes: 10 additions & 4 deletions Phoenix/Server/Source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ int main(int argc, char* argv[])
// Likely a single command from Quartz that launches the logger + any other critical tools

// ===== Load Voxel data / Load lua =====
voxels::BlockRegistry registry = voxels::BlockRegistry();
registry.registerBlock("core:dirt", "Dirt");
registry.registerBlock("core:cobble", "CobbleStone");
registry.registerBlock("core:stone", "Stone");
std::cout << "Program started \n";
//voxels::BlockRegistry *registry = registry->get();
std::cout << "register dirt \n";
voxels::BlockRegistry::get()->registerBlock("core:dirt", "Dirt");
voxels::BlockRegistry::get()->registerBlock("core:cobble", "CobbleStone");
voxels::BlockRegistry::get()->registerBlock("core:stone", "Stone");
// TODO: Replace these manual calls to register blocks with a call to run lua files

std::cout << voxels::BlockRegistry::get()->getDisplayName(1);
std::cout << std::to_string(voxels::BlockRegistry::get()->getBlockId("core::dirt"));

// ===== Load save data =====
// Save::Load(argv[0]) //This will detect internally if a new map needs generated based on if save exists

Expand All @@ -33,6 +38,7 @@ int main(int argc, char* argv[])
}*/

// ===== Begin shutdown =====
std::cout << "Begin Shutdown \n \n";

// Send signal for listener to terminate
// Confirm map has saved
Expand Down

0 comments on commit 3f52473

Please sign in to comment.