This commit is contained in:
aozhiwei 2023-01-05 19:16:24 +08:00
parent d933f25c93
commit 6f5f9f11e6
6 changed files with 125 additions and 3 deletions

View File

@ -0,0 +1,30 @@
#include "precompile.h"
#include "mt/MapArea.h"
IMPL_TABLE(mt::MapArea)
std::map<int, std::vector<const mt::MapArea*>> mt::MapArea::map_areas;
namespace mt
{
void MapArea::Init1()
{
auto itr = map_areas.find(map_id());
if (itr != map_areas.end()) {
itr->second.push_back(this);
} else {
map_areas[map_id()] = std::vector<const mt::MapArea*>({this});
}
{
std::vector<std::string> strings;
a8::Split(area_center(), strings, ':');
}
}
std::vector<const mt::MapArea*>* MapArea::GetAreas(int map_id)
{
auto itr = map_areas.find(map_id);
return itr != map_areas.end() ? &itr->second : nullptr;
}
}

View File

@ -0,0 +1,24 @@
#pragma once
#include "mt/macro.h"
#include "mtb/MapArea.h"
namespace mt
{
DECLARE_AUTO_ID_TABLE(MapArea, mtb::MapArea,
"mapArea@mapArea.csv"
)
public:
void Init1();
const glm::vec2 GetCenter() { return center_; };
static std::vector<const mt::MapArea*>* GetAreas(int map_id);
private:
glm::vec2 center_ = glm::vec2(0.0f, 0.0f);
static std::map<int, std::vector<const mt::MapArea*>> map_areas;
};
}

View File

@ -36,6 +36,7 @@
#include "mt/SafeAreaPos.h"
#include "mt/Skill.h"
#include "mt/SkillNumber.h"
#include "mt/MapArea.h"
#include "app.h"
@ -102,6 +103,7 @@ namespace mt
RegMetaTable<SafeAreaPos>(res_path_);
RegMetaTable<Skill>(res_path_);
RegMetaTable<SkillNumber>(res_path_);
RegMetaTable<MapArea>(res_path_);
}
void MetaMgr::Load()

View File

@ -0,0 +1,40 @@
#pragma once
#include <bitset>
namespace mtb
{
class MapArea
{
public:
a8::reflect::Class* GetClass() const;
int map_id() const { return map_id_; };
int area_type() const { return area_type_; };
int area_subtype() const { return area_subtype_; };
const std::string area_center() const { return area_center_; };
float area_width() const { return area_width_; };
float area_height() const { return area_height_; };
bool has_map_id() const { return __flags__.test(0);};
bool has_area_type() const { return __flags__.test(1);};
bool has_area_subtype() const { return __flags__.test(2);};
bool has_area_center() const { return __flags__.test(3);};
bool has_area_width() const { return __flags__.test(4);};
bool has_area_height() const { return __flags__.test(5);};
protected:
int map_id_ = 0;
int area_type_ = 0;
int area_subtype_ = 0;
std::string area_center_;
float area_width_ = 0.0f;
float area_height_ = 0.0f;
public:
std::bitset<6> __flags__;
};
};

View File

@ -4,6 +4,7 @@
#include "mtb/Parameter.h"
#include "mtb/Attr.h"
#include "mtb/Map.h"
#include "mtb/MapArea.h"
#include "mtb/MapThing.h"
#include "mtb/SafeArea.h"
#include "mtb/SafeAreaPos.h"
@ -89,6 +90,21 @@ namespace mtb
return meta_class;
}
a8::reflect::Class* MapArea::GetClass() const
{
a8::reflect::Class* meta_class = nullptr;
if (!meta_class) {
meta_class = new a8::reflect::Class("MapArea", 6, 0);
meta_class->SetSimpleField(0, "map_id", a8::reflect::ET_INT32, my_offsetof2(MapArea, map_id_));
meta_class->SetSimpleField(1, "area_type", a8::reflect::ET_INT32, my_offsetof2(MapArea, area_type_));
meta_class->SetSimpleField(2, "area_subtype", a8::reflect::ET_INT32, my_offsetof2(MapArea, area_subtype_));
meta_class->SetSimpleField(3, "area_center", a8::reflect::ET_STRING, my_offsetof2(MapArea, area_center_));
meta_class->SetSimpleField(4, "area_width", a8::reflect::ET_FLOAT, my_offsetof2(MapArea, area_width_));
meta_class->SetSimpleField(5, "area_height", a8::reflect::ET_FLOAT, my_offsetof2(MapArea, area_height_));
}
return meta_class;
}
a8::reflect::Class* MapThing::GetClass() const
{
a8::reflect::Class* meta_class = nullptr;

View File

@ -15,9 +15,9 @@ message Attr
message Map
{
optional int32 map_id = 1; //id
optional string template_list = 2; //
optional string map_name = 3; //
optional int32 map_id = 1;
optional string template_list = 2;
optional string map_name = 3;
optional float map_width = 4;
optional float map_height = 5;
optional string airdrops = 6;
@ -35,6 +35,16 @@ message Map
optional float scale = 18;
}
message MapArea
{
optional int32 map_id = 1;
optional int32 area_type = 2;
optional int32 area_subtype = 3;
optional string area_center = 4;
optional float area_width = 5;
optional float area_height = 6;
}
message MapThing
{
optional int32 thing_id = 1; //id