diff options
Diffstat (limited to 'src/game/base/ship.cc')
-rw-r--r-- | src/game/base/ship.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index a18616e..0bc1b7c 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -38,6 +38,9 @@ Ship::Ship(core::Player *owner, const ShipModel *shipmodel) : core::EntityContro ship_jumpdrive_timer = 0; ship_jumpdepart = 0; + ship_dock = 0; + ship_spawn = 0; + current_impulse = false; // apply ship type settings @@ -289,6 +292,54 @@ void Ship::set_zone(core::Zone *zone) owner()->set_zone(zone); } +void Ship::set_state(int state) +{ + EntityControlable::set_state(state); + + if (state != core::Entity::Docked) + ship_dock = 0; +} +void Ship::set_dock(core::Entity *dock) +{ + if (!dock) + return; + + ship_dock = dock; + get_location().assign(dock->location()); + get_axis().assign(dock->axis()); + set_state(core::Entity::Docked); + + // if the dock is not owned by a player. set it as spawn + const core::Player *owner = (dock->type() == core::Entity::Controlable ? static_cast<core::EntityControlable *>(dock)->owner() : 0 ); + if (!owner) + set_spawn(dock); + reset(); +} + +void Ship::launch() +{ + if (!ship_dock) + return; + + get_axis().assign(ship_dock->axis()); + + if (ship_dock->type() == core::Entity::Globe) + get_location().assign(ship_dock->location() + (ship_dock->axis().forward() * (planet_safe_distance + this->radius() + ship_dock->radius()))); + else + get_location().assign(ship_dock->location() + (ship_dock->axis().forward() * (this->radius() + ship_dock->radius()))); + + set_state(core::Entity::Normal); + + ship_dock = 0; + + reset(); +} + +void Ship::set_spawn(core::Entity *spawn) +{ + ship_spawn = spawn; +} + void Ship::action (btScalar seconds) { //float maxspeed = 0; |