addobjectlater ok
This commit is contained in:
parent
4ac5881160
commit
5120480f41
@ -180,6 +180,7 @@ void Room::AddPlayer(Player* hum)
|
|||||||
unsigned short Room::AllocUniid()
|
unsigned short Room::AllocUniid()
|
||||||
{
|
{
|
||||||
while (GetEntityByUniId(++current_uniid) ||
|
while (GetEntityByUniId(++current_uniid) ||
|
||||||
|
later_add_hash_.find(current_uniid) != later_add_hash_.end() ||
|
||||||
current_uniid == 0) {}
|
current_uniid == 0) {}
|
||||||
return current_uniid;
|
return current_uniid;
|
||||||
}
|
}
|
||||||
@ -503,7 +504,6 @@ void Room::RemoveObjectLater(Entity* entity)
|
|||||||
auto remove_func = [] (const a8::XParams& param)
|
auto remove_func = [] (const a8::XParams& param)
|
||||||
{
|
{
|
||||||
Entity* entity = (Entity*)param.sender.GetUserData();
|
Entity* entity = (Entity*)param.sender.GetUserData();
|
||||||
entity->room->uniid_hash_.erase(entity->entity_uniid);
|
|
||||||
switch (entity->entity_type) {
|
switch (entity->entity_type) {
|
||||||
case ET_Bullet:
|
case ET_Bullet:
|
||||||
{
|
{
|
||||||
@ -521,6 +521,7 @@ void Room::RemoveObjectLater(Entity* entity)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
entity->room->uniid_hash_.erase(entity->entity_uniid);
|
||||||
delete entity;
|
delete entity;
|
||||||
};
|
};
|
||||||
xtimer.AddDeadLineTimerAndAttach(0,
|
xtimer.AddDeadLineTimerAndAttach(0,
|
||||||
@ -969,5 +970,19 @@ Obstacle* Room::InternalCreateObstacle(int id, float x, float y,
|
|||||||
|
|
||||||
void Room::AddObjectLater(Entity* entity)
|
void Room::AddObjectLater(Entity* entity)
|
||||||
{
|
{
|
||||||
|
auto add_func = [] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Entity* entity = (Entity*)param.sender.GetUserData();
|
||||||
|
if (entity->entity_type == ET_Bullet) {
|
||||||
|
entity->room->moveable_hash_[entity->entity_uniid] = entity;
|
||||||
|
}
|
||||||
|
entity->room->uniid_hash_[entity->entity_uniid] = entity;
|
||||||
|
entity->room->later_add_hash_.erase(entity->entity_uniid);
|
||||||
|
};
|
||||||
|
later_add_hash_[entity->entity_uniid] = entity;
|
||||||
|
xtimer.AddDeadLineTimerAndAttach(0,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(entity),
|
||||||
|
add_func,
|
||||||
|
&entity->xtimer_attacher.timer_list_);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,6 @@ public:
|
|||||||
void ScatterDrop(Vector2D center, int drop_id);
|
void ScatterDrop(Vector2D center, int drop_id);
|
||||||
void DropItem(Vector2D pos, int item_id, int item_count);
|
void DropItem(Vector2D pos, int item_id, int item_count);
|
||||||
|
|
||||||
Obstacle* CreateObstacle(int id, float x, float y);
|
|
||||||
void CreateLoot(int equip_id, Vector2D pos, int count);
|
void CreateLoot(int equip_id, Vector2D pos, int count);
|
||||||
void CreateBullet(Human* hum, MetaData::Equip* gun_meta,
|
void CreateBullet(Human* hum, MetaData::Equip* gun_meta,
|
||||||
Vector2D pos, Vector2D dir, float fly_distance);
|
Vector2D pos, Vector2D dir, float fly_distance);
|
||||||
@ -95,6 +94,7 @@ private:
|
|||||||
void AirDrop(int appear_time, int box_id);
|
void AirDrop(int appear_time, int box_id);
|
||||||
void ShuaPlane();
|
void ShuaPlane();
|
||||||
int NewTeam();
|
int NewTeam();
|
||||||
|
Obstacle* CreateObstacle(int id, float x, float y);
|
||||||
void CreateThings();
|
void CreateThings();
|
||||||
void CreateBuilding(int thing_id, float building_x, float building_y);
|
void CreateBuilding(int thing_id, float building_x, float building_y);
|
||||||
Obstacle* InternalCreateObstacle(int id, float x, float y,
|
Obstacle* InternalCreateObstacle(int id, float x, float y,
|
||||||
@ -115,5 +115,6 @@ private:
|
|||||||
std::map<std::string, Player*> accountid_hash_;
|
std::map<std::string, Player*> accountid_hash_;
|
||||||
std::map<unsigned short, Entity*> moveable_hash_;
|
std::map<unsigned short, Entity*> moveable_hash_;
|
||||||
std::map<unsigned short, Entity*> uniid_hash_;
|
std::map<unsigned short, Entity*> uniid_hash_;
|
||||||
|
std::map<unsigned short, Entity*> later_add_hash_;
|
||||||
std::map<unsigned short, Human*> human_hash_;
|
std::map<unsigned short, Human*> human_hash_;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user