Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-12-28 12:33:04 +0000
committerStijn Buys <ingar@osirion.org>2008-12-28 12:33:04 +0000
commit4e1d951705204899ee99d7fcedf582b25b86b506 (patch)
tree03cb919ff062368dfc334b9f71b932cf89e31517 /src/game/base/planet.cc
parent82c63c49134a6fca91d908792438e6284dc4cebf (diff)
generic docking API,
race activating requires docking
Diffstat (limited to 'src/game/base/planet.cc')
-rw-r--r--src/game/base/planet.cc23
1 files changed, 23 insertions, 0 deletions
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<Ship *>(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