From a08b11e11c1deafe3371b2bdeb7a0eaa4ec747fa Mon Sep 17 00:00:00 2001 From: Erik Onarheim Date: Thu, 24 Oct 2024 23:26:50 -0500 Subject: [PATCH] refactor: Remove unused legacy ex.Configurable --- CHANGELOG.md | 1 + src/engine/Configurable.ts | 35 ----------------------------------- src/engine/index.ts | 1 - 3 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 src/engine/Configurable.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 37d5edd7f..84c0f1659 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Breaking Changes +- Removed legacy `ex.Configurable` function type used for doing dark magic to allow types to be configured by instances of that same type :boom: - Collision events now only target `ex.Collider` types, this previously would sometimes emit an `ex.Entity` if you attached to the `ex.ColliderComponent` * `ex.PreCollisionEvent` * `ex.PostCollisionEvent` diff --git a/src/engine/Configurable.ts b/src/engine/Configurable.ts deleted file mode 100644 index b4d81ae8a..000000000 --- a/src/engine/Configurable.ts +++ /dev/null @@ -1,35 +0,0 @@ -export type Constructor = { - new (...args: any[]): T; -}; -/** - * Configurable helper extends base type and makes all properties available as option bag arguments - * @internal - * @param base - */ -export function Configurable>(base: T): T { - return class extends base { - public assign(props: Partial) { - //set the value of every property that was passed in, - //if the constructor previously set this value, it will be overridden here - for (const k in props) { - // eslint-disable-next-line - if (typeof (this)[k] !== 'function') { - // eslint-disable-next-line - (this)[k] = (props)[k]; - } - } - } - - constructor(...args: any[]) { - super(...args); - //get the number of arguments that aren't undefined. TS passes a value to all parameters - //of whatever ctor is the implementation, so args.length doesn't work here. - const size = args.filter(function (value) { - return value !== undefined; - }).length; - if (size === 1 && args[0] && typeof args[0] === 'object' && !(args[0] instanceof Array)) { - this.assign(args[0]); - } - } - }; -} diff --git a/src/engine/index.ts b/src/engine/index.ts index 147292bf2..f86b09f9e 100644 --- a/src/engine/index.ts +++ b/src/engine/index.ts @@ -16,7 +16,6 @@ export * from './Screen'; export * from './Actor'; export * from './Math/Index'; export * from './Camera'; -export * from './Configurable'; export * from './Debug/index'; export * from './EventDispatcher'; export * from './EventEmitter';