Browse Source

chore: add structures.h and API.h(unfinished)

tags/0.1.0
DragonAura 3 years ago
parent
commit
84fc6ec4c5
5 changed files with 487 additions and 50 deletions
  1. +154
    -0
      CAPI/API/include/API.h
  2. +151
    -0
      CAPI/API/include/structures.h
  3. +108
    -50
      CAPI/proto/Message2Clients.pb.cc
  4. +72
    -0
      CAPI/proto/Message2Clients.pb.h
  5. +2
    -0
      dependency/proto/Message2Clients.proto

+ 154
- 0
CAPI/API/include/API.h View File

@@ -0,0 +1,154 @@
#pragma once
#ifndef API_H
#define API_H

#ifdef _MSC_VER
#pragma warning(disable : 4996)
#endif

#include <Message2Server.pb.h>
#include <Message2Clients.pb.h>
#include <MessageType.pb.h>
#include <Message2Server.grpc.pb.h>
#include <Message2Clients.grpc.pb.h>
#include <MessageType.grpc.pb.h>
#include <future>
#include <iostream>
#include <vector>

#include "structures.h"

const constexpr int num_of_grid_per_cell = 1000;

class ILogic
{
// API中依赖Logic的部分

public:
// 获取服务器发来的所有消息,要注意线程安全问题
virtual protobuf::MessageToClient GetFullMessage() = 0;

// 供IAPI使用的操作相关的部分
virtual bool Move(protobuf::MoveMsg) = 0;
virtual bool PickProp(protobuf::PickMsg) = 0;
virtual bool UseProp(protobuf::IDMsg) = 0;
virtual bool UseSkill(protobuf::IDMsg) = 0;
virtual void SendMessage(protobuf::SendMsg) = 0;
virtual bool HaveMessage(protobuf::IDMsg) = 0;
virtual protobuf::MsgRes GetMessage(protobuf::IDMsg) = 0;

virtual bool Escape(protobuf::IDMsg) = 0;

// 说明:双向stream由三个函数共同实现,两个记录开始和结束,结果由Logic里的私有的成员变量记录,获得返回值则另调函数
virtual bool StartFixMachine(protobuf::IDMsg) = 0;
virtual bool EndFixMachine(protobuf::IDMsg) = 0;
virtual bool GetFixStatus() = 0;

virtual bool StartSaveHuman(protobuf::IDMsg) = 0;
virtual bool EndSaveHuman(protobuf::IDMsg) = 0;
virtual bool GetSaveStatus() = 0;

virtual bool Attack(protobuf::AttackMsg) = 0;
virtual bool CarryHuman(protobuf::IDMsg) = 0;
virtual bool ReleaseHuman(protobuf::IDMsg) = 0;
virtual bool HangHuman(protobuf::IDMsg) = 0;

virtual bool WaitThread() = 0;

virtual int GetCounter() = 0;
};

