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-11-09 21:45:18 +0000
committerStijn Buys <ingar@osirion.org>2008-11-09 21:45:18 +0000
commita1eb1b4dc4d81df724ee43fc4e895dd22e81760f (patch)
tree5d53a557540147e1e981c5cd3c6be8ccc8448381 /src/game/base/jumppoint.cc
parent568e868ef43cc79ad277ec5ab2c3e08647725131 (diff)
working jumpgates
Diffstat (limited to 'src/game/base/jumppoint.cc')
-rw-r--r--src/game/base/jumppoint.cc84
1 files changed, 81 insertions, 3 deletions
diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc
index da221cf..fcf20d6 100644
--- a/src/game/base/jumppoint.cc
+++ b/src/game/base/jumppoint.cc
@@ -4,13 +4,15 @@
the terms and conditions of the GNU General Public License version 2
*/
-#include "base/base.h"
+#include "base/game.h"
#include "base/jumppoint.h"
-namespace base
+namespace game
{
-JumpPoint::JumpPoint() : core::Entity(core::Entity::Static | core::Entity::Bright)
+/* ---- class JumpPoint -------------------------------------------- */
+
+JumpPoint::JumpPoint() : core::EntityDynamic(core::Entity::Static | core::Entity::Bright)
{
entity_shape = core::Entity::Diamond;
entity_color.assign(0.0f, 0.8f, 0.8f, 1.0f);
@@ -26,4 +28,80 @@ JumpPoint::~JumpPoint()
{
}
+void JumpPoint::set_targetlabel(const std::string &label)
+{
+ jumppoint_targetlabel.assign(label);
+}
+
+void JumpPoint::validate()
+{
+ jumppoint_target = 0;
+
+ if (targetlabel().size() < 3) {
+ con_warn << " Jumppoint with invalid target label '" << targetlabel() << "'\n";
+ return;
+ }
+ size_t pos = targetlabel().find(':');
+ if ((pos < 1 ) || (pos >= (targetlabel().size()-1))) {
+ con_warn << " Jumppoint with invalid target label '" << targetlabel() << "'\n";
+ return;
+ }
+
+ std::string zonelabel(targetlabel().substr(0, pos));
+ std::string entitylabel(targetlabel().substr(pos+1, targetlabel().size()-pos));
+
+ core::Zone *targetzone = core::Zone::find(zonelabel);
+ if (!targetzone) {
+ con_warn << " Jumppoint with invalid target zone '" << zonelabel << "'\n";
+ return;
+ }
+
+ core::Entity *targetentity = targetzone->find_entity(entitylabel);
+ if (!targetentity) {
+ con_warn << " Could not find target jumppoint '" << entitylabel << "'\n";
+ return;
+ }
+
+ if ((targetentity->moduletype() != jumppoint_enttype) && (targetentity->moduletype() != jumpgate_enttype)) {
+ con_warn << " Jumppoint with invalid target jumppoint '" << entitylabel << "'\n";
+ return;
+ }
+
+ jumppoint_target = static_cast<JumpPoint *>(targetentity);
+
+ //con_debug << " Jumppoint " << zone->label() << ":" << label() << " with target " << targetlabel() << std::endl;
+}
+
+/* ---- class JumpGate --------------------------------------------- */
+
+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;
+}
+
+JumpGate::~JumpGate()
+{
+}
+
+void JumpGate::activate()
+{
+ jumpgate_timer = 10.0f;
+ entity_eventstate = core::Entity::Normal;
+}
+
+void JumpGate::frame(float elapsed)
+{
+ if (jumpgate_timer > 0)
+ jumpgate_timer -= elapsed;
+
+ if (jumpgate_timer < 0) {
+ entity_eventstate = core::Entity::NoPower;
+ }
+}
+
}