diff options
Diffstat (limited to 'src/game/base/jumppoint.cc')
-rw-r--r-- | src/game/base/jumppoint.cc | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc index fcf20d6..e943c24 100644 --- a/src/game/base/jumppoint.cc +++ b/src/game/base/jumppoint.cc @@ -12,7 +12,7 @@ namespace game /* ---- class JumpPoint -------------------------------------------- */ -JumpPoint::JumpPoint() : core::EntityDynamic(core::Entity::Static | core::Entity::Bright) +JumpPoint::JumpPoint() : core::EntityDynamic(core::Entity::Bright) { entity_shape = core::Entity::Diamond; entity_color.assign(0.0f, 0.8f, 0.8f, 1.0f); @@ -68,7 +68,7 @@ void JumpPoint::validate() } jumppoint_target = static_cast<JumpPoint *>(targetentity); - + //con_debug << " Jumppoint " << zone->label() << ":" << label() << " with target " << targetlabel() << std::endl; } @@ -79,8 +79,6 @@ JumpGate::JumpGate() : JumpPoint() unset_flag(core::Entity::Bright); entity_radius = 1.0f; entity_moduletypeid = jumpgate_enttype; - set_flag(core::Entity::Dockable); - entity_eventstate = core::Entity::NoPower; } @@ -88,6 +86,53 @@ JumpGate::~JumpGate() { } +void JumpGate::validate() +{ + JumpPoint::validate(); + if (target()) { + set_flag(core::Entity::Dockable); + } else { + unset_flag(core::Entity::Dockable); + } +} + +void JumpGate::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()) { + if (ship->owner()) + ship->owner()->send("Jumpgate out of range"); + return; + } + + con_debug << name() << " received docking request from " << entity->name() << std::endl; + if (target()) { + if (activated()) { + if (ship->owner()) + ship->owner()->send("Jumpgate in use"); + return; + } + + ship->initiate_jump(this); + activate(); + if (target()->moduletype() == jumpgate_enttype) { + static_cast<JumpGate *>(target())->activate(); + } + + if (ship->owner() && ship->owner()->control() == ship) { + ship->owner()->set_view(this); + } + } else { + if (ship->owner()) + ship->owner()->send("Jumpgate inactive"); + return; + } +} + void JumpGate::activate() { jumpgate_timer = 10.0f; @@ -101,6 +146,7 @@ void JumpGate::frame(float elapsed) if (jumpgate_timer < 0) { entity_eventstate = core::Entity::NoPower; + jumpgate_timer = 0; } } |