summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/game.cpp b/src/game.cpp
index f9ef95e..897d305 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1,5 +1,6 @@
#include "game.hpp"
+#include "memory.hpp"
#include <cstring>
@@ -12,6 +13,11 @@ char readLine[readLineLength];
const char *levelName = "demo-level";
+struct EntityTypeInstanceCreateInfo {
+ EntityHandle entityTypeEntityHandle;
+};
+DynArray<EntityTypeInstanceCreateInfo> entityInstancesToCreate{16};
+
const char *PKE_FILE_BEGIN = ":PKFB:";
const char *PKE_FILE_END = ":PKFE:";
const char *PKE_FILE_VERSION = ":0:";
@@ -187,7 +193,6 @@ void Game_Tick(double delta) {
* ECS_Tick() gets called first because it updates the public
* `EntitiesToBeRemoved` for all other ticks to use.
*/
- ECS_Tick(delta);
if (shouldCreateEntityType) {
assert(entityTypeToCreate != nullptr);
assert(entityTypeToCreate != CAFE_BABE(EntityType));
@@ -202,6 +207,13 @@ void Game_Tick(double delta) {
Pke_Delete<EntityType>(entityTypeToCreate);
shouldCreateEntityType = false;
}
+ while (entityInstancesToCreate.Count() > 0) {
+ auto createInfo = entityInstancesToCreate.Pop();
+ EntityHandle newEntity = ECS_CreateEntity();
+ ECS_CreateInstance(newEntity, createInfo.entityTypeEntityHandle);
+ }
+
+ ECS_Tick(delta);
}
void RecordImGuiEditorWrapper() {
@@ -356,6 +368,12 @@ void RecordImGui_CompGrBinds(bool readonly, CompGrBinds *component) {
ImGui::Text("CompGRBinds");
ImGui::Separator();
+ if (ImGui::Button("Create Instance")) {
+ entityInstancesToCreate.Push({
+ .entityTypeEntityHandle = component->entHandle,
+ });
+ }
+
if (component->vkPipelineLayout)
ImGui::InputScalar("VkPipelineLayout", ImGuiDataType_U64, &component->vkPipelineLayout, nullptr, nullptr, "0x%016lX", ImGuiInputTextFlags_ReadOnly);
if (component->vkDescriptorSet)
@@ -435,6 +453,8 @@ void RecordImGuiSceneEditor() {
selectedEntity = EntityHandle_MAX;
}
+ ImGui::Spacing();
+
if (selectedEntity != EntityHandle_MAX) {
RecordImGui_CompGrBinds(true, ECS_GetGrBinds(selectedEntity));
RecordImGui_CompInstPos(false, ECS_GetInstance(selectedEntity));