debugable wip
This commit is contained in:
parent
9500f6dabf
commit
5a5e490aa5
@ -3,12 +3,14 @@ import { TrackSegment } from "../track/system.ts";
|
||||
import { Train, TrainCar } from "../train/train.ts";
|
||||
import { InputManager } from "./input.ts";
|
||||
import { ResourceManager } from "./resources.ts";
|
||||
import { Debuggable } from "./debuggable.ts";
|
||||
|
||||
interface ContextMap {
|
||||
inputManager: InputManager;
|
||||
doodler: ZoomableDoodler;
|
||||
resources: ResourceManager;
|
||||
debug: Debug;
|
||||
debuggables: Debuggable[];
|
||||
colors: [
|
||||
string,
|
||||
string,
|
||||
|
@ -12,22 +12,24 @@ export abstract class Debuggable extends Drawable {
|
||||
if (typeof debugKeys[0] === "boolean") {
|
||||
drawFirst = debugKeys.shift() as boolean;
|
||||
}
|
||||
const draw = this.draw.bind(this);
|
||||
this.draw = drawFirst
|
||||
? (...args: unknown[]) => {
|
||||
draw(...args);
|
||||
const debug = getContextItem<Debug>("debug");
|
||||
if (debugKeys.some((k) => debug[k as keyof Debug])) {
|
||||
this.debugDraw();
|
||||
}
|
||||
}
|
||||
: (...args: unknown[]) => {
|
||||
const debug = getContextItem<Debug>("debug");
|
||||
if (debugKeys.some((k) => debug[k as keyof Debug])) {
|
||||
this.debugDraw();
|
||||
}
|
||||
draw(...args);
|
||||
};
|
||||
const debuggables = getContextItem("debuggables");
|
||||
debuggables.push(this);
|
||||
// const draw = this.draw.bind(this);
|
||||
// this.draw = drawFirst
|
||||
// ? (...args: unknown[]) => {
|
||||
// draw(...args);
|
||||
// const debug = getContextItem<Debug>("debug");
|
||||
// if (debugKeys.some((k) => debug[k as keyof Debug])) {
|
||||
// this.debugDraw();
|
||||
// }
|
||||
// }
|
||||
// : (...args: unknown[]) => {
|
||||
// const debug = getContextItem<Debug>("debug");
|
||||
// if (debugKeys.some((k) => debug[k as keyof Debug])) {
|
||||
// this.debugDraw();
|
||||
// }
|
||||
// draw(...args);
|
||||
// };
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user