| 1563 | } |
| 1564 | |
| 1565 | void GameState::logEvent(GameEvent *ev) |
| 1566 | { |
| 1567 | if (messages.size() == MAX_MESSAGES) |
| 1568 | { |
| 1569 | messages.pop_front(); |
| 1570 | } |
| 1571 | Vec3<int> location = EventMessage::NO_LOCATION; |
| 1572 | if (GameVehicleEvent *gve = dynamic_cast<GameVehicleEvent *>(ev)) |
| 1573 | { |
| 1574 | location = gve->vehicle->position; |
| 1575 | } |
| 1576 | else if (GameBuildingEvent *gve = dynamic_cast<GameBuildingEvent *>(ev)) |
| 1577 | { |
| 1578 | location = {gve->building->bounds.p0.x, gve->building->bounds.p0.y, 1}; |
| 1579 | } |
| 1580 | else if (GameAgentEvent *gae = dynamic_cast<GameAgentEvent *>(ev)) |
| 1581 | { |
| 1582 | if (gae->agent->unit) |
| 1583 | { |
| 1584 | location = gae->agent->unit->position; |
| 1585 | } |
| 1586 | else |
| 1587 | { |
| 1588 | location = gae->agent->position; |
| 1589 | } |
| 1590 | } |
| 1591 | else if (GameBaseEvent *gbe = dynamic_cast<GameBaseEvent *>(ev)) |
| 1592 | { |
| 1593 | location = |
| 1594 | Vec3<int>(gbe->base->building->bounds.p0.x + gbe->base->building->bounds.p1.x, |
| 1595 | gbe->base->building->bounds.p0.y + gbe->base->building->bounds.p1.y, 1) / |
| 1596 | 2; |
| 1597 | } |
| 1598 | // TODO: Other event types |
| 1599 | messages.emplace_back(EventMessage{gameTime, ev->message(), location}); |
| 1600 | } |
| 1601 | |
| 1602 | uint64_t getNextObjectID(GameState &state, const UString &objectPrefix) |
| 1603 | { |
no test coverage detected