class IAPI
{
public:
// 选手可执行的操作,应当保证所有函数的返回值都应当为std::future,例如下面的移动函数:
// 指挥本角色进行移动,`timeInMilliseconds` 为移动时间,单位为毫秒;`angleInRadian` 表示移动的方向,单位是弧度,使用极坐标——竖直向下方向为 x 轴,水平向右方向为 y 轴
virtual std::future<bool> Move(uint32_t timeInMilliseconds, double angleInRadian) = 0;

// 向特定方向移动
virtual std::future<bool> MoveRight(uint32_t timeInMilliseconds) = 0;
virtual std::future<bool> MoveUp(uint32_t timeInMilliseconds) = 0;
virtual std::future<bool> MoveLeft(uint32_t timeInMilliseconds) = 0;
virtual std::future<bool> MoveDown(uint32_t timeInMilliseconds) = 0;

// 捡道具、使用技能
virtual std::future<bool> PickProp() = 0;
virtual std::future<bool> UseProp() = 0;
virtual std::future<bool> UseSkill() = 0;

// 发送信息、接受信息
virtual std::future<bool> SendMessage(int, std::string) = 0;
[[nodiscard]] virtual std::future<bool> HaveMessage() = 0;
[[nodiscard]] virtual std::future<std::pair<int, std::string>> GetMessage() = 0;

// 等待下一帧
virtual std::future<bool> Wait() = 0;

// 获取视野内可见的人类/屠夫的信息
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI6::Human>> GetHuman() const = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI6::Buthcer>> GetButcher() const = 0;

// 获取视野内可见的道具信息
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI6::Prop>> GetProps() const = 0;

// 获取地图信息,视野外的地图统一为Land
[[nodiscard]] virtual std::array<std::array<THUAI6::PlaceType, 50>, 50> GetFullMap() const = 0;
[[nodiscard]] virtual THUAI6::PlaceType GetPlaceType(int32_t CellX, int32_t CellY) const = 0;

// 获取所有玩家的GUID
[[nodiscard]] virtual const std::vector<int64_t> GetPlayerGUIDs() const = 0;

// 获取游戏目前所进行的帧数
[[nodiscard]] virtual int GetFrameCount() const = 0;

/*****选手可能用的辅助函数*****/

// 获取指定格子中心的坐标
[[nodiscard]] static inline int CellToGrid(int cell) noexcept
{
return cell * num_of_grid_per_cell + num_of_grid_per_cell / 2;
}

// 获取指定坐标点所位于的格子的 X 序号
[[nodiscard]] static inline int GridToCell(int grid) noexcept
{
return grid / num_of_grid_per_cell;
}

IAPI(ILogic& logic) :
logic(logic)
{
}

virtual ~IAPI()
{
}

protected:
ILogic& logic;
};

class IHumanAPI : public IAPI
{
public:
virtual std::future<bool> StartFixMachine() = 0;
virtual std::future<bool> EndFixMachine() = 0;
virtual std::future<bool> GetFixStatus() = 0;
virtual std::future<bool> StartSaveHuman() = 0;
virtual std::future<bool> EndSaveHuman() = 0;
virtual std::future<bool> GetSaveStatus() = 0;
virtual std::future<bool> Escape() = 0;
[[nodiscard]] virtual std::shared_ptr<const THUAI6::Human> GetSelfInfo() const = 0;
};

class IButcherAPI : public IAPI
{
public:
virtual std::future<bool> Attack(double angleInRadian) = 0;
virtual std::future<bool> CarryHuman() = 0;
virtual std::future<bool> ReleaseHuman() = 0;
virtual std::future<bool> HangHuman() = 0;
[[nodiscard]] virtual std::shared_ptr<const THUAI6::Buthcer> GetSelfInfo() const = 0;
};

#endif

+ 151
- 0
CAPI/API/include/structures.h View File

@@ -0,0 +1,151 @@
#pragma once
#ifndef STRUCTURES_H
#define STRUCTURES_H

#include <cstdint>
#include <array>
#include <map>

