Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodBoyDigital committed May 13, 2024
1 parent bf4ceca commit cea0d27
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/rendering/mask/MaskEffectManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ interface MaskConversionTest
maskClass: new (item: any) => Effect & PoolItem;
}

export type MaskEffect = {mask: unknown} & Effect;

/**
* A class that manages the conversion of masks to mask effects.
* @memberof rendering
Expand Down Expand Up @@ -44,7 +46,7 @@ export class MaskEffectManagerClass
this._tests.push(test);
}

public getMaskEffect(item: any): Effect
public getMaskEffect(item: any): MaskEffect
{
if (!this._initialized) this.init();

Expand All @@ -54,7 +56,7 @@ export class MaskEffectManagerClass

if (test.test(item))
{
return BigPool.get(test.maskClass as PoolItemConstructor<Effect & PoolItem>, item);
return BigPool.get(test.maskClass as PoolItemConstructor<MaskEffect & PoolItem>, item);
}
}

Expand Down
19 changes: 10 additions & 9 deletions src/scene/container/container-mixins/effectsMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MaskEffectManager } from '../../../rendering/mask/MaskEffectManager';

import type { Filter } from '../../../filters/Filter';
import type { Rectangle } from '../../../maths/shapes/Rectangle';
import type { MaskEffect } from '../../../rendering/mask/MaskEffectManager';
import type { Container } from '../Container';
import type { Effect } from '../Effect';

Expand All @@ -13,7 +14,7 @@ export interface EffectsMixinConstructor
}
export interface EffectsMixin extends Required<EffectsMixinConstructor>
{
_maskEffect?: {mask: unknown} & Effect;
_maskEffect?: MaskEffect;
_filterEffect?: FilterEffect,

filterArea?: Rectangle,
Expand Down Expand Up @@ -81,22 +82,22 @@ export const effectsMixin: Partial<Container> = {

set mask(value: number | Container | null)
{
if (this._maskEffect?.mask === value) return;
const effect = this._maskEffect;

if (this._maskEffect)
if (effect?.mask === value) return;

if (effect)
{
this.removeEffect(this._maskEffect);
this.removeEffect(effect);

MaskEffectManager.returnMaskEffect(this._maskEffect);
MaskEffectManager.returnMaskEffect(effect);
}

if (value === null || value === undefined) return;

const effect = MaskEffectManager.getMaskEffect(value);

this._maskEffect = effect as {mask: unknown} & Effect;
this._maskEffect = MaskEffectManager.getMaskEffect(value);

this.addEffect(effect);
this.addEffect(this._maskEffect);
},

/**
Expand Down

0 comments on commit cea0d27

Please sign in to comment.