--- a/src/Rope.cc Sun Dec 07 00:46:04 2008 +0000
+++ b/src/Rope.cc Sun Dec 07 01:18:59 2008 +0000
@@ -31,6 +31,9 @@
// enable the physics object
enable();
+
+ // inform network
+ player.handleRopeState(state);
}
void Rope::onCollision() {
@@ -42,6 +45,9 @@
// set player's pivot
player.setPivot(this);
+
+ // inform network
+ player.handleRopeState(state);
}
void Rope::release (void) {
@@ -54,18 +60,58 @@
// player doesn't have a pivot anymore
player.setPivot(NULL);
+
+ // inform network
+ player.handleRopeState(state);
}
void Rope::changeLength (float delta) {
+ // change length
length += delta;
-
+
+ // minimum length
if (length < 0)
length = 0;
+
+ // inform network
+ player.handleRopeLength(length);
}
RopeState Rope::getState (void) {
return state;
}
+
+float Rope::getLength (void) {
+ return length;
+}
+
+void Rope::updateState (RopeState new_state, Vector position, Vector velocity, float new_length) {
+ // update physics enabled/disabled state
+ if (new_state == ROPE_FOLDED || new_state == ROPE_FIXED)
+ disable();
+
+ else // new_state == ROPE_FLYING
+ enable();
+
+ // update player.pivot
+ if (new_state == ROPE_FIXED)
+ player.setPivot(this);
+
+ else if (this->state == ROPE_FIXED)
+ player.setPivot(NULL);
+
+ // update position stuff
+ updatePhysics(position, velocity, true, false, 0);
+
+ // update vars
+ this->state = new_state;
+ this->length = new_length;
+}
+
+void Rope::updateLength (float length) {
+ // update length
+ this->length = length;
+}
float Rope::getPivotForce (PhysicsObject *bob) {
if ((position - player.getPosition()).length() >= length)