namespace THUAI6
{
// 所有NullXXXType均为错误类型,其余为可能出现的正常类型

// 位置标志
enum class PlaceType : unsigned char
{
NullPlaceType = 0,
Land = 1,
Wall = 2,
Grass = 3,
Machine = 4,
Gate = 5,
HiddenGate = 6,
};

// 形状标志
enum class ShapeType : unsigned char
{
NullShapeType = 0,
Circle = 1,
Square = 2,
};

// 道具类型
enum class PropType : unsigned char
{
NullPropType = 0,
PropType1 = 1,
PropType2 = 2,
PropType3 = 3,
PropType4 = 4,
};

// 玩家类型
enum class PlayerType : unsigned char
{
NullPlayerType = 0,
HumanPlayer = 1,
ButcherType = 2,
};

// 人类类型
enum class HumanType : unsigned char
{
NullHumanType = 0,
HumanType1 = 1,
HumanType2 = 2,
HumanType3 = 3,
HumanType4 = 4,
};

// 屠夫类型
enum class ButcherType : unsigned char
{
NullButcherType = 0,
ButcherType1 = 1,
ButcherType2 = 2,
ButcherType3 = 3,
ButcherType4 = 4,
};

// 人类Buff类型
enum class HumanBuffType : unsigned char
{
NullHumanBuffType = 0,
HumanBuffType1 = 1,
HumanBuffType2 = 2,
HumanBuffType3 = 3,
HumanBuffType4 = 4,
};

// 玩家类
struct Player
{
int32_t x; // x坐标
int32_t y; // y坐标
uint32_t speed; // 移动速度
uint32_t viewRange; // 视野范围
uint64_t playerID; // 玩家ID
uint64_t guid; // 全局唯一ID
uint16_t radius; // 圆形物体的半径或正方形物体的内切圆半径

double timeUntilSkillAvailable; // 技能冷却时间

PlayerType playerType; // 玩家类型
PropType prop; // 手上的道具类型
PlaceType place; // 所处格子的类型
};

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

HumanType humanType; // 人类类型
std::vector<HumanBuffType> buff; // buff
};

struct Butcher : public Player
{
uint32_t damage; // 攻击伤害
bool movable; // 是否处在攻击后摇中

ButcherType butcherType; // 屠夫类型
std::vector<ButcherBuffType> buff; // buff
};

struct Prop
{
int32_t x;
int32_t y;
uint32_t size;
uint64_t guid;
PropType type;
PlaceType place;
double facingDirection; // 朝向
bool isMoving;
};

// 仅供DEBUG使用,名称可改动
// 还没写完,后面待续

inline std::map<PlaceType, std::string> placeDict{
{PlaceType::NullPlaceType, "NullPlaceType"},
{PlaceType::Land, "Land"},
{PlaceType::Wall, "Wall"},
{PlaceType::Grass, "Grass"},
{PlaceType::Machine, "Machine"},
{PlaceType::Gate, "Gate"},
{PlaceType::HiddenGate, "HiddenGate"},
};

inline std::map<PropType, std::string> propDict{
{PropType::NullPropType, "NullPropType"},

};

} // namespace THUAI6

#endif

+ 108
- 50
CAPI/proto/Message2Clients.pb.cc View File

@@ -114,7 +114,9 @@ namespace protobuf
place_(0)

,
guid_(int64_t{0})
guid_(int64_t{0}),
size_(0),
is_moving_(false)
{
}
struct MessageOfPropDefaultTypeInternal
@@ -352,6 +354,8 @@ const uint32_t TableStruct_Message2Clients_2eproto::offsets[] PROTOBUF_SECTION_V
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfProp, facing_direction_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfProp, guid_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfProp, place_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfProp, size_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfProp, is_moving_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfPickedProp, _internal_metadata_),
~0u, // no _extensions_
@@ -416,13 +420,13 @@ static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOB
{0, -1, -1, sizeof(::protobuf::MessageOfHuman)},
{23, -1, -1, sizeof(::protobuf::MessageOfButcher)},
{42, -1, -1, sizeof(::protobuf::MessageOfProp)},
{54, -1, -1, sizeof(::protobuf::MessageOfPickedProp)},
{65, -1, -1, sizeof(::protobuf::MessageOfMap_Row)},
{72, -1, -1, sizeof(::protobuf::MessageOfMap)},
{79, -1, -1, sizeof(::protobuf::MessageToClient)},
{89, -1, -1, sizeof(::protobuf::MoveRes)},
{97, -1, -1, sizeof(::protobuf::BoolRes)},
{104, -1, -1, sizeof(::protobuf::MsgRes)},
{56, -1, -1, sizeof(::protobuf::MessageOfPickedProp)},
{67, -1, -1, sizeof(::protobuf::MessageOfMap_Row)},
{74, -1, -1, sizeof(::protobuf::MessageOfMap)},
{81, -1, -1, sizeof(::protobuf::MessageToClient)},
{91, -1, -1, sizeof(::protobuf::MoveRes)},
{99, -1, -1, sizeof(::protobuf::BoolRes)},
{106, -1, -1, sizeof(::protobuf::MsgRes)},
};

