Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3.8.6] Add SystemPriority enum for inline. #18194

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cocos/animation/animation-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/

import { ccclass } from 'cc.decorator';
import { System, errorID, cclegacy, js } from '../core';
import { director, Director, DirectorEvent } from '../game/director';
import { System, errorID, cclegacy, js, SystemPriority } from '../core';
import { director, DirectorEvent } from '../game/director';
import { Node } from '../scene-graph';
import { LegacyBlendStateBuffer } from '../3d/skeletal-animation/skeletal-animation-blending';
import { AnimationState } from './animation-state';
Expand Down Expand Up @@ -162,7 +162,7 @@ export class AnimationManager extends System {

director.on(DirectorEvent.INIT, (): void => {
const animationManager = new AnimationManager();
director.registerSystem(AnimationManager.ID, animationManager, System.Priority.HIGH);
director.registerSystem(AnimationManager.ID, animationManager, SystemPriority.HIGH);
});

cclegacy.AnimationManager = AnimationManager;
4 changes: 2 additions & 2 deletions cocos/core/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import * as math from './math';
import { Scheduler } from './scheduler';
import { legacyCC } from './global-exports';

import { System } from './system';
import { SystemPriority } from './system';

// VMATH

Expand Down Expand Up @@ -205,7 +205,7 @@ replaceProperty(Scheduler, 'Scheduler', [
name: 'PRIORITY_SYSTEM',
newName: 'System.Priority.SCHEDULER',
customGetter (): number {
return System.Priority.SCHEDULER;
return SystemPriority.SCHEDULER;
},
},
]);
Expand Down
6 changes: 3 additions & 3 deletions cocos/core/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { IDGenerator } from './utils/id-generator';
import { createMap } from './utils/js';
import { System } from './system';
import { System, SystemPriority } from './system';
import { legacyCC } from './global-exports';
import { errorID, warnID, logID, assertID } from './platform/debug';

