-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dynamic data on gameobjects at runtime
- Loading branch information
Showing
9 changed files
with
92 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[*.{cpp,h,hpp}] | ||
indent_style = space | ||
indent_size = 2 | ||
tab_width = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <sol/sol.hpp> | ||
|
||
#include <string> | ||
#include <unordered_map> | ||
|
||
namespace Jenjin { | ||
struct DataStore { | ||
std::unordered_map<std::string, sol::object> entries; | ||
|
||
void DynamicSet(std::string key, sol::stack_object value); | ||
sol::object DynamicGet(std::string key); | ||
}; | ||
} // namespace Jenjin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "jenjin/datastore.h" | ||
|
||
using namespace Jenjin; | ||
|
||
void DataStore::DynamicSet(std::string key, sol::stack_object value) { | ||
auto it = entries.find(key); | ||
if (it == entries.cend()) { | ||
entries.insert(it, {std::move(key), std::move(value)}); | ||
} else { | ||
std::pair<const std::string, sol::object> &kvp = *it; | ||
sol::object &entry = kvp.second; | ||
entry = sol::object(std::move(value)); | ||
} | ||
} | ||
|
||
sol::object DataStore::DynamicGet(std::string key) { | ||
auto it = entries.find(key); | ||
if (it == entries.cend()) { | ||
return sol::lua_nil; | ||
} | ||
|
||
return it->second; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule megasource
updated
10 files
+6 −0 | .gitmodules | |
+3 −0 | CMakeLists.txt | |
+3 −0 | libs/CMakeLists.txt | |
+1 −1 | libs/IconFontCppHeaders | |
+1 −1 | libs/imgui | |
+1 −0 | libs/miniaudio | |
+1 −1 | libs/spdlog | |
+1 −1 | libs/stb | |
+1 −0 | libs/yaml-cpp | |
+14 −1 | src/test.cpp |