static ::PROTOBUF_NAMESPACE_ID::Message const* const file_default_instances[] = {
@@ -459,46 +463,46 @@ const char descriptor_table_protodef_Message2Clients_2eproto[] PROTOBUF_SECTION_
" \001(\0162\025.protobuf.ButcherType\022\014\n\004guid\030\t \001("
"\003\022\017\n\007movable\030\n \001(\010\022\020\n\010playerID\030\013 \001(\003\022\022\n\n"
"view_range\030\014 \001(\005\022\'\n\004buff\030\r \003(\0162\031.protobu"
"f.ButcherBuffType\"\223\001\n\rMessageOfProp\022 \n\004t"
"f.ButcherBuffType\"\264\001\n\rMessageOfProp\022 \n\004t"
"ype\030\001 \001(\0162\022.protobuf.PropType\022\t\n\001x\030\002 \001(\005"
"\022\t\n\001y\030\003 \001(\005\022\030\n\020facing_direction\030\004 \001(\001\022\014\n"
"\004guid\030\005 \001(\003\022\"\n\005place\030\006 \001(\0162\023.protobuf.Pl"
"aceType\"{\n\023MessageOfPickedProp\022 \n\004type\030\001"
" \001(\0162\022.protobuf.PropType\022\t\n\001x\030\002 \001(\005\022\t\n\001y"
"\030\003 \001(\005\022\030\n\020facing_direction\030\004 \001(\001\022\022\n\nmapp"
"ing_id\030\005 \001(\003\"`\n\014MessageOfMap\022\'\n\003row\030\002 \003("
"\0132\032.protobuf.MessageOfMap.Row\032\'\n\003Row\022 \n\003"
"col\030\001 \003(\0162\023.protobuf.PlaceType\"\323\001\n\017Messa"
"geToClient\022/\n\rhuman_message\030\001 \003(\0132\030.prot"
"obuf.MessageOfHuman\0223\n\017butcher_message\030\002"
" \003(\0132\032.protobuf.MessageOfButcher\022-\n\014prop"
"_message\030\003 \003(\0132\027.protobuf.MessageOfProp\022"
"+\n\013map_massage\030\004 \001(\0132\026.protobuf.MessageO"
"fMap\"5\n\007MoveRes\022\024\n\014actual_speed\030\001 \001(\003\022\024\n"
"\014actual_angle\030\002 \001(\001\"\036\n\007BoolRes\022\023\n\013act_su"
"ccess\030\001 \001(\010\"P\n\006MsgRes\022\024\n\014have_message\030\001 "
"\001(\010\022\026\n\016from_player_id\030\002 \001(\003\022\030\n\020message_r"
"eceived\030\003 \001(\t2\213\006\n\020AvailableService\022=\n\tAd"
"dPlayer\022\023.protobuf.PlayerMsg\032\031.protobuf."
"MessageToClient0\001\022,\n\004Move\022\021.protobuf.Mov"
"eMsg\032\021.protobuf.MoveRes\0220\n\010PickProp\022\021.pr"
"otobuf.PickMsg\032\021.protobuf.BoolRes\022-\n\007Use"
"Prop\022\017.protobuf.IDMsg\032\021.protobuf.BoolRes"
"\022.\n\010UseSkill\022\017.protobuf.IDMsg\032\021.protobuf"
".BoolRes\0223\n\013SendMessage\022\021.protobuf.SendM"
"sg\032\021.protobuf.BoolRes\0221\n\013HaveMessage\022\017.p"
"rotobuf.IDMsg\032\021.protobuf.BoolRes\022/\n\nGetM"
"essage\022\017.protobuf.IDMsg\032\020.protobuf.MsgRe"
"s\0224\n\nFixMachine\022\017.protobuf.IDMsg\032\021.proto"
"buf.BoolRes(\0010\001\0223\n\tSaveHuman\022\017.protobuf."
"IDMsg\032\021.protobuf.BoolRes(\0010\001\0220\n\006Attack\022\023"
".protobuf.AttackMsg\032\021.protobuf.BoolRes\0220"
"\n\nCarryHuman\022\017.protobuf.IDMsg\032\021.protobuf"
".BoolRes\0222\n\014ReleaseHuman\022\017.protobuf.IDMs"
"g\032\021.protobuf.BoolRes\022/\n\tHangHuman\022\017.prot"
"obuf.IDMsg\032\021.protobuf.BoolRes\022,\n\006Escape\022"
"\017.protobuf.IDMsg\032\021.protobuf.BoolResb\006pro"
"to3";
"aceType\022\014\n\004size\030\007 \001(\005\022\021\n\tis_moving\030\010 \001(\010"
"\"{\n\023MessageOfPickedProp\022 \n\004type\030\001 \001(\0162\022."
"protobuf.PropType\022\t\n\001x\030\002 \001(\005\022\t\n\001y\030\003 \001(\005\022"
"\030\n\020facing_direction\030\004 \001(\001\022\022\n\nmapping_id\030"
"\005 \001(\003\"`\n\014MessageOfMap\022\'\n\003row\030\002 \003(\0132\032.pro"
"tobuf.MessageOfMap.Row\032\'\n\003Row\022 \n\003col\030\001 \003"
"(\0162\023.protobuf.PlaceType\"\323\001\n\017MessageToCli"
"ent\022/\n\rhuman_message\030\001 \003(\0132\030.protobuf.Me"
"ssageOfHuman\0223\n\017butcher_message\030\002 \003(\0132\032."
"protobuf.MessageOfButcher\022-\n\014prop_messag"
"e\030\003 \003(\0132\027.protobuf.MessageOfProp\022+\n\013map_"
"massage\030\004 \001(\0132\026.protobuf.MessageOfMap\"5\n"
"\007MoveRes\022\024\n\014actual_speed\030\001 \001(\003\022\024\n\014actual"
"_angle\030\002 \001(\001\"\036\n\007BoolRes\022\023\n\013act_success\030\001"
" \001(\010\"P\n\006MsgRes\022\024\n\014have_message\030\001 \001(\010\022\026\n\016"
"from_player_id\030\002 \001(\003\022\030\n\020message_received"
"\030\003 \001(\t2\213\006\n\020AvailableService\022=\n\tAddPlayer"
"\022\023.protobuf.PlayerMsg\032\031.protobuf.Message"
"ToClient0\001\022,\n\004Move\022\021.protobuf.MoveMsg\032\021."
"protobuf.MoveRes\0220\n\010PickProp\022\021.protobuf."
"PickMsg\032\021.protobuf.BoolRes\022-\n\007UseProp\022\017."
"protobuf.IDMsg\032\021.protobuf.BoolRes\022.\n\010Use"
"Skill\022\017.protobuf.IDMsg\032\021.protobuf.BoolRe"
"s\0223\n\013SendMessage\022\021.protobuf.SendMsg\032\021.pr"
"otobuf.BoolRes\0221\n\013HaveMessage\022\017.protobuf"
".IDMsg\032\021.protobuf.BoolRes\022/\n\nGetMessage\022"
"\017.protobuf.IDMsg\032\020.protobuf.MsgRes\0224\n\nFi"
"xMachine\022\017.protobuf.IDMsg\032\021.protobuf.Boo"
"lRes(\0010\001\0223\n\tSaveHuman\022\017.protobuf.IDMsg\032\021"
".protobuf.BoolRes(\0010\001\0220\n\006Attack\022\023.protob"
"uf.AttackMsg\032\021.protobuf.BoolRes\0220\n\nCarry"
"Human\022\017.protobuf.IDMsg\032\021.protobuf.BoolRe"
"s\0222\n\014ReleaseHuman\022\017.protobuf.IDMsg\032\021.pro"
"tobuf.BoolRes\022/\n\tHangHuman\022\017.protobuf.ID"
"Msg\032\021.protobuf.BoolRes\022,\n\006Escape\022\017.proto"
"buf.IDMsg\032\021.protobuf.BoolResb\006proto3";
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* const descriptor_table_Message2Clients_2eproto_deps[2] = {
&::descriptor_table_Message2Server_2eproto,
&::descriptor_table_MessageType_2eproto,
@@ -507,7 +511,7 @@ static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_Message2Cli
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_Message2Clients_2eproto = {
false,
false,
2363,
2396,
descriptor_table_protodef_Message2Clients_2eproto,
"Message2Clients.proto",
&descriptor_table_Message2Clients_2eproto_once,
@@ -1875,13 +1879,13 @@ namespace protobuf
::PROTOBUF_NAMESPACE_ID::Message()
{
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::memcpy(&type_, &from.type_, static_cast<size_t>(reinterpret_cast<char*>(&guid_) - reinterpret_cast<char*>(&type_)) + sizeof(guid_));
::memcpy(&type_, &from.type_, static_cast<size_t>(reinterpret_cast<char*>(&is_moving_) - reinterpret_cast<char*>(&type_)) + sizeof(is_moving_));
// @@protoc_insertion_point(copy_constructor:protobuf.MessageOfProp)
}

inline void MessageOfProp::SharedCtor()
{
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(reinterpret_cast<char*>(&type_) - reinterpret_cast<char*>(this)), 0, static_cast<size_t>(reinterpret_cast<char*>(&guid_) - reinterpret_cast<char*>(&type_)) + sizeof(guid_));
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(reinterpret_cast<char*>(&type_) - reinterpret_cast<char*>(this)), 0, static_cast<size_t>(reinterpret_cast<char*>(&is_moving_) - reinterpret_cast<char*>(&type_)) + sizeof(is_moving_));
}

MessageOfProp::~MessageOfProp()
@@ -1918,7 +1922,7 @@ namespace protobuf
// Prevent compiler warnings about cached_has_bits being unused
(void)cached_has_bits;

::memset(&type_, 0, static_cast<size_t>(reinterpret_cast<char*>(&guid_) - reinterpret_cast<char*>(&type_)) + sizeof(guid_));
::memset(&type_, 0, static_cast<size_t>(reinterpret_cast<char*>(&is_moving_) - reinterpret_cast<char*>(&type_)) + sizeof(is_moving_));
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

@@ -1995,6 +1999,26 @@ namespace protobuf
else
goto handle_unusual;
continue;
// int32 size = 7;
case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 56))
{
size_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
}
else
goto handle_unusual;
continue;
// bool is_moving = 8;
case 8:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 64))
{
is_moving_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
}
else
goto handle_unusual;
continue;
default:
goto handle_unusual;
} // switch
@@ -2079,6 +2103,20 @@ namespace protobuf
);
}

