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/jumppoint.cc
parent82c63c49134a6fca91d908792438e6284dc4cebf (diff)
generic docking API,
race activating requires docking
Diffstat (limited to 'src/game/base/jumppoint.cc')
-rw-r--r--src/game/base/jumppoint.cc54
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;
}
}