Skip to content

Commit

Permalink
[revert] "fix: Prevent errant overrides of .update()"
Browse files Browse the repository at this point in the history
This reverts commit df59264.
  • Loading branch information
eonarheim committed Jan 25, 2024
1 parent 4ec8f1c commit 45016df
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 38 deletions.
10 changes: 1 addition & 9 deletions sandbox/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -954,12 +954,4 @@ game.currentScene.camera.y = 200;
// Run the mainloop
game.start(boot).then(() => {
logger.info('All Resources have finished loading');
});


class MySceneCustomUpdate extends ex.Scene {
//@ts-ignore
update() {
console.log('my update')
}
}
});
1 change: 0 additions & 1 deletion sandbox/tests/collisionvelocity/vel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var player = new ex.Actor({
collisionType: ex.CollisionType.Active
});

//@ts-ignore
player.update = (e, ms) => {
if (engine.input.keyboard.isHeld(ex.Keys.Space)) {
player.vel.x = 0;
Expand Down
1 change: 0 additions & 1 deletion sandbox/tests/coordinates/coordinates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class PointLabel extends ex.Actor {
this.addChild(this._actualLabel);
}

//@ts-ignore
update(engine: ex.Engine, delta: number) {
super.update(engine, delta);

Expand Down
10 changes: 1 addition & 9 deletions src/engine/Actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ import { Text } from './Graphics/Text';
import { CoordPlane } from './Math/coord-plane';
import { EventEmitter, EventKey, Handler, Subscription } from './EventEmitter';

declare const _: unique symbol;
type Forbidden = { [_]: typeof _; }
type NoOverride<T=void> = T & Forbidden;

/**
* Type guard for checking if something is an Actor
* @param x
Expand Down Expand Up @@ -856,16 +852,12 @@ export class Actor extends Entity implements Eventable, PointerEvents, CanInitia
// #region Update

/**
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
*
* Use **[[onPreUpdate]]** or **[[onPostUpdate]]**, or be sure to call the **`super.update()`**
*
* Called by the Engine, updates the state of the actor
* @internal
* @param engine The reference to the current game engine
* @param delta The time elapsed since the last update in milliseconds
*/
public update(engine: Engine, delta: number): NoOverride<void> {
public update(engine: Engine, delta: number) {
this._initialize(engine);
this._preupdate(engine, delta);
this._postupdate(engine, delta);
Expand Down
2 changes: 0 additions & 2 deletions src/engine/Particles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export class ParticleImpl extends Entity {
this.emitter.removeParticle(this);
}

//@ts-ignore
public update(engine: Engine, delta: number) {
this.life = this.life - delta;
this.elapsedMultiplier = this.elapsedMultiplier + delta;
Expand Down Expand Up @@ -597,7 +596,6 @@ export class ParticleEmitter extends Actor {
return p;
}

//@ts-ignore
public update(engine: Engine, delta: number) {
super.update(engine, delta);

Expand Down
18 changes: 2 additions & 16 deletions src/engine/Scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ import { Color } from './Color';
import { DefaultLoader } from './Director/DefaultLoader';
import { Transition } from './Director';

declare const _: unique symbol;
type Forbidden = { [_]: typeof _; }
type NoOverride<T=void> = T & Forbidden;

export class PreLoadEvent {
loader: DefaultLoader;
}
Expand Down Expand Up @@ -399,16 +395,11 @@ implements CanInitialize, CanActivate<TActivationData>, CanDeactivate, CanUpdate
}

/**
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
*
* Use **[[onPreUpdate]]** or **[[onPostUpdate]]**, or be sure to call the **`super.update()`**
*
* Updates all the actors and timers in the scene. Called by the [[Engine]].
* @internal
* @param engine Reference to the current Engine
* @param delta The number of milliseconds since the last update
*/
public update(engine: Engine, delta: number): NoOverride<void> {
public update(engine: Engine, delta: number) {
if (!this.isInitialized) {
throw new Error('Scene update called before it was initialized!');
}
Expand Down Expand Up @@ -440,16 +431,11 @@ implements CanInitialize, CanActivate<TActivationData>, CanDeactivate, CanUpdate
}

/**
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
*
* Use **[[onPreDraw]]** or **[[onPostDraw]]**, or be sure to call the **`super.update()`**
*
* Draws all the actors in the Scene. Called by the [[Engine]].
* @internal
* @param ctx The current rendering context
* @param delta The number of milliseconds since the last draw
*/
public draw(ctx: ExcaliburGraphicsContext, delta: number): NoOverride<void> {
public draw(ctx: ExcaliburGraphicsContext, delta: number) {
this._predraw(ctx, delta);

this.world.update(SystemType.Draw, delta);
Expand Down

0 comments on commit 45016df

Please sign in to comment.