Skip to content

Commit

Permalink
Revert particle-system-2d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
dumganhar committed Jan 27, 2025
1 parent 98c064f commit f3b492a
Showing 1 changed file with 8 additions and 82 deletions.
90 changes: 8 additions & 82 deletions cocos/particle-2d/particle-system-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,80 +141,6 @@ function getParticleComponents (node): ParticleSystem2D[] {
const wrapParseInt: (str: string | number) => number = parseInt as any;
const wrapParseFloat: (str: string | number) => number = parseFloat as any;

interface IParticle2DParameters {
maxParticles?: string;
particleLifespan?: string;
particleLifespanVariance?: string;
emissionRate?: string;
duration?: string;
blendFuncSource?: string;
blendFuncDestination?: string;
startColorRed?: string;
startColorGreen?: string;
startColorBlue?: string;
startColorAlpha?: string;

startColorVarianceRed?: string;
startColorVarianceGreen?: string;
startColorVarianceBlue?: string;
startColorVarianceAlpha?: string;

finishColorRed?: string;
finishColorGreen?: string;
finishColorBlue?: string;
finishColorAlpha?: string;

finishColorVarianceRed?: string;
finishColorVarianceGreen?: string;
finishColorVarianceBlue?: string;
finishColorVarianceAlpha?: string;

startParticleSize?: string;
startParticleSizeVariance?: string;
finishParticleSize?: string;
finishParticleSizeVariance?: string;

positionType?: string;

sourcePositionVariancex?: string;
sourcePositionVariancey?: string;

angle?: string;
angleVariance?: string;

rotationStart?: string;
rotationStartVariance?: string;
rotationEnd?: string;
rotationEndVariance?: string;

emitterType?: string;

gravityx?: string;
gravityy?: string;

speed?: string;
speedVariance?: string;

radialAcceleration?: string;
radialAccelVariance?: string;

tangentialAcceleration?: string;
tangentialAccelVariance?: string;

rotationIsDir?: string;

maxRadius?: string;
maxRadiusVariance?: string;
minRadius?: string;
minRadiusVariance?: string;
rotatePerSecond?: string;
rotatePerSecondVariance?: string;

spriteFrameUuid?: string;
textureFileName?: string;
textureImageData?: string;
}

/**
* @en Particle System base class.
* cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
Expand Down Expand Up @@ -993,14 +919,14 @@ export class ParticleSystem2D extends UIRenderer {
if (!this._custom) {
const isDiffFrame = this._spriteFrame !== file.spriteFrame;
if (isDiffFrame) this.spriteFrame = file.spriteFrame;
this._initWithDictionary(file._nativeAsset as IParticle2DParameters);
this._initWithDictionary(file._nativeAsset as Record<string, number>);
}

if (!this._spriteFrame) {
if (file.spriteFrame) {
this.spriteFrame = file.spriteFrame;
} else if (this._custom) {
this._initTextureWithDictionary(file._nativeAsset as IParticle2DParameters);
this._initTextureWithDictionary(file._nativeAsset);
}
} else if (!this._renderSpriteFrame && this._spriteFrame) {
this._applySpriteFrame();
Expand All @@ -1011,9 +937,9 @@ export class ParticleSystem2D extends UIRenderer {
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
public _initTextureWithDictionary (dict: IParticle2DParameters): boolean {
public _initTextureWithDictionary (dict: any): boolean {
if (dict.spriteFrameUuid) {
const spriteFrameUuid = dict.spriteFrameUuid;
const spriteFrameUuid: string = dict.spriteFrameUuid;
assetManager.loadAny(spriteFrameUuid, (err: Error, spriteFrame: SpriteFrame): void => {
if (err) {
dict.spriteFrameUuid = undefined;
Expand All @@ -1025,7 +951,7 @@ export class ParticleSystem2D extends UIRenderer {
});
} else {
// texture
const imgPath = path.changeBasename(this._plistFile, dict.textureFileName || '');
const imgPath = path.changeBasename(this._plistFile, dict.textureFileName as string || '');
if (dict.textureFileName) {
// Try to get the texture from the cache
assetManager.loadRemote<ImageAsset>(imgPath, (err: Error | null, imageAsset: ImageAsset): void => {
Expand All @@ -1043,7 +969,7 @@ export class ParticleSystem2D extends UIRenderer {
}
});
} else if (dict.textureImageData) {
const textureData = dict.textureImageData;
const textureData: string = dict.textureImageData;

if (textureData && textureData.length > 0) {
let imgPathName = imgPath;
Expand Down Expand Up @@ -1097,7 +1023,7 @@ export class ParticleSystem2D extends UIRenderer {
/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
public _initWithDictionary (dict: IParticle2DParameters): boolean {
public _initWithDictionary (dict: Record<string, number>): boolean {
this._useFile = true;
this.totalParticles = wrapParseInt(dict.maxParticles || 0);

Expand All @@ -1108,7 +1034,7 @@ export class ParticleSystem2D extends UIRenderer {
// emission Rate
const _tempEmissionRate = dict.emissionRate;
if (_tempEmissionRate) {
this.emissionRate = wrapParseFloat(_tempEmissionRate);
this.emissionRate = _tempEmissionRate;
} else {
this.emissionRate = Math.min(this.totalParticles / this.life, Number.MAX_VALUE);
}
Expand Down

0 comments on commit f3b492a

Please sign in to comment.