diff options
Diffstat (limited to 'src/game/base/ship.cc')
| -rw-r--r-- | src/game/base/ship.cc | 31 | 
1 files changed, 31 insertions, 0 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index 7edc183..0da57ab 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -82,6 +82,37 @@ void Ship::reset()  	current_target_strafe = 0.0f;  	current_target_afterburner = 0.0f;  } + +// this is called if another shuo wants to dock this ship +void Ship::dock(Entity *entity) +{ +	if (!flag_is_set(core::Entity::Dockable)) +		return; +	 +	if (entity->moduletype() != ship_enttype) +		return; + +	Ship *other_ship = static_cast<Ship *>(entity); + +	if (math::distance(location(), other_ship->location()) > radius() + other_ship->radius()) { +		if (other_ship->owner()) +			other_ship->owner()->send("Target out of range"); +		return; +	} + +	other_ship->get_location().assign(location()); +	other_ship->set_state(core::Entity::Docked); + +	if (other_ship->owner() && other_ship->owner()->control() == other_ship) { +		other_ship->owner()->set_view(this); +		if (owner()) { +			other_ship->owner()->send("^BDocking at " + owner()->name() + "^B's " + name()); +		} else { +			other_ship->owner()->send("^BDocking at " + name()); +		} +	} +} +	  void Ship::func_impulse()  {  	if (entity_state == core::Entity::Impulse) {  | 
