walls
This commit is contained in:
+4
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+76
-8
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
+2
-1
@@ -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;
|
||||
|
||||
+7
-4
@@ -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");
|
||||
|
||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Reference in New Issue
Block a user