From 18f514196e4fe34602c3389069bbbe27f4b6cb63 Mon Sep 17 00:00:00 2001 From: Tyler Lentz Date: Thu, 6 Jun 2024 19:06:00 -0700 Subject: [PATCH] add chest --- config.json | 6 ++-- include/client/client.hpp | 1 + include/shared/game/sharedmodel.hpp | 3 +- src/client/client.cpp | 47 +++++++++++------------------ src/server/game/item.cpp | 2 +- src/server/game/object.cpp | 3 +- 6 files changed, 26 insertions(+), 36 deletions(-) diff --git a/config.json b/config.json index 8045f629..ac1170cd 100644 --- a/config.json +++ b/config.json @@ -14,8 +14,8 @@ "server": { "lobby_name": "Hope you're doing well!", "lobby_broadcast": true, - "max_players": 2, - "disable_dm": false, + "max_players": 1, + "disable_dm": true, "skip_intro": true }, "client": { @@ -25,6 +25,6 @@ "draw_bboxes": false, "fps_counter": true, "presentation": false, - "render": 75 + "render": 50 } } diff --git a/include/client/client.hpp b/include/client/client.hpp index 4c3ee6e1..7506f7b1 100644 --- a/include/client/client.hpp +++ b/include/client/client.hpp @@ -278,6 +278,7 @@ class Client { std::unique_ptr lava_vertical_model; std::unique_ptr lava_horizontal_model; std::unique_ptr lightning_model; + std::unique_ptr chest_model; GLFWwindow *window; diff --git a/include/shared/game/sharedmodel.hpp b/include/shared/game/sharedmodel.hpp index 3dafb911..fbd54214 100644 --- a/include/shared/game/sharedmodel.hpp +++ b/include/shared/game/sharedmodel.hpp @@ -44,5 +44,6 @@ enum class ModelType { SunGod, Mirror, LightCut, - TorchPost + TorchPost, + Chest }; \ No newline at end of file diff --git a/src/client/client.cpp b/src/client/client.cpp index 96973c92..ee767f64 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -238,6 +238,9 @@ bool Client::init() { auto lava_cross_model_path = env_models_dir / "lava" / "lava_cross.obj"; this->lava_cross_model = std::make_unique(lava_cross_model_path.string(), false); + auto chest_model_path = item_models_dir / "Chest1" / "Chest1 1.obj"; + this->chest_model = std::make_unique(chest_model_path.string(), false); + auto lava_row_model_path = env_models_dir / "lava" / "lava_row.obj"; this->lava_horizontal_model = std::make_unique(lava_row_model_path.string(), false); // thank you openai! @@ -838,7 +841,8 @@ void Client::geometryPass() { sharedObject->type == ObjectType::ArrowTrap || sharedObject->type == ObjectType::SpikeTrap || sharedObject->type == ObjectType::TeleporterTrap || - sharedObject->type == ObjectType::Projectile) + sharedObject->type == ObjectType::Projectile || + sharedObject->modelType == ModelType::Chest) && dist > this->config.client.render / 2) { continue; } @@ -853,7 +857,8 @@ void Client::geometryPass() { sharedObject->type == ObjectType::ArrowTrap || sharedObject->type == ObjectType::SpikeTrap || sharedObject->type == ObjectType::Projectile || - sharedObject->type == ObjectType::Torchlight) // dont render post from far away + sharedObject->type == ObjectType::Torchlight || // light post + sharedObject->modelType == ModelType::Chest) && dist > this->config.client.render) { continue; } @@ -1162,14 +1167,7 @@ void Client::geometryPass() { } case ObjectType::Potion: { if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) { - Model* model = this->item_model.get(); - if (sharedObject->modelType == ModelType::HealthPotion) { - model = this->item_model.get(); - } else if (sharedObject->modelType == ModelType::NauseaPotion || sharedObject->modelType == ModelType::InvincibilityPotion) { - model = this->item_model.get(); - } else if (sharedObject->modelType == ModelType::InvisibilityPotion) { - model = this->item_model.get(); - } + Model* model = this->chest_model.get(); model->setDimensions(sharedObject->physics.dimensions); model->translateAbsolute(sharedObject->physics.getCenterPosition()); @@ -1181,20 +1179,9 @@ void Client::geometryPass() { } case ObjectType::Spell: { if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) { - glm::vec3 color; - if (sharedObject->modelType == ModelType::FireSpell) { - color = glm::vec3(0.9f, 0.1f, 0.0f); - } - else if (sharedObject->modelType == ModelType::HealSpell) { - color = glm::vec3(1.0f, 1.0f, 0.0f); - } - else { - color = glm::vec3(0.8f, 0.7f, 0.6f); - } - - this->item_model->setDimensions(sharedObject->physics.dimensions); - this->item_model->translateAbsolute(sharedObject->physics.getCenterPosition()); - this->item_model->draw(this->deferred_geometry_shader.get(), + this->chest_model->setDimensions(sharedObject->physics.dimensions); + this->chest_model->translateAbsolute(sharedObject->physics.getCenterPosition()); + this->chest_model->draw(this->deferred_geometry_shader.get(), this->cam->getPos(), true); } @@ -1222,9 +1209,9 @@ void Client::geometryPass() { } case ObjectType::Weapon: { if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) { - this->item_model->setDimensions(sharedObject->physics.dimensions); - this->item_model->translateAbsolute(sharedObject->physics.getCenterPosition()); - this->item_model->draw(this->deferred_geometry_shader.get(), + this->chest_model->setDimensions(sharedObject->physics.dimensions); + this->chest_model->translateAbsolute(sharedObject->physics.getCenterPosition()); + this->chest_model->draw(this->deferred_geometry_shader.get(), this->cam->getPos(), true); } @@ -1257,9 +1244,9 @@ void Client::geometryPass() { } case ObjectType::Mirror: { if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) { - this->item_model->setDimensions(sharedObject->physics.dimensions); - this->item_model->translateAbsolute(sharedObject->physics.getCenterPosition()); - this->item_model->draw(this->deferred_geometry_shader.get(), + this->chest_model->setDimensions(sharedObject->physics.dimensions); + this->chest_model->translateAbsolute(sharedObject->physics.getCenterPosition()); + this->chest_model->draw(this->deferred_geometry_shader.get(), this->cam->getPos(), true); } diff --git a/src/server/game/item.cpp b/src/server/game/item.cpp index 985af95f..8b82618c 100644 --- a/src/server/game/item.cpp +++ b/src/server/game/item.cpp @@ -6,7 +6,7 @@ /* Constructors and Destructors */ Item::Item(ObjectType type, bool movable, glm::vec3 corner, ModelType model, glm::vec3 dimensions): - Object(type, Physics(movable, Collider::Box, corner, dimensions), ModelType::Cube), + Object(type, Physics(movable, Collider::Box, corner, dimensions), ModelType::Chest), iteminfo(SharedItemInfo{ .held = false, .used = false }) {} diff --git a/src/server/game/object.cpp b/src/server/game/object.cpp index d3f73eb0..723b6522 100644 --- a/src/server/game/object.cpp +++ b/src/server/game/object.cpp @@ -56,7 +56,8 @@ std::unordered_map Object::models ({ {ModelType::FloorSpikeHorizontal, FLOOR_SPIKE_DIMENSIONS}, {ModelType::FloorSpikeVertical, FLOOR_SPIKE_DIMENSIONS}, {ModelType::Lightning, glm::vec3(3.0f, 100.0f, 3.0f)}, - {ModelType::Orb, glm::vec3(0.887116, 0.941508, 0.950092)} + {ModelType::Orb, glm::vec3(0.887116, 0.941508, 0.950092)}, + {ModelType::Chest, glm::vec3(1.377020, 1.355794, 1.092905)} }); /* SharedGameState generation */