feat: real input & other goodies!

This commit is contained in:
cha0s 2021-01-18 07:57:30 -06:00
parent 1c4934a250
commit b0b80cb094
16 changed files with 613 additions and 56 deletions

View File

@ -6,6 +6,7 @@ import {hot} from 'react-hot-loader';
import 'pixi.js-legacy';
import {LatusContext, useLatus} from '@latus/react/client';
import {Provider, useStore} from '@latus/redux';
import {ConnectedRouter} from 'connected-react-router';
import PropTypes from 'prop-types';
import React from 'react';
@ -38,18 +39,21 @@ const isLoggedIn = true;
const RoutedStage = () => {
const location = useLocation();
const latus = useLatus();
const store = useStore();
return (
<Stage width={320} height={180}>
<LatusContext.Provider value={latus} >
<__RouterContext.Provider value={{location}}>
<Switch>
<Route path="/login">
<Dumb />
</Route>
<Route path="/universe">
<RoomView />
</Route>
</Switch>
<Provider store={store}>
<Switch>
<Route path="/login">
<Dumb />
</Route>
<Route path="/universe">
<RoomView />
</Route>
</Switch>
</Provider>
</__RouterContext.Provider>
</LatusContext.Provider>
</Stage>

View File

@ -1,19 +1,59 @@
import './index.scss';
import {ActionRegistry, InputNormalizer} from '@avocado/input';
import {setSelfEntity, useSelfEntity} from '@humus/core';
import {useLatus} from '@latus/react/client';
import {useDispatch} from '@latus/redux';
import {useSocket} from '@latus/socket';
import {hot} from 'react-hot-loader';
import React, {useEffect} from 'react';
import React, {useEffect, useRef} from 'react';
import {useParams} from 'react-router';
const Room = () => {
const Play = () => {
const dispatch = useDispatch();
const latus = useLatus();
const {uuid} = useParams();
const ref = useRef();
const selfEntity = useSelfEntity();
const socket = useSocket();
useEffect(() => {
socket.send(['Join', uuid]);
}, [socket, uuid]);
const join = async () => {
dispatch(setSelfEntity(await socket.send(['Join', uuid])));
};
join();
}, [dispatch, socket, uuid]);
useEffect(() => {
if (!ref.current) {
return undefined;
}
const inputNormalizer = new InputNormalizer();
inputNormalizer.listen(window.document.body);
const actionRegistry = new ActionRegistry();
actionRegistry.mapKeysToActions(latus.get('@humus/core.keyMap'));
actionRegistry.listen(inputNormalizer);
const inputHandle = setInterval(() => {
const inputStream = actionRegistry.drain();
if (inputStream.length > 0) {
// Inject input.
if (selfEntity) {
selfEntity.inputStream = inputStream;
}
socket.send(['Input', inputStream]);
}
}, 1000 / 60);
ref.current.focus();
return () => {
clearInterval(inputHandle);
};
});
return (
<div className="room" />
<div
className="play"
ref={ref}
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex="0"
/>
);
};
export default hot(module)(Room);
export default hot(module)(Play);

View File

@ -1,27 +1,33 @@
import React, {useEffect, useMemo, useState} from 'react';
import {Container, Renderer} from '@avocado/graphics';
import {resource} from '@avocado/resource';
import {Vector} from '@avocado/math';
import {createLoop, destroyLoop} from '@avocado/timing';
import {RoomView} from '@avocado/topdown';
import {useRoom, useSelfEntity} from '@humus/core';
import {PixiComponent, useApp} from '@inlet/react-pixi';
import {useLatus} from '@latus/react/client';
const container = new Container();
const Component = PixiComponent('RoomView', {
create: () => container.internal,
applyProps: (instance, oldProps, newProps) => {
if (oldProps.room) {
container.removeAllChildren();
if (oldProps.room !== newProps.room) {
if (oldProps.room) {
container.removeAllChildren();
}
if (newProps.room) {
container.addChild(new RoomView(newProps.room, newProps.renderer));
}
}
if (newProps.room) {
container.addChild(new RoomView(newProps.room, newProps.renderer));
const [roomView] = container.children;
if (roomView) {
[roomView.x, roomView.y] = Vector.scale(newProps.offset, -1);
}
},
});
export default () => {
const RoomViewComponent = () => {
const app = useApp();
const renderer = useMemo(() => {
if (app.renderer) {
@ -31,39 +37,39 @@ export default () => {
}
return undefined;
}, [app.renderer]);
const latus = useLatus();
const [room, setRoom] = useState();
const synchronizer = latus.get('%synchronizer');
const selfEntity = useSelfEntity();
const [offset, setOffset] = useState([0, 0]);
const room = useRoom();
useEffect(() => {
if (!room) {
return undefined;
}
if (!selfEntity) {
return undefined;
}
selfEntity.camera.realPosition = selfEntity.camera.position;
const onCameraRealOffsetChanged = () => {
setOffset(selfEntity.camera.realOffset);
};
onCameraRealOffsetChanged();
selfEntity.camera.on('realOffsetChanged', onCameraRealOffsetChanged);
return () => {
selfEntity.camera.off('realOffsetChanged', onCameraRealOffsetChanged);
};
}, [room, selfEntity]);
useEffect(() => {
if (!room) {
return undefined;
}
const handle = createLoop((elapsed) => {
room.tick(elapsed);
container.renderTick(elapsed);
});
return () => {
destroyLoop(handle);
};
});
useEffect(() => {
if (!synchronizer) {
return undefined;
}
const onCreated = (type, created) => {
const {fromResourceType: {Room}} = resource(latus);
switch (type) {
// Track room.
case Room.resourceId: {
setRoom(created);
break;
}
default:
}
};
synchronizer.on('created', onCreated);
return () => {
synchronizer.off('created', onCreated);
};
});
return <Component renderer={renderer} room={room} />;
}, [room]);
return <Component renderer={renderer} room={room} offset={offset} />;
};
export default RoomViewComponent;

View File

@ -20,10 +20,16 @@
"test.js.map"
],
"dependencies": {
"@avocado/core": "^2.0.0",
"@avocado/entity": "^2.0.0",
"@avocado/input": "^2.0.0",
"@avocado/math": "^2.0.0",
"@avocado/resource": "^2.0.0",
"@avocado/s13n": "^2.0.0",
"@avocado/traits": "^2.0.0",
"@latus/core": "^2.0.0",
"@latus/react": "^2.0.0",
"@latus/redux": "^2.0.0",
"debug": "4.3.1"
},
"devDependencies": {

View File

@ -0,0 +1,2 @@
export {default as useRoom} from './use-room';
export {default as useSelfEntity} from './use-self-entity';

View File

@ -0,0 +1,29 @@
import {resource} from '@avocado/resource';
import {useEffect, useLatus, useState} from '@latus/react/client';
export default () => {
const [room, setRoom] = useState();
const latus = useLatus();
const synchronizer = latus.get('%synchronizer');
useEffect(() => {
if (!synchronizer) {
return undefined;
}
const onCreated = (type, created) => {
const {fromResourceType: {Room}} = resource(latus);
switch (type) {
// Track room.
case Room.resourceId: {
setRoom(created);
break;
}
default:
}
};
synchronizer.on('created', onCreated);
return () => {
synchronizer.off('created', onCreated);
};
}, [latus, synchronizer]);
return room;
};

View File

@ -0,0 +1,18 @@
import {useEffect, useState} from '@latus/react/client';
import {useSelector} from '@latus/redux';
import {selfEntitySelector} from '../state';
import useRoom from './use-room';
export default () => {
const room = useRoom();
const selfEntity = useSelector(selfEntitySelector);
const [entity, setEntity] = useState();
useEffect(() => {
if (!room) {
return;
}
setEntity(room.findEntity(selfEntity));
}, [room, selfEntity]);
return entity;
};

View File

@ -1,9 +1,42 @@
import {InputPacket} from '@avocado/input';
import {gatherWithLatus} from '@latus/core';
import {selfEntity} from './state';
export * from './hooks';
export * from './state';
export default {
hooks: {
'@avocado/traits': gatherWithLatus(
require.context('./traits', false, /\.js$/),
),
'@latus/core/config': () => ({
actionIds: {
MoveUp: 0,
MoveLeft: 1,
MoveDown: 2,
MoveRight: 3,
UseItem: 4,
Interact: 5,
},
keyMap: {
MoveUp: 'w',
MoveLeft: 'a',
MoveDown: 's',
MoveRight: 'd',
UseItem: 'ArrowLeft',
Interact: 'e',
},
}),
'@latus/core/starting': ({config: {'@humus/core': {actionIds}}}) => {
InputPacket.setActionIds(actionIds);
},
'@latus/http/plugins': (req, {config: {'@humus/core': config}}) => ({
'@latus/core': config,
}),
'@latus/redux/slices': () => ({
selfEntity,
}),
},
};

View File

@ -0,0 +1,2 @@
export * from './self-entity';
export {default as selfEntity} from './self-entity';

View File

@ -0,0 +1,23 @@
import {
createSlice,
} from '@latus/redux';
export const selfEntitySelector = ({selfEntity}) => selfEntity;
const slice = createSlice({
name: 'humus/self-entity',
initialState: null,
/* eslint-disable no-param-reassign */
reducers: {
setSelfEntity: (state, {payload}) => payload,
},
extraReducers: {
},
/* eslint-enable no-param-reassign */
});
export const {
setSelfEntity,
} = slice.actions;
export default slice.reducer;

View File

@ -0,0 +1,63 @@
import {TickingPromise} from '@avocado/core';
import {Vector} from '@avocado/math';
import {Trait} from '@avocado/traits';
// Input handling.
export default () => class Controllable extends Trait {
constructor(entity, params, state) {
super(entity, params, state);
this._isUsingItem = -1;
this._itemPromise = undefined;
this._movementVector = [0, 0];
}
set inputStream(inputStream) {
for (let i = 0; i < inputStream.length; i++) {
const {action, value} = inputStream[i];
const normalized = 0 === value ? -1 : 1;
switch (action) {
case 'MoveUp':
this._movementVector[1] -= normalized;
break;
case 'MoveRight':
this._movementVector[0] += normalized;
break;
case 'MoveDown':
this._movementVector[1] += normalized;
break;
case 'MoveLeft':
this._movementVector[0] -= normalized;
break;
case 'UseItem':
if ('client' !== process.env.SIDE) {
this._isUsingItem = value;
}
break;
default:
}
}
if (Vector.isZero(this._movementVector)) {
this.entity.currentAnimation = 'idle';
}
else {
this.entity.currentAnimation = 'moving';
}
}
tick(elapsed) {
if (-1 !== this._isUsingItem && !this._itemPromise) {
this._itemPromise = this.entity.useItemInSlot(this._isUsingItem);
Promise.resolve(this._itemPromise).then(() => {
this._itemPromise = undefined;
});
}
if (this._itemPromise && this._itemPromise instanceof TickingPromise) {
this._itemPromise.tick(elapsed);
}
if (!Vector.isZero(this._movementVector)) {
this.entity.requestMovement(this._movementVector);
}
}
};

View File

@ -2,6 +2,18 @@
# yarn lockfile v1
"@avocado/behavior@2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2fbehavior/-/behavior-2.0.0.tgz#976fa06c4959a3e58835f0157400cf0d9bdbae38"
integrity sha512-dzrn+QmiTLVuTZ1X7/0EylkFzYWRW2eFEMaAYcyodyVqURVHMszEu+Wg712Qo1rQCtyuwv7SNcmLHA/ddRvzNg==
dependencies:
"@avocado/core" "2.0.0"
"@avocado/traits" "^2.0.0"
"@latus/core" "2.0.0"
debug "4.3.1"
deepmerge "^4.2.2"
lodash.mapvalues "^4.6.0"
"@avocado/core@2.0.0", "@avocado/core@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2fcore/-/core-2.0.0.tgz#6c8c14ca33b7bc3e55893b1b2d44a53f6df42c7d"
@ -9,7 +21,59 @@
dependencies:
debug "4.3.1"
"@avocado/math@^2.0.0":
"@avocado/entity@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2fentity/-/entity-2.0.0.tgz#eb7bcd06b92760889b67da1fc67df4d514f30469"
integrity sha512-v6ghK5fatqKcraneucPTJmSYpnPTVi0kZfEltZzFCMAZkN323xGJ18k7S/qXinuhwHbiY0966gXXHLoGkKbaTw==
dependencies:
"@avocado/behavior" "2.0.0"
"@avocado/core" "2.0.0"
"@avocado/graphics" "^2.0.0"
"@avocado/math" "2.0.0"
"@avocado/resource" "2.0.0"
"@avocado/s13n" "2.0.0"
"@avocado/timing" "2.0.0"
"@avocado/traits" "^2.0.0"
"@latus/core" "2.0.0"
"@latus/socket" "2.0.0"
debug "4.3.1"
deepmerge "^4.2.2"
lodash.without "^4.4.0"
"@avocado/graphics@2.0.0", "@avocado/graphics@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2fgraphics/-/graphics-2.0.0.tgz#d4480986fd43690b02afdc52a3b8eda0d352f3b8"
integrity sha512-0PUdPs7rXlzXWXOXrUHYjygDZA89jFcWNCauZlOJXre1bjVVfpqAVeNRP8UlP220tjZlR7sizxWOKPtAV4jNMw==
dependencies:
"@avocado/core" "2.0.0"
"@avocado/input" "2.0.0"
"@avocado/math" "2.0.0"
"@avocado/resource" "2.0.0"
"@avocado/traits" "^2.0.0"
"@latus/core" "^2.0.0"
"@latus/socket" "2.0.0"
"@pixi/constants" "^5.3.6"
"@pixi/core" "^5.3.6"
"@pixi/display" "^5.3.6"
"@pixi/filter-advanced-bloom" "^3.2.0"
"@pixi/filter-color-matrix" "^5.3.6"
"@pixi/graphics" "^5.3.6"
"@pixi/settings" "^5.3.6"
"@pixi/sprite" "^5.3.6"
"@pixi/text" "^5.3.6"
debug "4.3.1"
image-size "^0.9.3"
"@avocado/input@2.0.0", "@avocado/input@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2finput/-/input-2.0.0.tgz#5f28a22f3f845d2b796e1f1013a902bda69541f0"
integrity sha512-Te50oxHNRE4v4+TfD5+luotk4TEclfqaxkyWHDLw5UvLS8IOd9OQERt5XuaBIJJy3ZqevuRuixaCKr4TrAG4vw==
dependencies:
"@latus/core" "2.0.0"
"@latus/socket" "2.0.0"
debug "4.3.1"
"@avocado/math@2.0.0", "@avocado/math@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2fmath/-/math-2.0.0.tgz#656a88a7e2b6d0e0e614b7ed1bb8ac43b0a5f618"
integrity sha512-yQiXBT7V8H4MCtD6mSNbf+wgpGCJKBQI6G4lW7XLysThlIACYooDvUdhfytYYzdm/eeQ4RXybMtksTbLnjKKbg==
@ -19,7 +83,7 @@
d3-quadtree "^2.0.0"
debug "4.3.1"
"@avocado/resource@^2.0.0":
"@avocado/resource@2.0.0", "@avocado/resource@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2fresource/-/resource-2.0.0.tgz#2b1a96cea9cbf7d7d4725e16dcfc19024fef197a"
integrity sha512-8zE7TIJ1F26OcfBkc+22Q4+wVqR2xkAunQQOX0juqyz/D9X6myJXVgN3OTwP3IC0TbGHjQrN9ygDJ5+oSbzl0A==
@ -30,7 +94,7 @@
deepmerge "^4.2.2"
uuid "^8.3.2"
"@avocado/s13n@^2.0.0":
"@avocado/s13n@2.0.0", "@avocado/s13n@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2fs13n/-/s13n-2.0.0.tgz#2016fb4654ea9a090d53ce5bda85d3c9bdf14837"
integrity sha512-t3PSjLIvlaK5nsJS1JNsvkDOTFn3D+HOouPGngP++cKfpaWfR0bKe1SEsAv7+Swo058pO1SGtloJbIC1PDLtxg==
@ -41,6 +105,21 @@
debug "4.3.1"
msgpack-lite "^0.1.26"
"@avocado/timing@2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2ftiming/-/timing-2.0.0.tgz#218c19b1a1ac3005f9fe6429f414b8ffe4b5a1a1"
integrity sha512-NlB+U/OYhtLzThxL4Wg/Z8cL5eEzqZaP/nIaklg7ncZ13livy2qYYiUE2Oa4pfYjc4GWbnAopv025+qjV/81Dg==
dependencies:
"@avocado/core" "2.0.0"
"@avocado/graphics" "2.0.0"
"@avocado/math" "2.0.0"
"@avocado/resource" "2.0.0"
"@avocado/traits" "^2.0.0"
"@latus/core" "2.0.0"
"@latus/socket" "2.0.0"
debug "4.3.1"
lodash.mapvalues "^4.6.0"
"@avocado/traits@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2ftraits/-/traits-2.0.0.tgz#551ecb08248dbed99db859a71f1534829863df11"
@ -886,7 +965,7 @@
pirates "^4.0.0"
source-map-support "^0.5.16"
"@babel/runtime@^7.8.4":
"@babel/runtime@^7.12.1", "@babel/runtime@^7.8.4":
version "7.12.5"
resolved "http://npm.cha0sdev/@babel%2fruntime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e"
integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==
@ -986,7 +1065,7 @@
webpack-hot-middleware "^2.25.0"
webpack-virtual-modules "^0.4.1"
"@latus/react@2.0.0":
"@latus/react@2.0.0", "@latus/react@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@latus%2freact/-/react-2.0.0.tgz#e56110e0fc48de2601e8b5dad7ca6d0e5a4b5c68"
integrity sha512-stcRzji4pA9jWwGtqsmlJHTlpDNfzb/5ugw40t9oaHnxqS2gzIvDfS4RcVV/zdxo2BEGYo20uhSmXXSM3JEnGg==
@ -1001,7 +1080,22 @@
react-hot-loader "^4.13.0"
sass-loader "^10.1.0"
"@latus/socket@2.0.0":
"@latus/redux@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@latus%2fredux/-/redux-2.0.0.tgz#ee9076751d28804991b01e8648df4e7bda6e3882"
integrity sha512-FbYRQ7v7xCAd9Xu3gDGUkLjnAtjMpW+8a3Rp03LVYRJRbfOAILpS3gNEHA72icZiAFzVNIql8SuKO+oySpo/LQ==
dependencies:
"@latus/core" "2.0.0"
"@latus/socket" "^2.0.0"
"@reduxjs/toolkit" "^1.5.0"
debug "4.3.1"
deepmerge "^4.2.2"
lodash.throttle "^4.1.1"
react-redux "^7.2.2"
reduce-reducers "^1.0.4"
redux "^4.0.5"
"@latus/socket@2.0.0", "@latus/socket@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@latus%2fsocket/-/socket-2.0.0.tgz#d6907fd7ac7bcccd5aff0ff5d98d791afcd0d472"
integrity sha512-JwKCOGXBe79/molvPr9OiTDA6tR+B9iaqq4pRLAB1S1Y7B07STBzqlRXW0cDHng9meZ2CwmIVOzi2CPLY9NrVQ==
@ -1151,6 +1245,131 @@
babel-merge "^3.0.0"
deepmerge "^1.5.2"
"@pixi/constants@5.3.7", "@pixi/constants@^5.3.6":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2fconstants/-/constants-5.3.7.tgz#a2e1789a98deb3713cfcb3eba3db84588bc9161e"
integrity sha512-MBcgIM/mSqonFezkCI9080IqNlc0wb8S9QJ5otBdseOWUQa/ua2jF7Jd1sCBGmi0IzS9/NOHFXzZVTdS7AC7Ow==
"@pixi/core@5.3.7", "@pixi/core@^5.3.6":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2fcore/-/core-5.3.7.tgz#a8d65ca17f0c4ef8c0c5a22d31b9e02a4ab73b93"
integrity sha512-WBhU2f5aJSVVaFP55FFBFKjKlRf5fYGxgA/U3kD4yD4Y3d3d6V3MIZv+o0VX+kBs1Eq7ePZqEv2smDrlzzMEjQ==
dependencies:
"@pixi/constants" "5.3.7"
"@pixi/math" "5.3.7"
"@pixi/runner" "5.3.7"
"@pixi/settings" "5.3.7"
"@pixi/ticker" "5.3.7"
"@pixi/utils" "5.3.7"
"@pixi/display@5.3.7", "@pixi/display@^5.3.6":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2fdisplay/-/display-5.3.7.tgz#b661d2ecfd2a67f213665a0698acd29e17eee8fe"
integrity sha512-ma1JyLe5vaEgmaOR+anvj5YOKqT9OEWnboIe7NVmwGF1CZ7JFnB12rsRulHUsSaFG9bP5xjvroAZjFg/WvyGLw==
dependencies:
"@pixi/math" "5.3.7"
"@pixi/settings" "5.3.7"
"@pixi/utils" "5.3.7"
"@pixi/filter-advanced-bloom@^3.2.0":
version "3.2.0"
resolved "http://npm.cha0sdev/@pixi%2ffilter-advanced-bloom/-/filter-advanced-bloom-3.2.0.tgz#c345adebf6605d814fb7ff8fda2292ed3d04ec01"
integrity sha512-t5WlbFGewxYQ8biRsgQCW/j7vNwQxYVDv3DpHJ7PghNdYlD2OKQ7b6bgcUzFQcsbJ2fm/8e+dSKI17zCK5idMg==
dependencies:
"@pixi/filter-kawase-blur" "3.2.0"
"@pixi/filter-color-matrix@^5.3.6":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2ffilter-color-matrix/-/filter-color-matrix-5.3.7.tgz#230cafe46bde36e25441b13f3ac5dd8e8fee4311"
integrity sha512-Z12cxoHx9uMh3CZ0PLVRzsaFHHF/CfU3J83KI9k+Bg/DFOh/J/5EToCd44jYJbMKp3nvXcO1EJyZ3wwC/IsyfQ==
dependencies:
"@pixi/core" "5.3.7"
"@pixi/filter-kawase-blur@3.2.0":
version "3.2.0"
resolved "http://npm.cha0sdev/@pixi%2ffilter-kawase-blur/-/filter-kawase-blur-3.2.0.tgz#f3fe6e3c17d191ae353959768c1170e85b2ad1dc"
integrity sha512-IO1UKn/XLvnV+ya4r1UOC9fTfXZjWvH9m6eQ/U+moBsQN5I5FihQfXCu586X4jb9VHNu3gFl7SUzirobhBfgtA==
"@pixi/graphics@^5.3.6":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2fgraphics/-/graphics-5.3.7.tgz#36ae80e2508e0a9c61ce454807d517d370d90a74"
integrity sha512-+6+bT/AC29a1Hw5XDxsH1UqBsXSqcna7wNTTrBQ02owotIJtyRc6w48f5qxzhxycumyVCR87IV5tAtdwX3xhag==
dependencies:
"@pixi/constants" "5.3.7"
"@pixi/core" "5.3.7"
"@pixi/display" "5.3.7"
"@pixi/math" "5.3.7"
"@pixi/sprite" "5.3.7"
"@pixi/utils" "5.3.7"
"@pixi/math@5.3.7":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2fmath/-/math-5.3.7.tgz#066e7ea149fd38db8d8a9584aac5f41d02b36bdd"
integrity sha512-WnjUwX7rkxR36F0xknpsNd9BsfQosV0BbyFE0Il88IURBM3Tu9X4tC7RGJDgWU+aXw23HgHu0j+MWJrCVCM2fA==
"@pixi/runner@5.3.7":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2frunner/-/runner-5.3.7.tgz#78ed2c92b392b8c099d2e4557dded7faa921446b"
integrity sha512-kt5apNb21HAvpBaDaPRs33k2O0VzrKe13w4we8iftCpXX8w68ErAY1lH68vmtDNrxnlHg4M9nRgEoMeiHlo2RA==
"@pixi/settings@5.3.7", "@pixi/settings@^5.3.6":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2fsettings/-/settings-5.3.7.tgz#b661883231bf2a1ff5260c214bd0c4b438759841"
integrity sha512-g6AoRSGWxU34gtKSQwX2AMQoLUv86L/5iIXRsqo+X4bfUSCenTci1X7ueVrSIbo39dxh6IOpriZF2Yk3TeHG5w==
dependencies:
ismobilejs "^1.1.0"
"@pixi/sprite@5.3.7", "@pixi/sprite@^5.3.6":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2fsprite/-/sprite-5.3.7.tgz#c6edf3d4a9928868696b62e35a60ded27d167058"
integrity sha512-Bjl+NOOvigEzUsm1cDr1KmBUpPSWO8pDXpUPTi+v2N75gwRfTycmj5f2TU0QmMW3Gc6sv0CB0AkL7dkMPwPb8g==
dependencies:
"@pixi/constants" "5.3.7"
"@pixi/core" "5.3.7"
"@pixi/display" "5.3.7"
"@pixi/math" "5.3.7"
"@pixi/settings" "5.3.7"
"@pixi/utils" "5.3.7"
"@pixi/text@^5.3.6":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2ftext/-/text-5.3.7.tgz#cb71b2576bdc1f66fb79977d281f9575dd06d3d5"
integrity sha512-WVAc31MDgHTvP0dJNWsvLVJhjeVGZ3NrLpHcH9iIAd6HVO5Z+i+fk4zvodD+Y7jWU0psx8ZD8xe1wy8ECfbCBA==
dependencies:
"@pixi/core" "5.3.7"
"@pixi/math" "5.3.7"
"@pixi/settings" "5.3.7"
"@pixi/sprite" "5.3.7"
"@pixi/utils" "5.3.7"
"@pixi/ticker@5.3.7":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2fticker/-/ticker-5.3.7.tgz#c331b270042d507fe18543ae435a9a857a8fd5ae"
integrity sha512-ZEXiJwPtuPeWa0QmRODF5qK0+ugZu/xeq7QxCvFOCc3NFVBeGms4g92HPucOju9R7jcODIoJxtICALsuwLAr9w==
dependencies:
"@pixi/settings" "5.3.7"
"@pixi/utils@5.3.7":
version "5.3.7"
resolved "http://npm.cha0sdev/@pixi%2futils/-/utils-5.3.7.tgz#55fe2a2fbf0fba842da5a602576ce68c498e7e16"
integrity sha512-f8zAeHHURxfwBr8MZiXEIwY2h9wbS6vN0ypvapGvKFOexZ1EInTs35FhEiRWzLEPLHyn1RgCdKzR2zl++E4tIw==
dependencies:
"@pixi/constants" "5.3.7"
"@pixi/settings" "5.3.7"
earcut "^2.1.5"
eventemitter3 "^3.1.0"
url "^0.11.0"
"@reduxjs/toolkit@^1.5.0":
version "1.5.0"
resolved "http://npm.cha0sdev/@reduxjs%2ftoolkit/-/toolkit-1.5.0.tgz#1025c1ccb224d1fc06d8d98a61f6717d57e6d477"
integrity sha512-E/FUraRx+8guw9Hlg/Ja8jI/hwCrmIKed8Annt9YsZw3BQp+F24t5I5b2OWR6pkEHY4hn1BgP08FrTZFRKsdaQ==
dependencies:
immer "^8.0.0"
redux "^4.0.0"
redux-thunk "^2.3.0"
reselect "^4.0.0"
"@types/anymatch@*":
version "1.3.1"
resolved "http://npm.cha0sdev/@types%2fanymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a"
@ -3040,6 +3259,11 @@ duplexify@^3.4.2, duplexify@^3.6.0:
readable-stream "^2.0.0"
stream-shift "^1.0.0"
earcut@^2.1.5:
version "2.2.2"
resolved "http://npm.cha0sdev/earcut/-/earcut-2.2.2.tgz#41b0bc35f63e0fe80da7cddff28511e7e2e80d11"
integrity sha512-eZoZPPJcUHnfRZ0PjLvx2qBordSiO8ofC3vt+qACLM95u+4DovnbYNpQtJh0DNsWj8RnxrQytD4WA8gj5cRIaQ==
ecc-jsbn@~0.1.1:
version "0.1.2"
resolved "http://npm.cha0sdev/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9"
@ -3503,6 +3727,11 @@ event-lite@^0.1.1:
resolved "http://npm.cha0sdev/event-lite/-/event-lite-0.1.2.tgz#838a3e0fdddef8cc90f128006c8e55a4e4e4c11b"
integrity sha512-HnSYx1BsJ87/p6swwzv+2v6B4X+uxUteoDfRxsAb1S1BePzQqOLevVmkdA15GHJVd9A9Ok6wygUR18Hu0YeV9g==
eventemitter3@^3.1.0:
version "3.1.2"
resolved "http://npm.cha0sdev/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7"
integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==
eventemitter3@^4.0.0:
version "4.0.7"
resolved "http://npm.cha0sdev/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f"
@ -4253,7 +4482,7 @@ hmac-drbg@^1.0.0:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"
hoist-non-react-statics@^3.3.0:
hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
version "3.3.2"
resolved "http://npm.cha0sdev/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
@ -4467,6 +4696,18 @@ ignore@^4.0.6:
resolved "http://npm.cha0sdev/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
image-size@^0.9.3:
version "0.9.3"
resolved "http://npm.cha0sdev/image-size/-/image-size-0.9.3.tgz#f7efce6b0a1649b44b9bc43b9d9a5acf272264b6"
integrity sha512-5SakFa79uhUVSjKeQE30GVzzLJ0QNzB53+I+/VD1vIesD6GP6uatWIlgU0uisFNLt1u0d6kBydp7yfk+lLJhLQ==
dependencies:
queue "6.0.1"
immer@^8.0.0:
version "8.0.0"
resolved "http://npm.cha0sdev/immer/-/immer-8.0.0.tgz#08763549ba9dd7d5e2eb4bec504a8315bd9440c2"
integrity sha512-jm87NNBAIG4fHwouilCHIecFXp5rMGkiFrAuhVO685UnMAlOneEAnOyzPt8OnP47TC11q/E7vpzZe0WvwepFTg==
import-cwd@^2.0.0:
version "2.1.0"
resolved "http://npm.cha0sdev/import-cwd/-/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9"
@ -4871,6 +5112,11 @@ isexe@^2.0.0:
resolved "http://npm.cha0sdev/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=
ismobilejs@^1.1.0:
version "1.1.1"
resolved "http://npm.cha0sdev/ismobilejs/-/ismobilejs-1.1.1.tgz#c56ca0ae8e52b24ca0f22ba5ef3215a2ddbbaa0e"
integrity sha512-VaFW53yt8QO61k2WJui0dHf4SlL8lxBofUuUmwBo0ljPk0Drz2TiuDW4jo3wDcv41qy/SxrJ+VAzJ/qYqsmzRw==
isobject@^2.0.0:
version "2.1.0"
resolved "http://npm.cha0sdev/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89"
@ -5139,6 +5385,11 @@ lodash.get@^4.4.2:
resolved "http://npm.cha0sdev/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=
lodash.mapvalues@^4.6.0:
version "4.6.0"
resolved "http://npm.cha0sdev/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz#1bafa5005de9dd6f4f26668c30ca37230cc9689c"
integrity sha1-G6+lAF3p3W9PJmaMMMo3IwzJaJw=
lodash.omit@^4.5.0:
version "4.5.0"
resolved "http://npm.cha0sdev/lodash.omit/-/lodash.omit-4.5.0.tgz#6eb19ae5a1ee1dd9df0b969e66ce0b7fa30b5e60"
@ -5149,6 +5400,16 @@ lodash.set@^4.3.2:
resolved "http://npm.cha0sdev/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=
lodash.throttle@^4.1.1:
version "4.1.1"
resolved "http://npm.cha0sdev/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ=
lodash.without@^4.4.0:
version "4.4.0"
resolved "http://npm.cha0sdev/lodash.without/-/lodash.without-4.4.0.tgz#3cd4574a00b67bae373a94b748772640507b7aac"
integrity sha1-PNRXSgC2e643OpS3SHcmQFB7eqw=
lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@~4.17.10:
version "4.17.20"
resolved "http://npm.cha0sdev/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
@ -6551,6 +6812,13 @@ querystringify@^2.1.1:
resolved "http://npm.cha0sdev/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6"
integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==
queue@6.0.1:
version "6.0.1"
resolved "http://npm.cha0sdev/queue/-/queue-6.0.1.tgz#abd5a5b0376912f070a25729e0b6a7d565683791"
integrity sha512-AJBQabRCCNr9ANq8v77RJEv73DPbn55cdTb+Giq4X0AVnNVZvMHlYp7XlQiN+1npCZj1DuSmaA2hYVUUDgxFDg==
dependencies:
inherits "~2.0.3"
randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0:
version "2.1.0"
resolved "http://npm.cha0sdev/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"
@ -6604,7 +6872,7 @@ react-hot-loader@^4.13.0:
shallowequal "^1.1.0"
source-map "^0.7.3"
react-is@^16.7.0, react-is@^16.8.1:
react-is@^16.13.1, react-is@^16.7.0, react-is@^16.8.1:
version "16.13.1"
resolved "http://npm.cha0sdev/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
@ -6614,6 +6882,17 @@ react-lifecycles-compat@^3.0.4:
resolved "http://npm.cha0sdev/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==
react-redux@^7.2.2:
version "7.2.2"
resolved "http://npm.cha0sdev/react-redux/-/react-redux-7.2.2.tgz#03862e803a30b6b9ef8582dadcc810947f74b736"
integrity sha512-8+CQ1EvIVFkYL/vu6Olo7JFLWop1qRUeb46sGtIMDCSpgwPQq8fPLpirIB0iTqFe9XYEFPHssdX8/UwN6pAkEA==
dependencies:
"@babel/runtime" "^7.12.1"
hoist-non-react-statics "^3.3.2"
loose-envify "^1.4.0"
prop-types "^15.7.2"
react-is "^16.13.1"
react@^17.0.1:
version "17.0.1"
resolved "http://npm.cha0sdev/react/-/react-17.0.1.tgz#6e0600416bd57574e3f86d92edba3d9008726127"
@ -6712,6 +6991,24 @@ redent@^1.0.0:
indent-string "^2.1.0"
strip-indent "^1.0.1"
reduce-reducers@^1.0.4:
version "1.0.4"
resolved "http://npm.cha0sdev/reduce-reducers/-/reduce-reducers-1.0.4.tgz#fb77e751a9eb0201760ac5a605ca8c9c2d0537f8"
integrity sha512-Mb2WZ2bJF597exiqX7owBzrqJ74DHLK3yOQjCyPAaNifRncE8OD0wFIuoMhXxTnHK07+8zZ2SJEKy/qtiyR7vw==
redux-thunk@^2.3.0:
version "2.3.0"
resolved "http://npm.cha0sdev/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622"
integrity sha512-km6dclyFnmcvxhAcrQV2AkZmPQjzPDjgVlQtR0EQjxZPyJ0BnMf3in1ryuR8A2qU0HldVRfxYXbFSKlI3N7Slw==
redux@^4.0.0, redux@^4.0.5:
version "4.0.5"
resolved "http://npm.cha0sdev/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f"
integrity sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w==
dependencies:
loose-envify "^1.4.0"
symbol-observable "^1.2.0"
regenerate-unicode-properties@^8.2.0:
version "8.2.0"
resolved "http://npm.cha0sdev/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz#e5de7111d655e7ba60c057dbe9ff37c87e65cdec"
@ -6865,6 +7162,11 @@ requires-port@^1.0.0:
resolved "http://npm.cha0sdev/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=
reselect@^4.0.0:
version "4.0.0"
resolved "http://npm.cha0sdev/reselect/-/reselect-4.0.0.tgz#f2529830e5d3d0e021408b246a206ef4ea4437f7"
integrity sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==
resolve-cwd@^2.0.0:
version "2.0.0"
resolved "http://npm.cha0sdev/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"
@ -7703,6 +8005,11 @@ supports-color@^6.1.0:
dependencies:
has-flag "^3.0.0"
symbol-observable@^1.2.0:
version "1.2.0"
resolved "http://npm.cha0sdev/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==
table@^6.0.4:
version "6.0.7"
resolved "http://npm.cha0sdev/table/-/table-6.0.7.tgz#e45897ffbcc1bcf9e8a87bf420f2c9e5a7a52a34"

View File

@ -1,4 +1,5 @@
import {gatherWithLatus} from '@latus/core';
import {universes} from './state';
export * from './state';

View File

@ -1,6 +1,8 @@
import {resource} from '@avocado/resource';
import {gatherWithLatus} from '@latus/core';
import UniverseInput from './packets/decorators/universe-input';
export default {
hooks: {
'@latus/core/up': async (latus) => {
@ -26,6 +28,10 @@ export default {
'@latus/socket/packets': gatherWithLatus(
require.context('./packets', false, /\.js$/),
),
'@latus/socket/packets.decorate': (Packets, latus) => ({
...Packets,
Input: UniverseInput(latus, Packets.Input),
}),
},
};

View File

@ -0,0 +1,17 @@
// import {ValidationError} from '@latus/socket';
export default (latus, InputPacket) => class UniverseInputPacket extends InputPacket {
static respond(packet, {req: {user}}) {
const universe = latus.get('%universe');
const {entity} = universe.playerForUser(user.id);
entity.inputStream = packet.data;
}
// static validate(packet, {req: {user}}) {
// if (0 === user.id) {
// throw new ValidationError({code: 400, reason: 'anonymous'});
// }
// }
};

View File

@ -8,7 +8,7 @@ import Join from '../../packets/join';
export default (latus) => class ServerJoin extends Join() {
// static async validate(packet, {req: {user}}) {
// // if (!user) {
// // if (0 === user.id) {
// // throw new ValidationError({code: 401, reason: 'unauthenticated'});
// // }
// }
@ -31,7 +31,7 @@ export default (latus) => class ServerJoin extends Join() {
extends: join(
dirname(universe.uri),
'players',
user ? user.name : 'cha0s',
'cha0s',
'index.entity.json',
),
},