refactor: encapsulate InventoryItemContainer internals
Make `updateHitArea` and `renderGraphics` private to prevent external access to internal rendering logic. Move the preview rotation reset to ensure it always executes after a drag operation.
This commit is contained in:
parent
eff62bc0ed
commit
093eadbefd
|
|
@ -85,7 +85,11 @@ export class InventoryItemContainer extends Phaser.GameObjects.Container {
|
|||
});
|
||||
}
|
||||
|
||||
updateHitArea(value: number): Point2D[] {
|
||||
setItem(item: GameItem): void {
|
||||
this.itemState.setItem(item);
|
||||
}
|
||||
|
||||
private updateHitArea(value: number): Point2D[] {
|
||||
const shape = this.itemState.shape.value;
|
||||
if (!shape) return [];
|
||||
|
||||
|
|
@ -104,11 +108,7 @@ export class InventoryItemContainer extends Phaser.GameObjects.Container {
|
|||
}));
|
||||
}
|
||||
|
||||
setItem(item: GameItem): void {
|
||||
this.itemState.setItem(item);
|
||||
}
|
||||
|
||||
renderGraphics(
|
||||
private renderGraphics(
|
||||
graphics: Phaser.GameObjects.Graphics,
|
||||
shape: ParsedShape,
|
||||
itemColor: number,
|
||||
|
|
@ -167,12 +167,10 @@ export class InventoryItemContainer extends Phaser.GameObjects.Container {
|
|||
this.setAlpha(1);
|
||||
const finalRotation = this.itemState.previewRotation.peek();
|
||||
if (!this.handleDragEnd(finalRotation)) {
|
||||
this.itemState.setPreviewRotation(0);
|
||||
const t = this.itemState.transform.peek();
|
||||
t && this.snapBack(t);
|
||||
} else {
|
||||
this.itemState.setPreviewRotation(0);
|
||||
}
|
||||
this.itemState.setPreviewRotation(0);
|
||||
startX = startY = 0;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue