Skip to content

Commit

Permalink
fix: [#2855] Remove dunder prefixed parameters (#2859)
Browse files Browse the repository at this point in the history
Closes #2855
  • Loading branch information
eonarheim authored Dec 31, 2023
1 parent 37b13b5 commit a3ba631
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 66 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- Removed dunder prefixed parameters from overrideable methods
- Tweaked debug draw to be less noisy by default
- Removed dependency on `ex.IsometricMap` in the `ex.IsometricEntityComponent`, this allows for greater flexibility when using the component when a map may not be known or constructed.

Expand Down
18 changes: 9 additions & 9 deletions src/engine/Actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -666,17 +666,17 @@ 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);
}

/**
* Safe to override onPreKill lifecycle event handler. Synonymous with `.on('prekill', (evt) =>{...})`
*
* `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
}

Expand All @@ -686,17 +686,17 @@ 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);
}

/**
* Safe to override onPostKill lifecycle event handler. Synonymous with `.on('postkill', (evt) => {...})`
*
* `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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
28 changes: 14 additions & 14 deletions src/engine/Camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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;
}
}
Expand All @@ -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
}

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -754,15 +754,15 @@ export class Camera implements CanUpdate, CanInitialize {
this._yShake = ((Math.random() * this._shakeMagnitudeY) | 0) + 1;
}

this.runStrategies(_engine, delta);
this.runStrategies(engine, delta);

this.updateViewport();

// It's important to update the camera after strategies
// This prevents jitter
this.updateTransform();

this._postupdate(_engine, delta);
this._postupdate(engine, delta);
}

/**
Expand Down
22 changes: 11 additions & 11 deletions src/engine/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ O|===|* >________________>\n\
}
}

public onInitialize(_engine: Engine) {
public onInitialize(engine: Engine) {
// Override me
}

Expand Down Expand Up @@ -1242,7 +1242,7 @@ O|===|* >________________>\n\
this.onPreUpdate(this, delta);
}

public onPreUpdate(_engine: Engine, _delta: number) {
public onPreUpdate(engine: Engine, delta: number) {
// Override me
}

Expand All @@ -1254,7 +1254,7 @@ O|===|* >________________>\n\
this.onPostUpdate(this, delta);
}

public onPostUpdate(_engine: Engine, _delta: number) {
public onPostUpdate(engine: Engine, delta: number) {
// Override me
}

Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions src/engine/EntityComponentSystem/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export class ExcaliburGraphicsContext2DCanvas implements ExcaliburGraphicsContex
// pass
}

public updatePostProcessors(_delta: number) {
public updatePostProcessors(delta: number) {
// pass
}

Expand All @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions src/engine/Interfaces/LifecycleEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface CanInitialize {
/**
* Overridable implementation
*/
onInitialize(_engine: Engine): void;
onInitialize(engine: Engine): void;

/**
* Event signatures
Expand Down Expand Up @@ -127,7 +127,7 @@ export interface CanUpdate {
/**
* Overridable implementation
*/
onPreUpdate(_engine: Engine, _delta: number): void;
onPreUpdate(engine: Engine, delta: number): void;

/**
* Event signature
Expand All @@ -139,7 +139,7 @@ export interface CanUpdate {
/**
* Overridable implementation
*/
onPostUpdate(_engine: Engine, _delta: number): void;
onPostUpdate(engine: Engine, delta: number): void;

/**
* Event signatures
Expand All @@ -153,7 +153,7 @@ export interface OnPreDraw {
/**
* Overridable implementation
*/
onPreDraw(_ctx: ExcaliburGraphicsContext, _delta: number): void;
onPreDraw(ctx: ExcaliburGraphicsContext, delta: number): void;

/**
* Event signatures
Expand All @@ -167,7 +167,7 @@ export interface OnPostDraw {
/**
* Overridable implementation
*/
onPostDraw(_ctx: ExcaliburGraphicsContext, _delta: number): void;
onPostDraw(ctx: ExcaliburGraphicsContext, delta: number): void;

/**
* Event signatures
Expand Down
2 changes: 1 addition & 1 deletion src/engine/Loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export class Loader implements Loadable<Loadable<any>[]> {
}
}

update(_engine: Engine, _delta: number): void {
update(engine: Engine, delta: number): void {
// override me
}

Expand Down
2 changes: 1 addition & 1 deletion src/engine/Particles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading

0 comments on commit a3ba631

Please sign in to comment.