Expand Down Expand Up @@ -153,7 +153,7 @@
* @param paused
*/
class HashTimerEntry {
public static get (timers: CallbackTimer[] | null, target: ISchedulable, timerIndex: number, currentTimer: CallbackTimer | null, currentTimerSalvaged: boolean, paused: boolean): HashTimerEntry {

Check warning on line 156 in cocos/core/scheduler.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 198. Maximum allowed is 150
let result = HashTimerEntry._hashTimerEntries.pop();
if (result) {
result.timers = timers;
Expand Down Expand Up @@ -184,7 +184,7 @@
public currentTimerSalvaged: boolean;
public paused: boolean;

constructor (timers: CallbackTimer[] | null, target: ISchedulable, timerIndex: number, currentTimer: CallbackTimer | null, currentTimerSalvaged: boolean, paused: boolean) {

Check warning on line 187 in cocos/core/scheduler.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 176. Maximum allowed is 150
this.timers = timers;
this.target = target;
this.timerIndex = timerIndex;
Expand Down Expand Up @@ -235,7 +235,7 @@
this._target = null;
}

public initWithCallback (scheduler: Scheduler, callback: CallbackType, target: ISchedulable, seconds: number, repeat: number, delay: number): boolean {

Check warning on line 238 in cocos/core/scheduler.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 155. Maximum allowed is 150
this._lock = false;
this._scheduler = scheduler;
this._target = target;
Expand Down Expand Up @@ -388,7 +388,7 @@
this._updatesNegList = []; // list of priority < 0
this._updates0List = []; // list of priority == 0
this._updatesPosList = []; // list of priority > 0
this._hashForUpdates = createMap(true) as Record<string, HashUpdateEntry>; // hash used to fetch quickly the list entries for pause, delete, etc

Check warning on line 391 in cocos/core/scheduler.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 153. Maximum allowed is 150
this._hashForTimers = createMap(true) as Record<string, HashTimerEntry>; // Used for "selectors with interval"
this._currentTarget = null;
this._currentTargetSalvaged = false;
Expand Down Expand Up @@ -577,7 +577,7 @@
* @deprecated since v3.8.0, please use `Scheduler.schedule(callback, target, interval)` instead.
*/
public schedule (target: ISchedulable, callback: CallbackType, interval: number, repeat?: number, delay?: number, paused?: boolean): void;
public schedule (callbackTmp: CallbackType | ISchedulable, targetTmp: ISchedulable | CallbackType, interval: number, repeat?: number, delay?: number, paused?: boolean): void {

Check warning on line 580 in cocos/core/scheduler.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 179. Maximum allowed is 150
let callback: CallbackType;
let target: ISchedulable;
if (typeof callbackTmp !== 'function') {
Expand Down Expand Up @@ -859,7 +859,7 @@
* 不要调用此函数,除非你确定你在做什么。
*/
public unscheduleAll (): void {
this.unscheduleAllWithMinPriority(System.Priority.SCHEDULER);
this.unscheduleAllWithMinPriority(SystemPriority.SCHEDULER);
}

/**
Expand Down Expand Up @@ -976,7 +976,7 @@
* 不要调用这个方法,除非你知道你正在做什么。
*/
public pauseAllTargets (): ISchedulable[] {
return this.pauseAllTargetsWithMinPriority(System.Priority.SCHEDULER);
return this.pauseAllTargetsWithMinPriority(SystemPriority.SCHEDULER);
}

/**
Expand Down
15 changes: 11 additions & 4 deletions cocos/core/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,23 @@
import { ISchedulable } from './scheduler';
import { Enum } from './value-types/enum';

export enum SystemPriority {
LOW = 0,
MEDIUM = 100,
HIGH = 200,
SCHEDULER = (1 << 31) >>> 0,
}

/**
* @en Base class for all functional system managed by [[Director]].
* @zh 功能系统的基类,由 [[Director]] 管理。
*/
export class System implements ISchedulable {
static Priority = Enum({
LOW: 0,
MEDIUM: 100,
HIGH: 200,
SCHEDULER: (1 << 31) >>> 0,
LOW: SystemPriority.LOW,
MEDIUM: SystemPriority.MEDIUM,
HIGH: SystemPriority.HIGH,
SCHEDULER: SystemPriority.SCHEDULER,
});

protected _id = '';
Expand Down
4 changes: 2 additions & 2 deletions cocos/dragon-bones/ArmatureSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { director } from '../game/director';
import { System, cclegacy } from '../core';
import { System, SystemPriority, cclegacy } from '../core';
import { ArmatureDisplay } from './ArmatureDisplay';
/**
* @en The ArmatureSystem is mainly responsible for triggering and updating the animation uniformly.
Expand All @@ -49,7 +49,7 @@ export class ArmatureSystem extends System {
public static getInstance (): ArmatureSystem {
if (!ArmatureSystem._instance) {
ArmatureSystem._instance = new ArmatureSystem();
director.registerSystem(ArmatureSystem.ID, ArmatureSystem._instance, System.Priority.HIGH);
director.registerSystem(ArmatureSystem.ID, ArmatureSystem._instance, SystemPriority.HIGH);
}
return ArmatureSystem._instance;
}
Expand Down
4 changes: 2 additions & 2 deletions cocos/dragon-bones/CCFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants';
import { Armature, BaseObject, Animation, BaseFactory, DragonBones, DragonBonesData, DisplayData } from '@cocos/dragonbones-js';
import { ISchedulable, Scheduler, System, _decorator } from '../core';
import { ISchedulable, Scheduler, System, SystemPriority, _decorator } from '../core';
import { CCTextureAtlasData } from './CCTextureData';
import { TextureBase } from '../asset/assets/texture-base';
import { CCSlot } from './CCSlot';
Expand Down Expand Up @@ -110,7 +110,7 @@
initUpdate (dt?: number): void {
// director.getScheduler().enableForTarget(this);
Scheduler.enableForTarget(this);
director.getScheduler().scheduleUpdate(this, System.Priority.HIGH, false);
director.getScheduler().scheduleUpdate(this, SystemPriority.HIGH, false);
}
/**
* @en Trigger ArmatureDisplay components to update animation and render data.
Expand Down Expand Up @@ -206,7 +206,7 @@

const display = new CCArmatureDisplay();

armature.init(dataPackage.armature, display as any, display, this._dragonBones);

Check failure on line 209 in cocos/dragon-bones/CCFactory.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `ArmatureData`

Check failure on line 209 in cocos/dragon-bones/CCFactory.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `IArmatureProxy`

return armature;
}
Expand All @@ -214,7 +214,7 @@
_buildSlot (dataPackage, slotData, displays): CCSlot {
const slot = BaseObject.borrowObject(CCSlot);
const display = slot;
slot.init(slotData, displays, display, display);

Check failure on line 217 in cocos/dragon-bones/CCFactory.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `SlotData`

Check failure on line 217 in cocos/dragon-bones/CCFactory.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `(DisplayData | null)[] | null`
return slot;
}
/**
Expand All @@ -223,7 +223,7 @@
*/
getDragonBonesDataByUUID (uuid): DragonBonesData | null {
for (const name in this._dragonBonesDataMap) {
if (name.indexOf(uuid) !== -1) {

Check failure on line 226 in cocos/dragon-bones/CCFactory.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `string`
return this._dragonBonesDataMap[name];
}
}
Expand Down
4 changes: 2 additions & 2 deletions cocos/physics-2d/framework/physics-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { BUILD, EDITOR_NOT_IN_PREVIEW, LOAD_BOX2D_MANUALLY } from 'internal:constants';
import { System, Vec2, IVec2Like, Rect, Eventify, Enum, settings, cclegacy, SettingsCategory } from '../../core';
import { System, Vec2, IVec2Like, Rect, Eventify, Enum, settings, cclegacy, SettingsCategory, SystemPriority } from '../../core';
import { createPhysicsWorld, selector, IPhysicsSelector } from './physics-selector';

import { DelayEvent } from './physics-internal-types';
Expand Down Expand Up @@ -379,7 +379,7 @@ export class PhysicsSystem2D extends Eventify(System) {
return this.physicsWorld.testAABB(rect);
}
static constructAndRegister (): void {
director.registerSystem(PhysicsSystem2D.ID, PhysicsSystem2D.instance, System.Priority.LOW);
director.registerSystem(PhysicsSystem2D.ID, PhysicsSystem2D.instance, SystemPriority.LOW);
}
}

Expand Down
4 changes: 2 additions & 2 deletions cocos/spine/skeleton-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { director } from '../game/director';
import { System } from '../core';
import { System, SystemPriority } from '../core';
import { Skeleton } from './skeleton';
import { legacyCC } from '../core/global-exports';

Expand Down Expand Up @@ -51,7 +51,7 @@ export class SkeletonSystem extends System {
public static getInstance (): SkeletonSystem {
if (!SkeletonSystem._instance) {
SkeletonSystem._instance = new SkeletonSystem();
director.registerSystem(SkeletonSystem.ID, SkeletonSystem._instance, System.Priority.HIGH);
director.registerSystem(SkeletonSystem.ID, SkeletonSystem._instance, SystemPriority.HIGH);
}
return SkeletonSystem._instance;
}
Expand Down
4 changes: 2 additions & 2 deletions cocos/tween/tween-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants';
import { System } from '../core';
import { System, SystemPriority } from '../core';
import { ActionManager } from './actions/action-manager';
import { director, DirectorEvent } from '../game';

Expand Down Expand Up @@ -83,5 +83,5 @@ export class TweenSystem extends System {
director.on(DirectorEvent.INIT, () => {
const sys = new TweenSystem();
(TweenSystem as any).instance = sys;
director.registerSystem(TweenSystem.ID, sys, System.Priority.MEDIUM);
director.registerSystem(TweenSystem.ID, sys, SystemPriority.MEDIUM);
});
Loading