mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 07:57:30 +02:00
handle stopping handshake part-way through
This commit is contained in:
parent
beb848373b
commit
e2e7573e93
1 changed files with 28 additions and 1 deletions
|
@ -38,6 +38,7 @@ var entity;
|
||||||
var makingFriends = false; // really just for visualizations for now
|
var makingFriends = false; // really just for visualizations for now
|
||||||
var animHandlerId;
|
var animHandlerId;
|
||||||
var entityDimensionMultiplier = 1.0;
|
var entityDimensionMultiplier = 1.0;
|
||||||
|
var friendingId;
|
||||||
|
|
||||||
function debug() {
|
function debug() {
|
||||||
var stateString = "<" + STATE_STRINGS[state] + ">";
|
var stateString = "<" + STATE_STRINGS[state] + ">";
|
||||||
|
@ -155,9 +156,10 @@ function startHandshake(fromKeyboard) {
|
||||||
}
|
}
|
||||||
debug("starting handshake for", currentHand);
|
debug("starting handshake for", currentHand);
|
||||||
state = STATES.waiting;
|
state = STATES.waiting;
|
||||||
|
friendingId = undefined;
|
||||||
|
entityDimensionMultiplier = 1.0;
|
||||||
waitingInterval = Script.setInterval(
|
waitingInterval = Script.setInterval(
|
||||||
function () {
|
function () {
|
||||||
debug("currentHand", handToString(currentHand));
|
|
||||||
messageSend({
|
messageSend({
|
||||||
key: "waiting",
|
key: "waiting",
|
||||||
hand: handToString(currentHand)
|
hand: handToString(currentHand)
|
||||||
|
@ -174,6 +176,10 @@ function endHandshake() {
|
||||||
}
|
}
|
||||||
if (friendingInterval) {
|
if (friendingInterval) {
|
||||||
friendingInterval = Script.clearInterval(friendingInterval);
|
friendingInterval = Script.clearInterval(friendingInterval);
|
||||||
|
// send done to let friend know you are not making friends now
|
||||||
|
messageSend({
|
||||||
|
key: "done"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (animHandlerId) {
|
if (animHandlerId) {
|
||||||
debug("removing animation");
|
debug("removing animation");
|
||||||
|
@ -224,6 +230,11 @@ function isNearby(id, hand) {
|
||||||
function makeFriends(id) {
|
function makeFriends(id) {
|
||||||
// temp code to just flash the visualization really (for now!)
|
// temp code to just flash the visualization really (for now!)
|
||||||
makingFriends = true;
|
makingFriends = true;
|
||||||
|
// send done to let the friend know you have made friends.
|
||||||
|
messageSend({
|
||||||
|
key: "done",
|
||||||
|
friendId: id
|
||||||
|
});
|
||||||
Controller.triggerHapticPulse(FRIENDING_SUCCESS_HAPTIC_STRENGTH, HAPTIC_DURATION, handToHaptic(currentHand));
|
Controller.triggerHapticPulse(FRIENDING_SUCCESS_HAPTIC_STRENGTH, HAPTIC_DURATION, handToHaptic(currentHand));
|
||||||
Script.setTimeout(function () { makingFriends = false; entityDimensionMultiplier = 1.0; }, 1000);
|
Script.setTimeout(function () { makingFriends = false; entityDimensionMultiplier = 1.0; }, 1000);
|
||||||
}
|
}
|
||||||
|
@ -234,6 +245,7 @@ function makeFriends(id) {
|
||||||
function startFriending(id, hand) {
|
function startFriending(id, hand) {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
debug("friending", id, "hand", hand);
|
debug("friending", id, "hand", hand);
|
||||||
|
friendingId = id;
|
||||||
state = STATES.friending;
|
state = STATES.friending;
|
||||||
Controller.triggerHapticPulse(FRIENDING_HAPTIC_STRENGTH, HAPTIC_DURATION, handToHaptic(currentHand));
|
Controller.triggerHapticPulse(FRIENDING_HAPTIC_STRENGTH, HAPTIC_DURATION, handToHaptic(currentHand));
|
||||||
if (waitingInterval) {
|
if (waitingInterval) {
|
||||||
|
@ -318,6 +330,21 @@ function messageHandler(channel, messageString, senderID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "done":
|
||||||
|
if (state == STATES.friending && friendingId == senderID) {
|
||||||
|
// if they are done, and didn't friend us, terminate our
|
||||||
|
// friending
|
||||||
|
if (message.friendId !== friendingId) {
|
||||||
|
if (friendingInterval) {
|
||||||
|
friendingInterval = Script.clearInterval(friendingInterval);
|
||||||
|
}
|
||||||
|
// now just call startHandshake. Should be ok to do so without a
|
||||||
|
// value for isKeyboard, as we should not change the animation
|
||||||
|
// state anyways (if any)
|
||||||
|
startHandshake();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
debug("unknown message", message);
|
debug("unknown message", message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue