91 lines
2.5 KiB
C++
91 lines
2.5 KiB
C++
#include "precompile.h"
|
|
|
|
#include "mt/SafeArea.h"
|
|
|
|
IMPL_TABLE(mt::SafeArea)
|
|
|
|
std::map<int, std::vector<mt::SafeArea*>> mt::SafeArea::type_hash_;
|
|
|
|
namespace mt
|
|
{
|
|
|
|
void SafeArea::Init1()
|
|
{
|
|
#ifdef MYDEBUG1
|
|
wait_time_ = 30;
|
|
#endif
|
|
{
|
|
auto itr = type_hash_.find(type());
|
|
if (itr == type_hash_.end()) {
|
|
type_hash_[type()] = std::vector<mt::SafeArea*>({this});
|
|
} else {
|
|
if (itr->second.empty()) {
|
|
abort();
|
|
}
|
|
if (itr->second.at(itr->second.size() - 1)->id() + 1 != id()) {
|
|
abort();
|
|
}
|
|
itr->second.push_back(this);
|
|
}
|
|
}
|
|
if (!boss().empty()) {
|
|
std::vector<std::string> strings;
|
|
a8::Split(boss(), strings, ':');
|
|
if (strings.size() != 5) {
|
|
abort();
|
|
}
|
|
_boss = std::make_shared<std::tuple<glm::vec3, float, int>>
|
|
(
|
|
glm::vec3((float)a8::XValue(strings[0]).GetDouble(),
|
|
(float)a8::XValue(strings[1]).GetDouble(),
|
|
(float)a8::XValue(strings[2]).GetDouble()
|
|
),
|
|
(float)a8::XValue(strings[3]).GetDouble(),
|
|
a8::XValue(strings[4]).GetInt()
|
|
);
|
|
}
|
|
}
|
|
|
|
void SafeArea::StaticPostInit()
|
|
{
|
|
for (auto& pair : type_hash_) {
|
|
if (pair.second.size() < 1) {
|
|
abort();
|
|
}
|
|
int ring_count = pair.second.size() - 1;
|
|
auto last_area = pair.second.at(pair.second.size() - 1);
|
|
bool can_revive = false;
|
|
for (auto& meta : pair.second) {
|
|
meta->small_ring_count_ = ring_count--;
|
|
if (!can_revive) {
|
|
can_revive = meta->rebirth() ? true : false;
|
|
}
|
|
meta->_can_revive = can_revive;
|
|
meta->last_area_ = last_area;
|
|
}
|
|
}
|
|
}
|
|
|
|
const SafeArea* SafeArea::GetByType(int type)
|
|
{
|
|
auto itr = type_hash_.find(type);
|
|
return itr != type_hash_.end() ? itr->second.at(0) : nullptr;
|
|
}
|
|
|
|
bool SafeArea::CanRevive() const
|
|
{
|
|
#ifdef MYDEBUG
|
|
return false;
|
|
#endif
|
|
return false;
|
|
return _can_revive;
|
|
}
|
|
|
|
bool SafeArea::IsLastGas() const
|
|
{
|
|
const mt::SafeArea* next_meta = mt::SafeArea::GetById(id() + 1);
|
|
return !next_meta || next_meta->type() != type();
|
|
}
|
|
|
|
}
|