Browse Source

feat(CAPI): commits with state

tags/0.1.0
DragonAura 3 years ago
parent
commit
0b43a2cd39
2 changed files with 12 additions and 5 deletions
  1. +2
    -3
      CAPI/API/include/structures.h
  2. +10
    -2
      CAPI/API/include/utils.hpp

+ 2
- 3
CAPI/API/include/structures.h View File

@@ -87,7 +87,7 @@ namespace THUAI6
ButcherBuffType4 = 4,
};

//人类状态枚举
// 人类状态枚举
enum class HumanState : unsigned char
{
NullHumanState = 0,
@@ -118,8 +118,7 @@ namespace THUAI6

struct Human : public Player
{
bool onChair; // 是否被挂
bool onGround; // 是否倒地
HumanState state; // 人类状态
int32_t life; // 剩余生命(本次倒地之前还能承受的伤害)
int32_t hangedTime; // 被挂的次数



+ 10
- 2
CAPI/API/include/utils.hpp View File

@@ -76,6 +76,15 @@ namespace Proto2THUAI6
{protobuf::ButcherBuffType::BBUFFTYPE4, THUAI6::ButcherBuffType::ButcherBuffType4},
};

inline std::map<protobuf::HumanState, THUAI6::HumanState> humanStateDict{
{protobuf::HumanState::NULL_STATUS, THUAI6::HumanState::NullHumanState},
{protobuf::HumanState::IDLE, THUAI6::HumanState::Idle},
{protobuf::HumanState::FIXING, THUAI6::HumanState::Fixing},
{protobuf::HumanState::DYING, THUAI6::HumanState::Dying},
{protobuf::HumanState::ON_CHAIR, THUAI6::HumanState::OnChair},
{protobuf::HumanState::DEAD, THUAI6::HumanState::Dead},
};

// 用于将Protobuf中的类转换为THUAI6的类
inline std::shared_ptr<THUAI6::Butcher> Protobuf2THUAI6Butcher(const protobuf::MessageOfButcher& butcherMsg)
{
@@ -115,8 +124,7 @@ namespace Proto2THUAI6
human->playerType = THUAI6::PlayerType::HumanPlayer;
human->prop = propTypeDict[humanMsg.prop()];
human->place = placeTypeDict[humanMsg.place()];
human->onChair = humanMsg.on_chair();
human->onGround = humanMsg.on_ground();
human->state = humanStateDict[humanMsg.state()];
human->life = humanMsg.life();
human->hangedTime = humanMsg.hanged_time();
human->humanType = humanTypeDict[humanMsg.human_type()];


Loading…
Cancel
Save