From 4e1d951705204899ee99d7fcedf582b25b86b506 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 28 Dec 2008 12:33:04 +0000 Subject: generic docking API, race activating requires docking --- src/game/base/planet.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/game/base/planet.cc') diff --git a/src/game/base/planet.cc b/src/game/base/planet.cc index 684b9dc..f63552c 100644 --- a/src/game/base/planet.cc +++ b/src/game/base/planet.cc @@ -36,4 +36,27 @@ void Planet::set_shipdealer(ShipDealer *shipdealer) planet_shipdealer = shipdealer; } + +void Planet::dock(core::Entity *entity) +{ + if (entity->moduletype() != ship_enttype) + return; + + Ship * ship = static_cast(entity); + + if (math::distance(location(), ship->location()) > radius() + ship->radius() + 50.0f ) { + if (ship->owner()) + ship->owner()->send("Planet out of range"); + return; + } + + ship->location().assign(entity->location()); + ship->set_eventstate(core::Entity::Docked); + + if (ship->owner() && ship->owner()->control() == ship) { + ship->owner()->set_view(this); + ship->owner()->send("^BDocking at " + entity->name()); + } +} + } // namespace game -- cgit v1.2.3