1
This commit is contained in:
parent
7321587966
commit
5d3889cb15
@ -8,12 +8,14 @@
|
||||
#include "boxdrop.h"
|
||||
#include "room.h"
|
||||
#include "hero.h"
|
||||
#include "obstacle.h"
|
||||
#include "roomobstacle.h"
|
||||
#include "httpproxy.h"
|
||||
#include "jsondatamgr.h"
|
||||
#include "player.h"
|
||||
|
||||
#include "mt/MapMode.h"
|
||||
#include "mt/Hero.h"
|
||||
#include "mt/MapThing.h"
|
||||
|
||||
const int BOX_ID = 150001;
|
||||
|
||||
@ -209,6 +211,7 @@ void BoxDrop::OnAllocOk(int box_num)
|
||||
}
|
||||
alloced_ = true;
|
||||
alloc_box_num_ = box_num;
|
||||
AllocBoxToRoom();
|
||||
}
|
||||
|
||||
void BoxDrop::OnAllocFail()
|
||||
@ -217,3 +220,29 @@ void BoxDrop::OnAllocFail()
|
||||
room_->xtimer.Delete(get_box_num_timer_);
|
||||
}
|
||||
}
|
||||
|
||||
void BoxDrop::AllocBoxToRoom()
|
||||
{
|
||||
if (alloc_box_num_ <= 0) {
|
||||
return;
|
||||
}
|
||||
std::vector<Creature*> hero_list;
|
||||
std::vector<Obstacle*> box_list;
|
||||
room_->TraverseEntityList
|
||||
(
|
||||
[this, &hero_list, &box_list] (Entity* e) -> bool
|
||||
{
|
||||
if (e->IsCreature(room_) && ((Creature*)e)->IsHero()) {
|
||||
Hero* hero = (Hero*)e;
|
||||
if (hero->meta->HasDrop()) {
|
||||
hero_list.push_back(hero);
|
||||
}
|
||||
} else if (e->IsRoomObstacle()) {
|
||||
RoomObstacle* ob = (RoomObstacle*)e;
|
||||
if (ob->meta->HasDrop()) {
|
||||
box_list.push_back(ob);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
|
||||
bool FillAccountIdSessionId(std::string account_id, std::string session_id);
|
||||
void OnAllocOk(int box_num);
|
||||
void OnAllocFail();
|
||||
void AllocBoxToRoom();
|
||||
|
||||
private:
|
||||
Room* room_ = nullptr;
|
||||
@ -32,4 +33,5 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
|
||||
int alloc_box_num_ = 0;
|
||||
bool alloced_ = false;
|
||||
bool returned_ = false;
|
||||
std::map<int, int> drop_hash_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user