mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 02:03:11 +02:00
stop pouring on release
This commit is contained in:
parent
b9bd4cae93
commit
3dc39600cd
3 changed files with 63 additions and 43 deletions
|
@ -78,7 +78,7 @@
|
||||||
dimensions: _this.STARTING_FLOWER_DIMENSIONS,
|
dimensions: _this.STARTING_FLOWER_DIMENSIONS,
|
||||||
userData: JSON.stringify(_this.flowerUserData)
|
userData: JSON.stringify(_this.flowerUserData)
|
||||||
});
|
});
|
||||||
var xzGrowthRate = randFloat(0.0001, 0.0002);
|
var xzGrowthRate = randFloat(0.00005, 0.00015);
|
||||||
var flower = {
|
var flower = {
|
||||||
id: flowerEntityID,
|
id: flowerEntityID,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
|
@ -128,9 +128,10 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
unload: function() {
|
unload: function() {
|
||||||
_this.flowers.forEach(function(flower) {
|
print("EBL UNLOAD GROWING PLANT SCRIPT");
|
||||||
Entities.deleteEntity(flower.id);
|
// _this.flowers.forEach(function(flower) {
|
||||||
})
|
// Entities.deleteEntity(flower.id);
|
||||||
|
// })
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ var waterCan = Entities.addEntity({
|
||||||
dimensions: {x: 0.1859, y: 0.2762, z: 0.4115},
|
dimensions: {x: 0.1859, y: 0.2762, z: 0.4115},
|
||||||
position: waterCanPosition,
|
position: waterCanPosition,
|
||||||
angularDamping: 1,
|
angularDamping: 1,
|
||||||
damping: 1,
|
|
||||||
dynamic: true,
|
dynamic: true,
|
||||||
|
gravity: { x: 0.0, y: -2.0, z: 0},
|
||||||
rotation: waterCanRotation
|
rotation: waterCanRotation
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -75,10 +75,10 @@ var waterSpout = Entities.addEntity({
|
||||||
});
|
});
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
Entities.deleteEntity(plant);
|
// Entities.deleteEntity(plant);
|
||||||
Entities.deleteEntity(bowl);
|
// Entities.deleteEntity(bowl);
|
||||||
Entities.deleteEntity(waterCan);
|
// Entities.deleteEntity(waterCan);
|
||||||
Entities.deleteEntity(waterSpout);
|
// Entities.deleteEntity(waterSpout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,45 @@
|
||||||
_this.POUR_ANGLE_THRESHOLD = 0;
|
_this.POUR_ANGLE_THRESHOLD = 0;
|
||||||
_this.waterPouring = false;
|
_this.waterPouring = false;
|
||||||
_this.WATER_SPOUT_NAME = "hifi-water-spout";
|
_this.WATER_SPOUT_NAME = "hifi-water-spout";
|
||||||
|
_this.GROWABLE_ENTITIES_SEARCH_RANGE = 100;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WaterSpout.prototype = {
|
WaterSpout.prototype = {
|
||||||
|
|
||||||
|
startNearGrab: function() {
|
||||||
|
_this.startHold();
|
||||||
|
},
|
||||||
|
|
||||||
|
startEquip: function() {
|
||||||
|
_this.startHold();
|
||||||
|
},
|
||||||
|
|
||||||
|
startHold: function() {
|
||||||
|
_this.findGrowableEntities();
|
||||||
|
print("EB: GROWABLE ENTITIES length " + _this.growableEntities.length)
|
||||||
|
},
|
||||||
|
|
||||||
|
releaseEquip: function() {
|
||||||
|
_this.releaseHold();
|
||||||
|
},
|
||||||
|
|
||||||
|
releaseGrab: function() {
|
||||||
|
_this.releaseHold();
|
||||||
|
},
|
||||||
|
|
||||||
|
releaseHold: function() {
|
||||||
|
_this.stopPouring();
|
||||||
|
},
|
||||||
|
|
||||||
|
stopPouring: function() {
|
||||||
|
Entities.editEntity(_this.waterEffect, {
|
||||||
|
isEmitting: false
|
||||||
|
});
|
||||||
|
_this.waterPouring = false;
|
||||||
|
//water no longer pouring...
|
||||||
|
_this.waterInjector.stop();
|
||||||
|
},
|
||||||
continueEquip: function() {
|
continueEquip: function() {
|
||||||
_this.continueHolding();
|
_this.continueHolding();
|
||||||
},
|
},
|
||||||
|
@ -43,16 +78,19 @@
|
||||||
var pitch = Quat.safeEulerAngles(rotation).x;
|
var pitch = Quat.safeEulerAngles(rotation).x;
|
||||||
if (pitch < _this.POUR_ANGLE_THRESHOLD) {
|
if (pitch < _this.POUR_ANGLE_THRESHOLD) {
|
||||||
// Water is pouring
|
// Water is pouring
|
||||||
var spoutProps = Entities.getEntityProperties(_this.waterSpout, ["rotation", "position"]);
|
var spoutProps = Entities.getEntityProperties(_this.waterSpout, ["rotation", "position"]);
|
||||||
if (!_this.waterPouring) {
|
if (!_this.waterPouring) {
|
||||||
Entities.editEntity(_this.waterEffect, {
|
Entities.editEntity(_this.waterEffect, {
|
||||||
isEmitting: true
|
isEmitting: true
|
||||||
});
|
});
|
||||||
_this.waterPouring = true;
|
_this.waterPouring = true;
|
||||||
if (!_this.waterInjector) {
|
if (!_this.waterInjector) {
|
||||||
print ("PLAY SOUND")
|
print("PLAY SOUND")
|
||||||
_this.waterInjector = Audio.playSound(_this.waterSound, {position: spoutProps.position, loop: true});
|
_this.waterInjector = Audio.playSound(_this.waterSound, {
|
||||||
|
position: spoutProps.position,
|
||||||
|
loop: true
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_this.waterInjector.restart();
|
_this.waterInjector.restart();
|
||||||
}
|
}
|
||||||
|
@ -63,23 +101,14 @@
|
||||||
emitOrientation: waterEmitOrientation
|
emitOrientation: waterEmitOrientation
|
||||||
});
|
});
|
||||||
} else if (pitch > _this.POUR_ANGLE_THRESHOLD && _this.waterPouring) {
|
} else if (pitch > _this.POUR_ANGLE_THRESHOLD && _this.waterPouring) {
|
||||||
Entities.editEntity(_this.waterEffect, {
|
_this.stopPouring();
|
||||||
isEmitting: false
|
|
||||||
});
|
|
||||||
_this.waterPouring = false;
|
|
||||||
//water no longer pouring...
|
|
||||||
_this.waterInjector.stop();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
castRay: function() {
|
castRay: function() {
|
||||||
var spoutProps = Entities.getEntityProperties(_this.waterSpout, ["position, rotation"]);
|
var spoutProps = Entities.getEntityProperties(_this.waterSpout, ["position, rotation"]);
|
||||||
var direction = Quat.getFront(spoutProps.rotation)
|
var direction = Quat.getFront(spoutProps.rotation)
|
||||||
var end = Vec3.sum(spoutProps.position, Vec3.multiply(5, direction));
|
var end = Vec3.sum(spoutProps.position, Vec3.multiply(5, direction));
|
||||||
Overlays.editOverlay(_this.rayCastLine, {
|
|
||||||
start: spoutProps.position,
|
|
||||||
end: end
|
|
||||||
});
|
|
||||||
|
|
||||||
var pickRay = {
|
var pickRay = {
|
||||||
origin: spoutProps.position,
|
origin: spoutProps.position,
|
||||||
|
@ -89,7 +118,10 @@
|
||||||
|
|
||||||
if (intersection.intersects) {
|
if (intersection.intersects) {
|
||||||
//We've intersected with a waterable object
|
//We've intersected with a waterable object
|
||||||
var data = JSON.stringify({position: intersection.intersection, surfaceNormal: intersection.surfaceNormal});
|
var data = JSON.stringify({
|
||||||
|
position: intersection.intersection,
|
||||||
|
surfaceNormal: intersection.surfaceNormal
|
||||||
|
});
|
||||||
Entities.callEntityMethod(intersection.entityID, 'continueWatering', [data]);
|
Entities.callEntityMethod(intersection.entityID, 'continueWatering', [data]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,8 +155,8 @@
|
||||||
maxParticles: 20000,
|
maxParticles: 20000,
|
||||||
lifespan: 2,
|
lifespan: 2,
|
||||||
emitRate: 2000,
|
emitRate: 2000,
|
||||||
emitSpeed: .2,
|
emitSpeed: .3,
|
||||||
speedSpread: 0.0,
|
speedSpread: 0.1,
|
||||||
emitDimensions: {
|
emitDimensions: {
|
||||||
x: 0.0,
|
x: 0.0,
|
||||||
y: 0.0,
|
y: 0.0,
|
||||||
|
@ -159,8 +191,8 @@
|
||||||
|
|
||||||
findGrowableEntities: function() {
|
findGrowableEntities: function() {
|
||||||
_this.growableEntities = [];
|
_this.growableEntities = [];
|
||||||
var entities = Entities.findEntities(_this.position, 50);
|
var entities = Entities.findEntities(_this.position, _this.GROWABLE_ENTITIES_SEARCH_RANGE);
|
||||||
entities.forEach( function(entity) {
|
entities.forEach(function(entity) {
|
||||||
var name = Entities.getEntityProperties(entity, "name").name;
|
var name = Entities.getEntityProperties(entity, "name").name;
|
||||||
if (name.length > 0 && name.indexOf("growable") !== -1) {
|
if (name.length > 0 && name.indexOf("growable") !== -1) {
|
||||||
_this.growableEntities.push(entity);
|
_this.growableEntities.push(entity);
|
||||||
|
@ -172,18 +204,6 @@
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
_this.entityID = entityID;
|
_this.entityID = entityID;
|
||||||
_this.position = Entities.getEntityProperties(_this.entityID, "position").position;
|
_this.position = Entities.getEntityProperties(_this.entityID, "position").position;
|
||||||
_this.rayCastLine = Overlays.addOverlay("line3d", {
|
|
||||||
color: {
|
|
||||||
red: 200,
|
|
||||||
green: 10,
|
|
||||||
blue: 200
|
|
||||||
},
|
|
||||||
lineWidth: 2,
|
|
||||||
alpha: 1,
|
|
||||||
visible: true,
|
|
||||||
ignoreRayIntersection: true
|
|
||||||
});
|
|
||||||
_this.findGrowableEntities();
|
|
||||||
// Wait a a bit for spout to spawn for case where preload is initial spawn, then save it
|
// Wait a a bit for spout to spawn for case where preload is initial spawn, then save it
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function() {
|
||||||
var entities = Entities.findEntities(_this.position, 1);
|
var entities = Entities.findEntities(_this.position, 1);
|
||||||
|
@ -206,7 +226,6 @@
|
||||||
|
|
||||||
|
|
||||||
unload: function() {
|
unload: function() {
|
||||||
Overlays.deleteOverlay(_this.rayCastLine);
|
|
||||||
Entities.deleteEntity(_this.waterEffect);
|
Entities.deleteEntity(_this.waterEffect);
|
||||||
if (_this.waterInjector) {
|
if (_this.waterInjector) {
|
||||||
_this.waterInjector.stop();
|
_this.waterInjector.stop();
|
||||||
|
|
Loading…
Reference in a new issue