shot ok
This commit is contained in:
parent
30c2d8255c
commit
d1c2e91058
@ -1,6 +1,7 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
#include "frameevent.h"
|
#include "frameevent.h"
|
||||||
|
#include "human.h"
|
||||||
|
|
||||||
void FrameEvent::AddAirDrop(int appear_time, int box_id, Vector2D box_pos)
|
void FrameEvent::AddAirDrop(int appear_time, int box_id, Vector2D box_pos)
|
||||||
{
|
{
|
||||||
@ -33,27 +34,20 @@ void FrameEvent::AddEmote(Human* hum, int emote_id)
|
|||||||
|
|
||||||
void FrameEvent::AddShot(Human* hum)
|
void FrameEvent::AddShot(Human* hum)
|
||||||
{
|
{
|
||||||
#if 0
|
auto& tuple = a8::FastAppend(shots_);
|
||||||
{
|
std::get<0>(tuple) = hum;
|
||||||
::google::protobuf::RepeatedPtrField<::cs::MFShot>* shots = nullptr;
|
auto& shot = std::get<1>(tuple);
|
||||||
{
|
shot.set_player_id(hum->entity_uniid);
|
||||||
{
|
hum->curr_weapon->ToPB(shot.mutable_weapon());
|
||||||
auto itr = room->frame_data.shots_.find(room->frame_no);
|
shot.set_offhand(true);
|
||||||
if (itr == room->frame_data.shots_.end()) {
|
shot.set_bullskin(10001);
|
||||||
room->frame_data.shots_[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFShot>();
|
|
||||||
itr = room->frame_data.shots_.find(room->frame_no);
|
|
||||||
}
|
|
||||||
shots = &itr->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cs::MFShot* shot = shots->Add();
|
int shot_idx = shots_.size() - 1;
|
||||||
shot->set_player_id(entity_uniid);
|
for (auto& cell : hum->grid_list) {
|
||||||
curr_weapon->ToPB(shot->mutable_weapon());
|
for (auto& hum : cell->human_list) {
|
||||||
shot->set_offhand(true);
|
hum->shots_.push_back(shot_idx);
|
||||||
shot->set_bullskin(10001);
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameEvent::AddBullet()
|
void FrameEvent::AddBullet()
|
||||||
@ -130,8 +124,8 @@ void FrameEvent::Clear()
|
|||||||
if (bullets_.size() > 0) {
|
if (bullets_.size() > 0) {
|
||||||
bullets_.Clear();
|
bullets_.Clear();
|
||||||
}
|
}
|
||||||
if (shots_.size() > 0) {
|
if (!shots_.empty()) {
|
||||||
shots_.Clear();
|
shots_.clear();
|
||||||
}
|
}
|
||||||
if (airdrops_.size() > 0) {
|
if (airdrops_.size() > 0) {
|
||||||
airdrops_.Clear();
|
airdrops_.Clear();
|
||||||
|
@ -20,8 +20,8 @@ private:
|
|||||||
::google::protobuf::RepeatedPtrField<::cs::MFSmoke> smokes_;
|
::google::protobuf::RepeatedPtrField<::cs::MFSmoke> smokes_;
|
||||||
::google::protobuf::RepeatedPtrField<::cs::MFEmote> emotes_;
|
::google::protobuf::RepeatedPtrField<::cs::MFEmote> emotes_;
|
||||||
::google::protobuf::RepeatedPtrField<::cs::MFBullet> bullets_;
|
::google::protobuf::RepeatedPtrField<::cs::MFBullet> bullets_;
|
||||||
::google::protobuf::RepeatedPtrField<::cs::MFShot> shots_;
|
|
||||||
::google::protobuf::RepeatedPtrField<::cs::MFAirDrop> airdrops_;
|
::google::protobuf::RepeatedPtrField<::cs::MFAirDrop> airdrops_;
|
||||||
|
std::vector<std::tuple<Human*, ::cs::MFShot>> shots_;
|
||||||
|
|
||||||
friend class FrameMaker;
|
friend class FrameMaker;
|
||||||
};
|
};
|
||||||
|
@ -6,13 +6,6 @@
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
for (auto& pair : room->frame_data.shots_hash) {
|
|
||||||
if (pair.first <= room->frame_no) {
|
|
||||||
for (auto& itr : pair.second) {
|
|
||||||
*msg->add_shots() = itr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto& pair : room->frame_data.bullets_hash) {
|
for (auto& pair : room->frame_data.bullets_hash) {
|
||||||
if (pair.first <= room->frame_no) {
|
if (pair.first <= room->frame_no) {
|
||||||
for (auto& itr : pair.second) {
|
for (auto& itr : pair.second) {
|
||||||
@ -77,6 +70,14 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
|||||||
hum->part_objects.erase(entity);
|
hum->part_objects.erase(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int shot_idx : hum->shots_) {
|
||||||
|
if (shot_idx < room->frame_event.shots_.size()) {
|
||||||
|
auto& tuple = room->frame_event.shots_[shot_idx];
|
||||||
|
if (hum->CanSee(std::get<0>(tuple))) {
|
||||||
|
*msg->add_shots() = std::get<1>(tuple);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (room->frame_event.airdrops_.size() > 0) {
|
if (room->frame_event.airdrops_.size() > 0) {
|
||||||
*msg->mutable_airdrop() = room->frame_event.airdrops_.Get(0);
|
*msg->mutable_airdrop() = room->frame_event.airdrops_.Get(0);
|
||||||
}
|
}
|
||||||
@ -101,6 +102,9 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
|||||||
if (!hum->del_objects.empty()) {
|
if (!hum->del_objects.empty()) {
|
||||||
hum->del_objects.clear();
|
hum->del_objects.clear();
|
||||||
}
|
}
|
||||||
|
if (!hum->shots_.empty()) {
|
||||||
|
hum->shots_.clear();
|
||||||
|
}
|
||||||
++hum->send_msg_times;
|
++hum->send_msg_times;
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@ -173,6 +173,19 @@ bool GridService::EntityInGridList(Entity* entity, std::set<GridCell*>& grid_lis
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GridService::InView(int a_grid, int b_grid)
|
||||||
|
{
|
||||||
|
return a_grid + grid_offset_arr_[0] == b_grid ||
|
||||||
|
a_grid + grid_offset_arr_[1] == b_grid ||
|
||||||
|
a_grid + grid_offset_arr_[2] == b_grid ||
|
||||||
|
a_grid + grid_offset_arr_[3] == b_grid ||
|
||||||
|
a_grid + grid_offset_arr_[4] == b_grid ||
|
||||||
|
a_grid + grid_offset_arr_[5] == b_grid ||
|
||||||
|
a_grid + grid_offset_arr_[6] == b_grid ||
|
||||||
|
a_grid + grid_offset_arr_[7] == b_grid ||
|
||||||
|
a_grid + grid_offset_arr_[8] == b_grid;
|
||||||
|
}
|
||||||
|
|
||||||
void GridService::GetGridList(int grid_id, int offset,
|
void GridService::GetGridList(int grid_id, int offset,
|
||||||
std::set<GridCell*>& grid_list)
|
std::set<GridCell*>& grid_list)
|
||||||
{
|
{
|
||||||
|
@ -41,6 +41,7 @@ class GridService
|
|||||||
|
|
||||||
bool HumanInGridList(Human* hum, std::set<GridCell*>& grid_list);
|
bool HumanInGridList(Human* hum, std::set<GridCell*>& grid_list);
|
||||||
bool EntityInGridList(Entity* entity, std::set<GridCell*>& grid_list);
|
bool EntityInGridList(Entity* entity, std::set<GridCell*>& grid_list);
|
||||||
|
bool InView(int a_grid, int b_grid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void GetGridList(int grid_id, int offset,
|
inline void GetGridList(int grid_id, int offset,
|
||||||
|
@ -836,3 +836,8 @@ void Human::FillMFGasData(cs::MFGasData* gas_data)
|
|||||||
gas_data->set_rad_old(room->gas_data.rad_old);
|
gas_data->set_rad_old(room->gas_data.rad_old);
|
||||||
gas_data->set_rad_new(room->gas_data.rad_new);
|
gas_data->set_rad_new(room->gas_data.rad_new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Human::CanSee(Human* hum)
|
||||||
|
{
|
||||||
|
return room->grid_service.InView(grid_id, hum->grid_id);
|
||||||
|
}
|
||||||
|
@ -128,14 +128,18 @@ class Human : public Entity
|
|||||||
);
|
);
|
||||||
void FillMFActivePlayerData(cs::MFActivePlayerData* player_data);
|
void FillMFActivePlayerData(cs::MFActivePlayerData* player_data);
|
||||||
void FillMFGasData(cs::MFGasData* gas_data);
|
void FillMFGasData(cs::MFGasData* gas_data);
|
||||||
|
bool CanSee(Human* hum);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
long long last_shot_frameno_ = 0;
|
long long last_shot_frameno_ = 0;
|
||||||
std::set<Entity*> new_objects;
|
std::set<Entity*> new_objects;
|
||||||
std::set<Entity*> part_objects;
|
std::set<Entity*> part_objects;
|
||||||
std::set<int> del_objects;
|
std::set<int> del_objects;
|
||||||
|
std::vector<int> shots_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CircleCollider* self_collider_ = nullptr;
|
CircleCollider* self_collider_ = nullptr;
|
||||||
long long last_sync_gas_frameno = 0;
|
long long last_sync_gas_frameno = 0;
|
||||||
friend class FrameMaker;
|
friend class FrameMaker;
|
||||||
|
friend class FrameEvent;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user