game2006/server/gameserver/mt/SafeAreaPos.cc
aozhiwei 2ecdfa8682 1
2022-12-25 15:52:32 +08:00

53 lines
1.4 KiB
C++

#include "precompile.h"
#include "mt/SafeAreaPos.h"
IMPL_TABLE(mt::SafeAreaPos)
std::map<int, std::vector<mt::SafeAreaPos*>> mt::SafeAreaPos::area_hash_;
namespace mt
{
void SafeAreaPos::Init1()
{
std::vector<a8::Vec2> tmp_list;
{
tmp_list.push_back(a8::Vec2(x1(), y1()));
tmp_list.push_back(a8::Vec2(x2(), y2()));
tmp_list.push_back(a8::Vec2(x3(), y3()));
tmp_list.push_back(a8::Vec2(x4(), y4()));
tmp_list.push_back(a8::Vec2(x5(), y5()));
tmp_list.push_back(a8::Vec2(x6(), y6()));
tmp_list.push_back(a8::Vec2(x7(), y7()));
tmp_list.push_back(a8::Vec2(x8(), y8()));
tmp_list.push_back(a8::Vec2(x9(), y9()));
tmp_list.push_back(a8::Vec2(x10(), y10()));
}
for (auto& pos : tmp_list) {
if (pos.x < 1.0f || pos.y < 1.0f) {
break;
}
_poses.push_back(pos);
}
}
void SafeAreaPos::Init2()
{
}
const SafeAreaPos* SafeAreaPos::RandSafeAreaPos(int area_id)
{
auto pos_list = GetSafeAreaPosList(area_id);
return pos_list && !pos_list->empty() ? pos_list->at(rand() % pos_list->size()) : nullptr;
}
std::vector<mt::SafeAreaPos*>* SafeAreaPos::GetSafeAreaPosList(int area_id)
{
auto itr = area_hash_.find(area_id);
return itr != area_hash_.end() ? &itr->second : nullptr;
}
}