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