// int32 size = 7;
if (this->_internal_size() != 0)
{
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(7, this->_internal_size(), target);
}

// bool is_moving = 8;
if (this->_internal_is_moving() != 0)
{
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(8, this->_internal_is_moving(), target);
}

if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields()))
{
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
@@ -2140,6 +2178,18 @@ namespace protobuf
total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64SizePlusOne(this->_internal_guid());
}

// int32 size = 7;
if (this->_internal_size() != 0)
{
total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_size());
}

// bool is_moving = 8;
if (this->_internal_is_moving() != 0)
{
total_size += 1 + 1;
}

return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
}

@@ -2193,6 +2243,14 @@ namespace protobuf
{
_internal_set_guid(from._internal_guid());
}
if (from._internal_size() != 0)
{
_internal_set_size(from._internal_size());
}
if (from._internal_is_moving() != 0)
{
_internal_set_is_moving(from._internal_is_moving());
}
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}

@@ -2215,7 +2273,7 @@ namespace protobuf
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(MessageOfProp, guid_) + sizeof(MessageOfProp::guid_) - PROTOBUF_FIELD_OFFSET(MessageOfProp, type_)>(
PROTOBUF_FIELD_OFFSET(MessageOfProp, is_moving_) + sizeof(MessageOfProp::is_moving_) - PROTOBUF_FIELD_OFFSET(MessageOfProp, type_)>(
reinterpret_cast<char*>(&type_),
reinterpret_cast<char*>(&other->type_)
);


+ 72
- 0
CAPI/proto/Message2Clients.pb.h View File

@@ -1011,6 +1011,8 @@ namespace protobuf
kYFieldNumber = 3,
kPlaceFieldNumber = 6,
kGuidFieldNumber = 5,
kSizeFieldNumber = 7,
kIsMovingFieldNumber = 8,
};
// .protobuf.PropType type = 1;
void clear_type();
@@ -1071,6 +1073,26 @@ namespace protobuf
int64_t _internal_guid() const;
void _internal_set_guid(int64_t value);

