debugable wip

This commit is contained in:
Emmaline Autumn 2025-03-27 20:26:14 -06:00
parent 9500f6dabf
commit 5a5e490aa5
2 changed files with 20 additions and 16 deletions

View File

@ -3,12 +3,14 @@ import { TrackSegment } from "../track/system.ts";
import { Train, TrainCar } from "../train/train.ts"; import { Train, TrainCar } from "../train/train.ts";
import { InputManager } from "./input.ts"; import { InputManager } from "./input.ts";
import { ResourceManager } from "./resources.ts"; import { ResourceManager } from "./resources.ts";
import { Debuggable } from "./debuggable.ts";
interface ContextMap { interface ContextMap {
inputManager: InputManager; inputManager: InputManager;
doodler: ZoomableDoodler; doodler: ZoomableDoodler;
resources: ResourceManager; resources: ResourceManager;
debug: Debug; debug: Debug;
debuggables: Debuggable[];
colors: [ colors: [
string, string,
string, string,

View File

@ -12,22 +12,24 @@ export abstract class Debuggable extends Drawable {
if (typeof debugKeys[0] === "boolean") { if (typeof debugKeys[0] === "boolean") {
drawFirst = debugKeys.shift() as boolean; drawFirst = debugKeys.shift() as boolean;
} }
const draw = this.draw.bind(this); const debuggables = getContextItem("debuggables");
this.draw = drawFirst debuggables.push(this);
? (...args: unknown[]) => { // const draw = this.draw.bind(this);
draw(...args); // this.draw = drawFirst
const debug = getContextItem<Debug>("debug"); // ? (...args: unknown[]) => {
if (debugKeys.some((k) => debug[k as keyof Debug])) { // draw(...args);
this.debugDraw(); // 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])) { // : (...args: unknown[]) => {
this.debugDraw(); // const debug = getContextItem<Debug>("debug");
} // if (debugKeys.some((k) => debug[k as keyof Debug])) {
draw(...args); // this.debugDraw();
}; // }
// draw(...args);
// };
} }
} }