This commit is contained in:
aozhiwei 2024-01-03 16:06:37 +08:00
parent 89e72625c9
commit 5b17e9bb9b
4 changed files with 67 additions and 0 deletions

View File

View File

@ -0,0 +1,15 @@
#pragma once
#include "mt/macro.h"
#include "mtb/BattleUnit.h"
namespace mt
{
DECLARE_ID_TABLE(BattleUnit, mtb::BattleUnit,
"battleUnit@battleUnit.json",
"id")
public:
};
}

View File

@ -0,0 +1,37 @@
#pragma once
#include <bitset>
namespace mtb
{
class BattleUnit
{
public:
std::shared_ptr<a8::reflect::Class> GetClass() const;
int id() const { return id_; };
int weapon() const { return weapon_; };
int level() const { return level_; };
const std::string levelAttribute() const { return levelAttribute_; };
const std::string cost() const { return cost_; };
bool has_id() const { return __flags__.test(0);};
bool has_weapon() const { return __flags__.test(1);};
bool has_level() const { return __flags__.test(2);};
bool has_levelAttribute() const { return __flags__.test(3);};
bool has_cost() const { return __flags__.test(4);};
protected:
int id_ = 0;
int weapon_ = 0;
int level_ = 0;
std::string levelAttribute_;
std::string cost_;
public:
std::bitset<5> __flags__;
};
};

View File

@ -45,6 +45,7 @@
#include "mtb/BattleLevelAttribute.h"
#include "mtb/BattleRandAttribute.h"
#include "mtb/BattleWeaponAttribute.h"
#include "mtb/BattleUnit.h"
#include "mtb/Condition.h"
#include "mtb/Distribution.h"
#include "mtb/LootConfig.h"
@ -976,6 +977,20 @@ namespace mtb
return meta_class;
}
std::shared_ptr<a8::reflect::Class> BattleUnit::GetClass() const
{
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;
if (!meta_class) {
meta_class = std::make_shared<a8::reflect::Class>("BattleUnit", 5, 0);
meta_class->SetSimpleField(0, "id", a8::reflect::ET_INT32, my_offsetof2(BattleUnit, id_));
meta_class->SetSimpleField(1, "weapon", a8::reflect::ET_INT32, my_offsetof2(BattleUnit, weapon_));
meta_class->SetSimpleField(2, "level", a8::reflect::ET_INT32, my_offsetof2(BattleUnit, level_));
meta_class->SetSimpleField(3, "levelAttribute", a8::reflect::ET_STRING, my_offsetof2(BattleUnit, levelAttribute_));
meta_class->SetSimpleField(4, "cost", a8::reflect::ET_STRING, my_offsetof2(BattleUnit, cost_));
}
return meta_class;
}
std::shared_ptr<a8::reflect::Class> Condition::GetClass() const
{
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;