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/station.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/game/base/station.cc') diff --git a/src/game/base/station.cc b/src/game/base/station.cc index 4efd662..59f51ac 100644 --- a/src/game/base/station.cc +++ b/src/game/base/station.cc @@ -31,5 +31,27 @@ void Station::set_shipdealer(ShipDealer *shipdealer) station_shipdealer = shipdealer; } + +void Station::dock(core::Entity *entity) +{ + if (entity->moduletype() != ship_enttype) + return; + + Ship * ship = static_cast(entity); + + if (math::distance(location(), ship->location()) > radius() + ship->radius()) { + if (ship->owner()) + ship->owner()->send("Target 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()); + } } +} -- cgit v1.2.3