From d53eea407d2aea122ee7ba9facee46e354f22725 Mon Sep 17 00:00:00 2001 From: Erik Onarheim Date: Sat, 30 Dec 2023 20:25:03 -0600 Subject: [PATCH] fix: [#2855] Remove dunder from overrideable methods --- src/engine/Actor.ts | 18 ++++----- src/engine/Camera.ts | 28 +++++++------- src/engine/Engine.ts | 22 +++++------ src/engine/EntityComponentSystem/Entity.ts | 6 +-- .../ExcaliburGraphicsContext2DCanvas.ts | 4 +- src/engine/Interfaces/LifecycleEvents.ts | 10 ++--- src/engine/Loader.ts | 2 +- src/engine/Particles.ts | 2 +- src/engine/Scene.ts | 38 +++++++++---------- src/engine/tsconfig.json | 2 +- 10 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/engine/Actor.ts b/src/engine/Actor.ts index 31d14458b..73310fbfd 100644 --- a/src/engine/Actor.ts +++ b/src/engine/Actor.ts @@ -615,7 +615,7 @@ export class Actor extends Entity implements Eventable, PointerEvents, CanInitia * * Synonymous with the event handler `.on('initialize', (evt) => {...})` */ - public onInitialize(_engine: Engine): void { + public onInitialize(engine: Engine): void { // Override me } @@ -666,9 +666,9 @@ export class Actor extends Entity implements Eventable, PointerEvents, CanInitia * Internal _prekill handler for [[onPreKill]] lifecycle event * @internal */ - public _prekill(_scene: Scene) { + public _prekill(scene: Scene) { this.events.emit('prekill', new PreKillEvent(this)); - this.onPreKill(_scene); + this.onPreKill(scene); } /** @@ -676,7 +676,7 @@ export class Actor extends Entity implements Eventable, PointerEvents, CanInitia * * `onPreKill` is called directly before an actor is killed and removed from its current [[Scene]]. */ - public onPreKill(_scene: Scene) { + public onPreKill(scene: Scene) { // Override me } @@ -686,9 +686,9 @@ export class Actor extends Entity implements Eventable, PointerEvents, CanInitia * Internal _prekill handler for [[onPostKill]] lifecycle event * @internal */ - public _postkill(_scene: Scene) { + public _postkill(scene: Scene) { this.events.emit('postkill', new PostKillEvent(this)); - this.onPostKill(_scene); + this.onPostKill(scene); } /** @@ -696,7 +696,7 @@ export class Actor extends Entity implements Eventable, PointerEvents, CanInitia * * `onPostKill` is called directly after an actor is killed and remove from its current [[Scene]]. */ - public onPostKill(_scene: Scene) { + public onPostKill(scene: Scene) { // Override me } @@ -865,7 +865,7 @@ export class Actor extends Entity implements Eventable, PointerEvents, CanInitia * * `onPreUpdate` is called directly before an actor is updated. */ - public onPreUpdate(_engine: Engine, _delta: number): void { + public onPreUpdate(engine: Engine, delta: number): void { // Override me } @@ -874,7 +874,7 @@ export class Actor extends Entity implements Eventable, PointerEvents, CanInitia * * `onPostUpdate` is called directly after an actor is updated. */ - public onPostUpdate(_engine: Engine, _delta: number): void { + public onPostUpdate(engine: Engine, delta: number): void { // Override me } diff --git a/src/engine/Camera.ts b/src/engine/Camera.ts index ea47cf068..c94d82d84 100644 --- a/src/engine/Camera.ts +++ b/src/engine/Camera.ts @@ -566,7 +566,7 @@ export class Camera implements CanUpdate, CanInitialize { * * `onPreUpdate` is called directly before a scene is updated. */ - public onPreUpdate(_engine: Engine, _delta: number): void { + public onPreUpdate(engine: Engine, delta: number): void { // Overridable } @@ -586,7 +586,7 @@ export class Camera implements CanUpdate, CanInitialize { * * `onPostUpdate` is called directly after a scene is updated. */ - public onPostUpdate(_engine: Engine, _delta: number): void { + public onPostUpdate(engine: Engine, delta: number): void { // Overridable } @@ -597,10 +597,10 @@ export class Camera implements CanUpdate, CanInitialize { return this._isInitialized; } - public _initialize(_engine: Engine) { + public _initialize(engine: Engine) { if (!this.isInitialized) { - this._engine = _engine; - this._screen = _engine.screen; + this._engine = engine; + this._screen = engine.screen; const currentRes = this._screen.contentArea; let center = vec(currentRes.width / 2, currentRes.height / 2); @@ -625,7 +625,7 @@ export class Camera implements CanUpdate, CanInitialize { this.updateTransform(); // Run strategies for first frame - this.runStrategies(_engine, _engine.clock.elapsed()); + this.runStrategies(engine, engine.clock.elapsed()); // Setup the first frame viewport this.updateViewport(); @@ -634,8 +634,8 @@ export class Camera implements CanUpdate, CanInitialize { // This prevents jitter this.updateTransform(); - this.onInitialize(_engine); - this.events.emit('initialize', new InitializeEvent(_engine, this)); + this.onInitialize(engine); + this.events.emit('initialize', new InitializeEvent(engine, this)); this._isInitialized = true; } } @@ -645,7 +645,7 @@ export class Camera implements CanUpdate, CanInitialize { * * `onPostUpdate` is called directly after a scene is updated. */ - public onInitialize(_engine: Engine) { + public onInitialize(engine: Engine) { // Overridable } @@ -690,9 +690,9 @@ export class Camera implements CanUpdate, CanInitialize { ); } - public update(_engine: Engine, delta: number) { - this._initialize(_engine); - this._preupdate(_engine, delta); + public update(engine: Engine, delta: number) { + this._initialize(engine); + this._preupdate(engine, delta); // Update placements based on linear algebra this.pos = this.pos.add(this.vel.scale(delta / 1000)); @@ -754,7 +754,7 @@ export class Camera implements CanUpdate, CanInitialize { this._yShake = ((Math.random() * this._shakeMagnitudeY) | 0) + 1; } - this.runStrategies(_engine, delta); + this.runStrategies(engine, delta); this.updateViewport(); @@ -762,7 +762,7 @@ export class Camera implements CanUpdate, CanInitialize { // This prevents jitter this.updateTransform(); - this._postupdate(_engine, delta); + this._postupdate(engine, delta); } /** diff --git a/src/engine/Engine.ts b/src/engine/Engine.ts index bfbf7e96f..b474e8236 100644 --- a/src/engine/Engine.ts +++ b/src/engine/Engine.ts @@ -1157,7 +1157,7 @@ O|===|* >________________>\n\ } } - public onInitialize(_engine: Engine) { + public onInitialize(engine: Engine) { // Override me } @@ -1242,7 +1242,7 @@ O|===|* >________________>\n\ this.onPreUpdate(this, delta); } - public onPreUpdate(_engine: Engine, _delta: number) { + public onPreUpdate(engine: Engine, delta: number) { // Override me } @@ -1254,7 +1254,7 @@ O|===|* >________________>\n\ this.onPostUpdate(this, delta); } - public onPostUpdate(_engine: Engine, _delta: number) { + public onPostUpdate(engine: Engine, delta: number) { // Override me } @@ -1290,24 +1290,24 @@ O|===|* >________________>\n\ /** * @internal */ - public _predraw(_ctx: ExcaliburGraphicsContext, delta: number) { - this.emit('predraw', new PreDrawEvent(_ctx, delta, this)); - this.onPreDraw(_ctx, delta); + public _predraw(ctx: ExcaliburGraphicsContext, delta: number) { + this.emit('predraw', new PreDrawEvent(ctx, delta, this)); + this.onPreDraw(ctx, delta); } - public onPreDraw(_ctx: ExcaliburGraphicsContext, _delta: number) { + public onPreDraw(ctx: ExcaliburGraphicsContext, delta: number) { // Override me } /** * @internal */ - public _postdraw(_ctx: ExcaliburGraphicsContext, delta: number) { - this.emit('postdraw', new PostDrawEvent(_ctx, delta, this)); - this.onPostDraw(_ctx, delta); + public _postdraw(ctx: ExcaliburGraphicsContext, delta: number) { + this.emit('postdraw', new PostDrawEvent(ctx, delta, this)); + this.onPostDraw(ctx, delta); } - public onPostDraw(_ctx: ExcaliburGraphicsContext, _delta: number) { + public onPostDraw(ctx: ExcaliburGraphicsContext, delta: number) { // Override me } diff --git a/src/engine/EntityComponentSystem/Entity.ts b/src/engine/EntityComponentSystem/Entity.ts index 12d848cbc..79d5a47e2 100644 --- a/src/engine/EntityComponentSystem/Entity.ts +++ b/src/engine/EntityComponentSystem/Entity.ts @@ -513,7 +513,7 @@ export class Entity implements OnInitialize, OnPreUpdate, OnPostUpdate { * * Synonymous with the event handler `.on('initialize', (evt) => {...})` */ - public onInitialize(_engine: Engine): void { + public onInitialize(engine: Engine): void { // Override me } @@ -522,7 +522,7 @@ export class Entity implements OnInitialize, OnPreUpdate, OnPostUpdate { * * `onPreUpdate` is called directly before an entity is updated. */ - public onPreUpdate(_engine: Engine, _delta: number): void { + public onPreUpdate(engine: Engine, delta: number): void { // Override me } @@ -531,7 +531,7 @@ export class Entity implements OnInitialize, OnPreUpdate, OnPostUpdate { * * `onPostUpdate` is called directly after an entity is updated. */ - public onPostUpdate(_engine: Engine, _delta: number): void { + public onPostUpdate(engine: Engine, delta: number): void { // Override me } diff --git a/src/engine/Graphics/Context/ExcaliburGraphicsContext2DCanvas.ts b/src/engine/Graphics/Context/ExcaliburGraphicsContext2DCanvas.ts index 07ed3d5ff..ff582f244 100644 --- a/src/engine/Graphics/Context/ExcaliburGraphicsContext2DCanvas.ts +++ b/src/engine/Graphics/Context/ExcaliburGraphicsContext2DCanvas.ts @@ -320,7 +320,7 @@ export class ExcaliburGraphicsContext2DCanvas implements ExcaliburGraphicsContex // pass } - public updatePostProcessors(_delta: number) { + public updatePostProcessors(delta: number) { // pass } @@ -332,7 +332,7 @@ export class ExcaliburGraphicsContext2DCanvas implements ExcaliburGraphicsContex // pass } - public set material(material: Material) { + public set material(material: Material | null) { this._state.current.material = material; } diff --git a/src/engine/Interfaces/LifecycleEvents.ts b/src/engine/Interfaces/LifecycleEvents.ts index be28af55f..27aeca049 100644 --- a/src/engine/Interfaces/LifecycleEvents.ts +++ b/src/engine/Interfaces/LifecycleEvents.ts @@ -78,7 +78,7 @@ export interface CanInitialize { /** * Overridable implementation */ - onInitialize(_engine: Engine): void; + onInitialize(engine: Engine): void; /** * Event signatures @@ -127,7 +127,7 @@ export interface CanUpdate { /** * Overridable implementation */ - onPreUpdate(_engine: Engine, _delta: number): void; + onPreUpdate(engine: Engine, delta: number): void; /** * Event signature @@ -139,7 +139,7 @@ export interface CanUpdate { /** * Overridable implementation */ - onPostUpdate(_engine: Engine, _delta: number): void; + onPostUpdate(engine: Engine, delta: number): void; /** * Event signatures @@ -153,7 +153,7 @@ export interface OnPreDraw { /** * Overridable implementation */ - onPreDraw(_ctx: ExcaliburGraphicsContext, _delta: number): void; + onPreDraw(ctx: ExcaliburGraphicsContext, delta: number): void; /** * Event signatures @@ -167,7 +167,7 @@ export interface OnPostDraw { /** * Overridable implementation */ - onPostDraw(_ctx: ExcaliburGraphicsContext, _delta: number): void; + onPostDraw(ctx: ExcaliburGraphicsContext, delta: number): void; /** * Event signatures diff --git a/src/engine/Loader.ts b/src/engine/Loader.ts index ec82e407e..291e5ba46 100644 --- a/src/engine/Loader.ts +++ b/src/engine/Loader.ts @@ -336,7 +336,7 @@ export class Loader implements Loadable[]> { } } - update(_engine: Engine, _delta: number): void { + update(engine: Engine, delta: number): void { // override me } diff --git a/src/engine/Particles.ts b/src/engine/Particles.ts index f4d26c03a..6fb3825b9 100644 --- a/src/engine/Particles.ts +++ b/src/engine/Particles.ts @@ -151,7 +151,7 @@ export class ParticleImpl extends Entity { this.emitter.removeParticle(this); } - public update(_engine: Engine, delta: number) { + public update(engine: Engine, delta: number) { this.life = this.life - delta; this.elapsedMultiplier = this.elapsedMultiplier + delta; diff --git a/src/engine/Scene.ts b/src/engine/Scene.ts index 1c6c48721..bb71e4c63 100644 --- a/src/engine/Scene.ts +++ b/src/engine/Scene.ts @@ -178,7 +178,7 @@ implements CanInitialize, CanActivate, CanDeactivate, CanUpdate * This is called before the first update of the [[Scene]]. Initializes scene members like the camera. This method is meant to be * overridden. This is where initialization of child actors should take place. */ - public onInitialize(_engine: Engine): void { + public onInitialize(engine: Engine): void { // will be overridden } @@ -186,7 +186,7 @@ implements CanInitialize, CanActivate, CanDeactivate, CanUpdate * This is called when the scene is made active and started. It is meant to be overridden, * this is where you should setup any DOM UI or event handlers needed for the scene. */ - public onActivate(_context: SceneActivationContext): void { + public onActivate(context: SceneActivationContext): void { // will be overridden } @@ -194,7 +194,7 @@ implements CanInitialize, CanActivate, CanDeactivate, CanUpdate * This is called when the scene is made transitioned away from and stopped. It is meant to be overridden, * this is where you should cleanup any DOM UI or event handlers needed for the scene. */ - public onDeactivate(_context: SceneActivationContext): void { + public onDeactivate(context: SceneActivationContext): void { // will be overridden } @@ -203,7 +203,7 @@ implements CanInitialize, CanActivate, CanDeactivate, CanUpdate * * `onPreUpdate` is called directly before a scene is updated. */ - public onPreUpdate(_engine: Engine, _delta: number): void { + public onPreUpdate(engine: Engine, delta: number): void { // will be overridden } @@ -212,7 +212,7 @@ implements CanInitialize, CanActivate, CanDeactivate, CanUpdate * * `onPostUpdate` is called directly after a scene is updated. */ - public onPostUpdate(_engine: Engine, _delta: number): void { + public onPostUpdate(engine: Engine, delta: number): void { // will be overridden } @@ -222,7 +222,7 @@ implements CanInitialize, CanActivate, CanDeactivate, CanUpdate * `onPreDraw` is called directly before a scene is drawn. * */ - public onPreDraw(_ctx: ExcaliburGraphicsContext, _delta: number): void { + public onPreDraw(ctx: ExcaliburGraphicsContext, delta: number): void { // will be overridden } @@ -232,7 +232,7 @@ implements CanInitialize, CanActivate, CanDeactivate, CanUpdate * `onPostDraw` is called directly after a scene is drawn. * */ - public onPostDraw(_ctx: ExcaliburGraphicsContext, _delta: number): void { + public onPostDraw(ctx: ExcaliburGraphicsContext, delta: number): void { // will be overridden } @@ -306,9 +306,9 @@ implements CanInitialize, CanActivate, CanDeactivate, CanUpdate * Internal _preupdate handler for [[onPreUpdate]] lifecycle event * @internal */ - public _preupdate(_engine: Engine, delta: number): void { - this.emit('preupdate', new PreUpdateEvent(_engine, delta, this)); - this.onPreUpdate(_engine, delta); + public _preupdate(engine: Engine, delta: number): void { + this.emit('preupdate', new PreUpdateEvent(engine, delta, this)); + this.onPreUpdate(engine, delta); } /** @@ -317,9 +317,9 @@ implements CanInitialize, CanActivate, CanDeactivate, CanUpdate * Internal _preupdate handler for [[onPostUpdate]] lifecycle event * @internal */ - public _postupdate(_engine: Engine, delta: number): void { - this.emit('postupdate', new PostUpdateEvent(_engine, delta, this)); - this.onPostUpdate(_engine, delta); + public _postupdate(engine: Engine, delta: number): void { + this.emit('postupdate', new PostUpdateEvent(engine, delta, this)); + this.onPostUpdate(engine, delta); } /** @@ -328,9 +328,9 @@ implements CanInitialize, CanActivate, CanDeactivate, CanUpdate * Internal _predraw handler for [[onPreDraw]] lifecycle event * @internal */ - public _predraw(_ctx: ExcaliburGraphicsContext, _delta: number): void { - this.emit('predraw', new PreDrawEvent(_ctx, _delta, this)); - this.onPreDraw(_ctx, _delta); + public _predraw(ctx: ExcaliburGraphicsContext, delta: number): void { + this.emit('predraw', new PreDrawEvent(ctx, delta, this)); + this.onPreDraw(ctx, delta); } /** @@ -339,9 +339,9 @@ implements CanInitialize, CanActivate, CanDeactivate, CanUpdate * Internal _postdraw handler for [[onPostDraw]] lifecycle event * @internal */ - public _postdraw(_ctx: ExcaliburGraphicsContext, _delta: number): void { - this.emit('postdraw', new PostDrawEvent(_ctx, _delta, this)); - this.onPostDraw(_ctx, _delta); + public _postdraw(ctx: ExcaliburGraphicsContext, delta: number): void { + this.emit('postdraw', new PostDrawEvent(ctx, delta, this)); + this.onPostDraw(ctx, delta); } /** diff --git a/src/engine/tsconfig.json b/src/engine/tsconfig.json index deec08df1..82ae668e7 100644 --- a/src/engine/tsconfig.json +++ b/src/engine/tsconfig.json @@ -15,7 +15,7 @@ "noImplicitReturns": true, "noImplicitThis": true, "noUnusedLocals": true, - "noUnusedParameters": true, + "noUnusedParameters": false, "allowUnreachableCode": false, "downlevelIteration": true, "lib": [