diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2023-09-26 16:03:14 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2023-09-26 16:03:14 -0400 |
| commit | 7c1ba040d64a3b877f44971048bf79410c2666b0 (patch) | |
| tree | 3afc202061e2d95fa4a4a6853e453db01a8adc19 /src | |
| parent | 211c14d7094a550fd1886123dbd52f718163d116 (diff) | |
create instance button
Diffstat (limited to 'src')
| -rw-r--r-- | src/game.cpp | 22 |
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)); |
