keep track of fired engines
parent
6d062c3137
commit
f65caa3ae6
|
@ -132,6 +132,7 @@ GameLib.Event.GET_RENDER_CONFIGURATION = 0x72;
|
||||||
GameLib.Event.SET_ACTIVE_RENDER_CONFIGURATION = 0x73;
|
GameLib.Event.SET_ACTIVE_RENDER_CONFIGURATION = 0x73;
|
||||||
GameLib.Event.REPLACE_COMPONENT = 0x74;
|
GameLib.Event.REPLACE_COMPONENT = 0x74;
|
||||||
GameLib.Event.COMPONENT_REPLACED = 0x75;
|
GameLib.Event.COMPONENT_REPLACED = 0x75;
|
||||||
|
GameLib.Event.ENGINE_FIRED_PARTICLES_ZERO = 0x76;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns string name of event ID
|
* Returns string name of event ID
|
||||||
|
@ -259,6 +260,7 @@ GameLib.Event.GetEventName = function(number) {
|
||||||
case 0x73 : return 'set_active_render_configuration';
|
case 0x73 : return 'set_active_render_configuration';
|
||||||
case 0x74 : return 'replace_component';
|
case 0x74 : return 'replace_component';
|
||||||
case 0x75 : return 'component_replaced';
|
case 0x75 : return 'component_replaced';
|
||||||
|
case 0x76 : return 'engine_fired_particles_zero';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ GameLib.Utils.LoadIdsFromObjectToIdObject = function(object, idToObject) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets random int exclusive of maximum
|
* Gets random int exclusive of maximum but inclusive of minimum
|
||||||
* @param min
|
* @param min
|
||||||
* @param max
|
* @param max
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
|
@ -253,7 +253,7 @@ GameLib.Utils.GetRandomInt = function(min, max) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets random int inclusive of maximum
|
* Gets random int inclusive of minimum and maximum
|
||||||
* @param min
|
* @param min
|
||||||
* @param max
|
* @param max
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
* @param elapsed
|
* @param elapsed
|
||||||
* @param camera
|
* @param camera
|
||||||
* @param pulse
|
* @param pulse
|
||||||
|
* @param fired
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +27,7 @@ GameLib.D3.API.ParticleEngine = function(
|
||||||
elapsed,
|
elapsed,
|
||||||
camera,
|
camera,
|
||||||
pulse,
|
pulse,
|
||||||
|
fired,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -84,6 +86,11 @@ GameLib.D3.API.ParticleEngine = function(
|
||||||
}
|
}
|
||||||
this.pulse = pulse;
|
this.pulse = pulse;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(fired)) {
|
||||||
|
fired = false;
|
||||||
|
}
|
||||||
|
this.fired = fired;
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
GameLib.API.Component.call(
|
||||||
this,
|
this,
|
||||||
GameLib.Component.PARTICLE_ENGINE,
|
GameLib.Component.PARTICLE_ENGINE,
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
* @param opacityType
|
* @param opacityType
|
||||||
* @param fadeInFactor
|
* @param fadeInFactor
|
||||||
* @param fadeOutFactor
|
* @param fadeOutFactor
|
||||||
|
* @param fadeInAfter
|
||||||
|
* @param fadeOutAfter
|
||||||
* @param positionOffsetType
|
* @param positionOffsetType
|
||||||
* @param positionOffset
|
* @param positionOffset
|
||||||
* @param positionOffsetFn
|
* @param positionOffsetFn
|
||||||
|
@ -35,6 +37,8 @@ GameLib.D3.API.Particle = function(
|
||||||
opacityType,
|
opacityType,
|
||||||
fadeInFactor,
|
fadeInFactor,
|
||||||
fadeOutFactor,
|
fadeOutFactor,
|
||||||
|
fadeInAfter,
|
||||||
|
fadeOutAfter,
|
||||||
positionOffsetType,
|
positionOffsetType,
|
||||||
positionOffset,
|
positionOffset,
|
||||||
positionOffsetFn,
|
positionOffsetFn,
|
||||||
|
@ -93,6 +97,16 @@ GameLib.D3.API.Particle = function(
|
||||||
}
|
}
|
||||||
this.fadeOutFactor = fadeOutFactor;
|
this.fadeOutFactor = fadeOutFactor;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(fadeInAfter)) {
|
||||||
|
fadeInAfter = 0;
|
||||||
|
}
|
||||||
|
this.fadeInAfter = fadeInAfter;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(fadeOutAfter)) {
|
||||||
|
fadeOutAfter = 0;
|
||||||
|
}
|
||||||
|
this.fadeOutAfter = fadeOutAfter;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(positionOffsetType)) {
|
if (GameLib.Utils.UndefinedOrNull(positionOffsetType)) {
|
||||||
positionOffsetType = GameLib.D3.API.Particle.POSITION_OFFSET_TYPE_CONSTANT;
|
positionOffsetType = GameLib.D3.API.Particle.POSITION_OFFSET_TYPE_CONSTANT;
|
||||||
}
|
}
|
||||||
|
@ -209,49 +223,7 @@ GameLib.D3.API.Particle.SPEED_TYPE_ONE_OVER_EXP = 0x7;
|
||||||
|
|
||||||
GameLib.D3.API.Particle.ROTATION_TYPE_CONSTANT = 0x1;
|
GameLib.D3.API.Particle.ROTATION_TYPE_CONSTANT = 0x1;
|
||||||
GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM = 0x2;
|
GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM = 0x2;
|
||||||
GameLib.D3.API.Particle.ROTATION_TYPE_FUNCTION = 0x3;
|
GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM_X = 0x3;
|
||||||
|
GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM_Y = 0x4;
|
||||||
/**
|
GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM_Z = 0x5;
|
||||||
* Creates an API Particle from an Object Particle
|
GameLib.D3.API.Particle.ROTATION_TYPE_FUNCTION = 0x6;
|
||||||
* @param objectParticle
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Particle.FromObject = function(objectParticle) {
|
|
||||||
|
|
||||||
var apiMesh = null;
|
|
||||||
if (objectParticle.mesh) {
|
|
||||||
if (objectParticle.mesh instanceof Object) {
|
|
||||||
apiMesh = GameLib.D3.API.Mesh.FromObject(objectParticle.mesh);
|
|
||||||
} else {
|
|
||||||
apiMesh = objectParticle.mesh;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new GameLib.D3.API.Particle(
|
|
||||||
objectParticle.id,
|
|
||||||
objectParticle.name,
|
|
||||||
objectParticle.lifeTime,
|
|
||||||
objectParticle.elapsed,
|
|
||||||
apiMesh,
|
|
||||||
objectParticle.opacityType,
|
|
||||||
objectParticle.fadeInFactor,
|
|
||||||
objectParticle.fadeOutFactor,
|
|
||||||
objectParticle.positionOffsetType,
|
|
||||||
GameLib.API.Vector3.FromObject(objectParticle.positionOffset),
|
|
||||||
objectParticle.positionOffsetFn,
|
|
||||||
objectParticle.directionType,
|
|
||||||
GameLib.API.Vector3.FromObject(objectParticle.direction),
|
|
||||||
objectParticle.directionFn,
|
|
||||||
objectParticle.speedType,
|
|
||||||
objectParticle.speed,
|
|
||||||
objectParticle.scaleType,
|
|
||||||
GameLib.API.Vector3.FromObject(objectParticle.scale),
|
|
||||||
objectParticle.scaleFn,
|
|
||||||
objectParticle.rotationType,
|
|
||||||
GameLib.API.Vector3.FromObject(objectParticle.rotation),
|
|
||||||
objectParticle.rotationFn,
|
|
||||||
objectParticle.parentParticleEngine,
|
|
||||||
objectParticle.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ GameLib.D3.ParticleEngine = function(
|
||||||
apiParticleEngine.elapsed,
|
apiParticleEngine.elapsed,
|
||||||
apiParticleEngine.camera,
|
apiParticleEngine.camera,
|
||||||
apiParticleEngine.pulse,
|
apiParticleEngine.pulse,
|
||||||
|
apiParticleEngine.fired,
|
||||||
apiParticleEngine.parentEntity
|
apiParticleEngine.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -51,6 +52,8 @@ GameLib.D3.ParticleEngine = function(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.elapsed = 0;
|
||||||
|
|
||||||
this.particles = [];
|
this.particles = [];
|
||||||
|
|
||||||
this.disabledForRemoval = false;
|
this.disabledForRemoval = false;
|
||||||
|
@ -262,25 +265,8 @@ GameLib.D3.ParticleEngine.prototype.toApiObject = function() {
|
||||||
this.elapsed,
|
this.elapsed,
|
||||||
GameLib.Utils.IdOrNull(this.camera),
|
GameLib.Utils.IdOrNull(this.camera),
|
||||||
this.pulse,
|
this.pulse,
|
||||||
|
this.fired,
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts from an Object ParticleEngine to a GameLib.D3.ParticleEngine
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param objectParticleEngine Object
|
|
||||||
* @returns {GameLib.D3.ParticleEngine}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.ParticleEngine.FromObject = function(graphics, objectParticleEngine) {
|
|
||||||
|
|
||||||
var apiParticleEngine = GameLib.D3.API.ParticleEngine.FromObject(objectParticleEngine);
|
|
||||||
|
|
||||||
return new GameLib.D3.ParticleEngine(
|
|
||||||
graphics,
|
|
||||||
apiParticleEngine
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ GameLib.D3.Particle = function(
|
||||||
apiParticle.opacityType,
|
apiParticle.opacityType,
|
||||||
apiParticle.fadeInFactor,
|
apiParticle.fadeInFactor,
|
||||||
apiParticle.fadeOutFactor,
|
apiParticle.fadeOutFactor,
|
||||||
|
apiParticle.fadeInAfter,
|
||||||
|
apiParticle.fadeOutAfter,
|
||||||
apiParticle.positionOffsetType,
|
apiParticle.positionOffsetType,
|
||||||
apiParticle.positionOffset,
|
apiParticle.positionOffset,
|
||||||
apiParticle.positionOffsetFn,
|
apiParticle.positionOffsetFn,
|
||||||
|
@ -108,6 +110,13 @@ GameLib.D3.Particle.prototype.createInstance = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Particle.prototype.updateInstance = function(property) {
|
GameLib.D3.Particle.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
|
if (!this.instance) {
|
||||||
|
this.createInstance();
|
||||||
|
if (!this.instance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (property === 'positionOffset') {
|
if (property === 'positionOffset') {
|
||||||
this.positionOffset.instance.x = this.positionOffset.x;
|
this.positionOffset.instance.x = this.positionOffset.x;
|
||||||
this.positionOffset.instance.y = this.positionOffset.y;
|
this.positionOffset.instance.y = this.positionOffset.y;
|
||||||
|
@ -322,6 +331,8 @@ GameLib.D3.Particle.prototype.toApiObject = function() {
|
||||||
this.opacityType,
|
this.opacityType,
|
||||||
this.fadeInFactor,
|
this.fadeInFactor,
|
||||||
this.fadeOutFactor,
|
this.fadeOutFactor,
|
||||||
|
this.fadeInAfter,
|
||||||
|
this.fadeOutAfter,
|
||||||
this.positionOffsetType,
|
this.positionOffsetType,
|
||||||
this.positionOffset.toApiObject(),
|
this.positionOffset.toApiObject(),
|
||||||
this.positionOffsetFn,
|
this.positionOffsetFn,
|
||||||
|
@ -341,21 +352,3 @@ GameLib.D3.Particle.prototype.toApiObject = function() {
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts from an Object Particle to a GameLib.D3.Particle
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param objectParticle Object
|
|
||||||
* @returns {GameLib.D3.Particle}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Particle.FromObject = function(graphics, objectParticle) {
|
|
||||||
|
|
||||||
var apiParticle = GameLib.D3.API.Particle.FromObject(objectParticle);
|
|
||||||
|
|
||||||
return new GameLib.D3.Particle(
|
|
||||||
graphics,
|
|
||||||
apiParticle
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
|
@ -1125,6 +1125,9 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
{
|
{
|
||||||
'constant': GameLib.D3.API.Particle.ROTATION_TYPE_CONSTANT,
|
'constant': GameLib.D3.API.Particle.ROTATION_TYPE_CONSTANT,
|
||||||
'random': GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM,
|
'random': GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM,
|
||||||
|
'random - x': GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM_X,
|
||||||
|
'random - y': GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM_Y,
|
||||||
|
'random - z': GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM_Z,
|
||||||
'function': GameLib.D3.API.Particle.ROTATION_TYPE_FUNCTION
|
'function': GameLib.D3.API.Particle.ROTATION_TYPE_FUNCTION
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -131,7 +131,9 @@ GameLib.System.Particle.prototype.beforeRender = function(data) {
|
||||||
GameLib.Utils.UndefinedOrNull(particleEngine.templateParticle) ||
|
GameLib.Utils.UndefinedOrNull(particleEngine.templateParticle) ||
|
||||||
GameLib.Utils.UndefinedOrNull(particleEngine.templateParticle.mesh) ||
|
GameLib.Utils.UndefinedOrNull(particleEngine.templateParticle.mesh) ||
|
||||||
GameLib.Utils.UndefinedOrNull(particleEngine.templateParticle.mesh.parentScene) ||
|
GameLib.Utils.UndefinedOrNull(particleEngine.templateParticle.mesh.parentScene) ||
|
||||||
GameLib.Utils.UndefinedOrNull(particleEngine.templateParticle.mesh.parentScene.instance)) {
|
GameLib.Utils.UndefinedOrNull(particleEngine.templateParticle.mesh.parentScene.instance) ||
|
||||||
|
!particleEngine.enabled
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,20 +204,28 @@ GameLib.System.Particle.prototype.beforeRender = function(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (particleEngine.templateParticle.opacityType === GameLib.D3.API.Particle.OPACITY_TYPE_FADE_IN_LINEAR) {
|
if (particleEngine.templateParticle.opacityType === GameLib.D3.API.Particle.OPACITY_TYPE_FADE_IN_LINEAR) {
|
||||||
|
if (particle.userData.elapsed > particleEngine.templateParticle.fadeInAfter) {
|
||||||
particle.material.opacity += particleEngine.templateParticle.fadeInFactor;
|
particle.material.opacity += particleEngine.templateParticle.fadeInFactor;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (particleEngine.templateParticle.opacityType === GameLib.D3.API.Particle.OPACITY_TYPE_FADE_OUT_LINEAR) {
|
if (particleEngine.templateParticle.opacityType === GameLib.D3.API.Particle.OPACITY_TYPE_FADE_OUT_LINEAR) {
|
||||||
|
if (particle.userData.elapsed > particleEngine.templateParticle.fadeOutAfter) {
|
||||||
particle.material.opacity -= particleEngine.templateParticle.fadeOutFactor;
|
particle.material.opacity -= particleEngine.templateParticle.fadeOutFactor;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (particleEngine.templateParticle.opacityType === GameLib.D3.API.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR) {
|
if (particleEngine.templateParticle.opacityType === GameLib.D3.API.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR) {
|
||||||
|
|
||||||
if (particle.userData.fadeIn) {
|
if (particle.userData.fadeIn) {
|
||||||
|
if (particle.userData.elapsed > particleEngine.templateParticle.fadeInAfter) {
|
||||||
particle.material.opacity += particleEngine.templateParticle.fadeInFactor;
|
particle.material.opacity += particleEngine.templateParticle.fadeInFactor;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (particle.userData.elapsed > particleEngine.templateParticle.fadeOutAfter) {
|
||||||
particle.material.opacity -= particleEngine.templateParticle.fadeOutFactor;
|
particle.material.opacity -= particleEngine.templateParticle.fadeOutFactor;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (particle.material.opacity >= 1) {
|
if (particle.material.opacity >= 1) {
|
||||||
particle.userData.fadeIn = false;
|
particle.userData.fadeIn = false;
|
||||||
|
@ -249,6 +259,15 @@ GameLib.System.Particle.prototype.beforeRender = function(data) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (particleEngine.fired && particleEngine.particles.length === 0) {
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.ENGINE_FIRED_PARTICLES_ZERO,
|
||||||
|
{
|
||||||
|
component : particleEngine
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (particleEngine.enabled && !particleEngine.disabledForRemoval) {
|
if (particleEngine.enabled && !particleEngine.disabledForRemoval) {
|
||||||
|
|
||||||
var instanceClone = null;
|
var instanceClone = null;
|
||||||
|
@ -268,6 +287,7 @@ GameLib.System.Particle.prototype.beforeRender = function(data) {
|
||||||
particleEngine.particles.push(instanceClone);
|
particleEngine.particles.push(instanceClone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
particleEngine.fired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue