cleaned RoomSpriteCanvas

This commit is contained in:
Dank074 2021-06-06 19:03:05 -05:00
parent 145f51e407
commit 26136d6d29
4 changed files with 36 additions and 36 deletions

View File

@ -2456,7 +2456,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
if(!this._Str_25871(canvas, x, y, type, altKey, ctrlKey, shiftKey)) if(!this._Str_25871(canvas, x, y, type, altKey, ctrlKey, shiftKey))
{ {
if(!canvas._Str_21232(x, y, type, altKey, ctrlKey, shiftKey, buttonDown)) if(!canvas.handleMouseEvent(x, y, type, altKey, ctrlKey, shiftKey, buttonDown))
{ {
let eventType: string = null; let eventType: string = null;
@ -3411,7 +3411,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
if(_arg_5) if(_arg_5)
{ {
canvas._Str_20787(); canvas.skipSpriteVisibilityChecking();
} }
let _local_8 = -1; let _local_8 = -1;
@ -3426,7 +3426,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
const _local_11 = _local_9._Str_24177(this); const _local_11 = _local_9._Str_24177(this);
const _local_12 = _local_9._Str_22985(k, canvas, this, _arg_2); const _local_12 = _local_9._Str_22985(k, canvas, this, _arg_2);
if(_arg_5) canvas._Str_22174(); if(_arg_5) canvas.resumeSpriteVisibilityChecking();
if(_arg_3) if(_arg_3)
{ {

View File

@ -350,7 +350,7 @@ export class SpriteDataCollector
_local_4.set(_local_6.uniqueId, _local_10); _local_4.set(_local_6.uniqueId, _local_10);
} }
const sprites = _arg_2._Str_14588(); const sprites = _arg_2.getPlaneSortableSprites();
sprites.sort((a, b) => sprites.sort((a, b) =>
{ {

View File

@ -13,10 +13,10 @@ export interface IRoomRenderingCanvas
render(time: number, update?: boolean): void; render(time: number, update?: boolean): void;
update(): void; update(): void;
setMouseListener(listener: IRoomCanvasMouseListener): void; setMouseListener(listener: IRoomCanvasMouseListener): void;
_Str_20787(): void; skipSpriteVisibilityChecking(): void;
_Str_22174(): void; resumeSpriteVisibilityChecking(): void;
_Str_14588(): SortableSprite[]; getPlaneSortableSprites(): SortableSprite[];
_Str_21232(k: number, _arg_2: number, _arg_3: string, _arg_4: boolean, _arg_5: boolean, _arg_6: boolean, _arg_7: boolean): boolean; handleMouseEvent(k: number, _arg_2: number, _arg_3: string, _arg_4: boolean, _arg_5: boolean, _arg_6: boolean, _arg_7: boolean): boolean;
getSortableSpriteList(): RoomObjectSpriteData[]; getSortableSpriteList(): RoomObjectSpriteData[];
getDisplayAsTexture(): RenderTexture; getDisplayAsTexture(): RenderTexture;
id: number; id: number;

View File

@ -137,7 +137,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
public dispose(): void public dispose(): void
{ {
this._Str_20677(0, true); this.cleanSprites(0, true);
if(this._geometry) if(this._geometry)
{ {
@ -185,7 +185,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
{ {
for(const sprite of this._spritePool) for(const sprite of this._spritePool)
{ {
this._Str_21974(sprite, true); this.cleanSprite(sprite, true);
} }
this._spritePool = []; this._spritePool = [];
@ -379,7 +379,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
iterator++; iterator++;
} }
this._Str_20677(spriteCount); this.cleanSprites(spriteCount);
if(update) this._canvasUpdated = true; if(update) this._canvasUpdated = true;
@ -388,14 +388,14 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
this._renderedHeight = this._height; this._renderedHeight = this._height;
} }
public _Str_20787(): void public skipSpriteVisibilityChecking(): void
{ {
this._noSpriteVisibilityChecking = true; this._noSpriteVisibilityChecking = true;
this.render(-1, true); this.render(-1, true);
} }
public _Str_22174(): void public resumeSpriteVisibilityChecking(): void
{ {
this._noSpriteVisibilityChecking = false; this._noSpriteVisibilityChecking = false;
} }
@ -405,7 +405,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
return this._objectCache.getSortableSpriteList(); return this._objectCache.getSortableSpriteList();
} }
public _Str_14588(): SortableSprite[] public getPlaneSortableSprites(): SortableSprite[]
{ {
return this._objectCache.getPlaneSortableSprites(); return this._objectCache.getPlaneSortableSprites();
} }
@ -628,7 +628,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
if(extendedSprite.scale.y !== 1) extendedSprite.scale.y = 1; if(extendedSprite.scale.y !== 1) extendedSprite.scale.y = 1;
} }
this._Str_21914(extendedSprite, objectSprite); this.updateEnterRoomEffect(extendedSprite, objectSprite);
} }
if(extendedSprite.x !== sprite.x) extendedSprite.x = sprite.x; if(extendedSprite.x !== sprite.x) extendedSprite.x = sprite.x;
@ -681,7 +681,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
if(sprite.flipV) extendedSprite.scale.y = -1; if(sprite.flipV) extendedSprite.scale.y = -1;
this._Str_21914(extendedSprite, sprite); this.updateEnterRoomEffect(extendedSprite, sprite);
if((index < 0) || (index >= this._spriteCount)) if((index < 0) || (index >= this._spriteCount))
{ {
@ -697,7 +697,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
this._activeSpriteCount++; this._activeSpriteCount++;
} }
private _Str_20677(spriteCount: number, _arg_2: boolean = false): void private cleanSprites(spriteCount: number, _arg_2: boolean = false): void
{ {
if(!this._display) return; if(!this._display) return;
@ -709,7 +709,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
while(iterator >= spriteCount) while(iterator >= spriteCount)
{ {
this._Str_21974(this.getExtendedSprite(iterator), _arg_2); this.cleanSprite(this.getExtendedSprite(iterator), _arg_2);
iterator--; iterator--;
} }
@ -718,7 +718,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
this._activeSpriteCount = spriteCount; this._activeSpriteCount = spriteCount;
} }
private _Str_21914(sprite: ExtendedSprite, _arg_2: IRoomObjectSprite): void private updateEnterRoomEffect(sprite: ExtendedSprite, _arg_2: IRoomObjectSprite): void
{ {
if(!RoomEnterEffect.isVisualizationOn() || !_arg_2) return; if(!RoomEnterEffect.isVisualizationOn() || !_arg_2) return;
@ -737,7 +737,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
} }
} }
private _Str_21974(sprite: ExtendedSprite, _arg_2: boolean): void private cleanSprite(sprite: ExtendedSprite, _arg_2: boolean): void
{ {
if(!sprite) return; if(!sprite) return;
@ -759,7 +759,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
{ {
if(!this._mouseCheckCount) if(!this._mouseCheckCount)
{ {
//this._Str_19207(this._mouseLocation.x, this._mouseLocation.y, MouseEventType.MOUSE_MOVE); //this.checkMouseHits(this._mouseLocation.x, this._mouseLocation.y, MouseEventType.MOUSE_MOVE);
} }
this._mouseCheckCount = 0; this._mouseCheckCount = 0;
@ -794,7 +794,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
return false; return false;
} }
public _Str_21232(x: number, y: number, type: string, altKey: boolean, ctrlKey: boolean, shiftKey: boolean, buttonDown: boolean): boolean public handleMouseEvent(x: number, y: number, type: string, altKey: boolean, ctrlKey: boolean, shiftKey: boolean, buttonDown: boolean): boolean
{ {
x = (x - this._screenOffsetX); x = (x - this._screenOffsetX);
y = (y - this._screenOffsetY); y = (y - this._screenOffsetY);
@ -804,14 +804,14 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
if((this._mouseCheckCount > 0) && (type == MouseEventType.MOUSE_MOVE)) return this._mouseSpriteWasHit; if((this._mouseCheckCount > 0) && (type == MouseEventType.MOUSE_MOVE)) return this._mouseSpriteWasHit;
this._mouseSpriteWasHit = this._Str_19207(Math.trunc(x / this._scale), Math.trunc(y / this._scale), type, altKey, ctrlKey, shiftKey, buttonDown); this._mouseSpriteWasHit = this.checkMouseHits(Math.trunc(x / this._scale), Math.trunc(y / this._scale), type, altKey, ctrlKey, shiftKey, buttonDown);
this._mouseCheckCount++; this._mouseCheckCount++;
return this._mouseSpriteWasHit; return this._mouseSpriteWasHit;
} }
private _Str_19207(x: number, y: number, type: string, altKey: boolean = false, ctrlKey: boolean = false, shiftKey: boolean = false, buttonDown: boolean = false): boolean private checkMouseHits(x: number, y: number, type: string, altKey: boolean = false, ctrlKey: boolean = false, shiftKey: boolean = false, buttonDown: boolean = false): boolean
{ {
const checkedSprites: string[] = []; const checkedSprites: string[] = [];
@ -843,19 +843,19 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
{ {
if(mouseData.spriteTag !== tag) if(mouseData.spriteTag !== tag)
{ {
mouseEvent = this._Str_11609(0, 0, 0, 0, MouseEventType.ROLL_OUT, mouseData.spriteTag, altKey, ctrlKey, shiftKey, buttonDown); mouseEvent = this.createMouseEvent(0, 0, 0, 0, MouseEventType.ROLL_OUT, mouseData.spriteTag, altKey, ctrlKey, shiftKey, buttonDown);
this._Str_14715(mouseEvent, identifier); this.bufferMouseEvent(mouseEvent, identifier);
} }
} }
if((type === MouseEventType.MOUSE_MOVE) && (!mouseData || (mouseData.spriteTag !== tag))) if((type === MouseEventType.MOUSE_MOVE) && (!mouseData || (mouseData.spriteTag !== tag)))
{ {
mouseEvent = this._Str_11609(x, y, (x - extendedSprite.x), (y - extendedSprite.y), MouseEventType.ROLL_OVER, tag, altKey, ctrlKey, shiftKey, buttonDown); mouseEvent = this.createMouseEvent(x, y, (x - extendedSprite.x), (y - extendedSprite.y), MouseEventType.ROLL_OVER, tag, altKey, ctrlKey, shiftKey, buttonDown);
} }
else else
{ {
mouseEvent = this._Str_11609(x, y, (x - extendedSprite.x), (y - extendedSprite.y), type, tag, altKey, ctrlKey, shiftKey, buttonDown); mouseEvent = this.createMouseEvent(x, y, (x - extendedSprite.x), (y - extendedSprite.y), type, tag, altKey, ctrlKey, shiftKey, buttonDown);
mouseEvent.spriteOffsetX = extendedSprite.offsetX; mouseEvent.spriteOffsetX = extendedSprite.offsetX;
mouseEvent.spriteOffsetY = extendedSprite.offsetY; mouseEvent.spriteOffsetY = extendedSprite.offsetY;
@ -873,7 +873,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
if(((type !== MouseEventType.MOUSE_MOVE) || (x !== this._mouseOldX)) || (y !== this._mouseOldY)) if(((type !== MouseEventType.MOUSE_MOVE) || (x !== this._mouseOldX)) || (y !== this._mouseOldY))
{ {
this._Str_14715(mouseEvent, identifier); this.bufferMouseEvent(mouseEvent, identifier);
} }
checkedSprites.push(identifier); checkedSprites.push(identifier);
@ -913,22 +913,22 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
if(existing) this._mouseActiveObjects.delete(key); if(existing) this._mouseActiveObjects.delete(key);
const mouseEvent = this._Str_11609(0, 0, 0, 0, MouseEventType.ROLL_OUT, existing.spriteTag, altKey, ctrlKey, shiftKey, buttonDown); const mouseEvent = this.createMouseEvent(0, 0, 0, 0, MouseEventType.ROLL_OUT, existing.spriteTag, altKey, ctrlKey, shiftKey, buttonDown);
this._Str_14715(mouseEvent, key); this.bufferMouseEvent(mouseEvent, key);
} }
index++; index++;
} }
this._Str_20604(); this.processMouseEvents();
this._mouseOldX = x; this._mouseOldX = x;
this._mouseOldY = y; this._mouseOldY = y;
return didHitSprite; return didHitSprite;
} }
protected _Str_11609(x: number, y: number, _arg_3: number, _arg_4: number, type: string, _arg_6: string, _arg_7: boolean, _arg_8: boolean, _arg_9: boolean, _arg_10: boolean): RoomSpriteMouseEvent protected createMouseEvent(x: number, y: number, _arg_3: number, _arg_4: number, type: string, _arg_6: string, _arg_7: boolean, _arg_8: boolean, _arg_9: boolean, _arg_10: boolean): RoomSpriteMouseEvent
{ {
const screenX: number = (x - (this._width / 2)); const screenX: number = (x - (this._width / 2));
const screenY: number = (y - (this._height / 2)); const screenY: number = (y - (this._height / 2));
@ -937,7 +937,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
return new RoomSpriteMouseEvent(type, ((canvasName + '_') + this._eventId), canvasName, _arg_6, screenX, screenY, _arg_3, _arg_4, _arg_8, _arg_7, _arg_9, _arg_10); return new RoomSpriteMouseEvent(type, ((canvasName + '_') + this._eventId), canvasName, _arg_6, screenX, screenY, _arg_3, _arg_4, _arg_8, _arg_7, _arg_9, _arg_10);
} }
protected _Str_14715(k: RoomSpriteMouseEvent, _arg_2: string): void protected bufferMouseEvent(k: RoomSpriteMouseEvent, _arg_2: string): void
{ {
if(!k || !this._eventCache) return; if(!k || !this._eventCache) return;
@ -945,7 +945,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
this._eventCache.set(_arg_2, k); this._eventCache.set(_arg_2, k);
} }
protected _Str_20604(): void protected processMouseEvents(): void
{ {
if(!this._container || !this._eventCache) return; if(!this._container || !this._eventCache) return;