This commit is contained in:
aozhiwei 2024-07-31 14:59:32 +08:00
parent 4cd54c4e0c
commit e4bd8249c2
3 changed files with 25 additions and 2 deletions

View File

@ -156,6 +156,7 @@ void BoxDrop::RequestReturnBoxNum()
url_params->SetVal("a", "requestReturnBoxNum");
url_params->SetVal("account_id", account_id);
url_params->SetVal("session_id", session_id);
url_params->SetVal("room_uuid", room_->GetRoomUuid());
url_params->SetVal("used_num", GetUsedBoxNum());
url_params->SetVal("alloc_box_num", alloc_box_num_);
HttpProxy::Instance()->HttpGet
@ -188,7 +189,7 @@ void BoxDrop::RequestReturnBoxNum()
}
}
bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session_id)
bool BoxDrop::FillAccountIdSessionId(std::string& account_id, std::string& session_id)
{
bool ok = false;
room_->TraversePlayerList
@ -298,3 +299,17 @@ int BoxDrop::GetUsedBoxNum()
});
return num;
}
bool BoxDrop::GetNextBoxPos(glm::vec3& pos)
{
for (auto& pair : drop_hash_) {
if (pair.second > 0) {
Entity* e = room_->GetEntityByUniId(pair.first);
if (e) {
pos = e->GetPos().ToGlmVec3();
return true;
}
}
}
return false;
}

View File

@ -15,12 +15,13 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
void OnHeroDeadDrop(Hero* hero);
void OnObstacleDeadDrop(Obstacle* ob);
void RequestReturnBoxNum();
bool GetNextBoxPos(glm::vec3& pos);
private:
void Drop(int num, const glm::vec3& center);
void RequestAllocBoxNum();
bool FillAccountIdSessionId(std::string account_id, std::string session_id);
bool FillAccountIdSessionId(std::string& account_id, std::string& session_id);
void OnAllocOk(int box_num);
void OnAllocFail();
void AllocBoxToRoom();

View File

@ -16,6 +16,7 @@
#include "loot.h"
#include "ability.h"
#include "trigger.h"
#include "boxdrop.h"
#include "cs_proto.pb.h"
@ -69,6 +70,12 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg)
room->grid_service->MoveCreature(this);
}
}
} else if (cmd == "goto_box") {
glm::vec3 pos;
if (room->GetBoxDrop()->GetNextBoxPos(pos)) {
GetMutablePos().FromGlmVec3(pos);
room->grid_service->MoveCreature(this);
}
} else if (cmd == "additem" && cmds.size() >= 3) {
int item_id = a8::XValue(cmds[1]);
int item_num = a8::XValue(cmds[2]);