diff --git a/src/game/Entity.h b/src/game/Entity.h index f3b770d..ac44fa3 100644 --- a/src/game/Entity.h +++ b/src/game/Entity.h @@ -20,6 +20,8 @@ namespace Game { + int32_t GetNextRenderID(); + struct EntityRenderData { Gen::Vec4 DotColor{1.0f, 1.0f, 1.0f, 1.0f}; @@ -29,7 +31,7 @@ namespace Game Gen::TextureHandle TextureHandle; Gen::ModelHandle ModelH; bool Visible = true; - bool DebugBreakOnRender = false; + int32_t RenderID = 0; void Render(const Model* models, const Material* materials, const Texture* textures); void LoadFromSaved(const Gen::SavedEntityRenderData& saved); @@ -124,6 +126,7 @@ namespace Game return {}; } Data[Count] = {}; + Data[Count].EData.RenderID = GetNextRenderID(); HandleT H; H.Idx = Count; ++Count; diff --git a/src/game/Instance.h b/src/game/Instance.h index 955999b..8acacba 100644 --- a/src/game/Instance.h +++ b/src/game/Instance.h @@ -60,6 +60,8 @@ namespace Game Gen::AssetHandle AssetHandles[MaxAssets]{0}; char AssetHandlePaths[MaxAssets][128]; bool ShowImguiDemo = false; + bool DebugBreakIDEnabled = false; + int DebugBreakID = -1; uint8_t DebugCardRotation = 0; bool ShortenLogFileNames = true; bool ShowStats = true; diff --git a/src/game/Level.cpp b/src/game/Level.cpp index ee4c495..44d19e2 100644 --- a/src/game/Level.cpp +++ b/src/game/Level.cpp @@ -29,10 +29,11 @@ namespace Game { void EntityRenderData::Render(const Model* models, const Material* materials, const Texture* textures) { - if (DebugBreakOnRender) + auto& debug = GetInstance().DebugData; + if ((int32_t)debug.DebugBreakID == RenderID && debug.DebugBreakIDEnabled) { bx::debugBreak(); - DebugBreakOnRender = false; + debug.DebugBreakIDEnabled = false; } if (models == nullptr || materials == nullptr || textures == nullptr) return; @@ -210,6 +211,11 @@ namespace Game ReloadLevelEntities(); UpdatePlayerInputMode(); + + for (int32_t i = 0; i < BX_COUNTOF(Puzzles); ++i) + { + Puzzles[i].WorldPosition = {0.0f, 0.0f, i * 50.0f}; + } } bool IsOnGround(Level& level, Vec3 worldPos) @@ -262,6 +268,14 @@ namespace Game } return height >= 110 && height <= 125; } + if (offsetX >= 0 && offsetX < puz.Data.WidthTiles / Puzzle::Config::CardSize && + offsetY == puz.Data.HeightTiles / Puzzle::Config::CardSize) + { + if (puz.IsSolved) + { + return true; + } + } } return false; } @@ -369,16 +383,16 @@ namespace Game } // Puzzle tiles + Puzzle::PuzzleSolver solver; uint16_t activeIdx = GetInstance().DebugData.SelectedDebugLevel; for (int32_t i = 0; i < BX_COUNTOF(Puzzles); ++i) { Puzzles[i].IsActive = activeIdx == i; Puzzles[i].Update(); + Puzzles[i].IsSolved = solver.IsPuzzleSolved(Puzzles[i].Data); } - Puzzle::PuzzleSolver solver; - bool isPuzzleSolved = solver.IsPuzzleSolved(Puzzles[activeIdx].Data); - PuzzleUI.Update(Puzzles[activeIdx].Data, isPuzzleSolved); + PuzzleUI.Update(Puzzles[activeIdx].Data, Puzzles[activeIdx].IsSolved); END_PERF(GetShared().Window.PerfCounters, PerfCounterType::GameLevelUpdate, GetShared().Window.FrameCounter); } @@ -444,22 +458,39 @@ namespace Game void WorldPuzzle::Setup() { - auto& level = GetInstance().GameLevel; + Level& level = GetInstance().GameLevel; for (int32_t i = 0; i < Puzzle::Config::MaxCardsInPuzzle; ++i) { TileHandles[i] = level.PuzzleTiles.New(); - auto& tile = level.PuzzleTiles.Get(TileHandles[i]); + PuzzleTileEntity& tile = level.PuzzleTiles.Get(TileHandles[i]); tile.EData.MaterialHandle = EMaterial::Default; for (int32_t j = 0; j < Puzzle::Config::MaxCoversInTile; ++j) { int32_t idx = i * Puzzle::Config::MaxCoversInTile + j; CoverHandles[idx] = level.PuzzleTileCovers.New(); - auto& cover = level.PuzzleTileCovers.Get(CoverHandles[idx]); + PuzzleTileCover& cover = level.PuzzleTileCovers.Get(CoverHandles[idx]); cover.EData.Visible = false; } } + for (int32_t i = 0; i < BX_COUNTOF(EndHandles); ++i) + { + EndHandles[i] = level.PuzzleTiles.New(); + PuzzleTileEntity& tile = level.PuzzleTiles.Get(EndHandles[i]); + tile.EData.MaterialHandle = EMaterial::Default; + } + + WallHandle = level.PuzzleTiles.New(); + PuzzleTileEntity& wHandle = level.PuzzleTiles.Get(WallHandle); + wHandle.EData.MaterialHandle = EMaterial::Default; + wHandle.EData.ModelH = GameRendering::Get().GetModelHandleFromPath("models/GateWall.glb"); + + DoorHandle = level.PuzzleTiles.New(); + PuzzleTileEntity& dHandle = level.PuzzleTiles.Get(DoorHandle); + dHandle.EData.MaterialHandle = EMaterial::Default; + dHandle.EData.ModelH = GameRendering::Get().GetModelHandleFromPath("models/GateDoor.glb"); + IsSetup = true; LOG("finished setup!"); } @@ -519,6 +550,37 @@ namespace Game } } } + + // End + for (int32_t i = 0; i < BX_COUNTOF(EndHandles); ++i) + { + auto& tile = level.PuzzleTiles.Get(EndHandles[i]); + if (i < Data.WidthTiles / 2) + { + tile.EData.Visible = true; + tile.EData.ModelH = staticCards[0].BaseModelHandle; + tile.EData.TextureHandle = staticCards[0].ModelTextureHandle; + tile.EData.DotColor = visuals.TileDotColor; + tile.EData.BaseColor = visuals.TileBaseColor + Vec4{0.1f, 0.1f, 0.1f, 0.0f}; + tile.EData.Transform.Position = WorldPosition + Vec3{ + i * Puzzle::Config::CardScaleWorld, + -5.0f, + (float)Data.HeightTiles / Puzzle::Config::CardSize * + Puzzle::Config::CardScaleWorld, + }; + } + else + { + tile.EData.Visible = false; + } + } + auto& wall = level.PuzzleTiles.Get(WallHandle); + wall.EData.Visible = true; + wall.EData.Transform.Position = WorldPosition + Vec3{30.0f, -5.0f, 40.2f}; + + auto& door = level.PuzzleTiles.Get(DoorHandle); + door.EData.Visible = !IsSolved; + door.EData.Transform.Position = WorldPosition + Vec3{30.0f, -5.0f, 40.2f}; } void Level::ReloadLevelEntities() @@ -532,4 +594,10 @@ namespace Game } } + int32_t GetNextRenderID() + { + static int32_t RenderIDCounter = 0; + RenderIDCounter++; + return RenderIDCounter; + } } // namespace Game diff --git a/src/game/Level.h b/src/game/Level.h index 3bf6803..6227d8b 100644 --- a/src/game/Level.h +++ b/src/game/Level.h @@ -18,8 +18,12 @@ namespace Game Gen::Vec3 WorldPosition; PuzzleTileEntityHandle TileHandles[Puzzle::Config::MaxCardsInPuzzle]; PuzzleTileCoverHandle CoverHandles[Puzzle::Config::MaxCardsInPuzzle * Puzzle::Config::MaxCoversInTile]; + PuzzleTileEntityHandle EndHandles[Puzzle::Config::MaxPuzzleSizeCards]; + PuzzleTileEntityHandle WallHandle; + PuzzleTileEntityHandle DoorHandle; bool IsSetup = false; bool IsActive = false; + bool IsSolved = false; void Setup(); void Update(); diff --git a/src/game/Puzzle.h b/src/game/Puzzle.h index 8177ff5..fcad3d4 100644 --- a/src/game/Puzzle.h +++ b/src/game/Puzzle.h @@ -19,7 +19,8 @@ namespace Puzzle static constexpr uint32_t MaxCardsInPuzzle = MaxPuzzleSizeCards * MaxPuzzleSizeCards; static constexpr uint32_t MaxPuzzleSizeTiles = 16 * CardSize; static constexpr uint32_t MaxTilesInPuzzle = MaxPuzzleSizeTiles * MaxPuzzleSizeTiles; - static constexpr uint32_t MaxTilesTotal = MaxTilesInPuzzle * MaxVisiblePuzzles; + static constexpr uint32_t MaxTilesTotal = + MaxTilesInPuzzle * MaxVisiblePuzzles + MaxPuzzleSizeCards * MaxVisiblePuzzles + 64; static constexpr uint32_t MaxAvailableStacks = 16; static constexpr uint32_t MaxGoalPositions = 16; static constexpr float CardScaleWorld = 10.0f; diff --git a/src/game/Tools.cpp b/src/game/Tools.cpp index b39ef5a..39c13f2 100644 --- a/src/game/Tools.cpp +++ b/src/game/Tools.cpp @@ -566,13 +566,12 @@ namespace Tools ImGui::Text("%u", i); ImGui::SameLine(); auto& quad = level.UIQuads.Get({i}); - ImGui::Checkbox("Debug Break on Render", &quad.EData.DebugBreakOnRender); - ImGui::SameLine(); ImGui::Checkbox("Visible", &quad.EData.Visible); TextureDropdown(quad.EData.TextureHandle); MaterialDropdown(quad.EData.MaterialHandle); ImGui::DragFloat3("Pos", &quad.EData.Transform.Position.x); ImGui::DragFloat3("UI Pos", &quad.UIPos.x); + ImGui::Text("RenderID: %i", quad.EData.RenderID); ImGui::PopID(); } ImGui::TreePop(); @@ -587,12 +586,11 @@ namespace Tools ImGui::Text("%u", i); ImGui::SameLine(); auto& levelEnt = level.LevelEntities.Get({i}); - ImGui::Checkbox("Debug Break on Render", &levelEnt.EData.DebugBreakOnRender); - ImGui::SameLine(); ImGui::Checkbox("Visible", &levelEnt.EData.Visible); TextureDropdown(levelEnt.EData.TextureHandle); MaterialDropdown(levelEnt.EData.MaterialHandle); ImGui::DragFloat3("Pos", &levelEnt.EData.Transform.Position.x); + ImGui::Text("RenderID: %i", levelEnt.EData.RenderID); ImGui::PopID(); } ImGui::TreePop(); @@ -715,6 +713,11 @@ namespace Tools { ImGui::Checkbox("ImGui Demo", &debug.ShowImguiDemo); ImGui::SliderFloat("Font Scale", &ImGui::GetIO().FontGlobalScale, 0.5f, 4.0f); + ImGui::Checkbox("Break on ID", &debug.DebugBreakIDEnabled); + ImGui::SameLine(); + ImGui::PushID("@#$"); + ImGui::InputInt("", &debug.DebugBreakID); + ImGui::PopID(); ImGui::Separator(); ImGui::Text("Arenas"); diff --git a/src/game/data/puzzles/0.pzl b/src/game/data/puzzles/0.pzl index f3c7c0c..751f4f6 100644 --- a/src/game/data/puzzles/0.pzl +++ b/src/game/data/puzzles/0.pzl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:471c696c17921985674f200f50fde641014ed15b56d4a6578b225643ddcdfd34 +oid sha256:ad3645b16777bfd1525939d50bb8a757670e90cdce39cfb0a84b9bf85db04dc3 size 11441 diff --git a/src/game/data/static/puzzle.dat b/src/game/data/static/puzzle.dat index 71e2da1..41dc9e9 100644 Binary files a/src/game/data/static/puzzle.dat and b/src/game/data/static/puzzle.dat differ diff --git a/src/game/data/static/uiconfig.dat b/src/game/data/static/uiconfig.dat index 6794047..f4bdd43 100644 Binary files a/src/game/data/static/uiconfig.dat and b/src/game/data/static/uiconfig.dat differ diff --git a/src/models/ConcretePlane.glb b/src/models/ConcretePlane.glb index ce10076..efe6c30 100644 --- a/src/models/ConcretePlane.glb +++ b/src/models/ConcretePlane.glb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fb7691da04448da3169880b4df7c051b86145e1514678ca91c7e6af512e1793d +oid sha256:abb26e18b8cf2cfba3173c30822e5fab16144833888a2f512093c9d9916da9da size 1440 diff --git a/src/models/GateDoor.glb b/src/models/GateDoor.glb new file mode 100644 index 0000000..bcb0f47 --- /dev/null +++ b/src/models/GateDoor.glb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd6a631a988202fde82b5f4ebf8274a5c6fcda87d0247a566d78e51082fda8b6 +size 4464 diff --git a/src/models/GateWall.glb b/src/models/GateWall.glb new file mode 100644 index 0000000..816a4a8 --- /dev/null +++ b/src/models/GateWall.glb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1cc57a570f4b13c599eee46c57736ddb78e033b9bf2269fe10153baa44d954b7 +size 10416