added waypoint system.
added "break-loop" return val for trigger box componentsbeta.r3js.org
parent
9cfa7da639
commit
81d7bc76c5
|
@ -7,7 +7,8 @@ GameLib.D3.ComponentTriggerBoxBox = function(
|
|||
entitiesToCheck,
|
||||
onInside,
|
||||
onEnter,
|
||||
onLeave
|
||||
onLeave,
|
||||
onSetParent
|
||||
) {
|
||||
this.componentId = componentId || GameLib.D3.Tools.RandomId();
|
||||
this.parentEntity = null;
|
||||
|
@ -19,6 +20,7 @@ GameLib.D3.ComponentTriggerBoxBox = function(
|
|||
this.onInside = onInside || null;
|
||||
this.onEnter = onEnter || null;
|
||||
this.onLeave = onLeave || null;
|
||||
this.onSetParent = onSetParent || null;
|
||||
|
||||
// runtime code
|
||||
this.entitiesInside = [];
|
||||
|
@ -52,23 +54,38 @@ GameLib.D3.ComponentTriggerBoxBox.prototype.onUpdate = function(
|
|||
this.entitiesInside.push(entityToCheck);
|
||||
|
||||
if(this.onEnter) {
|
||||
this.onEnter(parentEntity, entityToCheck);
|
||||
if(this.onEnter(parentEntity, entityToCheck)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(this.onInside) {
|
||||
this.onInside(parentEntity, entityToCheck);
|
||||
if(this.onInside(parentEntity, entityToCheck)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else if(this.entitiesInside.indexOf(entityToCheck) > -1) { // entity WAS inside the trigger
|
||||
this.entitiesInside.splice(this.entitiesInside.indexOf(entityToCheck), 1);
|
||||
|
||||
if(this.onLeave) {
|
||||
this.onLeave(parentEntity, entityToCheck);
|
||||
if(this.onLeave(parentEntity, entityToCheck)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
GameLib.D3.ComponentTriggerBoxBox.prototype.onSetParentEntity = function(
|
||||
parentScene,
|
||||
parentEntity
|
||||
) {
|
||||
if(this.onSetParent) {
|
||||
this.onSetParent(parentScene, parentEntity);
|
||||
}
|
||||
};
|
|
@ -7,7 +7,8 @@ GameLib.D3.ComponentTriggerBoxSphere = function(
|
|||
entitiesToCheck,
|
||||
onInside,
|
||||
onEnter,
|
||||
onLeave
|
||||
onLeave,
|
||||
onSetParent
|
||||
) {
|
||||
this.componentId = componentId || GameLib.D3.Tools.RandomId();
|
||||
this.parentEntity = null;
|
||||
|
@ -19,6 +20,7 @@ GameLib.D3.ComponentTriggerBoxSphere = function(
|
|||
this.onInside = onInside || null;
|
||||
this.onEnter = onEnter || null;
|
||||
this.onLeave = onLeave || null;
|
||||
this.onSetParent = onSetParent || null;
|
||||
|
||||
// runtime code
|
||||
this.entitiesInside = [];
|
||||
|
@ -79,23 +81,38 @@ GameLib.D3.ComponentTriggerBoxSphere.prototype.onUpdate = function(
|
|||
this.entitiesInside.push(entityToCheck);
|
||||
|
||||
if(this.onEnter) {
|
||||
this.onEnter(parentEntity, entityToCheck);
|
||||
if(this.onEnter(parentEntity, entityToCheck)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(this.onInside) {
|
||||
this.onInside(parentEntity, entityToCheck);
|
||||
if(this.onInside(parentEntity, entityToCheck)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else if(this.entitiesInside.indexOf(entityToCheck) > -1) { // entity WAS inside the trigger
|
||||
this.entitiesInside.splice(this.entitiesInside.indexOf(entityToCheck), 1);
|
||||
|
||||
if(this.onLeave) {
|
||||
this.onLeave(parentEntity, entityToCheck);
|
||||
if(this.onLeave(parentEntity, entityToCheck)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
GameLib.D3.ComponentTriggerBoxSphere.prototype.onSetParentEntity = function(
|
||||
parentScene,
|
||||
parentEntity
|
||||
) {
|
||||
if(this.onSetParent) {
|
||||
this.onSetParent(parentScene, parentEntity);
|
||||
}
|
||||
};
|
|
@ -9,7 +9,8 @@ GameLib.D3.ComponentTriggerSphereSphere = function(
|
|||
entitiesToCheck,
|
||||
onInside,
|
||||
onEnter,
|
||||
onLeave
|
||||
onLeave,
|
||||
onSetParent
|
||||
) {
|
||||
this.componentId = componentId || GameLib.D3.Tools.RandomId();
|
||||
this.parentEntity = null;
|
||||
|
@ -22,6 +23,7 @@ GameLib.D3.ComponentTriggerSphereSphere = function(
|
|||
this.onInside = onInside || null;
|
||||
this.onEnter = onEnter || null;
|
||||
this.onLeave = onLeave || null;
|
||||
this.onSetParent = onSetParent || null;
|
||||
|
||||
// runtime code
|
||||
this.entitiesInside = [];
|
||||
|
@ -84,20 +86,35 @@ GameLib.D3.ComponentTriggerSphereSphere.prototype.onUpdate = function(
|
|||
this.entitiesInside.push(entityToCheck);
|
||||
|
||||
if(this.onEnter) {
|
||||
this.onEnter(parentEntity, entityToCheck);
|
||||
if(this.onEnter(parentEntity, entityToCheck)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.onInside) {
|
||||
this.onInside(parentEntity, entityToCheck);
|
||||
if(this.onInside(parentEntity, entityToCheck)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else if(this.entitiesInside.indexOf(entityToCheck) > -1) { // entity WAS inside the trigger
|
||||
this.entitiesInside.splice(this.entitiesInside.indexOf(entityToCheck), 1);
|
||||
|
||||
if(this.onLeave) {
|
||||
this.onLeave(parentEntity, entityToCheck);
|
||||
if(this.onLeave(parentEntity, entityToCheck)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
GameLib.D3.ComponentTriggerSphereSphere.prototype.onSetParentEntity = function(
|
||||
parentScene,
|
||||
parentEntity
|
||||
) {
|
||||
if(this.onSetParent) {
|
||||
this.onSetParent(parentScene, parentEntity);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue