Skip to content

Commit

Permalink
[v3.8.5] Add default constructor for classes (#17746)
Browse files Browse the repository at this point in the history
  • Loading branch information
dumganhar authored Nov 13, 2024
1 parent d9daaae commit 01954f2
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 4 deletions.
4 changes: 4 additions & 0 deletions cocos/3d/assets/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export class Skeleton extends Asset {

private _invBindposes: Mat4[] | null = null;

constructor () {
super();
}

/**
* @en The path of all bones, the length always equals the length of [[bindposes]]
* @zh 所有关节的路径。该数组的长度始终与 [[bindposes]] 的长度相同。
Expand Down
4 changes: 4 additions & 0 deletions cocos/3d/reflection-probe/reflection-probe-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ export class ReflectionProbe extends Component {

private _position = new Vec3(0, 0, 0);

constructor () {
super();
}

/**
* @en
* Gets or sets the size of the box
Expand Down
4 changes: 4 additions & 0 deletions cocos/3d/skinned-mesh-renderer/skinned-mesh-batch-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {

private _batchMaterial: Material | null = null;

constructor () {
super();
}

@override
@visible(false)
get mesh (): Mesh | null {
Expand Down
4 changes: 2 additions & 2 deletions cocos/asset/assets/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ export class Asset extends Eventify(CCObject) {
return this._file;
}

constructor (...args: ConstructorParameters<typeof CCObject>) {
super(...args);
constructor (name = '') {
super(name);

Object.defineProperty(this, '_uuid', {
value: '',
Expand Down
6 changes: 5 additions & 1 deletion cocos/audio/audio-clip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export class AudioClip extends Asset {

private _player: AudioPlayer | null = null;

constructor () {
super();
}

public destroy (): boolean {
const destroyResult = super.destroy();
this._player?.destroy();
Expand Down Expand Up @@ -97,7 +101,7 @@ export class AudioClip extends Asset {
audioLoadMode: AudioType;
ext: string;
__isNative__: boolean;
} {
} {
return {
uuid: this._uuid,
audioLoadMode: this.loadMode,
Expand Down
2 changes: 2 additions & 0 deletions cocos/audio/audio-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export class AudioManager {
private _oneShotAudioInfoList: AudioInfo<OneShotAudio>[] = [];
private _audioPlayerInfoList: AudioInfo<AudioPlayer>[] = [];

constructor () {}

private _findIndex (audioInfoList: AudioInfo<ManagedAudio>[], audio: ManagedAudio): number {
return audioInfoList.findIndex((item) => item.audio === audio);
}
Expand Down
4 changes: 4 additions & 0 deletions cocos/audio/audio-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export class AudioSource extends Component {

private _lastSetClip: AudioClip | null = null;

constructor () {
super();
}

private _resetPlayer (): void {
if (this._player) {
audioManager.removePlaying(this._player);
Expand Down
4 changes: 4 additions & 0 deletions cocos/particle-2d/motion-streak-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class Point {
export class MotionStreak extends UIRenderer {
public static Point = Point;

constructor () {
super();
}

/**
* @en Preview the trailing effect in editor mode.
* @zh 在编辑器模式下预览拖尾效果。
Expand Down
3 changes: 3 additions & 0 deletions cocos/particle/animator/color-overtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const COLOR_OVERTIME_RAND_OFFSET = ModuleRandSeed.COLOR;
*/
@ccclass('cc.ColorOvertimeModule')
export default class ColorOvertimeModule extends ParticleModuleBase {
constructor () {
super();
}
@serializable
_enable = false;
/**
Expand Down
3 changes: 3 additions & 0 deletions cocos/particle/animator/noise-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const { ccclass, serializable, displayOrder, type, range, slide, visible } = _de
*/
@ccclass('cc.NoiseModule')
export class NoiseModule extends ParticleModuleBase {
constructor () {
super();
}
@serializable
_enable = false;
/**
Expand Down
3 changes: 3 additions & 0 deletions cocos/particle/animator/rotation-overtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const ROTATION_OVERTIME_RAND_OFFSET = ModuleRandSeed.ROTATION;
*/
@ccclass('cc.RotationOvertimeModule')
export default class RotationOvertimeModule extends ParticleModuleBase {
constructor () {
super();
}
@serializable
_enable = false;
/**
Expand Down
3 changes: 3 additions & 0 deletions cocos/particle/animator/size-overtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const SIZE_OVERTIME_RAND_OFFSET = ModuleRandSeed.SIZE;
*/
@ccclass('cc.SizeOvertimeModule')
export default class SizeOvertimeModule extends ParticleModuleBase {
constructor () {
super();
}
@serializable
_enable = false;
/**
Expand Down
3 changes: 3 additions & 0 deletions cocos/particle/animator/texture-animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ const Animation = Enum({
*/
@ccclass('cc.TextureAnimationModule')
export default class TextureAnimationModule extends ParticleModuleBase {
constructor () {
super();
}
@serializable
private _enable = false;

Expand Down
2 changes: 2 additions & 0 deletions cocos/terrain/terrain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const TERRAIN_EFFECT_UUID = '1d08ef62-a503-4ce2-8b9a-46c90873f7d3';
*/
@ccclass('cc.TerrainInfo')
export class TerrainInfo {
constructor () {
}
/**
* @en tile size
* @zh 栅格大小
Expand Down
5 changes: 4 additions & 1 deletion cocos/tiledmap/tiled-map-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ import { TextAsset } from '../asset/assets';
*/
@ccclass('cc.TiledMapAsset')
export class TiledMapAsset extends Asset {
constructor () {
super();
}
@serializable
tmxXmlStr = '';

Expand Down Expand Up @@ -70,7 +73,7 @@ export class TiledMapAsset extends Asset {
*/
@serializable
@type([SpriteFrame])
imageLayerSpriteFrame: SpriteFrame[] = []
imageLayerSpriteFrame: SpriteFrame[] = [];

/**
* @en
Expand Down
4 changes: 4 additions & 0 deletions cocos/tiledmap/tiled-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ export class TiledMap extends Component {
@serializable
protected cleanupImageCache = true;

constructor () {
super();
}

/**
* @en Gets the map size.
* @zh 获取地图大小。
Expand Down
4 changes: 4 additions & 0 deletions cocos/tiledmap/tiled-object-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ import { Node } from '../scene-graph/node';
export class TiledObjectGroup extends Component {
protected _premultiplyAlpha = false;

constructor () {
super();
}

@type(CCBoolean)
get premultiplyAlpha (): boolean {
return this._premultiplyAlpha;
Expand Down
4 changes: 4 additions & 0 deletions cocos/video/video-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export class VideoPlayer extends Component {
protected _impl: VideoPlayerImplWeb | null = null;
protected _cachedCurrentTime = 0;

constructor () {
super();
}

/**
* @en
* The resource type of video player, REMOTE for remote url and LOCAL for local file path.
Expand Down
4 changes: 4 additions & 0 deletions cocos/web-view/web-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export class WebView extends Component {
*/
public static EventType = WebViewEventType;

constructor () {
super();
}

/**
* @en
* A given URL to be loaded by the WebView, it should have a http or https prefix.
Expand Down

0 comments on commit 01954f2

Please sign in to comment.