This commit is contained in:
aozhiwei 2024-07-30 11:38:55 +08:00
parent 4d8ea40d07
commit 2abae9c0f3

View File

@ -494,5 +494,24 @@ void Obstacle::SetRotate(float rotate)
void Obstacle::DoTreasureBoxInteraction(Human* sender)
{
if (!IsDead(sender->room)) {
Die(sender->room);
BroadcastFullState(sender->room);
sender->room->xtimer.SetTimeoutEx
(meta->delay_destroy() / FRAME_RATE_MS,
[sender, obj_uniid = GetUniId()] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
Entity* entity = sender->room->GetEntityByUniId(obj_uniid);
if (entity && entity->IsEntityType(ET_Obstacle)) {
Obstacle* ob = (Obstacle*)entity;
if (ob->IsRoomObstacle()) {
sender->room->RemoveObjectLater((RoomObstacle*)entity);
}
}
return;
}
},
&sender->xtimer_attacher);
}
}