修复movement问题
This commit is contained in:
parent
df791a4fd7
commit
7ea450c80c
@ -7,7 +7,13 @@ void MovementComponent::Update(int delta_time)
|
|||||||
{
|
{
|
||||||
if (path_index_ < paths_.size()) {
|
if (path_index_ < paths_.size()) {
|
||||||
MovePathPoint& target_point = paths_[path_index_];
|
MovePathPoint& target_point = paths_[path_index_];
|
||||||
owner->pos = owner->pos + (target_point.pos - owner->pos) * delta_time * move_speed_;
|
if (owner->pos == target_point.pos) {
|
||||||
|
++path_index_;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Vector2D path = target_point.pos - owner->pos;
|
||||||
|
float distance = path.Norm();
|
||||||
|
owner->pos = owner->pos + path.Normalize() * std::min(move_speed_, distance);
|
||||||
if (owner->pos == target_point.pos) {
|
if (owner->pos == target_point.pos) {
|
||||||
++path_index_;
|
++path_index_;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,16 @@ void Room::AddPlayer(Player* hum)
|
|||||||
uniid_hash_[hum->entity_uniid] = hum;
|
uniid_hash_[hum->entity_uniid] = hum;
|
||||||
moveable_hash_[hum->entity_uniid] = hum;
|
moveable_hash_[hum->entity_uniid] = hum;
|
||||||
accountid_hash_[hum->account_id] = hum;
|
accountid_hash_[hum->account_id] = hum;
|
||||||
|
human_hash_[hum->entity_uniid] = hum;
|
||||||
++alive_count_;
|
++alive_count_;
|
||||||
|
for (auto& pair : human_hash_) {
|
||||||
|
if (pair.second != hum) {
|
||||||
|
pair.second->new_players.insert(hum);
|
||||||
|
pair.second->part_players.insert(hum);
|
||||||
|
hum->new_players.insert(pair.second);
|
||||||
|
hum->part_players.insert(pair.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short Room::AllocUniid()
|
unsigned short Room::AllocUniid()
|
||||||
@ -94,7 +103,17 @@ void Room::ShuaAndroid()
|
|||||||
hum->Initialize();
|
hum->Initialize();
|
||||||
uniid_hash_[hum->entity_uniid] = hum;
|
uniid_hash_[hum->entity_uniid] = hum;
|
||||||
moveable_hash_[hum->entity_uniid] = hum;
|
moveable_hash_[hum->entity_uniid] = hum;
|
||||||
|
human_hash_[hum->entity_uniid] = hum;
|
||||||
++alive_count_;
|
++alive_count_;
|
||||||
|
|
||||||
|
for (auto& pair : human_hash_) {
|
||||||
|
if (pair.second != hum) {
|
||||||
|
pair.second->new_players.insert(hum);
|
||||||
|
pair.second->part_players.insert(hum);
|
||||||
|
hum->new_players.insert(pair.second);
|
||||||
|
hum->part_players.insert(pair.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,4 +62,5 @@ private:
|
|||||||
std::map<std::string, Player*> accountid_hash_;
|
std::map<std::string, Player*> accountid_hash_;
|
||||||
std::map<unsigned short, Entity*> uniid_hash_;
|
std::map<unsigned short, Entity*> uniid_hash_;
|
||||||
std::map<unsigned short, Entity*> moveable_hash_;
|
std::map<unsigned short, Entity*> moveable_hash_;
|
||||||
|
std::map<unsigned short, Human*> human_hash_;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user