mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:37:51 +02:00
Get Cells and vesicles just once, 20 seconds after we start querying (and shut down queries).
This commit is contained in:
parent
abb05bc686
commit
e5c6fcaa70
2 changed files with 20 additions and 10 deletions
|
@ -39,11 +39,13 @@ var THROTTLE = true;
|
||||||
var THROTTLE_RATE = 5000;
|
var THROTTLE_RATE = 5000;
|
||||||
|
|
||||||
var sinceLastUpdate = 0;
|
var sinceLastUpdate = 0;
|
||||||
|
var entitiesToMove = [];
|
||||||
|
|
||||||
//print('cells script')
|
//print('cells script')
|
||||||
|
|
||||||
function findCells() {
|
function findCells() {
|
||||||
var results = Entities.findEntities(basePosition, 60000);
|
var results = Entities.findEntities(basePosition, 60000);
|
||||||
|
Script.clearInterval(octreeQueryInterval); // we don't need it any more
|
||||||
|
|
||||||
if (results.length === 0) {
|
if (results.length === 0) {
|
||||||
// print('no entities found')
|
// print('no entities found')
|
||||||
|
@ -55,9 +57,7 @@ function findCells() {
|
||||||
// print('name is:: ' + name)
|
// print('name is:: ' + name)
|
||||||
if (name === 'Cell') {
|
if (name === 'Cell') {
|
||||||
// print('found a cell!!' + v)
|
// print('found a cell!!' + v)
|
||||||
Script.setTimeout(function() {
|
entitiesToMove.push(v);
|
||||||
moveCell(v);
|
|
||||||
}, Math.random() * THROTTLE_RATE);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,7 @@ function update(deltaTime) {
|
||||||
Entities.setPacketsPerSecond(6000);
|
Entities.setPacketsPerSecond(6000);
|
||||||
print("PPS:" + Entities.getPacketsPerSecond());
|
print("PPS:" + Entities.getPacketsPerSecond());
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
Script.setTimeout(findCells, 20 * 1000); // After 20 seconds of getting entities, look for cells.
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +103,11 @@ function update(deltaTime) {
|
||||||
if (sinceLastUpdate > THROTTLE_RATE) {
|
if (sinceLastUpdate > THROTTLE_RATE) {
|
||||||
// print('SHOULD FIND CELLS!!!')
|
// print('SHOULD FIND CELLS!!!')
|
||||||
sinceLastUpdate = 0;
|
sinceLastUpdate = 0;
|
||||||
findCells();
|
entitiesToMove.forEach(function (v) {
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
moveCell(v);
|
||||||
|
}, Math.random() * THROTTLE_RATE); // don't move all of them every five seconds, but at random times over interval
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// print('returning in update ' + sinceLastUpdate)
|
// print('returning in update ' + sinceLastUpdate)
|
||||||
return;
|
return;
|
||||||
|
@ -116,4 +121,4 @@ function unload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
Script.scriptEnding.connect(unload);
|
Script.scriptEnding.connect(unload);
|
||||||
|
|
|
@ -39,11 +39,13 @@ var THROTTLE = true;
|
||||||
var THROTTLE_RATE = 5000;
|
var THROTTLE_RATE = 5000;
|
||||||
|
|
||||||
var sinceLastUpdate = 0;
|
var sinceLastUpdate = 0;
|
||||||
|
var entitiesToMove = [];
|
||||||
|
|
||||||
//print('vesicle script')
|
//print('vesicle script')
|
||||||
|
|
||||||
function findVesicles() {
|
function findVesicles() {
|
||||||
var results = Entities.findEntities(basePosition, 60000);
|
var results = Entities.findEntities(basePosition, 60000);
|
||||||
|
Script.clearInterval(octreeQueryInterval); // we don't need it any more
|
||||||
|
|
||||||
if (results.length === 0) {
|
if (results.length === 0) {
|
||||||
// print('no entities found');
|
// print('no entities found');
|
||||||
|
@ -54,9 +56,7 @@ function findVesicles() {
|
||||||
var name = Entities.getEntityProperties(v, 'name').name;
|
var name = Entities.getEntityProperties(v, 'name').name;
|
||||||
if (name === 'vesicle') {
|
if (name === 'vesicle') {
|
||||||
//print('found a vesicle!!' + v)
|
//print('found a vesicle!!' + v)
|
||||||
Script.setTimeout(function() {
|
entitiesToMove.push(v);
|
||||||
moveVesicle(v);
|
|
||||||
}, Math.random() * THROTTLE_RATE);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,7 @@ function update(deltaTime) {
|
||||||
Entities.setPacketsPerSecond(6000);
|
Entities.setPacketsPerSecond(6000);
|
||||||
print("PPS:" + Entities.getPacketsPerSecond());
|
print("PPS:" + Entities.getPacketsPerSecond());
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
Script.setTimeout(findVesicles, 20 * 1000); // After 20 seconds of getting entities, look for cells.
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +109,11 @@ function update(deltaTime) {
|
||||||
sinceLastUpdate = sinceLastUpdate + deltaTime * 1000;
|
sinceLastUpdate = sinceLastUpdate + deltaTime * 1000;
|
||||||
if (sinceLastUpdate > THROTTLE_RATE) {
|
if (sinceLastUpdate > THROTTLE_RATE) {
|
||||||
sinceLastUpdate = 0;
|
sinceLastUpdate = 0;
|
||||||
findVesicles();
|
entitiesToMove.forEach(function (v) {
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
moveVesicle(v);
|
||||||
|
}, Math.random() * THROTTLE_RATE); // don't move all of them every five seconds, but at random times over interval
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -121,4 +126,4 @@ function unload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
Script.scriptEnding.connect(unload);
|
Script.scriptEnding.connect(unload);
|
||||||
|
|
Loading…
Reference in a new issue