Merge branch 'escape001' of gitea.fishrungames.com:salmon-engine-projects/space-game001 into escape001
This commit is contained in:
commit
66da012d5a
3 files changed
+133
-9
No files matched your search
+33
-2
@@ -25,6 +25,7 @@ namespace ZL
|
||||
: renderer(iRenderer)
|
||||
, inventory(iInventory)
|
||||
, locationId(locId)
|
||||
, roofObjectKey("")
|
||||
{
|
||||
|
||||
}
|
||||
@@ -105,7 +106,7 @@ void Location::setup()
|
||||
std::vector<ModelAsset> models = {
|
||||
{"resources/out/AzsBase001.txt", "resources/ghost_avatar.png", {0.0f, 2.0f, 0.0f}, 2.0f},
|
||||
{"resources/out/AzsRoof001.txt", "resources/ghost_avatar.png", {0.0f, 2.0f, 0.0f}, 2.0f},
|
||||
{"resources/out/floor001.txt", "resources/ghost_avatar.png", {0.0f, 2.0f, 0.0f}, 2.0f},
|
||||
{"resources/out/floor001.txt", "resources/ghost_avatar.png", {0.0f, -1.97f, 0.0f}, 2.0f},
|
||||
{"resources/out/roof001.txt", "resources/ghost_avatar.png", {0.0f, 2.0f, 0.0f}, 2.0f},
|
||||
{"resources/out/Walls001.txt", "resources/ghost_avatar.png", {0.0f, 2.0f, 0.0f}, 2.0f},
|
||||
{"resources/out/Price001.txt", "resources/w/blue.png", {0.0f, 1.0f, 5.0f}, 2.0f}
|
||||
@@ -119,7 +120,16 @@ void Location::setup()
|
||||
obj.mesh.data.Move(m.position);
|
||||
obj.mesh.RefreshVBO();
|
||||
obj.texture = std::make_shared<Texture>(CreateTextureDataFromPng(m.texPath, CONST_ZIP_FILE));
|
||||
gameObjects["forest_model_" + std::to_string(i)] = std::move(obj);
|
||||
//gameObjects["forest_model_" + std::to_string(i)] = std::move(obj);
|
||||
roofHideZones.clear();
|
||||
roofHideZones.emplace_back(Eigen::Vector2f(-9.3f, -5.0f), Eigen::Vector2f(2.5f, 1.7f));
|
||||
if (i == 3) {
|
||||
gameObjects["roof"] = std::move(obj);
|
||||
roofObjectKey = "roof";
|
||||
}
|
||||
else {
|
||||
gameObjects["forest_model_" + std::to_string(i)] = std::move(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -409,6 +419,9 @@ void Location::setup()
|
||||
}
|
||||
|
||||
for (auto& [name, gameObj] : gameObjects) {
|
||||
if (name == roofObjectKey && !roofVisible) {
|
||||
continue;
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, gameObj.texture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(gameObj.mesh);
|
||||
}
|
||||
@@ -518,6 +531,9 @@ void Location::setup()
|
||||
renderer.DrawVertexRenderStruct(roomMesh);
|
||||
|
||||
for (auto& [name, gameObj] : gameObjects) {
|
||||
if (name == roofObjectKey && !roofVisible) {
|
||||
continue;
|
||||
}
|
||||
renderer.DrawVertexRenderStruct(gameObj.mesh);
|
||||
}
|
||||
|
||||
@@ -610,6 +626,9 @@ void Location::setup()
|
||||
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
for (auto& [name, gameObj] : gameObjects) {
|
||||
if (name == roofObjectKey && !roofVisible) {
|
||||
continue;
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, gameObj.texture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(gameObj.mesh);
|
||||
}
|
||||
@@ -655,6 +674,18 @@ void Location::setup()
|
||||
if (player) {
|
||||
player->update(delta);
|
||||
dialogueSystem.update(static_cast<int>(delta), player->position);
|
||||
if (!roofObjectKey.empty()) {
|
||||
bool insideAnyZone = false;
|
||||
const Eigen::Vector2f playerPos2d(player->position.x(), player->position.z());
|
||||
for (const auto& zone : roofHideZones) {
|
||||
if (zone.contains(playerPos2d)) {
|
||||
insideAnyZone = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const float maxHeightForHide = 3.0f;
|
||||
roofVisible = !(insideAnyZone && player->position.y() < maxHeightForHide);
|
||||
}
|
||||
}
|
||||
|
||||
if (girlfriend)
|
||||
|
||||
@@ -112,6 +112,9 @@ namespace ZL
|
||||
|
||||
private:
|
||||
std::string locationId;
|
||||
std::string roofObjectKey;
|
||||
bool roofVisible = true;
|
||||
std::vector<Eigen::AlignedBox<float, 2>> roofHideZones;
|
||||
};
|
||||
|
||||
} // namespace ZL
|
||||
Reference in new issue
Block a user