public:
// int32 size = 7;
void clear_size();
int32_t size() const;
void set_size(int32_t value);

private:
int32_t _internal_size() const;
void _internal_set_size(int32_t value);

public:
// bool is_moving = 8;
void clear_is_moving();
bool is_moving() const;
void set_is_moving(bool value);

private:
bool _internal_is_moving() const;
void _internal_set_is_moving(bool value);

public:
// @@protoc_insertion_point(class_scope:protobuf.MessageOfProp)

@@ -1087,6 +1109,8 @@ namespace protobuf
int32_t y_;
int place_;
int64_t guid_;
int32_t size_;
bool is_moving_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_Message2Clients_2eproto;
};
@@ -3534,6 +3558,54 @@ namespace protobuf
// @@protoc_insertion_point(field_set:protobuf.MessageOfProp.place)
}

// int32 size = 7;
inline void MessageOfProp::clear_size()
{
size_ = 0;
}
inline int32_t MessageOfProp::_internal_size() const
{
return size_;
}
inline int32_t MessageOfProp::size() const
{
// @@protoc_insertion_point(field_get:protobuf.MessageOfProp.size)
return _internal_size();
}
inline void MessageOfProp::_internal_set_size(int32_t value)
{
size_ = value;
}
inline void MessageOfProp::set_size(int32_t value)
{
_internal_set_size(value);
// @@protoc_insertion_point(field_set:protobuf.MessageOfProp.size)
}

// bool is_moving = 8;
inline void MessageOfProp::clear_is_moving()
{
is_moving_ = false;
}
inline bool MessageOfProp::_internal_is_moving() const
{
return is_moving_;
}
inline bool MessageOfProp::is_moving() const
{
// @@protoc_insertion_point(field_get:protobuf.MessageOfProp.is_moving)
return _internal_is_moving();
}
inline void MessageOfProp::_internal_set_is_moving(bool value)
{
is_moving_ = value;
}
inline void MessageOfProp::set_is_moving(bool value)
{
_internal_set_is_moving(value);
// @@protoc_insertion_point(field_set:protobuf.MessageOfProp.is_moving)
}

// -------------------------------------------------------------------

// MessageOfPickedProp


+ 2
- 0
dependency/proto/Message2Clients.proto View File

@@ -51,6 +51,8 @@ message MessageOfProp // 可拾取道具的信息
double facing_direction = 4;
int64 guid = 5;
PlaceType place = 6;
int32 size = 7;
bool is_moving = 8;
}

message MessageOfPickedProp //for Unity,直接继承自THUAI5


Loading…
Cancel
Save