mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-04-19 17:16:08 +08:00
feat: render 中递归调用 update 检查
This commit is contained in:
parent
baec3d5429
commit
c505efeb66
@ -351,6 +351,13 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
|
|||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region debug
|
||||||
|
|
||||||
|
/** 是否需要禁用更新,如果出现更新,那么发出警告并停止更新操作 */
|
||||||
|
private forbidUpdate: boolean = false;
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
type: RenderItemPosition,
|
type: RenderItemPosition,
|
||||||
enableCache: boolean = true,
|
enableCache: boolean = true,
|
||||||
@ -392,6 +399,7 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
|
|||||||
*/
|
*/
|
||||||
renderContent(canvas: MotaOffscreenCanvas2D, transform: Transform) {
|
renderContent(canvas: MotaOffscreenCanvas2D, transform: Transform) {
|
||||||
if (this.hidden) return;
|
if (this.hidden) return;
|
||||||
|
this.forbidUpdate = true;
|
||||||
this.emit('beforeRender', transform);
|
this.emit('beforeRender', transform);
|
||||||
if (this.transformFallThrough) {
|
if (this.transformFallThrough) {
|
||||||
this.fallTransform = transform;
|
this.fallTransform = transform;
|
||||||
@ -425,6 +433,7 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
|
|||||||
}
|
}
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
this.emit('afterRender', transform);
|
this.emit('afterRender', transform);
|
||||||
|
this.forbidUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -601,6 +610,11 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
|
|||||||
}
|
}
|
||||||
|
|
||||||
update(item: RenderItem<any> = this): void {
|
update(item: RenderItem<any> = this): void {
|
||||||
|
if (import.meta.env.DEV) {
|
||||||
|
if (this.forbidUpdate) {
|
||||||
|
logger.warn(61, this.constructor.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (this._parent) {
|
if (this._parent) {
|
||||||
if (this.cacheDirty && this._parent.cacheDirty) return;
|
if (this.cacheDirty && this._parent.cacheDirty) return;
|
||||||
this.cacheDirty = true;
|
this.cacheDirty = true;
|
||||||
|
@ -92,6 +92,7 @@
|
|||||||
"58": "Fail to set ellipse round rect, since length of 'ellipse' property should only be 2, 4, 6 or 8. delivered: $1",
|
"58": "Fail to set ellipse round rect, since length of 'ellipse' property should only be 2, 4, 6 or 8. delivered: $1",
|
||||||
"59": "Unknown icon '$1' in parsing text content.",
|
"59": "Unknown icon '$1' in parsing text content.",
|
||||||
"60": "Repeated Tip id: '$1'.",
|
"60": "Repeated Tip id: '$1'.",
|
||||||
|
"61": "Unexpected recursive call of $1.update in render function. Please ensure you must do this, if you do, ignore this warn.",
|
||||||
"1001": "Item-detail extension needs 'floor-binder' and 'floor-damage' extension as dependency.",
|
"1001": "Item-detail extension needs 'floor-binder' and 'floor-damage' extension as dependency.",
|
||||||
"1101": "Cannot add new effect to point effect instance, for there's no more reserve space for it. Please increase the max count of the instance."
|
"1101": "Cannot add new effect to point effect instance, for there's no more reserve space for it. Please increase the max count of the instance."
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user