refactor: App::isDebugging
This commit is contained in:
parent
92e36587d0
commit
44597caa96
|
@ -3,6 +3,9 @@ import {EventEmitter, Property} from '@avocado/mixins';
|
||||||
|
|
||||||
const decorate = compose(
|
const decorate = compose(
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
|
Property('isDebugging', {
|
||||||
|
track: true,
|
||||||
|
}),
|
||||||
Property('selfEntity', {
|
Property('selfEntity', {
|
||||||
track: true,
|
track: true,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -85,6 +85,12 @@ room.on('entityAdded', (entity) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Accept input.
|
// Accept input.
|
||||||
|
window.addEventListener('keydown', (event) => {
|
||||||
|
event = event || window.event;
|
||||||
|
if ('F2' === event.key) {
|
||||||
|
app.isDebugging = !app.isDebugging;
|
||||||
|
}
|
||||||
|
});
|
||||||
const actionRegistry = new ActionRegistry();
|
const actionRegistry = new ActionRegistry();
|
||||||
actionRegistry.mapKeysToActions({
|
actionRegistry.mapKeysToActions({
|
||||||
'w': 'MoveUp',
|
'w': 'MoveUp',
|
||||||
|
@ -155,7 +161,8 @@ const pointerMovementHandle = setInterval(() => {
|
||||||
do {
|
do {
|
||||||
let normal;
|
let normal;
|
||||||
if (isPointingAtAnything()) {
|
if (isPointingAtAnything()) {
|
||||||
normal = createMoveToNormal(pointingAt);
|
const toVector = Vector.scale(pointingAt, app.isDebugging ? 2 : 1);
|
||||||
|
normal = createMoveToNormal(toVector);
|
||||||
if (normal) {
|
if (normal) {
|
||||||
actionRegistry.state = actionRegistry.state.withMutations((state) => {
|
actionRegistry.state = actionRegistry.state.withMutations((state) => {
|
||||||
if (normal[0]) {
|
if (normal[0]) {
|
||||||
|
|
|
@ -40,15 +40,12 @@ const DebugUi = ({
|
||||||
}, []);
|
}, []);
|
||||||
// F2 toggle debug.
|
// F2 toggle debug.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onKeyDown = (event) => {
|
const onIsDebuggingChanged = () => {
|
||||||
event = event || window.event;
|
setIsDebugging(app.isDebugging);
|
||||||
if ('F2' === event.key) {
|
|
||||||
setIsDebugging(!isDebugging);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
window.addEventListener('keydown', onKeyDown);
|
app.on('isDebuggingChanged', onIsDebuggingChanged);
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('keydown', onKeyDown);
|
app.off('isDebuggingChanged', onIsDebuggingChanged);
|
||||||
};
|
};
|
||||||
}, [isDebugging]);
|
}, [isDebugging]);
|
||||||
// Scale stage when debugging.
|
// Scale stage when debugging.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user