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.REPLACE_COMPONENT = 0x74;
|
||||
GameLib.Event.COMPONENT_REPLACED = 0x75;
|
||||
GameLib.Event.ENGINE_FIRED_PARTICLES_ZERO = 0x76;
|
||||
|
||||
/**
|
||||
* Returns string name of event ID
|
||||
|
@ -259,6 +260,7 @@ GameLib.Event.GetEventName = function(number) {
|
|||
case 0x73 : return 'set_active_render_configuration';
|
||||
case 0x74 : return 'replace_component';
|
||||
case 0x75 : return 'component_replaced';
|
||||
case 0x76 : return 'engine_fired_particles_zero';
|
||||
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 max
|
||||
* @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 max
|
||||
* @returns {*}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
* @param elapsed
|
||||
* @param camera
|
||||
* @param pulse
|
||||
* @param fired
|
||||
* @param parentEntity
|
||||
* @constructor
|
||||
*/
|
||||
|
@ -26,6 +27,7 @@ GameLib.D3.API.ParticleEngine = function(
|
|||
elapsed,
|
||||
camera,
|
||||
pulse,
|
||||
fired,
|
||||
parentEntity
|
||||
) {
|
||||
|
||||
|
@ -84,6 +86,11 @@ GameLib.D3.API.ParticleEngine = function(
|
|||
}
|
||||
this.pulse = pulse;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(fired)) {
|
||||
fired = false;
|
||||
}
|
||||
this.fired = fired;
|
||||
|
||||
GameLib.API.Component.call(
|
||||
this,
|
||||
GameLib.Component.PARTICLE_ENGINE,
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @param opacityType
|
||||
* @param fadeInFactor
|
||||
* @param fadeOutFactor
|
||||
* @param fadeInAfter
|
||||
* @param fadeOutAfter
|
||||
* @param positionOffsetType
|
||||
* @param positionOffset
|
||||
* @param positionOffsetFn
|
||||
|
@ -35,6 +37,8 @@ GameLib.D3.API.Particle = function(
|
|||
opacityType,
|
||||
fadeInFactor,
|
||||
fadeOutFactor,
|
||||
fadeInAfter,
|
||||
fadeOutAfter,
|
||||
positionOffsetType,
|
||||
positionOffset,
|
||||
positionOffsetFn,
|
||||
|
@ -93,6 +97,16 @@ GameLib.D3.API.Particle = function(
|
|||
}
|
||||
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)) {
|
||||
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_RANDOM = 0x2;
|
||||
GameLib.D3.API.Particle.ROTATION_TYPE_FUNCTION = 0x3;
|
||||
|
||||
/**
|
||||
* Creates an API Particle from an Object Particle
|
||||
* @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
|
||||
);
|
||||
|
||||
};
|
||||
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;
|
||||
GameLib.D3.API.Particle.ROTATION_TYPE_FUNCTION = 0x6;
|
||||
|
|
|
@ -29,6 +29,7 @@ GameLib.D3.ParticleEngine = function(
|
|||
apiParticleEngine.elapsed,
|
||||
apiParticleEngine.camera,
|
||||
apiParticleEngine.pulse,
|
||||
apiParticleEngine.fired,
|
||||
apiParticleEngine.parentEntity
|
||||
);
|
||||
|
||||
|
@ -51,6 +52,8 @@ GameLib.D3.ParticleEngine = function(
|
|||
)
|
||||
}
|
||||
|
||||
this.elapsed = 0;
|
||||
|
||||
this.particles = [];
|
||||
|
||||
this.disabledForRemoval = false;
|
||||
|
@ -262,25 +265,8 @@ GameLib.D3.ParticleEngine.prototype.toApiObject = function() {
|
|||
this.elapsed,
|
||||
GameLib.Utils.IdOrNull(this.camera),
|
||||
this.pulse,
|
||||
this.fired,
|
||||
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.fadeInFactor,
|
||||
apiParticle.fadeOutFactor,
|
||||
apiParticle.fadeInAfter,
|
||||
apiParticle.fadeOutAfter,
|
||||
apiParticle.positionOffsetType,
|
||||
apiParticle.positionOffset,
|
||||
apiParticle.positionOffsetFn,
|
||||
|
@ -108,6 +110,13 @@ GameLib.D3.Particle.prototype.createInstance = function() {
|
|||
*/
|
||||
GameLib.D3.Particle.prototype.updateInstance = function(property) {
|
||||
|
||||
if (!this.instance) {
|
||||
this.createInstance();
|
||||
if (!this.instance) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (property === 'positionOffset') {
|
||||
this.positionOffset.instance.x = this.positionOffset.x;
|
||||
this.positionOffset.instance.y = this.positionOffset.y;
|
||||
|
@ -322,6 +331,8 @@ GameLib.D3.Particle.prototype.toApiObject = function() {
|
|||
this.opacityType,
|
||||
this.fadeInFactor,
|
||||
this.fadeOutFactor,
|
||||
this.fadeInAfter,
|
||||
this.fadeOutAfter,
|
||||
this.positionOffsetType,
|
||||
this.positionOffset.toApiObject(),
|
||||
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,
|
||||
'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
|
||||
}
|
||||
)
|
||||
|
|
|
@ -131,7 +131,9 @@ GameLib.System.Particle.prototype.beforeRender = function(data) {
|
|||
GameLib.Utils.UndefinedOrNull(particleEngine.templateParticle) ||
|
||||
GameLib.Utils.UndefinedOrNull(particleEngine.templateParticle.mesh) ||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -202,19 +204,27 @@ GameLib.System.Particle.prototype.beforeRender = function(data) {
|
|||
}
|
||||
|
||||
if (particleEngine.templateParticle.opacityType === GameLib.D3.API.Particle.OPACITY_TYPE_FADE_IN_LINEAR) {
|
||||
particle.material.opacity += particleEngine.templateParticle.fadeInFactor;
|
||||
if (particle.userData.elapsed > particleEngine.templateParticle.fadeInAfter) {
|
||||
particle.material.opacity += particleEngine.templateParticle.fadeInFactor;
|
||||
}
|
||||
}
|
||||
|
||||
if (particleEngine.templateParticle.opacityType === GameLib.D3.API.Particle.OPACITY_TYPE_FADE_OUT_LINEAR) {
|
||||
particle.material.opacity -= particleEngine.templateParticle.fadeOutFactor;
|
||||
if (particle.userData.elapsed > particleEngine.templateParticle.fadeOutAfter) {
|
||||
particle.material.opacity -= particleEngine.templateParticle.fadeOutFactor;
|
||||
}
|
||||
}
|
||||
|
||||
if (particleEngine.templateParticle.opacityType === GameLib.D3.API.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR) {
|
||||
|
||||
if (particle.userData.fadeIn) {
|
||||
particle.material.opacity += particleEngine.templateParticle.fadeInFactor;
|
||||
if (particle.userData.elapsed > particleEngine.templateParticle.fadeInAfter) {
|
||||
particle.material.opacity += particleEngine.templateParticle.fadeInFactor;
|
||||
}
|
||||
} else {
|
||||
particle.material.opacity -= particleEngine.templateParticle.fadeOutFactor;
|
||||
if (particle.userData.elapsed > particleEngine.templateParticle.fadeOutAfter) {
|
||||
particle.material.opacity -= particleEngine.templateParticle.fadeOutFactor;
|
||||
}
|
||||
}
|
||||
|
||||
if (particle.material.opacity >= 1) {
|
||||
|
@ -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) {
|
||||
|
||||
var instanceClone = null;
|
||||
|
@ -268,6 +287,7 @@ GameLib.System.Particle.prototype.beforeRender = function(data) {
|
|||
particleEngine.particles.push(instanceClone);
|
||||
}
|
||||
|
||||
particleEngine.fired = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue