This commit is contained in:
aozhiwei 2021-03-17 11:03:44 +08:00
parent 0050b02e81
commit ea40d7cc83
8 changed files with 19 additions and 7 deletions

View File

@ -16,7 +16,6 @@ class Car : public MoveableEntity
{ {
public: public:
int car_uniid = 0; int car_uniid = 0;
a8::Vec2 move_dir;
MetaData::Equip* meta = nullptr; MetaData::Equip* meta = nullptr;
Car(); Car();

View File

@ -29,7 +29,7 @@ void Hero::FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data)
cs::MFHeroPart* p = part_data->mutable_union_obj_10(); cs::MFHeroPart* p = part_data->mutable_union_obj_10();
p->set_obj_uniid(GetEntityUniId()); p->set_obj_uniid(GetEntityUniId());
TypeConvert::ToPb(GetPos(), p->mutable_pos()); TypeConvert::ToPb(GetPos(), p->mutable_pos());
//TypeConvert::ToPb(move_dir, p->mutable_dir()); TypeConvert::ToPb(move_dir, p->mutable_dir());
} }
void Hero::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) void Hero::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data)
@ -38,5 +38,12 @@ void Hero::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data)
cs::MFHeroFull* p = full_data->mutable_union_obj_10(); cs::MFHeroFull* p = full_data->mutable_union_obj_10();
p->set_obj_uniid(GetEntityUniId()); p->set_obj_uniid(GetEntityUniId());
TypeConvert::ToPb(GetPos(), p->mutable_pos()); TypeConvert::ToPb(GetPos(), p->mutable_pos());
//TypeConvert::ToPb(move_dir, p->mutable_dir()); TypeConvert::ToPb(move_dir, p->mutable_dir());
p->set_heroid(meta->i->id());
p->set_master_uniid(master ? master->GetEntityUniId() : 0);
}
void Hero::Update(int delta_time)
{
++updated_times_;
} }

View File

@ -23,6 +23,7 @@ class Hero : public MoveableEntity
virtual void FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data) override; virtual void FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data) override;
virtual void FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) override; virtual void FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) override;
virtual void Update(int delta_time) override;
private: private:
bool later_removed_ = false; bool later_removed_ = false;

View File

@ -54,7 +54,6 @@ class Human : public MoveableEntity
HumanAbility ability; HumanAbility ability;
long long last_shot_frameno_ = 0; long long last_shot_frameno_ = 0;
a8::Vec2 move_dir;
a8::Vec2 attack_dir; a8::Vec2 attack_dir;
std::function<void ()> on_loading_bullet; std::function<void ()> on_loading_bullet;
std::function<bool ()> on_move_collision; std::function<bool ()> on_move_collision;

View File

@ -6,6 +6,8 @@
class MoveableEntity : public RoomEntity class MoveableEntity : public RoomEntity
{ {
public: public:
a8::Vec2 move_dir;
virtual void Update(int delta_time) {}; virtual void Update(int delta_time) {};
int UpdatedTimes() { return updated_times_;} int UpdatedTimes() { return updated_times_;}
std::set<GridCell*>& GetGridList() { return grid_list_; } std::set<GridCell*>& GetGridList() { return grid_list_; }

View File

@ -572,12 +572,15 @@ Car* Room::CreateCar(Human* driver,
Hero* Room::CreateHero(Entity* master, Hero* Room::CreateHero(Entity* master,
MetaData::Player* meta, MetaData::Player* meta,
const a8::Vec2& pos) const a8::Vec2& pos,
const a8::Vec2& dir)
{ {
Hero* hero = EntityFactory::Instance()->MakeHero(AllocUniid()); Hero* hero = EntityFactory::Instance()->MakeHero(AllocUniid());
hero->meta = meta; hero->meta = meta;
hero->master = master;
hero->room = this; hero->room = this;
hero->SetPos(pos); hero->SetPos(pos);
hero->move_dir = dir;
hero->Initialize(); hero->Initialize();
AddToEntityHash(hero); AddToEntityHash(hero);
grid_service->AddHero(hero); grid_service->AddHero(hero);

View File

@ -116,7 +116,8 @@ public:
const a8::Vec2& pos); const a8::Vec2& pos);
Hero* CreateHero(Entity* master, Hero* CreateHero(Entity* master,
MetaData::Player* meta, MetaData::Player* meta,
const a8::Vec2& pos); const a8::Vec2& pos,
const a8::Vec2& dir);
void OnHumanDie(Human* hum); void OnHumanDie(Human* hum);
void OnHumanRevive(Human* hum); void OnHumanRevive(Human* hum);

View File

@ -385,7 +385,7 @@ message MFHeroFull
optional MFVec2 pos = 2; // optional MFVec2 pos = 2; //
optional MFVec2 dir = 3; // optional MFVec2 dir = 3; //
optional int32 heroid = 4; //id optional int32 heroid = 4; //id
optional int32 masert_uniid = 5; //id optional int32 master_uniid = 5; //id
} }
//- //-